* [patch] 21.3 dired.el direx-aux.el dired-read-shell-command and default values
@ 2004-02-07 14:30 Jari Aalto+mail.linux
0 siblings, 0 replies; 3+ messages in thread
From: Jari Aalto+mail.linux @ 2004-02-07 14:30 UTC (permalink / 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/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] 21.3 dired.el direx-aux.el dired-read-shell-command and default values
[not found] <mailman.2050.1076163753.928.bug-gnu-emacs@gnu.org>
@ 2004-02-09 18:51 ` Kevin Rodgers
[not found] ` <mailman.2134.1076352719.928.bug-gnu-emacs@gnu.org>
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Rodgers @ 2004-02-09 18:51 UTC (permalink / raw)
Jari Aalto+mail.linux wrote:
> 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.
Dan can get the behavior he desires by installing dired-x as documented
and adding a ("\\.pod\\'" "perldoc") entry to dired-guess-shell-alist-user.
If it is a bug that this is not configured by default, then you should
just patch dired-x.el and add that entry to dired-guess-shell-alist-default,
instead of defining a new variable and hacking up dired-aux.el.
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] 21.3 dired.el direx-aux.el dired-read-shell-command and default values
[not found] ` <mailman.2134.1076352719.928.bug-gnu-emacs@gnu.org>
@ 2004-03-24 11:33 ` Jari Aalto+mail.linux
0 siblings, 0 replies; 3+ messages in thread
From: Jari Aalto+mail.linux @ 2004-03-24 11:33 UTC (permalink / raw)
* Mon 2004-02-09 Kevin Rodgers <ihs_4664 <AT> yahoo.com> gnu.emacs.bug
* <http://groups.google.com/groups?oi=djq&as_umsgid=%3Cmailman.2134.1076352719.928.bug-gnu-emacs@gnu.org>
| Dan can get the behavior he desires by installing dired-x as documented
| and adding a ("\\.pod\\'" "perldoc") entry to dired-guess-shell-alist-user.
|
| If it is a bug that this is not configured by default, then you should
| just patch dired-x.el and add that entry to dired-guess-shell-alist-default,
| instead of defining a new variable and hacking up dired-aux.el.
Didn't know about dired-x's feature. OK, here is the correct patch
against 21.3
Jari
2004-03-24 Wed Jari Aalto <jari.aalto <AT> poboxes.com>
* dired-x.el (dired-guess-shell-alist-default):
Added Perl .pod support.
Index: dired-x.el
===================================================================
RCS file: /cygdrive/h/data/version-control/cvsroot/emacs/gnu-emacs/lisp213/dired-x.el,v
retrieving revision 1.1.1.1
diff -u -IId: -u -b -w -r1.1.1.1 dired-x.el
--- dired-x.el 26 Jun 2003 18:06:08 -0000 1.1.1.1
+++ dired-x.el 24 Mar 2004 11:28:28 -0000
@@ -961,7 +961,7 @@
;; Optional conversion to gzip format.
'(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
" " dired-guess-shell-znew-switches))
-
+ '("\\.pod$" "perldoc") ; Perl documentation
'("\\.dvi$" "xdvi" "dvips") ; preview and printing
'("\\.au$" "play") ; play Sun audiofiles
'("\\.mpg$" "mpeg_play")
--
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/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-03-24 11:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-07 14:30 [patch] 21.3 dired.el direx-aux.el dired-read-shell-command and default values Jari Aalto+mail.linux
[not found] <mailman.2050.1076163753.928.bug-gnu-emacs@gnu.org>
2004-02-09 18:51 ` Kevin Rodgers
[not found] ` <mailman.2134.1076352719.928.bug-gnu-emacs@gnu.org>
2004-03-24 11:33 ` Jari Aalto+mail.linux
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.