zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: Stopping wrap-round in menu completion?
Date: Fri, 17 Sep 1999 10:29:03 +0200 (MET DST)	[thread overview]
Message-ID: <199909170829.KAA02161@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Adam Spiers's message of Thu, 16 Sep 1999 16:51:13 +0100


[ list changed to workers ]

Adam Spiers wrote:

> Is it possible to prevent wrap-round (looping) in menu completion?  I
> have a _history_complete_word which returns unsorted matches via
> compgen -V (hence sorted by the time they went in the history), but if
> I menu complete beyond the oldest match, I'd like nothing to happen.

Not in the C-code. However for a bindable command in the new
completion system you can do that.

Dunno if the patch is worth including, but why not...

Try `compconf history_stop=yes' or `compconf history_stop=verbose'.

Bye
 Sven

diff -u oldcompletion/Commands/_history_complete_word Completion/Commands/_history_complete_word
--- oldcompletion/Commands/_history_complete_word	Fri Sep 17 09:32:41 1999
+++ Completion/Commands/_history_complete_word	Fri Sep 17 10:26:30 1999
@@ -2,9 +2,30 @@
 
 local expl
 
-if [[ -n "$compconfig[history_sort]" ]]; then
-  _description expl 'history word'
+if [[ -n "$compstate[old_list]" && -n "$compconfig[history_stop]" ]]; then
+  if [[ -z "$_hist_menu_end" &&
+        compstate[old_insert] -lt _hist_menu_length ]]; then
+    compstate[old_list]=keep
+    compstate[insert]=$((compstate[old_insert]+1))
+  else
+    _hist_menu_end=yes
+    if [[ "$compconfig[history_stop]" = verbose ]]; then
+      _message 'end of history reached'
+    else
+      compstate[old_list]=keep
+      compstate[insert]=_hist_menu_length
+    fi
+  fi
 else
-  _description -V expl 'history word'
+  if [[ -n "$compconfig[history_sort]" ]]; then
+    _description expl 'history word'
+  else
+    _description -V expl 'history word'
+  fi
+  compgen "$expl[@]" -Q -H 0 ''
+  compstate[insert]=1
+  if [[ -n "$compconfig[history_stop]" ]]; then
+    _hist_menu_length="$compstate[nmatches]"
+    _hist_menu_end=''
+  fi
 fi
-compgen "$expl[@]" -Q -H 0 ''
diff -u od/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- od/Zsh/compsys.yo	Fri Sep 17 09:32:18 1999
+++ Doc/Zsh/compsys.yo	Fri Sep 17 10:21:33 1999
@@ -1467,6 +1467,13 @@
 alphabetically instead of keeping them in the order in which they
 appear in the history (from youngest to oldest).
 )
+item(tt(history_stop))(
+If this is set to a non-empty string, the tt(_history_complete_word)
+bindable command will always insert matches as if menu-completion were 
+started and it will stop when the last match is inserted. If this key
+is set to tt(verbose) a message will be displayed when the last match
+is reached.
+)
 item(tt(cvs_disable_stat))(
 This is used by the completion function for the tt(cvs) command. If it 
 is set to a non-empty value, this function will not try to use the

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


                 reply	other threads:[~1999-09-17  8:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199909170829.KAA02161@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).