Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Re: history completion oddity



Peter Stephenson wrote:

> I expect Sven will tell me this is the way it should work (or has to work),
> but it's worth a try...

Given the way _history* were implemented, this was indeed correct.
What wasn't correct, however, was that it didn't use IPREFIX for
matching. That way, the completion code got IPREFIX==${ and
PREFIX==PWD, just as you thought.

> history completion (ESC-/) on
>   % echo ${PWD
> does nothing.  On
>   % echo ${PWD/
> it gives me what I expect (don't ask):
>   % echo ${PWD/bc01/bc01/test}/$f
> 
> I would guess that something visceral is grabbing potential parameter
> completions before the history code can do anything --- given the second
> result, the list of history words is OK, and also, more subtly, it's not
> falling over on the incompletely parsed parameter.  I didn't get very far
> looking at the trace output, a large chunk of which (in my case) seems to
> be testing for colouring strings.

Yes, I saw this in Andy's trace output, I'll try to improve that.


Bart wrote:

> ...
> 
> Incidentally, I just had an exchange with A. Spiegl in which he noted that
> history completion is unacceptably slow because he has HISTSIZE=15000.  He
> also has several match specs.  I played around with the _history completer
> a little and found that it gets called once for every match spec, which
> thus assigns h_words=("${(@)historywords[2,-1]}") each time ... I estimate
> that at ~5 words per command and ~4 bytes per word, zsh is copying about
> 300Kb of memory every time it does that assignment, so zsh rips through
> as much as 3Mb every time he hits TAB.

Hmhm. I wasn't happy when I used those temporal arrays. I was thinking 
about allowing `compadd -a "foo[2,-1]"', it seems that I forgot to
ask.

Would that be OK for everyone? Any better ideas?

Anyway I probably should have a look how the allocation behaviour in
the completion code can be improved, though.

Bye
 Sven

P.S.: HISTSIZE=15000 doesn't seem to make any sense to me, I doubt
      that this will ever be used...

Index: Completion/Commands/_history_complete_word
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Commands/_history_complete_word,v
retrieving revision 1.4
diff -u -r1.4 _history_complete_word
--- Completion/Commands/_history_complete_word	2000/05/31 09:38:26	1.4
+++ Completion/Commands/_history_complete_word	2000/06/21 08:02:09
@@ -85,6 +85,11 @@
     opt="${opt}V"
   fi
 
+  PREFIX="$IPREFIX$PREFIX"
+  IPREFIX=
+  SUFFIX="$SUFFIX$ISUFFIX"
+  ISUFFIX=
+
   h_words=( "${(@)historywords[2,-1]}" )
   _wanted "$opt" history-words expl 'history word' \
       compadd -Q -a h_words
Index: Completion/Core/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_expand,v
retrieving revision 1.19
diff -u -r1.19 _expand
--- Completion/Core/_expand	2000/06/19 09:55:31	1.19
+++ Completion/Core/_expand	2000/06/21 08:02:09
@@ -33,6 +33,8 @@
   word="$IPREFIX$PREFIX$SUFFIX$ISUFFIX"
 fi
 
+[[ "$word" = *\$\{[^\}]# ]] && return 1
+
 zstyle -T ":completion:${curcontext}:" suffix &&
   [[ "$word" = (\~*/*|\$[a-zA-Z0-9_\[\]]##[^a-zA-Z0-9_\[\]]*|\$\{*\}?*) ]] &&
   return 1
Index: Completion/Core/_history
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_history,v
retrieving revision 1.2
diff -u -r1.2 _history
--- Completion/Core/_history	2000/05/31 09:38:26	1.2
+++ Completion/Core/_history	2000/06/21 08:02:09
@@ -30,6 +30,11 @@
   opt="${opt}V"
 fi
 
+PREFIX="$IPREFIX$PREFIX"
+IPREFIX=
+SUFFIX="$SUFFIX$ISUFFIX"
+ISUFFIX=
+
 # We skip the first element of historywords so the current word doesn't
 # interfere with the completion
 h_words=( "${(@)historywords[2,-1]}" )

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author