[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] 21.3 dired.el direx-aux.el dired-read-shell-command and default
From: |
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 |
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 @@
;;; 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/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [patch] 21.3 dired.el direx-aux.el dired-read-shell-command and default values,
Jari Aalto+mail.linux <=