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

Re: substring version of history-complete-word?



On Jul 4, 12:45pm, Adam Spiers wrote:
}
} Is there any way of performing completion of words from history based
} on a substring rather than a prefix?

With the proper value of the matcher-list style, it should "just work."
E.g.:

schaefer<507> echo tec<ESC-/>
schaefer<507> echo aztec.zanshin.com

My particular settings cause words that match prefixes to be preferred
over words that match substrings:

schaefer<507> echo zan<ESC-/>
schaefer<507> echo zanshin@

Or:

schaefer<507> echo com<ESC-/>
Completing history word
compdump'  commit     compdump'  commit

(Hmm, I guess I don't have the remove-all-dups style set.)

} Ideally, it would be retrievable incrementally in the same way as C-r
} fetches whole lines.

I don't have a suggestion for how to do this except using incremental menu
selection (added to the CVS dev tree by Sven in zsh-workers/17366).

I haven't figured out how to set the matcher-list style specifically for
history completion, the above is all the result of my generic matchers.
There's some pretty strange code for styles in _history_complete_word:

        if [[ -z "$curcontext" ]]                                            
        then
                curcontext=history-words:::                       
        else
                curcontext="history-words${curcontext#*:}" 
        fi                                                        
	[...]
        zstyle -t ":completion:${curcontext}:history-words" stop && stop=yes 
        zstyle -T ":completion:${curcontext}:history-words" list || compstate[list]=''                                                   

(So we have styles that look like *:history-words:*:history-words ??  Is
that really intentional?)

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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