From: Nikolai Weibull <mailing-lists.zsh-users@rawuncut.elitemail.org>
To: zsh-users@sunsite.dk
Subject: Re: Adding a prefix to certain filename completions
Date: Fri, 8 Jul 2005 12:12:25 +0200 [thread overview]
Message-ID: <20050708101225.GA5434@puritan.pnetwork> (raw)
In-Reply-To: <1050708012444.ZM15812@candle.brasslantern.com>
[-- Attachment #1: Type: text/plain, Size: 1659 bytes --]
Bart Schaefer wrote:
> > Done. I modified the function a bit to handle files named +<n> a bit
> > better:
> I'm not sure this is better. Previously you should have seen the
> explanation of 'line number' on the first tab, and then been able to
> complete the file name on the second tab. With your change, you'll
> never see the 'line number' message, it'll always complete the file.
No, that's true. However, when I tried it, I never get to the second
group on sucessive tabs (even after an 'emulate zsh').
> But if that's the behavior you wanted, this would be a better way:
>
> _vim_files () {
> case $PREFIX in
> (+*) _files -P './' $* && return 0 ;;
> (*) _files $* ;;
> esac
> case $PREFIX in
> (+) _message -e 'start at given line (default: end of file)' ;;
> (+<->) _message -e 'line number' ;;
> esac
> }
OK, I changed it to that.
> Oh, one other thing ... having _vim_files embedded in the file named _vim
> in that way, causes _vim_files to be redefined as a function every time
> the _vim function is *called*. I should have noticed that before. See
> something like _cvs for an example of defining multiple functions in the
> same file.
Ah, I was looking for examples of completion functions using auxiliary
functions and actually saw that, but never got around to adding the
redefinition-protection. Thanks.
I've included a patch against CVS,
nikolai
--
Nikolai Weibull: now available free of charge at http://bitwi.se/!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}
[-- Attachment #2: _vim.patch --]
[-- Type: text/plain, Size: 765 bytes --]
--- _vim 2005-07-07 14:56:46.000000000 +0200
+++ /home/pcp/.local/etc/zsh/functions/_vim 2005-07-08 12:09:19.936813032 +0200
@@ -1,16 +1,15 @@
#compdef vim exim gvim gex gview rvim rview rgvim rgview evim eview vimdiff gvimdiff
+(( $+functions[_vim_files] )) ||
_vim_files () {
- if [[ $(echo $PREFIX*(N)) == '' ]]; then
- case $PREFIX in
- (+) _message -e 'start at a given line (default: end of file)' ;;
- (+<1->) _message -e 'line number' ;;
- esac
- fi
case $PREFIX in
- (+*) _files -P './' $* ;;
+ (+*) _files -P './' $* && return 0 ;;
(*) _files $* ;;
esac
+ case $PREFIX in
+ (+) _message -e 'start at a given line (default: end of file)' ;;
+ (+<1->) _message -e 'line number' ;;
+ esac
}
local arguments
next prev parent reply other threads:[~2005-07-08 10:12 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-04 19:37 Nikolai Weibull
2005-07-05 0:13 ` William Scott
2005-07-05 8:07 ` Nikolai Weibull
2005-07-05 15:09 ` William Scott
2005-07-05 15:23 ` William Scott
2005-07-05 4:23 ` Thomas Köhler
2005-07-05 8:09 ` Nikolai Weibull
2005-07-05 14:25 ` William Scott
2005-07-05 17:28 ` Nikolai Weibull
2005-07-05 16:56 ` John Reese
2005-07-05 17:07 ` William Scott
2005-07-06 5:00 ` Bart Schaefer
2005-07-06 11:31 ` Nikolai Weibull
2005-07-07 2:02 ` Nikolai Weibull
2005-07-07 5:40 ` Bart Schaefer
2005-07-07 7:21 ` Dan Nelson
2005-07-07 10:58 ` Nikolai Weibull
2005-07-07 11:18 ` Peter Stephenson
2005-07-07 11:58 ` Doug Kearns
2005-07-07 12:11 ` Nikolai Weibull
2005-07-07 12:54 ` Peter Stephenson
2005-07-07 19:00 ` Thomas Köhler
2005-07-07 14:51 ` William Scott
2005-07-07 15:57 ` Nikolai Weibull
2005-07-08 1:24 ` Bart Schaefer
2005-07-08 10:12 ` Nikolai Weibull [this message]
2005-07-05 17:01 ` Bart Schaefer
2005-07-05 19:14 ` Nikolai Weibull
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050708101225.GA5434@puritan.pnetwork \
--to=mailing-lists.zsh-users@rawuncut.elitemail.org \
--cc=zsh-users@sunsite.dk \
/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.vuxu.org/mirror/zsh/
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 NNTP newsgroup(s).