From: Juri Linkov <juri@jurta.org>
To: rms@gnu.org
Cc: emacs-devel@gnu.org
Subject: Re: Minibuffer default values list
Date: Mon, 12 Nov 2007 01:42:54 +0200 [thread overview]
Message-ID: <87prygxtot.fsf@jurta.org> (raw)
In-Reply-To: <87hckbecc0.fsf@jurta.org> (Juri Linkov's message of "Sun, 28 Oct 2007 12:57:19 +0200")
>> 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.
Below is a patch ready to install that implements this feature
without using cl functions:
Index: lisp/dired-aux.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/dired-aux.el,v
retrieving revision 1.157
diff -c -r1.157 dired-aux.el
*** lisp/dired-aux.el 9 Nov 2007 09:45:23 -0000 1.157
--- lisp/dired-aux.el 11 Nov 2007 23:41:29 -0000
***************
*** 463,468 ****
--- 498,547 ----
\f
;;; Shell commands
+ (defun dired-read-shell-command-default (files)
+ "Return a list of default commands for `dired-read-shell-command'."
+ (require 'mailcap)
+ (mailcap-parse-mailcaps)
+ (mailcap-parse-mimetypes)
+ (let* ((all-mime-type
+ ;; All unique MIME types from file extensions
+ (delete-dups (mapcar (lambda (file)
+ (mailcap-extension-to-mime
+ (file-name-extension file t)))
+ files)))
+ (all-mime-info
+ ;; All MIME info lists
+ (delete-dups (mapcar (lambda (mime-type)
+ (mailcap-mime-info mime-type 'all))
+ all-mime-type)))
+ (common-mime-info
+ ;; Intersection of mime-infos from different mime-types;
+ ;; or just the first MIME info for a single MIME type
+ (if (cdr all-mime-info)
+ (delq nil (mapcar (lambda (mi1)
+ (unless (memq nil (mapcar
+ (lambda (mi2)
+ (member mi1 mi2))
+ (cdr all-mime-info)))
+ mi1))
+ (car all-mime-info)))
+ (car all-mime-info)))
+ (commands
+ ;; Command strings from `viewer' field of the MIME info
+ (delq nil (mapcar (lambda (mime-info)
+ (let ((command (cdr (assoc 'viewer mime-info))))
+ (if (stringp command)
+ (replace-regexp-in-string
+ ;; Replace mailcap's `%s' placeholder
+ ;; with dired's `*' placeholder
+ "%s" "*"
+ (replace-regexp-in-string
+ ;; Remove the final filename placeholder
+ "\s*\\('\\)?%s\\1?\s*$" "" command nil t)
+ nil t))))
+ common-mime-info))))
+ commands))
+
(defun dired-read-shell-command (prompt arg files)
;; "Read a dired shell command prompting with PROMPT (using read-string).
;;ARG is the prefix arg and may be used to indicate in the prompt which
***************
*** 472,478 ****
nil 'shell files
(function read-string)
(format prompt (dired-mark-prompt arg files))
! nil 'shell-command-history))
;; The in-background argument is only needed in Emacs 18 where
;; shell-command doesn't understand an appended ampersand `&'.
--- 551,558 ----
nil 'shell files
(function read-string)
(format prompt (dired-mark-prompt arg files))
! nil 'shell-command-history
! (dired-read-shell-command-default files)))
;; The in-background argument is only needed in Emacs 18 where
;; shell-command doesn't understand an appended ampersand `&'.
--
Juri Linkov
http://www.jurta.org/emacs/
next prev parent reply other threads:[~2007-11-11 23:42 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-22 0:22 Minibuffer default values list Juri Linkov
2007-10-23 7:12 ` Richard Stallman
2007-10-28 10:57 ` Juri Linkov
2007-11-11 23:42 ` Juri Linkov [this message]
2007-11-12 5:59 ` Richard Stallman
2007-11-16 1:27 ` Substitute ? in dired without surrounding whitespace (was: Minibuffer default values list) Juri Linkov
2007-11-17 23:30 ` Richard Stallman
2007-11-17 23:57 ` Substitute ? in dired without surrounding whitespace Juri Linkov
2007-11-18 22:46 ` Richard Stallman
2007-11-19 0:48 ` Minibuffer default values list Juri Linkov
2007-11-22 2:28 ` Richard Stallman
2007-11-22 19:02 ` Juri Linkov
2007-11-23 4:35 ` Richard Stallman
2007-11-24 17:54 ` Juri Linkov
2007-11-25 3:43 ` Richard Stallman
2007-11-25 15:18 ` mb-pos.el (was: Minibuffer default values list) Juri Linkov
2007-12-02 21:27 ` Richard Stallman
2007-12-03 0:34 ` Minibuffer default values list Juri Linkov
2007-12-03 18:43 ` Richard Stallman
2007-11-25 15:19 ` Subject: mb-depth.el (was: Minibuffer default values list) Juri Linkov
2008-07-31 17:28 ` Juri Linkov
2008-07-31 18:08 ` Drew Adams
2008-07-31 18:24 ` Juanma Barranquero
2008-07-31 18:35 ` Drew Adams
2008-08-01 12:34 ` Juanma Barranquero
2008-08-01 16:27 ` Drew Adams
2008-08-01 17:09 ` mb-depth.el patch Drew Adams
2008-08-04 13:13 ` Juanma Barranquero
2007-11-23 4:35 ` Minibuffer default values list Richard Stallman
2007-11-23 15:05 ` Stefan Monnier
[not found] ` <E1IvwoM-0004oD-AU@fencepost.gnu.org>
[not found] ` <jwvwss5ptqv.fsf-monnier+emacs@gnu.org>
2007-12-03 18:42 ` Richard Stallman
2007-11-19 0:52 ` Juri Linkov
2007-11-19 19:02 ` Richard Stallman
2007-11-23 0:48 ` Juri Linkov
2007-11-11 23:43 ` Juri Linkov
2007-11-12 5:59 ` Richard Stallman
2007-11-11 23:45 ` Juri Linkov
2007-11-12 5:59 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87prygxtot.fsf@jurta.org \
--to=juri@jurta.org \
--cc=emacs-devel@gnu.org \
--cc=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.