changeset 94255:3849fa236ab2

(dired-smart-shell-command): Sync arguments and interactive spec with changes in `shell-command'. Use dired-get-filename to get the dired file name at point as the default value in dired mode.
author Juri Linkov <juri@jurta.org>
date Tue, 22 Apr 2008 19:52:37 +0000
parents 2816dadb8db9
children 604177fe5586
files lisp/dired-x.el
diffstat 1 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/dired-x.el	Tue Apr 22 19:51:57 2008 +0000
+++ b/lisp/dired-x.el	Tue Apr 22 19:52:37 2008 +0000
@@ -838,13 +838,22 @@
   (or (eval (cdr (assq major-mode default-directory-alist)))
       default-directory))
 
-(defun dired-smart-shell-command (cmd &optional insert)
+(defun dired-smart-shell-command (command &optional output-buffer error-buffer)
   "Like function `shell-command', but in the current Virtual Dired directory."
-  (interactive (list (read-from-minibuffer "Shell command: "
-					   nil nil nil 'shell-command-history)
-		     current-prefix-arg))
+  (interactive
+   (list
+    (minibuffer-with-setup-hook
+	(lambda ()
+	  (set (make-local-variable 'minibuffer-default-add-function)
+	       'minibuffer-default-add-shell-commands))
+      (read-shell-command "Shell command: " nil nil
+			  (cond
+			   (buffer-file-name (file-relative-name buffer-file-name))
+			   ((eq major-mode 'dired-mode) (dired-get-filename t t)))))
+    current-prefix-arg
+    shell-command-default-error-buffer))
   (let ((default-directory (dired-default-directory)))
-    (shell-command cmd insert)))
+    (shell-command command output-buffer error-buffer)))
 
 
 ;;; LOCAL VARIABLES FOR DIRED BUFFERS.