comparison lisp/dired-x.el @ 102200:74dd2284ef3a

(dired-guess-shell-command): Use read-shell-command instead of read-from-minibuffer. (dired-read-shell-command): Add code that uses minibuffer-with-setup-hook to set minibuffer-default-add-function to minibuffer-default-add-dired-shell-commands exactly like `dired-read-shell-command' in dired-aux.el already does. Doc fix.
author Juri Linkov <juri@jurta.org>
date Sun, 22 Feb 2009 23:36:46 +0000
parents 1c6cb8760e45
children a7393d93645e
comparison
equal deleted inserted replaced
102199:6f66db4c1c98 102200:74dd2284ef3a
1185 "Ask user with PROMPT for a shell command, guessing a default from FILES." 1185 "Ask user with PROMPT for a shell command, guessing a default from FILES."
1186 (let ((default (dired-guess-default files)) 1186 (let ((default (dired-guess-default files))
1187 default-list val) 1187 default-list val)
1188 (if (null default) 1188 (if (null default)
1189 ;; Nothing to guess 1189 ;; Nothing to guess
1190 (read-from-minibuffer prompt nil nil nil 'dired-shell-command-history) 1190 (read-shell-command prompt nil 'dired-shell-command-history)
1191 (if (listp default) 1191 (if (listp default)
1192 ;; More than one guess 1192 ;; More than one guess
1193 (setq default-list default 1193 (setq default-list default
1194 default (car default) 1194 default (car default)
1195 prompt (concat 1195 prompt (concat
1198 ;; Just one guess 1198 ;; Just one guess
1199 (setq default-list (list default))) 1199 (setq default-list (list default)))
1200 ;; Put the first guess in the prompt but not in the initial value. 1200 ;; Put the first guess in the prompt but not in the initial value.
1201 (setq prompt (concat prompt (format "[%s] " default))) 1201 (setq prompt (concat prompt (format "[%s] " default)))
1202 ;; All guesses can be retrieved with M-n 1202 ;; All guesses can be retrieved with M-n
1203 (setq val (read-from-minibuffer prompt nil nil nil 1203 (setq val (read-shell-command prompt nil
1204 'dired-shell-command-history 1204 'dired-shell-command-history
1205 default-list)) 1205 default-list))
1206 ;; If we got a return, then return default. 1206 ;; If we got a return, then return default.
1207 (if (equal val "") default val)))) 1207 (if (equal val "") default val))))
1208 1208
1209 ;; REDEFINE. 1209 ;; REDEFINE.
1210 ;; Redefine dired-aux.el's version: 1210 ;; Redefine dired-aux.el's version:
1211 (defun dired-read-shell-command (prompt arg files) 1211 (defun dired-read-shell-command (prompt arg files)
1212 "Read a dired shell command prompting with PROMPT (using read-string). 1212 "Read a dired shell command prompting with PROMPT (using read-shell-command).
1213 ARG is the prefix arg and may be used to indicate in the prompt which 1213 ARG is the prefix arg and may be used to indicate in the prompt which
1214 files are affected. 1214 FILES are affected.
1215 This is an extra function so that you can redefine it." 1215 This is an extra function so that you can redefine it."
1216 (dired-mark-pop-up 1216 (minibuffer-with-setup-hook
1217 nil 'shell files 1217 (lambda ()
1218 'dired-guess-shell-command 1218 (set (make-local-variable 'minibuffer-default-add-function)
1219 (format prompt (dired-mark-prompt arg files)) ; PROMPT 1219 'minibuffer-default-add-dired-shell-commands))
1220 files)) ; FILES 1220 (dired-mark-pop-up
1221 nil 'shell files
1222 'dired-guess-shell-command
1223 (format prompt (dired-mark-prompt arg files)) ; PROMPT
1224 files))) ; FILES
1221 1225
1222 1226
1223 ;;; RELATIVE SYMBOLIC LINKS. 1227 ;;; RELATIVE SYMBOLIC LINKS.
1224 1228
1225 (declare-function make-symbolic-link "fileio.c") 1229 (declare-function make-symbolic-link "fileio.c")