From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6318 invoked by alias); 11 Jul 2016 20:01:04 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 38830 Received: (qmail 1768 invoked from network); 11 Jul 2016 20:01:03 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.1 From: Eric Cook To: zsh-workers@zsh.org Subject: [PATCH] _fc: allow the user to limit the number of events Date: Mon, 11 Jul 2016 15:55:48 -0400 Message-Id: <1468266948-9318-1-git-send-email-llua@gmx.com> X-Mailer: git-send-email 2.6.6 In-Reply-To: <812932212.4222957.1467756469555.JavaMail.yahoo.ref@mail.yahoo.com> References: <812932212.4222957.1467756469555.JavaMail.yahoo.ref@mail.yahoo.com> X-Provags-ID: V03:K0:MJYseqIC/O0PZBU+nJTAdfhN17smZlccux3t97X1yaCUWu3OTQP fBtr/VOUjARBAGS+5xvJDDTmap7nDu+gJYbuHgs2MM3kuos3M1P3o7426BXMIMK0GE6aiEb h+0p1B4C0rtGeodMqN4FIdNw4qgU6yC6928oFj8MFUwbEmPKLIceFwDRj+Di0hCDM6qWnic vy7PuHKkoKo0K1Gv/luAA== X-UI-Out-Filterresults: notjunk:1;V01:K0:W4ncAppNBMU=:DkaXYSuNW5LuWBaKbZeMOo J1A22Xsa2HWGw7l678ylnZXer5ouIz83XP2g3eO8NDHGmJQ9xG4woPs2rPJrO8VIZZs2E/or8 UIyarK6bX9NNEg6bhbS9Ec2ZA+byw2Vsp+47HORLL3D9lW4Pqpak/O2E9X9CtEI97fSBzk9AP o6/P49i9XTGxkscZqZifzshI2cmU5lJVw1sSkR8vlmf7FtcJTJXaQ4S64mpc8qjpqFYKar4m2 TxOeHqQ/8oL2Qx6auaiVUMOXXIR+gwWOBqQhbJV2lCQrWEL/g85d1s862zKS5EJ5+sdqfNrwa hZyNWu8sgLCzDrKCdD/17C0Xp+AN1C3DxRPnfH3NkAfxySIKT7cGYp4f1MTccLivruncgoo+0 C1Dt0nZtJL/3XXwAtyS1yP6YmVw3pm8iGSuBFweSiezTuEHGdCgF3vLsZcd42dWTLono1YRz9 yBR/yzeovPWH5KrcuwcpmoacBxO8xkXQ1Mq4M+3gX2hN3bsE7f3BhreXz/TYs++NvSoDzB6kt 0pGq4VdJnjMXDlisQmQOlystuJa6p6ZyInhlU2pYnYk8xpphba4W5nzZXpOxxJWzLNwRkk2Kk bkoclkO1Wp1bGxJUefLzqKkEfb2me5GXfAUSbLPFvQqCipf1n8k5AV14EJb4WzaFXnGQD/Qzf Ts1lvKEBNZD2jG9rsqb85UUJO3bUyszSIwEW72J1J139TKw5b/LMj3p9tjB+kSslpXFrF5p27 pfmaLNkM83g7zlGqDWaT9FbJ0M7a8mJRJON71Tpka6y/7FV2lIwKgurobd4= What about `max-matches'? I did like `max-matches-length' until i read what `max-matches-width' does. Knowing that, i would personally expect m-m-length to do something related to m-m-width. I fixed _dates to allow single digit percentages too. I also don't know understand what the _next_tags stuff in _dates is doing So i didn't cargo cult it, do you mind explaining? --- diff --git a/Completion/Unix/Type/_dates b/Completion/Unix/Type/_dates index e4fa62e..64a1833 100644 --- a/Completion/Unix/Type/_dates +++ b/Completion/Unix/Type/_dates @@ -27,7 +27,7 @@ format=${userformat:-${format[2]:-%F}} zstyle -a ':completion:$curcontext:dates' max-matches-length r for ri in $r; do - [[ $ri = [0-9]##% ]] && (( ri = LINES * .${ri%%%} )) + [[ $ri = [0-9]##% ]] && (( ri = LINES * .${(l:2::0:)ri%%%} )) (( ri < rows )) && (( rows=ri )) done (( rows = rows / 8 )) diff --git a/Completion/Zsh/Command/_fc b/Completion/Zsh/Command/_fc index 68456cc..046cad2 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,15 @@ if [[ -n $state ]]; then _wanted -2V events expl "$state_descr" compadd -M "B:0=" -ld events - \ "${events[@]%% *}" elif [[ -prefix - ]]; then + zstyle -s ":completion:${curcontext}:events" max-matches _histno + if [[ $_histno = <->% ]]; then + (( _histno = HISTNO * .${(l:2::0:)_histno%%%} )) + elif ! [[ $_histno = <-> ]]; then + _histno=$((HISTNO+1)) + fi + 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 8792324..9c23bb5 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -2123,6 +2123,12 @@ performed. The default value for this style is `tt(2 numeric)'. ) +kindex(max-matches, completion style) +item(tt(max-matches))( +If this is set to an integer or percentage, it is used to limit the number +of matches for commands that support it. tt(fc) and tt(history) are two examples +that use it due to possibly generating a large number of matches. +) kindex(max-matches-width, completion style) item(tt(max-matches-width))( This style is used to determine the trade off between the width of the