From 37d14cab88e2aa09e6279bb96995e9f4521887a5 Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Thu, 27 Apr 2000 14:16:15 +0000 Subject: new _history completer (10979) --- ChangeLog | 3 +++ Completion/Core/.distfiles | 4 ++-- Completion/Core/_history | 36 ++++++++++++++++++++++++++++++++++++ Doc/Zsh/compsys.yo | 8 ++++++++ 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 Completion/Core/_history diff --git a/ChangeLog b/ChangeLog index ce6ae483e..2cd99d32b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2000-04-27 Sven Wischnowsky + * 10979: originally from Felix: 10894: Completion/Core/.distfiles, + Completion/Core/_history, Doc/Zsh/compsys.yo: new _history completer + * 10978: Src/Zle/complist.c: better wrap around for cursor movement widgets; avoid flicker when leaving menu-selection diff --git a/Completion/Core/.distfiles b/Completion/Core/.distfiles index 9ddf7f523..aaf844598 100644 --- a/Completion/Core/.distfiles +++ b/Completion/Core/.distfiles @@ -2,8 +2,8 @@ DISTFILES_SRC=' .distfiles _all_labels _alternative _approximate _call _compalso _complete _correct _description _expand - _file_descriptors _files _funcall _ignored _list _main_complete _match - _menu _multi_parts _message _next_label _normal _oldlist _options + _file_descriptors _files _funcall _history _ignored _list _main_complete + _match _menu _multi_parts _message _next_label _normal _oldlist _options _parameters _path_files _prefix _requested _sep_parts _set_options _setup _sort_tags _tags _unset_options _wanted diff --git a/Completion/Core/_history b/Completion/Core/_history new file mode 100644 index 000000000..978a75400 --- /dev/null +++ b/Completion/Core/_history @@ -0,0 +1,36 @@ +#autoload + +# Hm, this *can* sensibly be used as a completer. But it could also be used +# as a utility function, so maybe it should be moved into another directory. +# Or maybe not. Hm. +# +# +# Complete words from the history +# +# Code taken from _history_complete_words. +# +# Available styles: +# +# :history-words:sort -- sort matches lexically (default is to sort by age) +# :history-words:remove-all-dups -- +# remove /all/ duplicate matches rather than just +# consecutives + +local opt expl + +if zstyle -t ":completion:${curcontext}:" remove-all-dups; then + opt=- +else + opt=-1 +fi + +if zstyle -t ":completion:${curcontext}:" sort; then + opt="${opt}J" +else + opt="${opt}V" +fi + +# We skip the first element of historywords so the current word doesn't +# interfere with the completion +_wanted "$opt" history-words expl 'history word' \ + compadd -Q - "${(@)historywords[2,-1]}" diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 66d56f078..1e077d8ad 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -2138,6 +2138,14 @@ at all. In a different mode selected by the tt(completions) style, all em(completions) generated for the string on the line are inserted. ) +findex(_history) +item(tt(_history))( +Complete words from the shell's command history. This completer +uses the tt(remove-all-dups), and tt(sort) styles also used by the +tt(_history_complete_word) bindable command, see +ifzman(the section `Completion System Configuration' above)\ +ifnzman(noderef(Completion System Configuration)). +) findex(_list) item(tt(_list))( This completer allows one to delay the insertion of matches until -- cgit 1.4.1