aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2007-10-22 00:22:56 +0000
committerJuri Linkov2007-10-22 00:22:56 +0000
commit5420b514775c4592b6e86029f52f4ce455f09cf2 (patch)
tree299f4a24d7410da605256483939bacf319d15854
parentfb30dfd235a7528f77d0e39f737545562e209461 (diff)
downloademacs-5420b514775c4592b6e86029f52f4ce455f09cf2.tar.gz
emacs-5420b514775c4592b6e86029f52f4ce455f09cf2.zip
(dired-guess-shell-command): Put all guesses to the
minibuffer default value list instead of pushing them temporarily to the history list.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/dired-x.el46
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 @@
3 * simple.el (goto-history-element): Allow minibuffer-default to be 3 * simple.el (goto-history-element): Allow minibuffer-default to be
4 a list of default values accessible by typing M-n in the minibuffer. 4 a list of default values accessible by typing M-n in the minibuffer.
5 5
6 * dired-x.el (dired-guess-shell-command): Put all guesses to the
7 minibuffer default value list instead of pushing them temporarily
8 to the history list.
9
62007-10-21 Stefan Monnier <monnier@iro.umontreal.ca> 102007-10-21 Stefan Monnier <monnier@iro.umontreal.ca>
7 11
8 * emacs-lisp/byte-opt.el (byte-optimize-featurep): Fix paren typo. 12 * 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'."
1172 1172
1173(defun dired-guess-shell-command (prompt files) 1173(defun dired-guess-shell-command (prompt files)
1174 "Ask user with PROMPT for a shell command, guessing a default from FILES." 1174 "Ask user with PROMPT for a shell command, guessing a default from FILES."
1175
1176 (let ((default (dired-guess-default files)) 1175 (let ((default (dired-guess-default files))
1177 default-list old-history val (failed t)) 1176 default-list val)
1178
1179 (if (null default) 1177 (if (null default)
1180 ;; Nothing to guess 1178 ;; Nothing to guess
1181 (read-from-minibuffer prompt nil nil nil 'dired-shell-command-history) 1179 (read-from-minibuffer prompt nil nil nil 'dired-shell-command-history)
1182
1183 ;; Save current history list
1184 (setq old-history dired-shell-command-history)
1185
1186 (if (listp default) 1180 (if (listp default)
1187
1188 ;; More than one guess 1181 ;; More than one guess
1189 (setq default-list default 1182 (setq default-list default
1190 default (car default) 1183 default (car default)
1191 prompt (concat 1184 prompt (concat
1192 prompt 1185 prompt
1193 (format "{%d guesses} " (length default-list)))) 1186 (format "{%d guesses} " (length default-list))))
1194
1195 ;; Just one guess 1187 ;; Just one guess
1196 (setq default-list (list default))) 1188 (setq default-list (list default)))
1197 1189 ;; Put the first guess in the prompt but not in the initial value.
1198 ;; Push all guesses onto history so that they can be retrieved with M-p 1190 (setq prompt (concat prompt (format "[%s] " default)))
1199 ;; and put the first guess in the prompt but not in the initial value. 1191 ;; All guesses can be retrieved with M-n
1200 (setq dired-shell-command-history 1192 (setq val (read-from-minibuffer prompt nil nil nil
1201 (append default-list dired-shell-command-history) 1193 'dired-shell-command-history
1202 prompt (concat prompt (format "[%s] " default))) 1194 default-list))
1203 1195 ;; If we got a return, then return default.
1204 ;; The unwind-protect returns VAL, and we too. 1196 (if (equal val "") default val))))
1205 (unwind-protect
1206 ;; BODYFORM
1207 (progn
1208 (setq val (read-from-minibuffer prompt nil nil nil
1209 'dired-shell-command-history)
1210 failed nil)
1211 ;; If we got a return, then use default.
1212 (if (equal val "")
1213 (setq val default))
1214 val)
1215
1216 ;; UNWINDFORMS
1217 ;; Undo pushing onto the history list so that an aborted
1218 ;; command doesn't get the default in the next command.
1219 (setq dired-shell-command-history old-history)
1220 (if (not failed)
1221 (or (equal val (car-safe dired-shell-command-history))
1222 (setq dired-shell-command-history
1223 (cons val dired-shell-command-history))))))))
1224
1225 1197
1226;;; REDEFINE. 1198;;; REDEFINE.
1227;;; Redefine dired-aux.el's version: 1199;;; Redefine dired-aux.el's version: