Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Adding a prefix to certain filename completions
- X-seq: zsh-users 9043
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Adding a prefix to certain filename completions
- Date: Thu, 07 Jul 2005 05:40:07 +0000
- In-reply-to: <20050707020210.GA5084@xxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20050705172846.GB5362@xxxxxxxxxxxxxxxx> <20050704193711.GF6330@xxxxxxxxxxxxxxxx> <20050705042324.GA21301@xxxxxxxxxxxxxxxxx> <20050705080946.GC5333@xxxxxxxxxxxxxxxx> <Pine.OSX.4.58.0507050720380.17349@xxxxxxxxxxxxxxx> <1050706050022.ZM13972@xxxxxxxxxxxxxxxxxxxxxxx> <20050706113154.GA5313@xxxxxxxxxxxxxxxx> <20050707020210.GA5084@xxxxxxxxxxxxxxxx>
[Aside: Is it possible for you to convince your mail client not to send
text labeled us-ascii when it contains multi-byte characters (I think
they must be Unicode apostrophes?) It makes it quite difficult to read.
I've manually edited them back to ' in the excerpt.]
On Jul 7, 4:02am, Nikolai Weibull wrote:
} Subject: Re: Adding a prefix to certain filename completions
}
} There's a problem with the +<n> option, though. I couldn't figure out
} a proper way of escaping the + that is the options name (just using \+
} doesn't work).
The + is not the option's name. The name is whatever comes *after* the
initial - or + that introduces the option. In fact, in this case +<n>
is not really an option at all; really it's a non-option argument that
happens to be allowed to be mixed in among the options.
The most effective way to handle it is to rewrite _my_files:
_my_files () {
case $PREFIX in
(+) _message -e 'start at given line (default: end of file)' ;;
(+<1->) _message -e 'line number' ;;
esac
case $PREFIX in
(+*) _files -P './' $* ;;
(*) _files $* ;;
esac
}
Another way is to pretend that the number is the option name:
arguments=(
...
+{1..9}-'[start at given line (default: end of file)]::line number: '
...
)
I prefer the behavior of the modified _my_files (which, by the way,
should probably be renamed _vim_files if this is going to be added to
the stock completions).
Messages sorted by:
Reverse Date,
Date,
Thread,
Author