From e0987650e49822955b70504140e801f823ce4468 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 11 Nov 2009 00:11:40 +0000 Subject: [PATCH] (dired-get-filename): Tell the byte-compiler about dired-get-filename. (shell-command): In Dired mode, get filename from the current line as the default value. --- etc/TODO | 2 -- lisp/ChangeLog | 7 +++++++ lisp/simple.el | 9 +++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/etc/TODO b/etc/TODO index ba7af10134..3c5462a176 100644 --- a/etc/TODO +++ b/etc/TODO @@ -112,8 +112,6 @@ for users to customize. ** Add function to redraw the tool bar. -** M-! M-n should fetch the buffer-file-name as the default. - ** Redesign the load-history data structure so it can cope better with evaluating definitions of the same function from different files, recording which file the latest definition came from. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 652bd91d71..9bc07939f5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2009-11-11 Juri Linkov + + * simple.el (dired-get-filename): + Tell the byte-compiler about dired-get-filename. + (shell-command): In Dired mode, get filename from the current line + as the default value. + 2009-11-10 Glenn Morris * dired.el, hi-lock.el, calendar/cal-menu.el, calendar/calendar.el: diff --git a/lisp/simple.el b/lisp/simple.el index dbdcfde8ef..07ac2cc638 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2013,6 +2013,7 @@ is run interactively. A value of nil means that output to stderr and stdout will be intermixed in the output stream.") (declare-function mailcap-file-default-commands "mailcap" (files)) +(declare-function dired-get-filename "dired" (&optional localp no-error-if-not-filep)) (defun minibuffer-default-add-shell-commands () "Return a list of all commands associated with the current file. @@ -2136,8 +2137,12 @@ specifies the value of ERROR-BUFFER." (interactive (list (read-shell-command "Shell command: " nil nil - (and buffer-file-name - (file-relative-name buffer-file-name))) + (let ((filename + (cond + (buffer-file-name) + ((eq major-mode 'dired-mode) + (dired-get-filename nil t))))) + (and filename (file-relative-name filename)))) current-prefix-arg shell-command-default-error-buffer)) ;; Look for a handler in case default-directory is a remote file name. -- 2.20.1