aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2005-03-28 19:58:58 +0000
committerStefan Monnier2005-03-28 19:58:58 +0000
commita42e7db0c44718304f265bdd2426d3a95393e34a (patch)
tree31cd5841e00be43e07ff99695335ca59c0c09980
parenta7ad007929b1d18cf0487901b9294a54a2e51a0c (diff)
downloademacs-a42e7db0c44718304f265bdd2426d3a95393e34a.tar.gz
emacs-a42e7db0c44718304f265bdd2426d3a95393e34a.zip
(minibuffer-with-setup-hook): New macro.
(find-file-read-args): Use it to avoid let-binding minibuffer-with-setup-hook (which breaks turning on/off file-name-shadow-mode while in the prompt).
-rw-r--r--lisp/files.el33
1 files changed, 22 insertions, 11 deletions
diff --git a/lisp/files.el b/lisp/files.el
index b6ef1dea31f..15d6f794e16 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -928,20 +928,31 @@ documentation for additional customization information."
928(defvar find-file-default nil 928(defvar find-file-default nil
929 "Used within `find-file-read-args'.") 929 "Used within `find-file-read-args'.")
930 930
931(defmacro minibuffer-with-setup-hook (fun &rest body)
932 "Add FUN to `minibuffer-setup-hook' while executing BODY.
933BODY should use the minibuffer at most once.
934Recursive uses of the minibuffer will not be affected."
935 (declare (indent 1) (debug t))
936 (let ((hook (make-symbol "setup-hook")))
937 `(let ((,hook
938 (lambda ()
939 ;; Clear out this hook so it does not interfere
940 ;; with any recursive minibuffer usage.
941 (remove-hook 'minibuffer-setup-hook ,hook)
942 (,fun))))
943 (unwind-protect
944 (progn
945 (add-hook 'minibuffer-setup-hook ,hook)
946 ,@body)
947 (remove-hook 'minibuffer-setup-hook ,hook)))))
948
931(defun find-file-read-args (prompt mustmatch) 949(defun find-file-read-args (prompt mustmatch)
932 (list (let ((find-file-default 950 (list (let ((find-file-default
933 (and buffer-file-name 951 (and buffer-file-name
934 (abbreviate-file-name buffer-file-name))) 952 (abbreviate-file-name buffer-file-name))))
935 (munge-default-fun 953 (minibuffer-with-setup-hook
936 (lambda () 954 (lambda () (setq minibuffer-default find-file-default))
937 (setq minibuffer-default find-file-default) 955 (read-file-name prompt nil default-directory mustmatch)))
938 ;; Clear out this hook so it does not interfere
939 ;; with any recursive minibuffer usage.
940 (pop minibuffer-setup-hook)))
941 (minibuffer-setup-hook
942 minibuffer-setup-hook))
943 (add-hook 'minibuffer-setup-hook munge-default-fun)
944 (read-file-name prompt nil default-directory mustmatch))
945 t)) 956 t))
946 957
947(defun find-file (filename &optional wildcards) 958(defun find-file (filename &optional wildcards)