zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: history completion oddity
Date: Wed, 21 Jun 2000 10:03:40 +0200 (MET DST)	[thread overview]
Message-ID: <200006210803.KAA05777@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Peter Stephenson's message of Tue, 20 Jun 2000 17:31:48 +0100


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@informatik.hu-berlin.de


             reply	other threads:[~2000-06-21  8:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-06-21  8:03 Sven Wischnowsky [this message]
2000-06-21  9:06 ` Andy Spiegl
2000-06-21 14:52 ` Bart Schaefer
2000-06-21  9:13 Sven Wischnowsky
2000-06-21 15:13 ` Andy Spiegl
2000-06-22  8:33 Sven Wischnowsky

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=200006210803.KAA05777@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /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).