zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] _fc: allow the user to limit the number of events
@ 2016-07-04 21:32 Eric Cook
  2016-07-05  4:57 ` Daniel Shahaf
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Cook @ 2016-07-04 21:32 UTC (permalink / raw)
  To: zsh-workers

Which can be useful when someone has an very large HISTFILE.
I am open to a better style name if someone can think of one.

---
 Completion/Zsh/Command/_fc | 5 ++++-
 Doc/Zsh/compsys.yo         | 5 +++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Completion/Zsh/Command/_fc b/Completion/Zsh/Command/_fc
index 68456cc..5044451 100644
--- a/Completion/Zsh/Command/_fc
+++ b/Completion/Zsh/Command/_fc
@@ -1,7 +1,7 @@
 #compdef fc history r
 
 local curcontext="$curcontext" state state_descr line ret=1
-local events num cmd sep
+local events num cmd sep _histno _histi
 typeset -A opt_args
 local fc_common fc_hist fc_r
 
@@ -75,7 +75,10 @@ if [[ -n $state ]]; then
     _wanted -2V events expl "$state_descr" compadd -M "B:0=" -ld events - \
         "${events[@]%% *}"
   elif [[ -prefix - ]]; then
+    zstyle -s ":completion:${curcontext}:history-events" history-events _histno
+    _histno=${_histno%%:<->}; [[ $_histno = <-> ]] || _histno=$((HISTNO+1))
     for num cmd in "${(kv@)history}"; do
+      (( ++_histi < _histno )) || break
       (( num=num - HISTNO ))
       events+=( "${(r.1+$#HISTNO.)num} $sep $cmd" )
     done
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index fb0abce..fa20b6b 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -1691,6 +1691,11 @@ in the list.  To avoid having matches considered as possible
 completions at all, the tt(tag-order) style can be modified as described
 below.
 )
+kindex(history-events, completion style)
+item(tt(history-events))(
+If this is set to a number, it is used to limit the number of history
+events when completing tt(fc) or tt(history).
+)
 kindex(hosts, completion style)
 item(tt(hosts))(
 A list of names of hosts that should be completed.  If this is not set,
-- 
2.6.6


^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <812932212.4222957.1467756469555.JavaMail.yahoo.ref@mail.yahoo.com>]

end of thread, other threads:[~2016-07-11 20:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-04 21:32 [PATCH] _fc: allow the user to limit the number of events Eric Cook
2016-07-05  4:57 ` Daniel Shahaf
2016-07-05 14:58   ` Mikael Magnusson
     [not found] <812932212.4222957.1467756469555.JavaMail.yahoo.ref@mail.yahoo.com>
2016-07-05 22:07 ` Oliver Kiddle
2016-07-11 19:55 ` Eric Cook

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