* PATCH: Re: Proposed _history completer
@ 2000-04-27 14:14 Sven Wischnowsky
0 siblings, 0 replies; only message in thread
From: Sven Wischnowsky @ 2000-04-27 14:14 UTC (permalink / raw)
To: zsh-workers
Felix Rosencrantz wrote:
> I'm not currently doing any work on the _history completer. So if you
> want to commit the changes that would be fine with me. Though I think
> my testing is pretty limited (e.g. I don't use NUMERIC arguments, and I didn't
> try various zstyle configurations.) I was thinking that in case there were
> any obvious problems with the completer (e.g. _wanted shouldn't be used in
> a completer) someone would post that feedback.
>
> Also, I don't have a lot of time to work on it, this completer has been on my
> list for a while. So if other people want work on it I would be happy.
I'll be committing it in a second. As everyone can see by the patch
below, I haven't changed it yet, apart from adding a comment to the
top. That's because it really looks like one of our functions that
just generate matches of a certain type. And it could be used like
that, but using it as a completer is certainly sensible, too.
Bye
Sven
Index: Completion/Core/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/.distfiles,v
retrieving revision 1.4
diff -u -r1.4 .distfiles
--- Completion/Core/.distfiles 2000/04/20 00:48:28 1.4
+++ Completion/Core/.distfiles 2000/04/27 14:10:39
@@ -2,8 +2,8 @@
.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
Index: Completion/Core/_history
===================================================================
RCS file: _history
diff -N _history
--- /dev/null Tue May 5 13:32:27 1998
+++ _history Thu Apr 27 07:10:39 2000
@@ -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]}"
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.24
diff -u -r1.24 compsys.yo
--- Doc/Zsh/compsys.yo 2000/04/27 09:24:38 1.24
+++ Doc/Zsh/compsys.yo 2000/04/27 14:10:41
@@ -2138,6 +2138,14 @@
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
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2000-04-27 14:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-27 14:14 PATCH: Re: Proposed _history completer 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).