zsh-workers
 help / color / mirror / code / Atom feed
* Working with the historywords special parameter
@ 2001-08-24  6:54 Felix Rosencrantz
  2001-08-24  8:16 ` Sven Wischnowsky
  0 siblings, 1 reply; 7+ messages in thread
From: Felix Rosencrantz @ 2001-08-24  6:54 UTC (permalink / raw)
  To: zsh-workers

I'm trying to create a completer that uses the previous word on the line
and the special parameter historywords to determine what values current
word should be.

It looks to me like there is no single expression that can be used to
get just the list of all the elements that match an expression from an
array.  It seems like you need to iterate over the elements of an array
via an expression like:

    #the_word is $words[CURRENT-1]
    cnt=2
    words=()
    while [[ $historywords[(in:cnt:)the_word] -lt  $#historywords  ]] ; do
       words=($words $historywords[$historywords[(in:cnt:)the_word]-1]
       let "cnt = cnt + 1" 
    done

Is there a faster way to do this?

I'd like to do this with a large historywords (currently I have
4728 elements) doing this takes between 1 and 2 seconds. If I copy
historywords to a temporary array to do the search it goes much faster.
But if the search could be done in one operation, it would be faster and
wouldn't require a temporary copy of historywords.

Would anyone object to a new special parameter (maybe historywordsnums)
that has corresponding elements to historywords saying with which
history line the word is associated?  I ask since one of the problems
with this completer is that it picks up false "matches" when the
previous word is the last word of a previous command, it gets the next command.

It would be nice to be able to determine if a word is the last word of
the line, or what the first word of the line is.

-FR.


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/


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

end of thread, other threads:[~2001-08-28 15:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-24  6:54 Working with the historywords special parameter Felix Rosencrantz
2001-08-24  8:16 ` Sven Wischnowsky
2001-08-24 17:05   ` Bart Schaefer
2001-08-28  6:19     ` Felix Rosencrantz
2001-08-28 15:16       ` Bart Schaefer
2001-08-28  6:24     ` Seg Fault in paramsubst() Felix Rosencrantz
2001-08-28  8:35       ` PATCH: " Sven Wischnowsky

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