aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/rfn-eshadow.el73
2 files changed, 45 insertions, 37 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1e1a9ef131b..959f9cdebd9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -10,6 +10,12 @@
10 * progmodes/gud.el (gud-menu-map): Make visibility of stop and 10 * progmodes/gud.el (gud-menu-map): Make visibility of stop and
11 go buttons complementary. 11 go buttons complementary.
12 12
132005-11-15 Stefan Monnier <monnier@iro.umontreal.ca>
14
15 * rfn-eshadow.el (rfn-eshadow-regexp): Remove.
16 (rfn-eshadow-sifn-equal): New function.
17 (rfn-eshadow-update-overlay): Rewrite to use substitute-in-file-name.
18
132005-11-15 Michael Kifer <kifer@cs.stonybrook.edu> 192005-11-15 Michael Kifer <kifer@cs.stonybrook.edu>
14 20
15 * viper-utils (viper-non-word-characters-reformed-vi): Quote `-' in 21 * viper-utils (viper-non-word-characters-reformed-vi): Quote `-' in
@@ -40,8 +46,7 @@
40 46
412005-11-16 Kim F. Storm <storm@cua.dk> 472005-11-16 Kim F. Storm <storm@cua.dk>
42 48
43 * progmodes/gud.el (gud-tool-bar-item-visible-no-fringe): New 49 * progmodes/gud.el (gud-tool-bar-item-visible-no-fringe): New function.
44 function.
45 (gud-menu-map): Use it. 50 (gud-menu-map): Use it.
46 51
472005-11-14 Luc Teirlinck <teirllm@auburn.edu> 522005-11-14 Luc Teirlinck <teirllm@auburn.edu>
diff --git a/lisp/rfn-eshadow.el b/lisp/rfn-eshadow.el
index 9141b5220e8..d82dd6cba15 100644
--- a/lisp/rfn-eshadow.el
+++ b/lisp/rfn-eshadow.el
@@ -98,7 +98,7 @@
98 '(face file-name-shadow field shadow) 98 '(face file-name-shadow field shadow)
99 "Properties given to the `shadowed' part of a filename in the minibuffer. 99 "Properties given to the `shadowed' part of a filename in the minibuffer.
100Only used when `file-name-shadow-mode' is active. 100Only used when `file-name-shadow-mode' is active.
101If emacs is not running under a window system, 101If Emacs is not running under a window system,
102`file-name-shadow-tty-properties' is used instead." 102`file-name-shadow-tty-properties' is used instead."
103 :type file-name-shadow-properties-custom-type 103 :type file-name-shadow-properties-custom-type
104 :group 'minibuffer) 104 :group 'minibuffer)
@@ -121,20 +121,6 @@ system, `file-name-shadow-properties' is used instead."
121 121
122;;; Internal variables 122;;; Internal variables
123 123
124;; Regexp to locate dividing point between shadow and real pathname
125(defconst rfn-eshadow-regexp
126 (cond ((memq system-type '(ms-dos windows-nt))
127 ;; This horrible regexp considers the following patterns as
128 ;; starting an absolute pathname, when following a `/' or an `\':
129 ;; L: / // ~ $ \\ \\\\
130 "\\(.*[^/]+/+?\\|/*?\\|\\)\\(~\\|$[^$]\\|$\\'\\|[][\\^a-z]:\\|//?\\([^][\\^a-z/$~]\\|[^/$~][^:]\\|[^/$~]?\\'\\)\\)")
131 (t
132 ;; default is for unix-style filenames
133 "\\(.*/\\)\\([/~]\\|$[^$]\\|$\\'\\)"))
134 "Regular expression used to match shadowed filenames.
135There should be at least one regexp group; the end of the first one
136is used as the end of the shadowed portion of the filename.")
137
138;; A list of minibuffers to which we've added a post-command-hook. 124;; A list of minibuffers to which we've added a post-command-hook.
139(defvar rfn-eshadow-frobbed-minibufs nil) 125(defvar rfn-eshadow-frobbed-minibufs nil)
140 126
@@ -168,31 +154,48 @@ The prompt and initial input should already have been inserted."
168 (add-to-list 'rfn-eshadow-frobbed-minibufs (current-buffer)) 154 (add-to-list 'rfn-eshadow-frobbed-minibufs (current-buffer))
169 (add-hook 'post-command-hook #'rfn-eshadow-update-overlay nil t))) 155 (add-hook 'post-command-hook #'rfn-eshadow-update-overlay nil t)))
170 156
157(defsubst rfn-eshadow-sifn-equal (goal pos)
158 (equal goal (condition-case nil
159 (substitute-in-file-name
160 (buffer-substring-no-properties pos (point-max)))
161 ;; `substitute-in-file-name' can fail on partial input.
162 (error nil))))
163
171;; post-command-hook to update overlay 164;; post-command-hook to update overlay
172(defun rfn-eshadow-update-overlay () 165(defun rfn-eshadow-update-overlay ()
173 "Update `rfn-eshadow-overlay' to cover shadowed part of minibuffer input. 166 "Update `rfn-eshadow-overlay' to cover shadowed part of minibuffer input.
174This is intended to be used as a minibuffer post-command-hook for 167This is intended to be used as a minibuffer `post-command-hook' for
175`file-name-shadow-mode'; the minibuffer should have already 168`file-name-shadow-mode'; the minibuffer should have already
176been set up by `rfn-eshadow-setup-minibuffer'." 169been set up by `rfn-eshadow-setup-minibuffer'."
177 ;; This is not really a correct implementation; it won't always do the 170 (condition-case nil
178 ;; right thing in the presence of environment variables that 171 (let ((goal (substitute-in-file-name (minibuffer-contents)))
179 ;; substitute-in-file-name would expand; currently it just assumes any 172 (mid (overlay-end rfn-eshadow-overlay))
180 ;; environment variable contains an absolute filename. 173 (start (minibuffer-prompt-end))
181 (save-excursion 174 (end (point-max)))
182 (let ((inhibit-point-motion-hooks t)) 175 (unless
183 (goto-char (minibuffer-prompt-end)) 176 ;; Catch the common case where the shadow does not need to move.
184 ;; Update the overlay (which will evaporate if it's empty). 177 (and mid
185 (move-overlay rfn-eshadow-overlay 178 (or (eq mid end)
186 (point) 179 (not (rfn-eshadow-sifn-equal goal (1+ mid))))
187 (if (looking-at rfn-eshadow-regexp) 180 (or (eq mid start)
188 (match-end 1) 181 (rfn-eshadow-sifn-equal goal mid)))
189 (point)))))) 182 ;; Binary search for the greatest position still equivalent to
190 183 ;; the whole.
184 (while (or (< (1+ start) end)
185 (if (and (< (1+ end) (point-max))
186 (rfn-eshadow-sifn-equal goal (1+ end)))
187 ;; (SIFN end) != goal, but (SIFN (1+end)) == goal,
188 ;; We've reached a discontinuity: this can happen
189 ;; e.g. if `end' point to "/:...".
190 (setq start (1+ end) end (point-max))))
191 (setq mid (/ (+ start end) 2))
192 (if (rfn-eshadow-sifn-equal goal mid)
193 (setq start mid)
194 (setq end mid)))
195 (move-overlay rfn-eshadow-overlay (minibuffer-prompt-end) start)))
196 ;; `substitute-in-file-name' can fail on partial input.
197 (error nil)))
191 198
192;;; Note this definition must be at the end of the file, because
193;;; `define-minor-mode' actually calls the mode-function if the
194;;; associated variable is non-nil, which requires that all needed
195;;; functions be already defined. [This is arguably a bug in d-m-m]
196;;;###autoload 199;;;###autoload
197(define-minor-mode file-name-shadow-mode 200(define-minor-mode file-name-shadow-mode
198 "Toggle File-Name Shadow mode. 201 "Toggle File-Name Shadow mode.
@@ -220,5 +223,5 @@ Returns non-nil if the new state is enabled."
220 223
221(provide 'rfn-eshadow) 224(provide 'rfn-eshadow)
222 225
223;;; arch-tag: dcf70a52-0115-4ec2-b1e3-4f8d3541a888 226;; arch-tag: dcf70a52-0115-4ec2-b1e3-4f8d3541a888
224;;; rfn-eshadow.el ends here 227;;; rfn-eshadow.el ends here