zsh-users
 help / color / mirror / code / Atom feed
* Problem with ignore-line and parenthesis
@ 2004-08-26 18:18 Jesper Holmberg
  2004-08-26 22:14 ` Andy Spiegl
  2004-08-27  0:37 ` Problem with ignore-line and parenthesis Bart Schaefer
  0 siblings, 2 replies; 12+ messages in thread
From: Jesper Holmberg @ 2004-08-26 18:18 UTC (permalink / raw)
  To: Zsh-users List

I have the following zstyle in my .zshrc:

zstyle ':completion:*:(rm|cp|mv):*' ignore-line yes

Filenames with parentheses in them seem to cause problems, though. If I
have a file called for example "m(25).txt", and write the line:

% cp m(25).txt 

and then press tab after the space at the end of the line, m(25).txt is
again suggested as a completion. This does not happen with other files.

This is zsh 4.2.1 on Debian Sid.

Jesper


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Problem with ignore-line and parenthesis
  2004-08-26 18:18 Problem with ignore-line and parenthesis Jesper Holmberg
@ 2004-08-26 22:14 ` Andy Spiegl
  2004-08-30 15:13   ` another Problem with ignore-line Andy Spiegl
  2004-08-27  0:37 ` Problem with ignore-line and parenthesis Bart Schaefer
  1 sibling, 1 reply; 12+ messages in thread
From: Andy Spiegl @ 2004-08-26 22:14 UTC (permalink / raw)
  To: Zsh-users List

> This is zsh 4.2.1 on Debian Sid.

Same here with 4.2.0 on Debian testing.
 Andy.

-- 
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 A feature is a bug with seniority.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Problem with ignore-line and parenthesis
  2004-08-26 18:18 Problem with ignore-line and parenthesis Jesper Holmberg
  2004-08-26 22:14 ` Andy Spiegl
@ 2004-08-27  0:37 ` Bart Schaefer
  2004-08-27  7:32   ` Jesper Holmberg
  2004-08-27 10:14   ` Oliver Kiddle
  1 sibling, 2 replies; 12+ messages in thread
From: Bart Schaefer @ 2004-08-27  0:37 UTC (permalink / raw)
  To: Zsh-users List

On Thu, 26 Aug 2004, Jesper Holmberg wrote:

> I have the following zstyle in my .zshrc:
> 
> zstyle ':completion:*:(rm|cp|mv):*' ignore-line yes
> 
> Filenames with parentheses in them seem to cause problems, though.

Filenames with any glob pattern in them would have problems, I think.  See 
if this does the right thing.

Index: Completion/Base/Core/_description
--- _description.~1.5.~	2003-08-10 09:00:12.000000000 -0700
+++ _description	2004-08-26 17:32:46.000000000 -0700
@@ -49,13 +49,13 @@
 
   zstyle -s ":completion:${curcontext}:$1" ignore-line hidden &&
     case "$hidden" in
-    true|yes|on|1) _comp_ignore=( "$_comp_ignore[@]" "$words[@]" );;
-    current)       _comp_ignore=( "$_comp_ignore[@]" "$words[CURRENT]" );;
+    true|yes|on|1) _comp_ignore=( "$_comp_ignore[@]" "${(q)words[@]}" );;
+    current)       _comp_ignore=( "$_comp_ignore[@]" "${(q)words[CURRENT]}" );;
     current-shown) [[ "$compstate[old_list]" = *shown* ]] &&
-                       _comp_ignore=( "$_comp_ignore[@]" "$words[CURRENT]" );;
+                       _comp_ignore=( "$_comp_ignore[@]" "${(q)words[CURRENT]}" );;
     other)         _comp_ignore=( "$_comp_ignore[@]"
-                                  "${(@)words[1,CURRENT-1]}"
-				  "${(@)words[CURRENT+1,-1]}" );;
+                                  "${(@q)words[1,CURRENT-1]}"
+				  "${(@q)words[CURRENT+1,-1]}" );;
     esac
 
   (( $#_comp_ignore )) && opts=( $opts -F _comp_ignore )


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Problem with ignore-line and parenthesis
  2004-08-27  0:37 ` Problem with ignore-line and parenthesis Bart Schaefer
@ 2004-08-27  7:32   ` Jesper Holmberg
  2004-08-27 10:14   ` Oliver Kiddle
  1 sibling, 0 replies; 12+ messages in thread
From: Jesper Holmberg @ 2004-08-27  7:32 UTC (permalink / raw)
  To: Zsh-users List

* On Thu Aug 26, Bart Schaefer wrote:
> On Thu, 26 Aug 2004, Jesper Holmberg wrote:
> 
> > I have the following zstyle in my .zshrc:
> > 
> > zstyle ':completion:*:(rm|cp|mv):*' ignore-line yes
> > 
> > Filenames with parentheses in them seem to cause problems, though.
> 
> Filenames with any glob pattern in them would have problems, I think.  See 
> if this does the right thing.

Yes, your patch seems to fix my example problem. However, I have some
other files that still cause the same problem. They're called:

Meeting notes (2004-01-15).doc
Meeting notes (2004-01-30).doc

And when I have the first one on the command line, it is still
suggested as a completion when doing mv or cp.

Jesper


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Problem with ignore-line and parenthesis
  2004-08-27  0:37 ` Problem with ignore-line and parenthesis Bart Schaefer
  2004-08-27  7:32   ` Jesper Holmberg
@ 2004-08-27 10:14   ` Oliver Kiddle
  1 sibling, 0 replies; 12+ messages in thread
From: Oliver Kiddle @ 2004-08-27 10:14 UTC (permalink / raw)
  To: zsh-users

Bart wrote:
> On Thu, 26 Aug 2004, Jesper Holmberg wrote:
> 
> > I have the following zstyle in my .zshrc:
> > 
> > zstyle ':completion:*:(rm|cp|mv):*' ignore-line yes
> > 
> > Filenames with parentheses in them seem to cause problems, though.
> 
> Filenames with any glob pattern in them would have problems, I think.  See 
> if this does the right thing.

Unfortunately, this now looses the useful feature that where a glob
pattern is intentionally used, all files matching the pattern are
ignored. That's often quite useful because many matches can be cut out.

Not having no_nomatch or no_bad_pattern set, I've never noticed the
problem Jesper mentions.

One solution is to add both "$words[@]" and "${(q)words[@]}" to
_comp_ignore. Or should we check for the nomatch option or use more
values to the ignore-line style? Further discussion of that should
probably move to -workers.

Oliver


^ permalink raw reply	[flat|nested] 12+ messages in thread

* another Problem with ignore-line
  2004-08-26 22:14 ` Andy Spiegl
@ 2004-08-30 15:13   ` Andy Spiegl
  2004-08-30 15:25     ` Oliver Kiddle
  0 siblings, 1 reply; 12+ messages in thread
From: Andy Spiegl @ 2004-08-30 15:13 UTC (permalink / raw)
  To: Zsh-users List

Ever since I'm using
 zstyle ':completion:*:(rm|cp|mv):*' ignore-line yes
I've got some strange things happening.  For example:

 condor:~/zshtest>l -R
 .:
 insgesamt 4
 -rw-r--r--    1 spiegl   users           0 2004-08-30 13:54 foo
 drwxr-xr-x    2 spiegl   users        4096 2004-08-30 13:56 subdir/

 ./subdir:
 insgesamt 0
 -rw-r--r--    1 spiegl   users           0 2004-08-30 13:54 bar

 condor:~/zshtest>mv s<TAB>
 condor:~/zshtest>mv subdir/           <--- so far so good

 condor:~/zshtest>mv subdir a
 condor:~/zshtest>mv a<TAB>            <--- now it only BEEPs

Could this be due to some zsh options I've set or is it a bug?

Thanks,
 Andy.

-- 
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Santa's helpers are subordinate clauses.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: another Problem with ignore-line
  2004-08-30 15:13   ` another Problem with ignore-line Andy Spiegl
@ 2004-08-30 15:25     ` Oliver Kiddle
  2004-08-30 17:20       ` Andy Spiegl
  0 siblings, 1 reply; 12+ messages in thread
From: Oliver Kiddle @ 2004-08-30 15:25 UTC (permalink / raw)
  To: Zsh-users List

Andy Spiegl wrote:
>  condor:~/zshtest>mv s<TAB>
>  condor:~/zshtest>mv subdir/           <--- so far so good
> 
>  condor:~/zshtest>mv subdir a
>  condor:~/zshtest>mv a<TAB>            <--- now it only BEEPs
> 
> Could this be due to some zsh options I've set or is it a bug?

I can't reproduce it. Is completing `subdir/' first a necessary step to
reproduce this? Can you try to reproduce it starting from zsh -f. Does the
ignore-line style definitely make a difference here?

Oliver


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: another Problem with ignore-line
  2004-08-30 15:25     ` Oliver Kiddle
@ 2004-08-30 17:20       ` Andy Spiegl
  2004-08-30 21:21         ` Bart Schaefer
  0 siblings, 1 reply; 12+ messages in thread
From: Andy Spiegl @ 2004-08-30 17:20 UTC (permalink / raw)
  To: Zsh-users List

> I can't reproduce it. Is completing `subdir/' first a necessary step to
> reproduce this?
No, I included it just for demonstration.

> Can you try to reproduce it starting from zsh -f. Does the
> ignore-line style definitely make a difference here?
You're right.  In that case it doesn't make a difference!

But I can't find the culprit.  Only that it has to do with this line:
 zstyle ':completion:*' completer _expand_dots _complete _match _correct

If I remove it from my rcs, the completion after "a" works.
Oh, wait it's enough to remove "completer" from it.  Strange!
So if I replace
 zstyle ':completion:*' completer _expand_dots _complete _match _correct
with
 zstyle ':completion:*' _expand_dots _complete _match _correct
everything is fine or better said: seems to be fine for now.

Can you understand this?
 Andy.

-- 
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 "Let's just be friends -- friends who never talk or see each other."
  -- David Letterman, 7-22-92


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: another Problem with ignore-line
  2004-08-30 17:20       ` Andy Spiegl
@ 2004-08-30 21:21         ` Bart Schaefer
  2004-08-31  8:38           ` Andy Spiegl
  0 siblings, 1 reply; 12+ messages in thread
From: Bart Schaefer @ 2004-08-30 21:21 UTC (permalink / raw)
  To: Zsh-users List

On Mon, 30 Aug 2004, Andy Spiegl wrote:

> But I can't find the culprit.  Only that it has to do with this line:
>  zstyle ':completion:*' completer _expand_dots _complete _match _correct

Try removing "_expand_dots" from that, and see what happens.  The 
_expand_dots function dates from roughly v3.1.9 and isn't part of the 
regular distribution, so it hasn't been updated unless you've done so
yourself, and it may be doing something that isn't quite right anymore.

If it still happens after removing _expand_dots is removed, try using

condor:~/zshtest>mv a<\C-x?>

(ctrl-x question-mark) which invokes _complete_debug, and examine the temp 
file that gets dumped.

> Oh, wait it's enough to remove "completer" from it.  Strange!

No, not strange at all. The syntax is:

zstyle CONTEXT         STYLE     ARGUMENTS
       =============== ========= ====================================== 
zstyle ':completion:*' completer _expand_dots _complete _match _correct

If you remove "completer" you've changed the style name, and the whole 
thing gets ignored.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: another Problem with ignore-line
  2004-08-30 21:21         ` Bart Schaefer
@ 2004-08-31  8:38           ` Andy Spiegl
  2004-08-31 12:27             ` Oliver Kiddle
  0 siblings, 1 reply; 12+ messages in thread
From: Andy Spiegl @ 2004-08-31  8:38 UTC (permalink / raw)
  To: Zsh-users List

> Try removing "_expand_dots" from that, and see what happens.
No difference.

> If it still happens after removing _expand_dots is removed, try using
> 
> condor:~/zshtest>mv a<\C-x?>
> 
> (ctrl-x question-mark) which invokes _complete_debug, and examine the temp 
> file that gets dumped.
I did it once with the "ignore-line yes" and once without and tried to
interpret the differences in the dump files but I still don't understand
where the problem might be.  So I thought I'd include the dump files here.
No, maybe not as they are pretty big.  Instead I'll put them there:
 http://spiegl.de/zsh/dump_with_ignoreline
 http://spiegl.de/zsh/dump_without_ignoreline

Here are my current completion settings (I removed as much as possible):

----------------
if /bin/true && [[ "$ZSH_VERSION_TYPE" == 'new' ]]; then
  autoload -U compinit
  compinit -u
else
  #print "\nAdvanced completion system not found; ignoring zstyle settings."
  which zstyle >/dev/null || function zstyle { }
  which compdef >/dev/null || function compdef { }
fi

# General completion technique
zstyle ':completion:*' completer _complete

# don't complete the same filename
zstyle ':completion:*:(rm|cp|mv):*' ignore-line yes

# generic completions for programs which understand GNU long options(--help)
compdef _gnu_generic make df du casino wc gpg alien Eterm pump hwclock date mv cp wordtrans rechnerbackup

# colored completions
if which dircolors >/dev/null; then
  if [ -f ~/.dircolors ]; then
    eval "`dircolors -b ~/.dircolors`"
  else
    eval "`dircolors -b`"
  fi
fi

if [[ $ZSH_VERSION > 3.1.5 ]]; then
  if [[ $ZSH_VERSION_TYPE == 'new' ]]; then
    zmodload -i zsh/complist

	zstyle ':completion:*' list-colors ''
	zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
	# process lists
	zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
  else
    zmodload -i complist
	# old method
	ZLS_COLOURS=${LS_COLORS-${LS_COLOURS-''}}
  fi
fi  
----------------

Thanks,
 Andy.

-- 
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Windoze: For the one it is an operating system, for the others
          it is the longest virus of the world.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: another Problem with ignore-line
  2004-08-31  8:38           ` Andy Spiegl
@ 2004-08-31 12:27             ` Oliver Kiddle
  2004-08-31 14:41               ` Andy Spiegl
  0 siblings, 1 reply; 12+ messages in thread
From: Oliver Kiddle @ 2004-08-31 12:27 UTC (permalink / raw)
  To: Zsh-users List

Andy Spiegl wrote:

> Here are my current completion settings (I removed as much as possible):

> # General completion technique
> zstyle ':completion:*' completer _complete
> 
> # don't complete the same filename
> zstyle ':completion:*:(rm|cp|mv):*' ignore-line yes
> 

Try changing the ignore-line style to `other'. That is:
  zstyle ':completion:*:(rm|cp|mv):*' ignore-line other

Otherwise the current word (`a' in this case) is ignored along with any
preceding words.

The default if you don't have a completer style is for _ignored to be
run after _complete so normally that would pick up the current word. So
if you prefer, you can add the _ignored completer.

See the zsh-workers discussion starting 15998 for more on the
limitations of ignore-line.

Oliver


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: another Problem with ignore-line
  2004-08-31 12:27             ` Oliver Kiddle
@ 2004-08-31 14:41               ` Andy Spiegl
  0 siblings, 0 replies; 12+ messages in thread
From: Andy Spiegl @ 2004-08-31 14:41 UTC (permalink / raw)
  To: Zsh-users List

Hi Oliver Kiddle,

> Try changing the ignore-line style to `other'. That is:
>   zstyle ':completion:*:(rm|cp|mv):*' ignore-line other
> 
> Otherwise the current word (`a' in this case) is ignored along with any
> preceding words.
Ahhhh, sounds logical!

> The default if you don't have a completer style is for _ignored to be
> run after _complete so normally that would pick up the current word. So
> if you prefer, you can add the _ignored completer.
Hm, but that seems to conflict with
 zstyle ':completion:*' ignore-parents parent pwd
so that pressing TAB after "mv a" leads to "mv a/.."
if the subdir "a" is empty.

Thanks for you help and the pointer to zsh-workers!
 Andy.

-- 
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Form good habits.  They are just as hard to break as the bad ones!


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2004-08-31 14:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-26 18:18 Problem with ignore-line and parenthesis Jesper Holmberg
2004-08-26 22:14 ` Andy Spiegl
2004-08-30 15:13   ` another Problem with ignore-line Andy Spiegl
2004-08-30 15:25     ` Oliver Kiddle
2004-08-30 17:20       ` Andy Spiegl
2004-08-30 21:21         ` Bart Schaefer
2004-08-31  8:38           ` Andy Spiegl
2004-08-31 12:27             ` Oliver Kiddle
2004-08-31 14:41               ` Andy Spiegl
2004-08-27  0:37 ` Problem with ignore-line and parenthesis Bart Schaefer
2004-08-27  7:32   ` Jesper Holmberg
2004-08-27 10:14   ` Oliver Kiddle

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).