* Adding a prefix to certain filename completions @ 2005-07-04 19:37 Nikolai Weibull 2005-07-05 0:13 ` William Scott ` (2 more replies) 0 siblings, 3 replies; 28+ messages in thread From: Nikolai Weibull @ 2005-07-04 19:37 UTC (permalink / raw) To: zsh-users Vim has issues with files that begin with a + (or two +s for that matter), so I'd like to add a ./ prefix to such files when completing. I thought I knew how to do this, but alas I do not. Anyone that does? Thanks, 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);} ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-04 19:37 Adding a prefix to certain filename completions Nikolai Weibull @ 2005-07-05 0:13 ` William Scott 2005-07-05 8:07 ` Nikolai Weibull 2005-07-05 4:23 ` Thomas Köhler 2005-07-05 17:01 ` Bart Schaefer 2 siblings, 1 reply; 28+ messages in thread From: William Scott @ 2005-07-05 0:13 UTC (permalink / raw) To: Nikolai Weibull; +Cc: zsh-users Dear Nikolai: If I am understanding the question correctly, I think you need something like compadd -P "./" but I don't know if that will cure the problem with the + signs. Bill Scott Born in Chicago, IL USA; currently residing in Santa Crud, CA On Mon, 4 Jul 2005, Nikolai Weibull wrote: > Vim has issues with files that begin with a + (or two +s for that > matter), so I'd like to add a ./ prefix to such files when completing. > I thought I knew how to do this, but alas I do not. Anyone that does? > > Thanks, > 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);} > ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 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 0 siblings, 2 replies; 28+ messages in thread From: Nikolai Weibull @ 2005-07-05 8:07 UTC (permalink / raw) To: zsh-users William Scott wrote: > If I am understanding the question correctly, I think you need > something like > > compadd -P "./" > > but I don't know if that will cure the problem with the + signs. Adding the ./ prefix certainly helps, as Vim won't see the + signs as special any more. However, the solution I was looking for would automatically add the ./ prefix when completing a filename beginning with a + (perhaps only if vim is the command in command position). So I need even more basic information than the compadd command-line. I was hoping it could be done using zstyles. > Born in Chicago, IL USA; currently residing in Santa Crud, CA :-), 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);} ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-05 8:07 ` Nikolai Weibull @ 2005-07-05 15:09 ` William Scott 2005-07-05 15:23 ` William Scott 1 sibling, 0 replies; 28+ messages in thread From: William Scott @ 2005-07-05 15:09 UTC (permalink / raw) To: Nikolai Weibull; +Cc: zsh-users Hi Nikolai: This expands on my previous reply: #!/bin/zsh -f # newvim inputfilearray=( "$@" ) LIMIT=$# for ((i = 1; i <= $LIMIT; i++ )) do eval file="\$$i" if [[ -f $inputfilearray[i] && $inputfilearray[i] == "$(basename $inputfilearray[i])" ]] then inputfilearray[i]="./$inputfilearray[i]" else : fi done command vim "$inputfilearray" There is probably an easier way, but it works. Bill On Tue, 5 Jul 2005, Nikolai Weibull wrote > William Scott wrote: > > > If I am understanding the question correctly, I think you need > > something like > > > > compadd -P "./" > > > > but I don't know if that will cure the problem with the + signs. > > Adding the ./ prefix certainly helps, as Vim won't see the + signs as > special any more. However, the solution I was looking for would > automatically add the ./ prefix when completing a filename beginning > with a + (perhaps only if vim is the command in command position). So > I need even more basic information than the compadd command-line. I was > hoping it could be done using zstyles. > > > Born in Chicago, IL USA; currently residing in Santa Crud, CA > > :-), > 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);} > ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-05 8:07 ` Nikolai Weibull 2005-07-05 15:09 ` William Scott @ 2005-07-05 15:23 ` William Scott 1 sibling, 0 replies; 28+ messages in thread From: William Scott @ 2005-07-05 15:23 UTC (permalink / raw) To: Nikolai Weibull; +Cc: zsh-users Sorry, the last line should be command vim "$inputfilearray[@]" ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-04 19:37 Adding a prefix to certain filename completions Nikolai Weibull 2005-07-05 0:13 ` William Scott @ 2005-07-05 4:23 ` Thomas Köhler 2005-07-05 8:09 ` Nikolai Weibull 2005-07-05 17:01 ` Bart Schaefer 2 siblings, 1 reply; 28+ messages in thread From: Thomas Köhler @ 2005-07-05 4:23 UTC (permalink / raw) To: zsh-users [-- Attachment #1: Type: text/plain, Size: 633 bytes --] Nikolai Weibull wrote: > Vim has issues with files that begin with a + (or two +s for that > matter), so I'd like to add a ./ prefix to such files when completing. > I thought I knew how to do this, but alas I do not. Anyone that does? Not knowing the zsh answer, I would add a "--" once before the "strange" file name: vim -- +myfile Should help... Ciao, Thomas -- Thomas Köhler Email: jean-luc@picard.franken.de <>< WWW: http://gott-gehabt.de IRC: tkoehler PGP public key available from Homepage! [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-05 4:23 ` Thomas Köhler @ 2005-07-05 8:09 ` Nikolai Weibull 2005-07-05 14:25 ` William Scott 0 siblings, 1 reply; 28+ messages in thread From: Nikolai Weibull @ 2005-07-05 8:09 UTC (permalink / raw) To: zsh-users Thomas Köhler wrote: > Nikolai Weibull wrote: > > Vim has issues with files that begin with a + (or two +s for that > > matter), so I'd like to add a ./ prefix to such files when > > completing. I thought I knew how to do this, but alas I do not. > > Anyone that does? > Not knowing the zsh answer, I would add a "--" once before the > "strange" file name: > vim -- +myfile Again, the ./ prefix also works. However, I would like for this to be handled automatically, kind of like spaces being escaped when completing a path containing them. Thanks for responding, 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);} ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-05 8:09 ` Nikolai Weibull @ 2005-07-05 14:25 ` William Scott 2005-07-05 17:28 ` Nikolai Weibull 2005-07-06 5:00 ` Bart Schaefer 0 siblings, 2 replies; 28+ messages in thread From: William Scott @ 2005-07-05 14:25 UTC (permalink / raw) To: Nikolai Weibull; +Cc: zsh-users Hi Nikolai: I don't think this is a completion issue. In any case, this works: function vim { command vim ./"$@" } but you will want to put some lines in there to test whether the file is in $PWD, and if it is, do the above, otherwise, behave normally. HTH, Bill On Tue, 5 Jul 2005, Nikolai Weibull wrote: > Thomas Köhler wrote: > > > Nikolai Weibull wrote: > > > > Vim has issues with files that begin with a + (or two +s for that > > > matter), so I'd like to add a ./ prefix to such files when > > > completing. I thought I knew how to do this, but alas I do not. > > > Anyone that does? > > > Not knowing the zsh answer, I would add a "--" once before the > > "strange" file name: > > vim -- +myfile > > Again, the ./ prefix also works. However, I would like for this to be > handled automatically, kind of like spaces being escaped when completing > a path containing them. Thanks for responding, > 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);} > ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 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 1 sibling, 2 replies; 28+ messages in thread From: Nikolai Weibull @ 2005-07-05 17:28 UTC (permalink / raw) To: zsh-users William Scott wrote: > I don't think this is a completion issue. I know that the completion system can be made to suit this need. Filenames beginning with a = are escaped properly with the right settings. > In any case, this works: > > function vim { command vim ./"$@" } That will definitely not work. Specifically it won’t work for multiple file arguments (or options for that matter), 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);} ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-05 17:28 ` Nikolai Weibull @ 2005-07-05 16:56 ` John Reese 2005-07-05 17:07 ` William Scott 1 sibling, 0 replies; 28+ messages in thread From: John Reese @ 2005-07-05 16:56 UTC (permalink / raw) To: zsh-users 2005/7/5, Nikolai Weibull <mailing-lists.zsh-users@rawuncut.elitemail.org>: ... > I know that the completion system can be made to suit this need. > Filenames beginning with a = are escaped properly with the right > settings. > Unfortunately, I'm behind the times, but the following works with the old completion system. I'm sure something along the same lines can done with zstyle and compadd and all that other wackiness. compctl -f -x 'S[+]' -f -P './' -- vim That's: for vim, complete filenames, except for arguments starting with +, for which insert "./" at the beginning and then complete filenames. Note that the + already has to be on the command-line; if you have menu completion on and you type "vim <tab>", filenames starting with + won't match the above rule and they won't get the ./ prepended. But "vim +<tab>" does the right thing. ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-05 17:28 ` Nikolai Weibull 2005-07-05 16:56 ` John Reese @ 2005-07-05 17:07 ` William Scott 1 sibling, 0 replies; 28+ messages in thread From: William Scott @ 2005-07-05 17:07 UTC (permalink / raw) To: Nikolai Weibull; +Cc: zsh-users > > function vim { command vim ./"$@" } > > That will definitely not work. Specifically it won’t work for multiple > file arguments (or options for that matter), > nikolai The longer version I sent about an hour ago does (once you correct the last line as I quickly found). It tests each element of the input array and decides if it is a file or not (i.e., is an argument). Then if that element of the array is in the $PWD, it appends your fix, otherwise it leaves it alone. ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-05 14:25 ` William Scott 2005-07-05 17:28 ` Nikolai Weibull @ 2005-07-06 5:00 ` Bart Schaefer 2005-07-06 11:31 ` Nikolai Weibull 1 sibling, 1 reply; 28+ messages in thread From: Bart Schaefer @ 2005-07-06 5:00 UTC (permalink / raw) To: zsh-users > I'm sure something along the same lines can > done with zstyle and compadd and all that other wackiness. > > compctl -f -x 'S[+]' -f -P './' -- vim <span class="hand" style="position: forehead"> smack </span> I had assumed there was already an _vim completion, but there's not. So just write one. _vim() { [[ $PREFIX = +* ]] && _files -P './' || _files } compdef _vim vim ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-06 5:00 ` Bart Schaefer @ 2005-07-06 11:31 ` Nikolai Weibull 2005-07-07 2:02 ` Nikolai Weibull 0 siblings, 1 reply; 28+ messages in thread From: Nikolai Weibull @ 2005-07-06 11:31 UTC (permalink / raw) To: zsh-users Bart Schaefer wrote: > I had assumed there was already an _vim completion, but there's not. > So just write one. > > _vim() { > [[ $PREFIX = +* ]] && _files -P './' || _files > } > compdef _vim vim Ah, that’s great! I’ll try to find some time today to actually write a complete _vim completion. Thanks!, 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);} ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-06 11:31 ` Nikolai Weibull @ 2005-07-07 2:02 ` Nikolai Weibull 2005-07-07 5:40 ` Bart Schaefer 0 siblings, 1 reply; 28+ messages in thread From: Nikolai Weibull @ 2005-07-07 2:02 UTC (permalink / raw) To: zsh-users [-- Attachment #1: Type: text/plain, Size: 751 bytes --] Nikolai Weibull wrote: > Ah, that’s great! I’ll try to find some time today to actually write a > complete _vim completion. OK, so it’s sad that I can only find spare time at 2 am, but here it is, a quite complete Vim completion defintion. 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). Anyone have any brilliant ideas on this, or is this a problem with the _arguments argument-parser? Anyway, enjoy, 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 --] [-- Type: text/plain, Size: 3360 bytes --] #compdef vim _my_files () { [[ $PREFIX == +* ]] && _files -P './' $* || _files $* } local arguments arguments=( '( -e -s -d -y)-v[vi mode]' '(-v -d -y)-e[ex mode]' '(-v -e -s -y)-d[diff mode]' '(-v -e -s -d )-y[easy mode]' '-R[readonly mode]' '-Z[restricted mode]' '-m[modifications (writing files) not allowed]' '-M[modifications in text not allowed]' '-b[binary mode]' '-l[lisp mode]' '-C[make vim compatible with vi]' '-N[do not force compatibility with vi]' '-V-[verbosity level]::verbosity:((0\:"do not display any messages" 1\:"display when viminfo file is read or written" 2\:"display sourced files" 5\:"display every searched tag-file" 8\:"display files that trigger autocommands" 9\:"display every triggered autocommand (default)" 12\:"display every executed function" 13\:"report every thrown, caught, finished, or discarded exception" 14\:"display anything pending in a \:finally clause" 15\:"display every executed ex-command"))' '-D[debugging mode]' '-n[no swap file (memory only)]' {-r,-L}'[list swap files and exit or recover from a swap file]::swap file:_my_files -g \*.sw\?' '( -H -F)-A[start in Arabic mode]' '(-A -F)-H[start in Hebrew mode]' '(-A -H )-H[start in Farsi mode]' '-T[set terminal type]:::_terminals' '-u[use given RC file instead of default .vimrc]::rc file:_files' '--noplugin[do not load plugin scripts]' '-o-[number of windows to open (default: one for each file)]::window count: ' '-O-[number of windows to vertically split open (default is one for each file)]::window count: ' # '\+-[start at given line (default: end of file)]::line number: ' '*--cmd[execute given command before loading any RC files]:command: ' '-c[executed given command after loading the first file]:command: ' '-S[source a session file after loading the first file]:session file:_files' '-s[read normal-mode commands from script file]:script file:_files' '-w[append all typed commands to given file]:output file:_files' '-W[write all typed commands to given file]:output file:_files' '-x[edit encrypted files]' '-X[do not connect to X server]' '--remote[edit given files in a vim server if possible]:*:file:_my_files' '--remote-silent[as --remote but without complaining if not possible]:*:file:_my_files' '--remote-wait[as --remote but wait for files to have been edited]:*:file:_my_files' '--remote-wait-silent[as --remote-wait but without complaining if not possible]:*:file:_my_files' '--remote-send[send given keys to vim server if possible]:keys: ' '--remote-expr[evaluate given expression in a vim server and print result]:expression: ' '(- *)--serverlist[list available vim servers and exit]' '--servername[name of vim server to send to or name of server to become]:server name: ' '-i[use given viminfo file instead of default .viminfo]:viminfo file:_files' '(- *)'{-h,--help}'[print help and exit]' '(- *)--version[print version information and exit]' '*:file:_my_files' ) _arguments -S $arguments ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 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 0 siblings, 2 replies; 28+ messages in thread From: Bart Schaefer @ 2005-07-07 5:40 UTC (permalink / raw) To: zsh-users [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). ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-07 5:40 ` Bart Schaefer @ 2005-07-07 7:21 ` Dan Nelson 2005-07-07 10:58 ` Nikolai Weibull 1 sibling, 0 replies; 28+ messages in thread From: Dan Nelson @ 2005-07-07 7:21 UTC (permalink / raw) To: Bart Schaefer; +Cc: zsh-users In the last episode (Jul 07), Bart Schaefer said: > [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.] It looks fine to me; the message was utf-8, the attachment was ascii (and had no characters that would have forced anything else): Content-Type: multipart/mixed; boundary="4Ckj6UjgE2iN1+kY" Content-Disposition: inline Content-Transfer-Encoding: 8bit [-- Attachment #1 --] [-- Type: text/plain, Encoding: 8bit, Size: 0.7K --] Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit [-- Attachment #2: _vim --] [-- Type: text/plain, Encoding: 7bit, Size: 3.3K --] Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=_vim -- Dan Nelson dnelson@allantgroup.com ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 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 ` (2 more replies) 1 sibling, 3 replies; 28+ messages in thread From: Nikolai Weibull @ 2005-07-07 10:58 UTC (permalink / raw) To: zsh-users [-- Attachment #1: Type: text/plain, Size: 2019 bytes --] Bart Schaefer wrote: > [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.] As Dan Nelson points out, it all seems to be in order. I don't want to push it back at you, but perhaps your mail client is being fooled by the mime-type of the second attachment (which was us-ascii). Anyway, if this problem persists, I can live without using fancy apostrophes on this list. > On Jul 7, 4:02am, Nikolai Weibull wrote: > > 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. OK. > 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). Done. I modified the function a bit to handle files named +<n> a bit better: _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 $* ;; esac } This may not be the best solution, though. I kind of hope that there's a nicer way to test if there are any files having $PREFIX as a prefix. Thank you for your help, 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 --] [-- Type: text/plain, Size: 3511 bytes --] #compdef vim _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 $* ;; esac } local arguments arguments=( '( -e -s -d -y)-v[vi mode]' '(-v -d -y)-e[ex mode]' '(-v -e -s -y)-d[diff mode]' '(-v -e -s -d )-y[easy mode]' '-R[readonly mode]' '-Z[restricted mode]' '-m[modifications (writing files) not allowed]' '-M[modifications in text not allowed]' '-b[binary mode]' '-l[lisp mode]' '-C[make vim compatible with vi]' '-N[do not force compatibility with vi]' '-V-[verbosity level]::verbosity:((0\:"do not display any messages" 1\:"display when viminfo file is read or written" 2\:"display sourced files" 5\:"display every searched tag-file" 8\:"display files that trigger autocommands" 9\:"display every triggered autocommand (default)" 12\:"display every executed function" 13\:"report every thrown, caught, finished, or discarded exception" 14\:"display anything pending in a \:finally clause" 15\:"display every executed ex-command"))' '-D[debugging mode]' '-n[no swap file (memory only)]' {-r,-L}'[list swap files and exit or recover from a swap file]::swap file:_vim_files -g \*.sw\?' '( -H -F)-A[start in Arabic mode]' '(-A -F)-H[start in Hebrew mode]' '(-A -H )-H[start in Farsi mode]' '-T[set terminal type]:::_terminals' '-u[use given RC file instead of default .vimrc]::rc file:_files' '--noplugin[do not load plugin scripts]' '-o-[number of windows to open (default: one for each file)]::window count: ' '-O-[number of windows to vertically split open (default is one for each file)]::window count: ' '*--cmd[execute given command before loading any RC files]:command: ' '-c[executed given command after loading the first file]:command: ' '-S[source a session file after loading the first file]:session file:_files' '-s[read normal-mode commands from script file]:script file:_files' '-w[append all typed commands to given file]:output file:_files' '-W[write all typed commands to given file]:output file:_files' '-x[edit encrypted files]' '-X[do not connect to X server]' '--remote[edit given files in a vim server if possible]:*:file:_vim_files' '--remote-silent[as --remote but without complaining if not possible]:*:file:_vim_files' '--remote-wait[as --remote but wait for files to have been edited]:*:file:_vim_files' '--remote-wait-silent[as --remote-wait but without complaining if not possible]:*:file:_vim_files' '--remote-send[send given keys to vim server if possible]:keys: ' '--remote-expr[evaluate given expression in a vim server and print result]:expression: ' '(- *)--serverlist[list available vim servers and exit]' '--servername[name of vim server to send to or name of server to become]:server name: ' '-i[use given viminfo file instead of default .viminfo]:viminfo file:_files' '(- *)'{-h,--help}'[print help and exit]' '(- *)--version[print version information and exit]' '*:file:_vim_files' ) _arguments -S $arguments ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 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 14:51 ` William Scott 2005-07-08 1:24 ` Bart Schaefer 2 siblings, 2 replies; 28+ messages in thread From: Peter Stephenson @ 2005-07-07 11:18 UTC (permalink / raw) To: zsh-users Nikolai Weibull wrote: > Done. I modified the function a bit to handle files named +<n> a bit > better: I've committed _vim in this form. Ideally any changes to it from now on ought to be diffs. Thanks. The question remains whether this ought to be tied to vi in some cases, which is often vim in disguise and has a certain amount in common in other cases. -- Peter Stephenson <pws@csr.com> Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. ********************************************************************** ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-07 11:18 ` Peter Stephenson @ 2005-07-07 11:58 ` Doug Kearns 2005-07-07 12:11 ` Nikolai Weibull 1 sibling, 0 replies; 28+ messages in thread From: Doug Kearns @ 2005-07-07 11:58 UTC (permalink / raw) To: zsh-users On Thu, Jul 07, 2005 at 12:18:09PM +0100, Peter Stephenson wrote: > Nikolai Weibull wrote: > > Done. I modified the function a bit to handle files named +<n> a bit > > better: > > I've committed _vim in this form. Ideally any changes to it from now on > ought to be diffs. Thanks. > > The question remains whether this ought to be tied to vi in some cases, > which is often vim in disguise and has a certain amount in common in other > cases. FWIW, I've got one that parses --version to offer only the appropriate options etc but it's stuck on another machine I won't have access to for a few weeks... Regards, Doug ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 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 1 sibling, 1 reply; 28+ messages in thread From: Nikolai Weibull @ 2005-07-07 12:11 UTC (permalink / raw) To: zsh-users Peter Stephenson wrote: > The question remains whether this ought to be tied to vi in some cases, > which is often vim in disguise and has a certain amount in common in other > cases. Ah, of course. There are many commands that can use this actually. :help ex gives the following list: ex exim view gvim gex gview rvim rview rgvim rgview evim eview vimdiff gvimdiff and, as you say, there's usually a vi link as well, 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);} ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-07 12:11 ` Nikolai Weibull @ 2005-07-07 12:54 ` Peter Stephenson 2005-07-07 19:00 ` Thomas Köhler 0 siblings, 1 reply; 28+ messages in thread From: Peter Stephenson @ 2005-07-07 12:54 UTC (permalink / raw) To: zsh-users Nikolai Weibull wrote: > Ah, of course. There are many commands that can use this actually. > :help ex gives the following list: > > ex exim view gvim gex gview rvim rview rgvim rgview evim eview vimdiff gvimdi > ff > > and, as you say, there's usually a vi link as well, This adds the vim-specific versions. ex and view also come with vi. I'll wait for someone to decide how to manage these three. Index: Completion/Unix/Command/_vim =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_vim,v retrieving revision 1.1 diff -u -r1.1 _vim --- Completion/Unix/Command/_vim 7 Jul 2005 11:16:11 -0000 1.1 +++ Completion/Unix/Command/_vim 7 Jul 2005 12:51:01 -0000 @@ -1,4 +1,4 @@ -#compdef vim +#compdef vim exim gvim gex gview rvim rview rgvim rgview evim eview vimdiff gvimdiff _vim_files () { if [[ $(echo $PREFIX*(N)) == '' ]]; then -- Peter Stephenson <pws@csr.com> Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. ********************************************************************** ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-07 12:54 ` Peter Stephenson @ 2005-07-07 19:00 ` Thomas Köhler 0 siblings, 0 replies; 28+ messages in thread From: Thomas Köhler @ 2005-07-07 19:00 UTC (permalink / raw) To: zsh-users [-- Attachment #1: Type: text/plain, Size: 2667 bytes --] Peter Stephenson wrote: > Nikolai Weibull wrote: > > Ah, of course. There are many commands that can use this actually. > > :help ex gives the following list: > > > > ex exim view gvim gex gview rvim rview rgvim rgview evim eview vimdiff gvimdi > > ff > > > > and, as you say, there's usually a vi link as well, > > This adds the vim-specific versions. ex and view also come with vi. > I'll wait for someone to decide how to manage these three. > > Index: Completion/Unix/Command/_vim > =================================================================== > RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_vim,v > retrieving revision 1.1 > diff -u -r1.1 _vim > --- Completion/Unix/Command/_vim 7 Jul 2005 11:16:11 -0000 1.1 > +++ Completion/Unix/Command/_vim 7 Jul 2005 12:51:01 -0000 > @@ -1,4 +1,4 @@ > -#compdef vim > +#compdef vim exim gvim gex gview rvim rview rgvim rgview evim eview vimdiff gvimdiff > > _vim_files () { > if [[ $(echo $PREFIX*(N)) == '' ]]; then This whole discussion reminds me of some stuff that I always wanted to clean up a bit... My _vimhelp still depends on $VIM to be set (parsing "vim --version" output for vim's fallback for $VIM should be no problem), and removing sed out of the $vimversion calculation below could maybe also be done. Anyways... for those who think this might be useful: ----------------------- _vimhelp --------------------- #compdef vimhelp gvimhelp local vimversion curcontext="$curcontext" context state line expl ret tagsfile vimversion=$(vim --version |& head -1 | sed -e 's/VIM - Vi IMproved //' -e 's/ .*//' -e 's/\.//' -e 's/^/vim/') tagsfile=$VIM/$vimversion/doc/tags _vimhelp_update_tags() { if (( ! $+_vimhelp_tags )); then _vimhelp_tags=( $(cat $tagsfile | sed -e 's/ .*//') ) fi } _vimhelp() { _vimhelp_update_tags compadd -- $_vimhelp_tags } _vimhelp "$@" ---------------------- / .zshrc -------------------- ----------------------- _vimhelp --------------------- vimhelp () { vim -c "help $1" -c on -c "au! VimEnter *" } gvimhelp () { gvim -c "help $1" -c on -c "au! VimEnter *" } ---------------------- / .zshrc -------------------- I was once thinking like vim -c "h<TAB> => vim -c "help => vim -c "help Z<TAB> => vim -c "help ZZ" but then I just wrote my little vimhelp wrapper which was easier to do... Ciao, Thomas -- Thomas Köhler Email: jean-luc@picard.franken.de <>< WWW: http://gott-gehabt.de IRC: tkoehler PGP public key available from Homepage! [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-07 10:58 ` Nikolai Weibull 2005-07-07 11:18 ` Peter Stephenson @ 2005-07-07 14:51 ` William Scott 2005-07-07 15:57 ` Nikolai Weibull 2005-07-08 1:24 ` Bart Schaefer 2 siblings, 1 reply; 28+ messages in thread From: William Scott @ 2005-07-07 14:51 UTC (permalink / raw) To: Nikolai Weibull; +Cc: zsh-users Does this work? I sent it a couple of days ago but it seems not to have appeared on the list. In any case, it separates the arguments from the filenames, as well as local files from ones with relative or absolute paths prepended to them, and only issues ./++foo or the equivalent where needed. #!/bin/zsh -f # newvim inputfilearray=( "$@" ) LIMIT=$# for ((i = 1; i <= $LIMIT; i++ )) do eval file="\$$i" if [[ -f $inputfilearray[i] && $inputfilearray[i] == "$(basename $inputfilearray[i])" ]] then inputfilearray[i]="./$inputfilearray[i]" else : fi done command vim "$inputfilearray[@]" ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-07 14:51 ` William Scott @ 2005-07-07 15:57 ` Nikolai Weibull 0 siblings, 0 replies; 28+ messages in thread From: Nikolai Weibull @ 2005-07-07 15:57 UTC (permalink / raw) To: zsh-users William Scott wrote: > Does this work? I sent it a couple of days ago but it seems not to have > appeared on the list. I've seen it on the list. I haven't tried it though, as the completion definition that I've written - with help from Bart - and now posted works well. Thanks anyway, 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);} ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-07 10:58 ` Nikolai Weibull 2005-07-07 11:18 ` Peter Stephenson 2005-07-07 14:51 ` William Scott @ 2005-07-08 1:24 ` Bart Schaefer 2005-07-08 10:12 ` Nikolai Weibull 2 siblings, 1 reply; 28+ messages in thread From: Bart Schaefer @ 2005-07-08 1:24 UTC (permalink / raw) To: zsh-users On Jul 7, 12:58pm, Nikolai Weibull wrote: } } I don't want to push it back at you, but perhaps your mail client is } being fooled by the mime-type of the second attachment (which was } us-ascii). Not much point in discussing this further ... my mail client normally won't display a body part at all if it doesn't recognize the character set. And other messages from you have been just fine ... so I'm not sure what's going on there. I've already deleted it, so I can't check it now. } 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. 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 } 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. ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-08 1:24 ` Bart Schaefer @ 2005-07-08 10:12 ` Nikolai Weibull 0 siblings, 0 replies; 28+ messages in thread From: Nikolai Weibull @ 2005-07-08 10:12 UTC (permalink / raw) To: zsh-users [-- 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 ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-04 19:37 Adding a prefix to certain filename completions Nikolai Weibull 2005-07-05 0:13 ` William Scott 2005-07-05 4:23 ` Thomas Köhler @ 2005-07-05 17:01 ` Bart Schaefer 2005-07-05 19:14 ` Nikolai Weibull 2 siblings, 1 reply; 28+ messages in thread From: Bart Schaefer @ 2005-07-05 17:01 UTC (permalink / raw) To: zsh-users On Jul 4, 9:37pm, Nikolai Weibull wrote: } Subject: Adding a prefix to certain filename completions } } Vim has issues with files that begin with a + (or two +s for that } matter), so I'd like to add a ./ prefix to such files when completing. YOu can get most of the way there with this: zstyle -e ':completion:*:vim:*' fake-files 'reply=("$PWD:$(print ./+*)")' zstyle ':completion:*:vim:*' matcher 'b:+=./+' However, all that does is offer the ./+* as alternatives, it doesn't remove the originals. The trouble is that file completion is sensitive to directory separators, so as soon as you introduce the slash, the rules begin to apply to the stuff on the right of the slash rather than to the entire string. You'd be better off if there were some other way to protect the + from interpretation by vim. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: Adding a prefix to certain filename completions 2005-07-05 17:01 ` Bart Schaefer @ 2005-07-05 19:14 ` Nikolai Weibull 0 siblings, 0 replies; 28+ messages in thread From: Nikolai Weibull @ 2005-07-05 19:14 UTC (permalink / raw) To: zsh-users Bart Schaefer wrote: > On Jul 4, 9:37pm, Nikolai Weibull wrote: > > Vim has issues with files that begin with a + (or two +s for that > > matter), so I'd like to add a ./ prefix to such files when > > completing. > YOu can get most of the way there with this: > > zstyle -e ':completion:*:vim:*' fake-files 'reply=("$PWD:$(print ./+*)")' > zstyle ':completion:*:vim:*' matcher 'b:+=./+' > > However, all that does is offer the ./+* as alternatives, it doesn't > remove the originals. The trouble is that file completion is > sensitive to directory separators, so as soon as you introduce the > slash, the rules begin to apply to the stuff on the right of the slash > rather than to the entire string. Yeah, no...that works, but it wasn't great; damn. Anyway, thank you all for your suggestions, 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);} ^ permalink raw reply [flat|nested] 28+ messages in thread
end of thread, other threads:[~2005-07-08 10:12 UTC | newest] Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2005-07-04 19:37 Adding a prefix to certain filename completions 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 2005-07-05 17:01 ` Bart Schaefer 2005-07-05 19:14 ` Nikolai Weibull
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).