emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: minibuffer-default-add-shell-commands


From: Juri Linkov
Subject: Re: minibuffer-default-add-shell-commands
Date: Sun, 30 Mar 2008 21:28:45 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu)

> That means that whenever if I ever leave a M-! prompt open and go do
> something else, all my completions will now use
> minibuffer-default-add-shell-commands?  That's not right.
> Let-binding is not right for minibuffer-default-add-function.

This can be fixed by using `minibuffer-with-setup-hook'.
A diff below shows differences between my previous patch and a new one:

diff --git a/lisp/simple.el b/lisp/simple.el
index 06f1be9..516e475 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2084,13 +2084,16 @@ (defun shell-command
 specifies the value of ERROR-BUFFER."
 
   (interactive
-   (let ((minibuffer-default-add-function
-         'minibuffer-default-add-shell-commands))
-     (list (read-shell-command "Shell command: " nil nil
-                              (and buffer-file-name
-                                   (file-relative-name buffer-file-name)))
-          current-prefix-arg
-          shell-command-default-error-buffer)))
+   (list
+    (minibuffer-with-setup-hook
+       (lambda ()
+         (set (make-local-variable 'minibuffer-default-add-function)
+              'minibuffer-default-add-shell-commands))
+      (read-shell-command "Shell command: " nil nil
+                         (and buffer-file-name
+                              (file-relative-name buffer-file-name))))
+    current-prefix-arg
+    shell-command-default-error-buffer))
   ;; Look for a handler in case default-directory is a remote file name.
   (let ((handler
         (find-file-name-handler (directory-file-name default-directory)
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index b8e2872..faf515d 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -482,8 +482,10 @@ (defun dired-read-shell-command
 ;;ARG is the prefix arg and may be used to indicate in the prompt which
 ;;  files are affected.
 ;;This is an extra function so that you can redefine it, e.g., to use gmhist."
-  (let ((minibuffer-default-add-function
-        'minibuffer-default-add-dired-shell-commands))
+  (minibuffer-with-setup-hook
+      (lambda ()
+       (set (make-local-variable 'minibuffer-default-add-function)
+            'minibuffer-default-add-dired-shell-commands))
     (dired-mark-pop-up
      nil 'shell files
      (function read-string)
-- 
Juri Linkov
http://www.jurta.org/emacs/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]