Mercurial > emacs
comparison lisp/dired-x.el @ 85518:50f694f3549c
(dired-guess-shell-command): Put all guesses to the
minibuffer default value list instead of pushing them temporarily
to the history list.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Mon, 22 Oct 2007 00:22:37 +0000 |
parents | 9355f9b7bbff |
children | 1655a8cabb9d 4bc33ffdda1a |
comparison
equal
deleted
inserted
replaced
85517:ecea7a8a89d5 | 85518:50f694f3549c |
---|---|
1170 (t | 1170 (t |
1171 (mapcar (function eval) cmds))))) | 1171 (mapcar (function eval) cmds))))) |
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: |
1228 (defun dired-read-shell-command (prompt arg files) | 1200 (defun dired-read-shell-command (prompt arg files) |
1229 "Read a dired shell command prompting with PROMPT (using read-string). | 1201 "Read a dired shell command prompting with PROMPT (using read-string). |