annotate lisp/rfn-eshadow.el @ 90261:7beb78bc1f8e

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-97 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 616-696) - Add lisp/mh-e/.arch-inventory - Update from CVS - Merge from gnus--rel--5.10 - Update from CVS: lisp/smerge-mode.el: Add 'tools' to file keywords. - lisp/gnus/ChangeLog: Remove duplicate entry * gnus--rel--5.10 (patch 147-181) - Update from CVS - Merge from emacs--cvs-trunk--0 - Update from CVS: lisp/mml.el (mml-preview): Doc fix. - Update from CVS: texi/message.texi: Fix default values. - Update from CVS: texi/gnus.texi (RSS): Addition.
author Miles Bader <miles@gnu.org>
date Mon, 16 Jan 2006 08:37:27 +0000
parents 2d92f5c9d6ae 4571a040cf5b
children c5406394f567
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
1 ;;; rfn-eshadow.el --- Highlight `shadowed' part of read-file-name input text
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
2 ;;
64762
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64091
diff changeset
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64091
diff changeset
4 ;; 2005 Free Software Foundation, Inc.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
5 ;;
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
6 ;; Author: Miles Bader <miles@gnu.org>
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
7 ;; Keywords: convenience minibuffer
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
8
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
10
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
14 ;; any later version.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
15
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
20
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63053
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63053
diff changeset
24 ;; Boston, MA 02110-1301, USA.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
25
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
27 ;;
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
28 ;; Defines the mode `file-name-shadow-mode'.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
29 ;;
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
30 ;; The `read-file-name' function passes its result through
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
31 ;; `substitute-in-file-name', so any part of the string preceding
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
32 ;; multiple slashes (or a drive indicator on MS-DOS/MS-Windows) is
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
33 ;; ignored.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
34 ;;
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
35 ;; If `file-name-shadow-mode' is active, any part of the
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
36 ;; minibuffer text that would be ignored because of this is given the
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
37 ;; properties in `file-name-shadow-properties', which may
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
38 ;; be used to make the ignored text invisible, dim, etc.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
39 ;;
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
40
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
41 ;;; Code:
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
42
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
43
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
44 ;;; Customization
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
45
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
46 (defconst file-name-shadow-properties-custom-type
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
47 '(list
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
48 (checklist :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
49 (const :tag "Invisible"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
50 :doc "Make shadowed part of filename invisible"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
51 :format "%t%n%h"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
52 :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
53 (invisible t intangible t))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
54 (list :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
55 :format "%v"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
56 :tag "Face"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
57 :doc "Display shadowed part of filename using a different face"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
58 (const :format "" face)
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
59 (face :value file-name-shadow))
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
60 (list :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
61 :format "%t: %v%h"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
62 :tag "Brackets"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
63 ;; Note the 4 leading spaces in the doc string;
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
64 ;; this is hack to get around the fact that the
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
65 ;; newline after the second string widget comes
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
66 ;; from the string widget, and doesn't indent
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
67 ;; correctly. We could use a :size attribute to
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
68 ;; make the second string widget not have a
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
69 ;; terminating newline, but this makes it impossible
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
70 ;; to enter trailing whitespace, and it's desirable
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
71 ;; that it be possible.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
72 :doc " Surround shadowed part of filename with brackets"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
73 (const :format "" before-string)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
74 (string :format "%v" :size 4 :value "{")
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
75 (const :format "" after-string)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
76 ;; see above about why the 2nd string doesn't use :size
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
77 (string :format " and: %v" :value "} "))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
78 (list :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
79 :format "%t: %v%n%h"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
80 :tag "String"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
81 :doc "Display a string instead of the shadowed part of filename"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
82 (const :format "" display)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
83 (string :format "%v" :size 15 :value "<...ignored...>"))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
84 (const :tag "Avoid"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
85 :doc "Try to keep cursor out of shadowed part of filename"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
86 :format "%t%n%h"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
87 :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
88 (field shadow)))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
89 (repeat :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
90 :tag "Other Properties"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
91 (list :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
92 :format "%v"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
93 (symbol :tag "Property")
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
94 (sexp :tag "Value")))))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
95
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
96 (defcustom file-name-shadow-properties
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
97 '(face file-name-shadow field shadow)
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
98 "Properties given to the `shadowed' part of a filename in the minibuffer.
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
99 Only used when `file-name-shadow-mode' is active.
66900
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
100 If Emacs is not running under a window system,
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
101 `file-name-shadow-tty-properties' is used instead."
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
102 :type file-name-shadow-properties-custom-type
66918
a4fc9278ae05 (file-name-shadow-properties, file-name-shadow-tty-properties)
Luc Teirlinck <teirllm@auburn.edu>
parents: 66911
diff changeset
103 :group 'minibuffer
a4fc9278ae05 (file-name-shadow-properties, file-name-shadow-tty-properties)
Luc Teirlinck <teirllm@auburn.edu>
parents: 66911
diff changeset
104 :version "22.1")
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
105
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
106 (defcustom file-name-shadow-tty-properties
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
107 '(before-string "{" after-string "} " field shadow)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
108 "Properties given to the `shadowed' part of a filename in the minibuffer.
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
109 Only used when `file-name-shadow-mode' is active and emacs
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
110 is not running under a window-system; if emacs is running under a window
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
111 system, `file-name-shadow-properties' is used instead."
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
112 :type file-name-shadow-properties-custom-type
66918
a4fc9278ae05 (file-name-shadow-properties, file-name-shadow-tty-properties)
Luc Teirlinck <teirllm@auburn.edu>
parents: 66911
diff changeset
113 :group 'minibuffer
a4fc9278ae05 (file-name-shadow-properties, file-name-shadow-tty-properties)
Luc Teirlinck <teirllm@auburn.edu>
parents: 66911
diff changeset
114 :version "22.1")
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
115
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
116 (defface file-name-shadow
63053
4ef6975cd244 * rfn-eshadow.el (file-name-shadow): Inherit from `shadow' face.
Juri Linkov <juri@jurta.org>
parents: 52401
diff changeset
117 '((t :inherit shadow))
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
118 "Face used by `file-name-shadow-mode' for the shadow."
66918
a4fc9278ae05 (file-name-shadow-properties, file-name-shadow-tty-properties)
Luc Teirlinck <teirllm@auburn.edu>
parents: 66911
diff changeset
119 :group 'minibuffer
a4fc9278ae05 (file-name-shadow-properties, file-name-shadow-tty-properties)
Luc Teirlinck <teirllm@auburn.edu>
parents: 66911
diff changeset
120 :version "22.1")
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
121
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
122
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
123 ;;; Internal variables
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
124
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
125 ;; A list of minibuffers to which we've added a post-command-hook.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
126 (defvar rfn-eshadow-frobbed-minibufs nil)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
127
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
128 ;; An overlay covering the shadowed part of the filename (local to the
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
129 ;; minibuffer).
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
130 (defvar rfn-eshadow-overlay)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
131 (make-variable-buffer-local 'rfn-eshadow-overlay)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
132
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
133
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
134 ;;; Hook functions
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
135
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
136 ;; This function goes on minibuffer-setup-hook
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
137 (defun rfn-eshadow-setup-minibuffer ()
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
138 "Set up a minibuffer for `file-name-shadow-mode'.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
139 The prompt and initial input should already have been inserted."
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
140 (when minibuffer-completing-file-name
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
141 (setq rfn-eshadow-overlay
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
142 (make-overlay (minibuffer-prompt-end) (minibuffer-prompt-end)))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
143 ;; Give rfn-eshadow-overlay the user's props.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
144 (let ((props
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
145 (if window-system
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
146 file-name-shadow-properties
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
147 file-name-shadow-tty-properties)))
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
148 (while props
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
149 (overlay-put rfn-eshadow-overlay (pop props) (pop props))))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
150 ;; Turn on overlay evaporation so that we don't have to worry about
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
151 ;; odd effects when the overlay sits empty at the beginning of the
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
152 ;; minibuffer.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
153 (overlay-put rfn-eshadow-overlay 'evaporate t)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
154 ;; Add our post-command hook, and make sure can remove it later.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
155 (add-to-list 'rfn-eshadow-frobbed-minibufs (current-buffer))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
156 (add-hook 'post-command-hook #'rfn-eshadow-update-overlay nil t)))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
157
66900
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
158 (defsubst rfn-eshadow-sifn-equal (goal pos)
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
159 (equal goal (condition-case nil
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
160 (substitute-in-file-name
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
161 (buffer-substring-no-properties pos (point-max)))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
162 ;; `substitute-in-file-name' can fail on partial input.
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
163 (error nil))))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
164
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
165 ;; post-command-hook to update overlay
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
166 (defun rfn-eshadow-update-overlay ()
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
167 "Update `rfn-eshadow-overlay' to cover shadowed part of minibuffer input.
66900
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
168 This is intended to be used as a minibuffer `post-command-hook' for
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
169 `file-name-shadow-mode'; the minibuffer should have already
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
170 been set up by `rfn-eshadow-setup-minibuffer'."
66900
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
171 (condition-case nil
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
172 (let ((goal (substitute-in-file-name (minibuffer-contents)))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
173 (mid (overlay-end rfn-eshadow-overlay))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
174 (start (minibuffer-prompt-end))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
175 (end (point-max)))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
176 (unless
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
177 ;; Catch the common case where the shadow does not need to move.
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
178 (and mid
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
179 (or (eq mid end)
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
180 (not (rfn-eshadow-sifn-equal goal (1+ mid))))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
181 (or (eq mid start)
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
182 (rfn-eshadow-sifn-equal goal mid)))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
183 ;; Binary search for the greatest position still equivalent to
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
184 ;; the whole.
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
185 (while (or (< (1+ start) end)
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
186 (if (and (< (1+ end) (point-max))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
187 (rfn-eshadow-sifn-equal goal (1+ end)))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
188 ;; (SIFN end) != goal, but (SIFN (1+end)) == goal,
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
189 ;; We've reached a discontinuity: this can happen
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
190 ;; e.g. if `end' point to "/:...".
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
191 (setq start (1+ end) end (point-max))))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
192 (setq mid (/ (+ start end) 2))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
193 (if (rfn-eshadow-sifn-equal goal mid)
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
194 (setq start mid)
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
195 (setq end mid)))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
196 (move-overlay rfn-eshadow-overlay (minibuffer-prompt-end) start)))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
197 ;; `substitute-in-file-name' can fail on partial input.
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
198 (error nil)))
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
199
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
200 (define-minor-mode file-name-shadow-mode
47034
820cb95c5776 Doc fix.
Miles Bader <miles@gnu.org>
parents: 47028
diff changeset
201 "Toggle File-Name Shadow mode.
820cb95c5776 Doc fix.
Miles Bader <miles@gnu.org>
parents: 47028
diff changeset
202 When active, any part of a filename being read in the minibuffer
820cb95c5776 Doc fix.
Miles Bader <miles@gnu.org>
parents: 47028
diff changeset
203 that would be ignored (because the result is passed through
820cb95c5776 Doc fix.
Miles Bader <miles@gnu.org>
parents: 47028
diff changeset
204 `substitute-in-file-name') is given the properties in
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
205 `file-name-shadow-properties', which can be used to make
45177
3cb6d6563fba rfn-eshadow.el (read-file-name-electric-shadow-mode): Fix typos in
Juanma Barranquero <lekktu@gmail.com>
parents: 43893
diff changeset
206 that portion dim, invisible, or otherwise less visually noticeable.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
207
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
208 With prefix argument ARG, turn on if positive, otherwise off.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
209 Returns non-nil if the new state is enabled."
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
210 :global t
66905
e0955732eb23 (file-name-shadow-mode): Set :init-value to t.
Luc Teirlinck <teirllm@auburn.edu>
parents: 66900
diff changeset
211 :init-value t
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
212 :group 'minibuffer
66918
a4fc9278ae05 (file-name-shadow-properties, file-name-shadow-tty-properties)
Luc Teirlinck <teirllm@auburn.edu>
parents: 66911
diff changeset
213 :version "22.1"
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
214 (if file-name-shadow-mode
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
215 ;; Enable the mode
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
216 (add-hook 'minibuffer-setup-hook 'rfn-eshadow-setup-minibuffer)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
217 ;; Disable the mode
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
218 (remove-hook 'minibuffer-setup-hook 'rfn-eshadow-setup-minibuffer)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
219 ;; Remove our entry from any post-command-hook variable's it's still in
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
220 (dolist (minibuf rfn-eshadow-frobbed-minibufs)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
221 (with-current-buffer minibuf
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
222 (remove-hook 'post-command-hook #'rfn-eshadow-update-overlay t)))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
223 (setq rfn-eshadow-frobbed-minibufs nil)))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
224
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
225
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
226 (provide 'rfn-eshadow)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
227
66900
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
228 ;; arch-tag: dcf70a52-0115-4ec2-b1e3-4f8d3541a888
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
229 ;;; rfn-eshadow.el ends here