all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: rms@gnu.org
Cc: emacs-devel@gnu.org
Subject: Re: Minibuffer default values list
Date: Mon, 03 Dec 2007 02:34:55 +0200	[thread overview]
Message-ID: <87ir3gljd3.fsf_-_@jurta.org> (raw)
In-Reply-To: <E1IywLN-0006eu-OU@fencepost.gnu.org> (Richard Stallman's message of "Sun, 02 Dec 2007 16:27:17 -0500")

> The "pre-hook" should be a single function, not a hook,
> and ideally should only run when trying to move into the future,
> for the reasons I gave.

In the patch below I added a new one-function variable
`minibuffer-default-set-function' run before `goto-history-element'
reads the value of `minibuffer-default' when moving into the future.

Note that `shell-command' still depends on dired, but this can be avoided
by moving `dired-read-shell-command-default' to mailcap.el.

Also I added another dependence on dired, and I think for a good reason:
when M-! is typed in the dired buffer, then it gets the dired file
under point and provides its commands to the list of future values.

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	3 Dec 2007 00:34:45 -0000
***************
*** 1298,1307 ****
--- 1298,1316 ----
  
  (defvar minibuffer-temporary-goal-position nil)
  
+ (defvar minibuffer-default-set-function nil
+   "*Function run by `goto-history-element' before using `minibuffer-default'.
+ This is useful to dynamically set the value of `minibuffer-default'
+ before `goto-history-element' reads it when moves into the future.")
+ 
  (defun goto-history-element (nabs)
    "Puts element of the minibuffer history in the minibuffer.
  The argument NABS specifies the absolute history position."
    (interactive "p")
+   (when (and (functionp minibuffer-default-set-function)
+ 	     (< nabs (if (stringp minibuffer-default) -1 0)))
+     (setq minibuffer-default (funcall minibuffer-default-set-function)
+ 	  minibuffer-default-set-function nil))
    (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)
--- 1972,1991 ----
  In an interactive call, the variable `shell-command-default-error-buffer'
  specifies the value of ERROR-BUFFER."
  
!   (interactive
!    (let* ((filename
! 	   (cond (buffer-file-name (file-relative-name buffer-file-name))
! 		 ((eq major-mode 'dired-mode) (dired-get-filename t))))
! 	  (default filename)
! 	  (minibuffer-default-set-function
! 	   (lambda ()
! 	     (if filename
! 		 (cons filename
! 		       (dired-read-shell-command-default (list filename)))))))
!      (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	3 Dec 2007 00:34:48 -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,529 ----
  ;;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-function
! 	 (lambda () (dired-read-shell-command-default files))))
!     (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/

  reply	other threads:[~2007-12-03  0:34 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-22  0:22 Minibuffer default values list Juri Linkov
2007-10-23  7:12 ` Richard Stallman
2007-10-28 10:57   ` Juri Linkov
2007-11-11 23:42     ` Juri Linkov
2007-11-12  5:59       ` Richard Stallman
2007-11-16  1:27         ` Substitute ? in dired without surrounding whitespace (was: Minibuffer default values list) Juri Linkov
2007-11-17 23:30           ` Richard Stallman
2007-11-17 23:57             ` Substitute ? in dired without surrounding whitespace Juri Linkov
2007-11-18 22:46               ` Richard Stallman
2007-11-19  0:48         ` Minibuffer default values list Juri Linkov
2007-11-22  2:28           ` Richard Stallman
2007-11-22 19:02             ` Juri Linkov
2007-11-23  4:35               ` Richard Stallman
2007-11-24 17:54                 ` Juri Linkov
2007-11-25  3:43                   ` Richard Stallman
2007-11-25 15:18                     ` mb-pos.el (was: Minibuffer default values list) Juri Linkov
2007-12-02 21:27                       ` Richard Stallman
2007-12-03  0:34                         ` Juri Linkov [this message]
2007-12-03 18:43                           ` Minibuffer default values list Richard Stallman
2007-11-25 15:19                     ` Subject: mb-depth.el (was: Minibuffer default values list) Juri Linkov
2008-07-31 17:28                       ` Juri Linkov
2008-07-31 18:08                         ` Drew Adams
2008-07-31 18:24                           ` Juanma Barranquero
2008-07-31 18:35                             ` Drew Adams
2008-08-01 12:34                               ` Juanma Barranquero
2008-08-01 16:27                                 ` Drew Adams
2008-08-01 17:09                                   ` mb-depth.el patch Drew Adams
2008-08-04 13:13                                     ` Juanma Barranquero
2007-11-23  4:35               ` Minibuffer default values list Richard Stallman
2007-11-23 15:05                 ` Stefan Monnier
     [not found]                   ` <E1IvwoM-0004oD-AU@fencepost.gnu.org>
     [not found]                     ` <jwvwss5ptqv.fsf-monnier+emacs@gnu.org>
2007-12-03 18:42                       ` Richard Stallman
2007-11-19  0:52         ` Juri Linkov
2007-11-19 19:02           ` Richard Stallman
2007-11-23  0:48             ` Juri Linkov
2007-11-11 23:43 ` Juri Linkov
2007-11-12  5:59   ` Richard Stallman
2007-11-11 23:45 ` Juri Linkov
2007-11-12  5:59   ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ir3gljd3.fsf_-_@jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.