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: Sun, 28 Oct 2007 12:57:19 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)

> Thanks for implementing this feature.
>
>     Now I propose to improve dired-x to read a list of commands from the 
> mailcap
>     mechanism, and later to move this code to dired.el.  An alternative would 
> be
>     to start implementing this in dired.el (provide a list of mailcap commands
>     available via M-n), but then after loading dired-x users will get less
>     useful list of commands in ! (since this is not implemented in dired-x).
>
> You could put this code in both.  dired-x is not used by most users,
> so having it only in dired-x is not very useful.

Below is a prototype code that puts commands retrieved by the mailcap
feature into the default list of the command `!' in Dired.  `M-n' allows
selecting a command to run.  The default list contains commands common to
all marked files.  Since mailcap marks the argument placeholder with
`%s', it's necessary to replace it with `*' used in Dired for the
same purpose, or remove it at the end of the command.

If this approach is right, before installing in CVS this code could be
changed to not use cl functions.

(defun dired-read-shell-command (prompt arg files)
  (dired-mark-pop-up
   nil 'shell files
   (function read-string)
   (format prompt (dired-mark-prompt arg files))
   nil 'shell-command-history
   (mapcan (lambda (mime-info)
             (let ((command (cdr (assoc 'viewer mime-info))))
               (if (stringp command)
                   (list (replace-regexp-in-string
                          "'%s'" "*"
                          (replace-regexp-in-string
                           "\s*'%s'$" "" command nil t) nil t)))))
           (reduce 'intersection
                   (mapcar (lambda (mime-type)
                             (mailcap-mime-info mime-type 'all))
                           (delete-dups (mapcar (lambda (file)
                                                  (mailcap-extension-to-mime
                                                   (file-name-extension file 
t)))
                                                files)))))))

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




reply via email to

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