From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22426 invoked from network); 4 Jun 2007 12:00:26 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.0 (2007-05-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=no version=3.2.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 4 Jun 2007 12:00:26 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 36098 invoked from network); 4 Jun 2007 12:00:20 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 4 Jun 2007 12:00:20 -0000 Received: (qmail 3854 invoked by alias); 4 Jun 2007 12:00:18 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23518 Received: (qmail 3845 invoked from network); 4 Jun 2007 12:00:17 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 4 Jun 2007 12:00:17 -0000 Received: (qmail 35854 invoked from network); 4 Jun 2007 12:00:17 -0000 Received: from cluster-d.mailcontrol.com (217.69.20.190) by a.mx.sunsite.dk with SMTP; 4 Jun 2007 12:00:12 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly38d.srv.mailcontrol.com (MailControl) with ESMTP id l54BvwiW026872 for ; Mon, 4 Jun 2007 12:59:42 +0100 Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Mon, 4 Jun 2007 12:59:05 +0100 Date: Mon, 4 Jun 2007 12:59:05 +0100 From: Peter Stephenson To: Zsh-Workers Subject: Re: alias -s doesn't friendly deal with programs having an extension Message-ID: <20070604125905.4f1a48fd@news01.csr.com> In-Reply-To: <2007-06-03T23-14-39@devnull.michael-prokop.at> References: <20070601095747.GA23444@finlandia.home.infodrom.org> <200706011029.l51ATZbo008613@news01.csr.com> <20070601105036.GB26375@finlandia.home.infodrom.org> <200706011100.l51B0g4e008865@news01.csr.com> <2007-06-03T23-14-39@devnull.michael-prokop.at> Organization: CSR X-Mailer: Claws Mail 2.9.1 (GTK+ 2.10.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 04 Jun 2007 11:59:05.0635 (UTC) FILETIME=[C01AEF30:01C7A69F] X-Scanned-By: MailControl A-07-07-05 (www.mailcontrol.com) on 10.68.0.148 On Sun, 3 Jun 2007 23:18:05 +0200 Michael Prokop wrote: > This would be great, I stumbled upon this bug with > > autoload zsh-mime-setup && zsh-mime-setup > > and using catalyst.pl from the catalyst web framework. > It took me some seconds to figure out why invoking catalyst.pl > always resulted in "catalyst.pl baerli: No such file or directory". ;) Hmm... do you have the style handle-nonexistent set to false? Otherwise, if it doesn't find the file locally it will simply try to execute it anyway. So if that's a normal executable script it should work. Here's the fairly straighforward patch for the style option find-file-in-path, and also the style file-path so you can find different types of file in different paths, e.g. zstyle ':mime:.png:' find-file-in-path true zstyle ':mime:.png:' file-path ~/images /usr/local/share/pixmaps No completion support yet. That's a nice self-contained exercise for someone. Index: Doc/Zsh/contrib.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/contrib.yo,v retrieving revision 1.69 diff -u -r1.69 contrib.yo --- Doc/Zsh/contrib.yo 21 May 2007 11:32:03 -0000 1.69 +++ Doc/Zsh/contrib.yo 4 Jun 2007 11:54:51 -0000 @@ -1510,12 +1510,14 @@ to style patterns in case the system is extended in future. Some examples are given below. startitem() +kindex(current-shell, MIME style) item(tt(current-shell))( If this boolean style is true, the mailcap handler for the context in question is run using the tt(eval) builtin instead of by starting a new tt(sh) process. This is more efficient, but may not work in the occasional cases where the mailcap handler uses strict POSIX syntax. ) +kindex(execute-as-is, MIME style) item(tt(execute-as-is))( This style gives a list of patterns to be matched against files passed for execution with a handler program. If the file matches @@ -1527,10 +1529,36 @@ handler, and the option tt(AUTO_CD) may be used to change to directories that happen to have MIME suffixes. ) +kindex(file-path, MIME style) +item(tt(file-path))( +Used if the style tt(find-file-in-path) is true for the same context. +Set to an array of directories that are used for searching for the +file to be handled; the default is the command path given by the +special parameter tt(path). The shell option tt(PATH_DIRS) is respected; +if that is set, the appropriate path will be searched even if the +name of the file to be handled as it appears on the command line contains +a `tt(/)'. +The full context is tt(:mime:.)var(suffix)tt(:), as described for the style +tt(handler). +) +kindex(find-file-in-path, MIME style) +item(tt(find-file-in-path))( +If set, allows files whose names do not contain absolute paths +to be searched for in the command path or the path specified by the +tt(file-path) style. If the file is not found in the path, it is looked +for locally (whether or not the current directory is in the path); if it is +not found locally, the handler will abort unless the tt(handle-nonexistent) +style is set. Files found in the path are tested as described for +the style tt(execute-as-is). +The full context is tt(:mime:.)var(suffix)tt(:), as described for the style +tt(handler). +) +kindex(flags, MIME style) item(tt(flags))( Defines flags to go with a handler; the context is as for the tt(handler) style, and the format is as for the flags in tt(mailcap). ) +kindex(handle-nonexistent, MIME style) item(tt(handle-nonexistent))( By default, arguments that don't correspond to files are not passed to the MIME handler in order to prevent it from intercepting commands found @@ -1539,7 +1567,10 @@ handler even if they don't exist. If it is not explicitly set it defaults to tt([[:alpha:]]#:/*) which allows URLs to be passed to the MIME handler even though they don't exist in that format in the file system. +The full context is tt(:mime:.)var(suffix)tt(:), as described for the style +tt(handler). ) +kindex(handler, MIME style) item(tt(handler))( Specifies a handler for a suffix; the suffix is given by the context as tt(:mime:.)var(suffix)tt(:), and the format of the handler is exactly @@ -1550,12 +1581,14 @@ or if the output is to be displayed through a pager (but not if the handler is itself a pager), it should include tt(copiousoutput). ) +kindex(mailcap, MIME style) item(tt(mailcap))( A list of files in the format of tt(~/.mailcap) and tt(/etc/mailcap) to be read during setup, replacing the default list which consists of those two files. The context is tt(:mime:). A tt(PLUS()) in the list will be replaced by the default files. ) +kindex(mailcap-priorities, MIME style) item(tt(mailcap-priorities))( This style is used to resolve multiple mailcap entries for the same MIME type. It consists of an array of the following elements, in descending @@ -1585,6 +1618,7 @@ Note that as this style is handled during initialisation, the context is always tt(:mime:), with no discrimination by suffix. ) +kindex(mailcap-prio-flags, MIME style) item(tt(mailcap-prio-flags))( This style is used when the keyword tt(flags) is encountered in the list of tests specified by the tt(mailcap-priorities) style. @@ -1594,18 +1628,21 @@ patterns in the list are preferred to later ones, and matched patterns are preferred to unmatched ones. ) +kindex(mime-types, MIME style) item(tt(mime-types))( A list of files in the format of tt(~/.mime.types) and tt(/etc/mime.types) to be read during setup, replacing the default list which consists of those two files. The context is tt(:mime:). A tt(PLUS()) in the list will be replaced by the default files. ) +kindex(never-background, MIME style) item(tt(never-background))( If this boolean style is set, the handler for the given context is always run in the foreground, even if the flags provided in the mailcap entry suggest it need not be (for example, it doesn't require a terminal). ) +kindex(pager, MIME style) item(tt(pager))( If set, will be used instead of tt($PAGER) or tt(more) to handle suffixes where the tt(copiousoutput) flag is set. The context is Index: Functions/MIME/zsh-mime-handler =================================================================== RCS file: /cvsroot/zsh/zsh/Functions/MIME/zsh-mime-handler,v retrieving revision 1.9 diff -u -r1.9 zsh-mime-handler --- Functions/MIME/zsh-mime-handler 9 Aug 2006 16:17:13 -0000 1.9 +++ Functions/MIME/zsh-mime-handler 4 Jun 2007 11:54:51 -0000 @@ -64,6 +64,22 @@ local pattern local -a files +# Search some path for the file, if required. +# We do this before any other tests that need to find the +# actual file or its directory. +local dir +local -a filepath +if zstyle -t $context find-file-in-path && [[ $1 != /* ]] && + [[ $1 != */* || -o pathdirs ]]; then + zstyle -a $context file-path filepath || filepath=($path) + for dir in $filepath; do + if [[ -e $dir/$1 ]]; then + 1=$dir/$1 + break + fi + done +fi + # In case the pattern contains glob qualifiers, as it does by default, # we need to do real globbing, not just pattern matching. # The strategy is to glob the files in the directory using the @@ -111,7 +127,6 @@ # terminal and display is set. zstyle -t $context never-background && no_bg=yes -local -a files local hasmeta stdin # See if the handler has shell metacharacters in. @@ -120,7 +135,7 @@ hasmeta=1 fi -local -a execargs +local -a execargs files if [[ $handler = *%s* ]]; then # We need to replace %s with the file(s). -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview