[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Minibuffer default values list
From: |
Juri Linkov |
Subject: |
Re: Minibuffer default values list |
Date: |
Sat, 24 Nov 2007 19:54:45 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) |
> If you don't want loading mailcap.el on M-! then what do you think about
> loading mailcap.el only when the user types M-n in the shell command's
> minibuffer?
>
> That is an interesting approach.
Below is a patch that implements this approach.
It adds a new variable `goto-history-element-pre-hook' run at the beginning
of `goto-history-element'. And `shell-command' binds it to a function
that after typing e.g. `M-n M-n' and going to the second default value
(the first element is a static value set to the current file name)
adds more commands extracted from mailcap to `minibuffer-default'.
`dired-read-shell-command' below does the same.
Index: lisp/simple.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/simple.el,v
retrieving revision 1.889
diff -c -r1.889 simple.el
*** lisp/simple.el 15 Nov 2007 16:42:43 -0000 1.889
--- lisp/simple.el 24 Nov 2007 17:54:00 -0000
***************
*** 1298,1307 ****
--- 1298,1311 ----
(defvar minibuffer-temporary-goal-position nil)
+ (defvar goto-history-element-pre-hook nil
+ "*List of functions run by `goto-history-element' before changing history
position.")
+
(defun goto-history-element (nabs)
"Puts element of the minibuffer history in the minibuffer.
The argument NABS specifies the absolute history position."
(interactive "p")
+ (run-hooks 'goto-history-element-pre-hook)
(let ((minimum (if minibuffer-default
(- (if (listp minibuffer-default)
(length minibuffer-default)
***************
*** 1962,1971 ****
In an interactive call, the variable `shell-command-default-error-buffer'
specifies the value of ERROR-BUFFER."
! (interactive (list (read-from-minibuffer "Shell command: "
! nil nil nil 'shell-command-history)
! 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)
--- 1966,1988 ----
In an interactive call, the variable `shell-command-default-error-buffer'
specifies the value of ERROR-BUFFER."
! (interactive
! (let* ((filename
! (if buffer-file-name (file-relative-name buffer-file-name)))
! (default filename)
! (minibuffer-default-set nil)
! (goto-history-element-pre-hook
! (cons (lambda ()
! (when (and (null minibuffer-default-set) (< nabs -1))
! (setq minibuffer-default
! (cons filename (dired-read-shell-command-default
! (list filename))))
! (setq minibuffer-default-set t)))
! goto-history-element-pre-hook)))
! (list (read-from-minibuffer "Shell command: " nil nil nil
! 'shell-command-history default)
! 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)
Index: lisp/dired-aux.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/dired-aux.el,v
retrieving revision 1.160
diff -c -r1.160 dired-aux.el
*** lisp/dired-aux.el 22 Nov 2007 13:49:34 -0000 1.160
--- lisp/dired-aux.el 24 Nov 2007 17:54:25 -0000
***************
*** 517,528 ****
;;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."
! (dired-mark-pop-up
! nil 'shell files
! (function read-string)
! (format prompt (dired-mark-prompt arg files))
! nil 'shell-command-history
! (dired-read-shell-command-default files)))
;; The in-background argument is only needed in Emacs 18 where
;; shell-command doesn't understand an appended ampersand `&'.
--- 517,534 ----
;;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-set nil)
! (goto-history-element-pre-hook
! (cons (lambda ()
! (when (and (null minibuffer-default-set) (< nabs 0))
! (setq minibuffer-default (dired-read-shell-command-default
files)
! minibuffer-default-set t)))
! goto-history-element-pre-hook)))
! (dired-mark-pop-up
! nil 'shell files
! (function read-string)
! (format prompt (dired-mark-prompt arg files))
! nil 'shell-command-history)))
;; The in-background argument is only needed in Emacs 18 where
;; shell-command doesn't understand an appended ampersand `&'.
--
Juri Linkov
http://www.jurta.org/emacs/
- Re: Minibuffer default values list, (continued)
- Re: Minibuffer default values list, Juri Linkov, 2007/11/18
- Re: Minibuffer default values list, Richard Stallman, 2007/11/21
- Re: Minibuffer default values list, Juri Linkov, 2007/11/22
- Re: Minibuffer default values list, Richard Stallman, 2007/11/22
- Re: Minibuffer default values list,
Juri Linkov <=
- Re: Minibuffer default values list, Richard Stallman, 2007/11/24
- mb-pos.el (was: Minibuffer default values list), Juri Linkov, 2007/11/25
- Subject: mb-depth.el (was: Minibuffer default values list), Juri Linkov, 2007/11/25
- Re: Minibuffer default values list, Richard Stallman, 2007/11/22
- Re: Minibuffer default values list, Stefan Monnier, 2007/11/23
- Re: Minibuffer default values list, Juri Linkov, 2007/11/18
- Re: Minibuffer default values list, Richard Stallman, 2007/11/19
- Re: Minibuffer default values list, Juri Linkov, 2007/11/22