From 5420b514775c4592b6e86029f52f4ce455f09cf2 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 22 Oct 2007 00:22:56 +0000 Subject: [PATCH] (dired-guess-shell-command): Put all guesses to the minibuffer default value list instead of pushing them temporarily to the history list. --- lisp/ChangeLog | 4 ++++ lisp/dired-x.el | 46 +++++++++------------------------------------- 2 files changed, 13 insertions(+), 37 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f96e92a6150..c6dd6c68c43 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -3,6 +3,10 @@ * simple.el (goto-history-element): Allow minibuffer-default to be a list of default values accessible by typing M-n in the minibuffer. + * dired-x.el (dired-guess-shell-command): Put all guesses to the + minibuffer default value list instead of pushing them temporarily + to the history list. + 2007-10-21 Stefan Monnier * emacs-lisp/byte-opt.el (byte-optimize-featurep): Fix paren typo. diff --git a/lisp/dired-x.el b/lisp/dired-x.el index b06ca1b0908..245e41ba3a7 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -1172,56 +1172,28 @@ See `dired-guess-shell-alist-user'." (defun dired-guess-shell-command (prompt files) "Ask user with PROMPT for a shell command, guessing a default from FILES." - (let ((default (dired-guess-default files)) - default-list old-history val (failed t)) - + default-list val) (if (null default) ;; Nothing to guess (read-from-minibuffer prompt nil nil nil 'dired-shell-command-history) - - ;; Save current history list - (setq old-history dired-shell-command-history) - (if (listp default) - ;; More than one guess (setq default-list default default (car default) prompt (concat prompt (format "{%d guesses} " (length default-list)))) - ;; Just one guess (setq default-list (list default))) - - ;; Push all guesses onto history so that they can be retrieved with M-p - ;; and put the first guess in the prompt but not in the initial value. - (setq dired-shell-command-history - (append default-list dired-shell-command-history) - prompt (concat prompt (format "[%s] " default))) - - ;; The unwind-protect returns VAL, and we too. - (unwind-protect - ;; BODYFORM - (progn - (setq val (read-from-minibuffer prompt nil nil nil - 'dired-shell-command-history) - failed nil) - ;; If we got a return, then use default. - (if (equal val "") - (setq val default)) - val) - - ;; UNWINDFORMS - ;; Undo pushing onto the history list so that an aborted - ;; command doesn't get the default in the next command. - (setq dired-shell-command-history old-history) - (if (not failed) - (or (equal val (car-safe dired-shell-command-history)) - (setq dired-shell-command-history - (cons val dired-shell-command-history)))))))) - + ;; Put the first guess in the prompt but not in the initial value. + (setq prompt (concat prompt (format "[%s] " default))) + ;; All guesses can be retrieved with M-n + (setq val (read-from-minibuffer prompt nil nil nil + 'dired-shell-command-history + default-list)) + ;; If we got a return, then return default. + (if (equal val "") default val)))) ;;; REDEFINE. ;;; Redefine dired-aux.el's version: -- 2.39.2