From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: jari.aalto@poboxes.com (Jari Aalto+mail.linux) Newsgroups: gmane.emacs.bugs 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 Organization: Private Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1076163997 32691 80.91.224.253 (7 Feb 2004 14:26:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 7 Feb 2004 14:26:37 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 07 15:26:26 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ApTPd-0007rh-01 for ; Sat, 07 Feb 2004 15:26:25 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ApTLs-0005XZ-9n for geb-bug-gnu-emacs@m.gmane.org; Sat, 07 Feb 2004 09:22:32 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1ApTLr-0005X8-4c for bug-gnu-emacs@prep.ai.mit.edu; Sat, 07 Feb 2004 09:22:31 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1ApTLK-0005UA-2C for bug-gnu-emacs@prep.ai.mit.edu; Sat, 07 Feb 2004 09:22:30 -0500 Original-Received: from [216.168.1.22] (helo=trinity.supernews.net) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.24) id 1ApTIf-00049K-VL for bug-gnu-emacs@prep.ai.mit.edu; Sat, 07 Feb 2004 09:19:14 -0500 Original-Received: from smtp31.kolumbus.fi ([193.229.0.36]:46188) by trinity.supernews.net with esmtp (Exim 4.24; FreeBSD) id 1ApTIc-000Aow-Dt for gnu-emacs-bug@moderators.isc.org; Sat, 07 Feb 2004 14:19:12 +0000 Original-Received: from news.kolumbus.fi (news.kolumbus.fi [193.229.0.31]) by smtp31.kolumbus.fi (8.12.10/8.12.4) with ESMTP id i17EIw1A008232 for ; Sat, 7 Feb 2004 16:18:58 +0200 (EET) Original-Received: (from news@localhost) by news.kolumbus.fi (8.11.6+Sun/8.11.6) id i17EIvC25519 for gnu-emacs-bug@moderators.isc.org; Sat, 7 Feb 2004 16:18:57 +0200 (EET) Original-To: gnu-emacs-bug@moderators.isc.org Original-Path: not-for-mail Original-Newsgroups: gnu.emacs.bug Original-Lines: 118 Original-NNTP-Posting-Host: a110t7.elisa.omakaista.fi Original-X-Trace: phys-news1.kolumbus.fi 1076163537 25517 81.197.3.110 (7 Feb 2004 14:18:57 GMT) Original-X-Complaints-To: abuse@kolumbus.fi Original-NNTP-Posting-Date: Sat, 7 Feb 2004 14:18:57 +0000 (UTC) Cancel-Lock: sha1:/UtFOeDABb7pC9HJBgyDQ7MvEyU= X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:6898 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:6898 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.org> Subject: make .pod trigger perldoc Newsgroups: gnu.emacs.bug To: bug-gnu-emacs gnu.org Date: 2004-02-04 06:07 ke EET Message-ID: gnu.org> Make perldoc the default dired-do-shell-command when encountering .pod files. 2004-02-07 Sat Jari Aalto 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/