emacs-devel
[Top][All Lists]
Advanced

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

Re: Minibuffer default values list


From: Juri Linkov
Subject: Re: Minibuffer default values list
Date: Mon, 19 Nov 2007 02:48:33 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

There is the following etc/TODO item that could be implemented now:

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

I think in addition to the file name it will be useful add a list of
commands extracted from mailcap to the "future history" list where a
filename placeholder is replaced with the buffer-file-name.  This will
help the user to select one of predefined commands by using M-n and
run it on the current buffer's file.

Below is a first implementation that has one drawback: it uses a new
function dired-read-shell-command-default from dired.  I think this
function should be generalized and moved to simple.el.

Index: lisp/simple.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/simple.el,v
retrieving revision 1.889
diff -c -r1.889 simple.el
*** lisp/simple.el      15 Nov 2007 16:42:43 -0000      1.889
--- lisp/simple.el      19 Nov 2007 00:48:12 -0000
***************
*** 1962,1969 ****
  In an interactive call, the variable `shell-command-default-error-buffer'
  specifies the value of ERROR-BUFFER."
  
!   (interactive (list (read-from-minibuffer "Shell command: "
!                                          nil nil nil 'shell-command-history)
                     current-prefix-arg
                     shell-command-default-error-buffer))
    ;; Look for a handler in case default-directory is a remote file name.
--- 1962,1979 ----
  In an interactive call, the variable `shell-command-default-error-buffer'
  specifies the value of ERROR-BUFFER."
  
!   (interactive (list (read-from-minibuffer
!                     "Shell command: "
!                     nil nil nil 'shell-command-history
!                     (if buffer-file-name
!                         (let* ((filename (file-relative-name 
buffer-file-name))
!                                (defaults (dired-read-shell-command-default
!                                           (list filename))))
!                           (cons filename
!                                 (mapcar (lambda (command)
!                                           (replace-regexp-in-string
!                                            "?" filename command nil t))
!                                         defaults)))))
                     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]