diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2008-01-09 02:16:47 +0000 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2008-01-09 02:16:47 +0000 |
commit | ea27e496b7a188df399087219b7c717cf3f6316d (patch) | |
tree | 58d4cb287765f0ea141b2cda98a8b08b1389fcf2 /lisp/ffap.el | |
parent | c5578d5fff348216e1e25ef7153efb16ae1b17f5 (diff) | |
download | emacs-ea27e496b7a188df399087219b7c717cf3f6316d.tar.gz emacs-ea27e496b7a188df399087219b7c717cf3f6316d.tar.bz2 emacs-ea27e496b7a188df399087219b7c717cf3f6316d.zip |
(ffap-read-file-or-url): Don't use let-binding to temporarily
add a file-name handler.
Diffstat (limited to 'lisp/ffap.el')
-rw-r--r-- | lisp/ffap.el | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/lisp/ffap.el b/lisp/ffap.el index 52fb372b8cd..fa5e70e860b 100644 --- a/lisp/ffap.el +++ b/lisp/ffap.el @@ -1263,20 +1263,25 @@ which may actually result in an url rather than a filename." (setq dir (file-name-directory guess)))) (let ((minibuffer-completing-file-name t) (completion-ignore-case read-file-name-completion-ignore-case) - ;; because of `rfn-eshadow-update-overlay'. - (file-name-handler-alist - (cons (cons ffap-url-regexp 'url-file-handler) - file-name-handler-alist))) - (setq guess - (completing-read - prompt - 'ffap-read-file-or-url-internal - dir - nil - (if dir (cons guess (length dir)) guess) - (list 'file-name-history) - (and buffer-file-name - (abbreviate-file-name buffer-file-name))))) + (fnh-elem (cons ffap-url-regexp 'url-file-handler))) + ;; Explain to `rfn-eshadow' that we can use URLs here. + (push fnh-elem file-name-handler-alist) + (unwind-protect + (setq guess + (completing-read + prompt + 'ffap-read-file-or-url-internal + dir + nil + (if dir (cons guess (length dir)) guess) + (list 'file-name-history) + (and buffer-file-name + (abbreviate-file-name buffer-file-name)))) + ;; Remove the special handler manually. We used to just let-bind + ;; file-name-handler-alist to preserve its value, but that caused + ;; other modifications to be lost (e.g. when Tramp gets loaded + ;; during the completing-read call). + (setq file-name-handler-alist (delq fnh-elem file-name-handler-alist)))) ;; Do file substitution like (interactive "F"), suggested by MCOOK. (or (ffap-url-p guess) (setq guess (substitute-in-file-name guess))) ;; Should not do it on url's, where $ is a common (VMS?) character. |