From: jari.aalto@poboxes.com (Jari Aalto+mail.linux)
Subject: [patch] 21.3 dired.el direx-aux.el dired-read-shell-command and default values
Date: Sat, 07 Feb 2004 16:30:15 +0200 [thread overview]
Message-ID: <smhn3qtk.fsf@blue.sea.net> (raw)
In regard to this mail, here are patches for generally framework
of this kind. The command offered depends on file extension.
From: Dan Jacobson <jidanni <AT> jidanni.org>
Subject: make .pod trigger perldoc
Newsgroups: gnu.emacs.bug
To: bug-gnu-emacs <AT> gnu.org
Date: 2004-02-04 06:07 ke EET
Message-ID: <mailman.2008.1076101438.928.bug-gnu-emacs <AT> gnu.org>
Make perldoc the default dired-do-shell-command when encountering
.pod files.
2004-02-07 Sat Jari Aalto <jari.aalto <AT> poboxes.com>
* dired.el (dired-shell-command-list): New user variable.
* dired-aux.el (dired-read-shell-command-default-command): New.
(dired-read-shell-command): Consult
`dired-read-shell-command-default-command' and offer default if
any.
Index: dired.el
===================================================================
RCS file: /cygdrive/h/data/version-control/cvsroot/emacs/gnu-emacs/lisp213/dired.el,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -IId: -u -b -w -r1.1 -r1.2
--- dired.el 26 Jun 2003 18:06:08 -0000 1.1
+++ dired.el 7 Feb 2004 10:45:50 -0000 1.2
@@ -169,6 +169,24 @@
:type 'string
:group 'dired)
+(defcustom dired-shell-command-list
+ (list
+ '("man$" "nroff -man")
+ '("pod$" "perldoc")
+ (cond
+ ((and (not (memq system-type '(windows-nt ms-dos)))
+ (executable-find "xpdf"))
+ (list "pdf$" "xpdf"))))
+ "*In `dired-do-shell-command' if filename extension matches REGEXP, offer COMMAND.
+The format is: '((FILE-EXTENSION-REGEXP COMMAND) (... ...) ...)
+Notice that the FILE-EXTENSION-REGEXP is matched against result of
+`file-name-extension' whose return value does not include dot character."
+ :type '(repeat
+ (list
+ (string :tag "file extension regexp")
+ (string :tag "command to run")))
+ :group 'dired)
+
;;; Hook variables
(defvar dired-load-hook nil
Index: dired-aux.el
===================================================================
RCS file: /cygdrive/h/data/version-control/cvsroot/emacs/gnu-emacs/lisp213/dired-aux.el,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -IId: -u -b -w -r1.1 -r1.2
--- dired-aux.el 26 Jun 2003 18:06:08 -0000 1.1
+++ dired-aux.el 7 Feb 2004 14:05:08 -0000 1.2
@@ -296,6 +296,22 @@
\f
;;; Shell commands
+(defun dired-read-shell-command-default-command (files)
+ "From FILES, guess default command for `dired-read-shell-command'.
+Return nil or command."
+ (let (ext-list)
+ (dolist (file files)
+ (pushnew (file-name-extension (file-name-nondirectory file))
+ ext-list))
+ (when (eq 1 (length ext-list))
+ ;; All have the same extension
+ (dolist (elt dired-shell-command-list)
+ (multiple-value-bind (regexp command) elt
+ (when (and (stringp regexp)
+ (stringp command)
+ (string-match regexp (car ext-list)))
+ (return command)))))))
+
(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
@@ -305,7 +321,8 @@
nil 'shell files
(function read-string)
(format prompt (dired-mark-prompt arg files))
- nil 'shell-command-history))
+ (dired-read-shell-command-default-command files)
+ 'shell-command-history))
;; The in-background argument is only needed in Emacs 18 where
;; shell-command doesn't understand an appended ampersand `&'.
@@ -334,7 +351,8 @@
output files usually are created there instead of in a subdir.
In a noninteractive call (from Lisp code), you must specify
-the list of file names explicitly with the FILE-LIST argument."
+the list of file names explicitly with the FILE-LIST argument.
+See also variable `dired-shell-command-list'."
;;Functions dired-run-shell-command and dired-shell-stuff-it do the
;;actual work and can be redefined for customization.
(interactive
--
http://tiny-tools.sourceforge.net/
Swatch @time http://www.mir.com.my/iTime/itime.htm
http://www.ryanthiessen.com/swatch/resources.htm
Use Licenses! http://www.linuxjournal.com/article.php?sid=6225
Which Licence? http://www.linuxjournal.com/article.php?sid=4825
OSI Licences http://www.opensource.org/licenses/
next reply other threads:[~2004-02-07 14:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-07 14:30 Jari Aalto+mail.linux [this message]
[not found] <mailman.2050.1076163753.928.bug-gnu-emacs@gnu.org>
2004-02-09 18:51 ` [patch] 21.3 dired.el direx-aux.el dired-read-shell-command and default values Kevin Rodgers
[not found] ` <mailman.2134.1076352719.928.bug-gnu-emacs@gnu.org>
2004-03-24 11:33 ` Jari Aalto+mail.linux
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=smhn3qtk.fsf@blue.sea.net \
--to=jari.aalto@poboxes.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).