zsh-workers
 help / color / mirror / code / Atom feed
From: Greg Klanderman <gak@klanderman.net>
To: zsh-workers@zsh.org
Subject: Re: bug in 'rm' completion
Date: Mon, 09 Nov 2009 11:17:31 -0500	[thread overview]
Message-ID: <m38wef4qqs.fsf@klanderman.net> (raw)
In-Reply-To: <19191.43212.832827.724369@gargle.gargle.HOWL> (Greg Klanderman's message of "Mon, 9 Nov 2009 00:29:48 -0500")


>>>>> On November 9, 2009 Greg Klanderman <gak@klanderman.net> wrote:

> | lwm% mkdir temp2
> | lwm% cd temp2
> | lwm% touch foo foo-bar

> At this point, if you type "rm f" and hit <tab> it correctly completes
> to "rm foo".  If you then hit <tab> again, it incorrectly completes to
> "rm foo-bar".

It looks like the code in _rm is trying to ignore completing other
files already listed to be removed on the command line, but brokenly
including the current word being completed in the ignore pattern.

The patch below seems to fix the problem, provided you are completing
the last word on the line.  So for example,

% mkdir temp
% cd temp
% touch bar foo foo-bar
% rm f<tab> bar

if you hit <tab> with the cursor in the location indicated, the
problem still exists with my patch, so I don't really think this is
the right fix.. I guess I should use $CURRENT to exclude the current
word?

Can someone explain where $line is coming from in _rm?  I don't see it
listed in the 'Completion Special Parameters' or 'Parameters Set By
The Shell' sections of the manual, and the name is too generic to
effectively search for.  Is it the same as $words, which I do see
documented in 'Completion Special Parameters'?  Hmm, not exactly, as
$line does not contain the command.. can I assume line=$words[2,-1]
and adjust $CURRENT appropriately?

BTW, what's the deal with _files vs _path_files?  I see that revision
1.2 of _rm switched from using _path_files to _files:

| revision 1.2
| date: 2008/11/23 18:23:29;  author: barts;  state: Exp;  lines: +1 -1
| users/13477: call _files instead of _path_files to correctly handle
| cycling through choices.

but there are plenty of completion functions using each.

thanks,
Greg


  reply	other threads:[~2009-11-09 16:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-09  5:29 Greg Klanderman
2009-11-09 16:17 ` Greg Klanderman [this message]
2009-11-09 17:29   ` Bart Schaefer
2009-11-09 17:52     ` Greg Klanderman
2009-11-09 21:20       ` Greg Klanderman
2009-11-10 15:52         ` Bart Schaefer
2009-11-12  2:48           ` Greg Klanderman
2009-11-12  4:21             ` Bart Schaefer
2009-11-12 17:22               ` Greg Klanderman
2009-11-09 16:29 ` Bart Schaefer

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=m38wef4qqs.fsf@klanderman.net \
    --to=gak@klanderman.net \
    --cc=zsh-workers@zsh.org \
    /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).