emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

M-! M-n should fetch filename (Re: FFAP)


From: Juri Linkov
Subject: M-! M-n should fetch filename (Re: FFAP)
Date: Mon, 09 Nov 2009 12:36:33 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu)

There is the following etc/TODO item:

  ** M-! M-n should fetch the buffer-file-name as the default.

However, it seems it's already implemented.  What is missing
is an ability of M-! M-n to fetch the filename as the default
in Dired mode using `dired-get-filename'.  The patch below
implements this.

Please note that it doesn't use a guesser based on the
filename at point when not in Dired mode.  I'm not sure
whether it makes sense to get the filename at point as the
base for building a command line for `shell-command'.

Index: lisp/simple.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/simple.el,v
retrieving revision 1.1022
diff -c -r1.1022 simple.el
*** lisp/simple.el      30 Oct 2009 02:00:30 -0000      1.1022
--- lisp/simple.el      9 Nov 2009 10:31:21 -0000
***************
*** 2136,2143 ****
    (interactive
     (list
      (read-shell-command "Shell command: " nil nil
!                       (and buffer-file-name
!                            (file-relative-name buffer-file-name)))
      current-prefix-arg
      shell-command-default-error-buffer))
    ;; Look for a handler in case default-directory is a remote file name.
--- 2152,2163 ----
    (interactive
     (list
      (read-shell-command "Shell command: " nil nil
!                       (cond
!                        ((eq major-mode 'dired-mode)
!                         (let ((filename (dired-get-filename nil t)))
!                           (and filename (file-relative-name filename))))
!                        (buffer-file-name
!                         (file-relative-name buffer-file-name))))
      current-prefix-arg
      shell-command-default-error-buffer))
    ;; Look for a handler in case default-directory is a remote file name.

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]