zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: new menu selection and Re: New compinstall and bindkey
Date: Thu, 1 Jul 1999 11:29:32 +0200 (MET DST)	[thread overview]
Message-ID: <199907010929.LAA28695@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Sven Wischnowsky's message of Tue, 29 Jun 1999 16:09:12 +0200 (MET DST)


I wrote:

> Oliver Kiddle wrote:
> 
> > I've now looked at the new selection for menu completion. Firstly,
> > thanks Sven: it's great. There is one thing I don't like. When I move
> > the cursors to highlight the string I want to complete to and press
> > return, the highlighting is removed but menu-completion continues so if
> > I press tab again, it cycles through the selections as opposed to
> > accepting my selection and going on to complete whatever is next.
> 
> This once was intentional, when menu-select was intended as a
> menu-completion add-on. Now that it is more of a replacement we should 
> probably change this.

I've just taken send-break for it. So: send-break leaves selection
and you'll be in normal menu-completion and accept-line leaves
selection and accepts the current match. Accepting is done as for a
completion with only one match.

With that you can do

  bindkey -M menuselect '^J' send-break

to have return continue with menu-completion

Ok? Or should the meaning of send-break and accept-line be changed
(meaning: should the default for return be changed)?


Andrej Borsenkow wrote:

> I wanted to write about this anyway. Unfortunately, current widget system is not
> well suited for programming (in user-defined widgets). Currently widgets mostly
> are "high-level" ones, that do fairly complex tasks. That was fine when all
> widgets were builtin ones. But now more of a low-level, primitive widgets are
> needed - that do some well defined atomic action. Good example is completion.
> What is needed is probably such primitives as next-match, previous-match,
> insert-match, exit-menu etc. Using these most of other tasks could be easily
> porgrammed with user-defined widgets - and if some prove universally useful,
> they could be implemented as builtin.

That's what I suggested when I sent my first widget-args-patch. The
problem is to find out the generic functions behind all the
widgets. Also I was mainly thinking about (and still prefer in some
cases) changing more builtin widgets to accept options to get a
specific behavior, e.g. by changing complete-word to be able to do
everything the other completion widgets can (and probably more) by
giving it the right options. I hadn't thought about splitting the
completion stuff -- probably because I know too much about the
completion code ;-)

Bye
 Sven

diff -u od/Zsh/mod_complist.yo Doc/Zsh/mod_complist.yo
--- od/Zsh/mod_complist.yo	Tue Jun 29 12:51:32 1999
+++ Doc/Zsh/mod_complist.yo	Thu Jul  1 11:21:53 1999
@@ -99,7 +99,10 @@
 Selecting matches is done by moving the mark around using the zle movement
 functions. The zle functions tt(send-break) and tt(accept-line) can be used
 to leave menu-selection, leaving the match currently inserted into the line
-in place. The functions tt(accept-and-hold) and
+in place. In the case of tt(accept-line), the match currently inserted
+will be accepted and the immediatly trying completion again will
+complete after it. Using tt(send-break) leaves menu-selection and
+continues with normal menu-completion. The functions tt(accept-and-hold) and
 tt(accept-and-menu-complete) can be used to accept the match currently
 inserted and continue inserting matches after that. Matches inserted this
 way can be removed by invoking the tt(undo) function. Keys bound to one of
@@ -118,4 +121,9 @@
 tt(bindkey) builtin command (see
 ifzman(zmanref(zshmodules))\
 ifnzman(noderef(The zle Module))\
-).
+). For example, to make the return key leave menu-selection and
+continue with normal menu-completion one can call
+
+indent(tt(bindkey -M menuselect '^J' send-break))
+
+after loading the tt(complist) module.
diff -u os/Zle/complist.c Src/Zle/complist.c
--- os/Zle/complist.c	Wed Jun 30 11:56:57 1999
+++ Src/Zle/complist.c	Thu Jul  1 11:22:17 1999
@@ -649,12 +649,12 @@
     Cmgroup *pg;
     Thingy cmd;
     Menustack u = NULL;
-    int i = 0;
+    int i = 0, acc = 0;
     char *s;
 
     if (dummy && (!(s = getsparam("SELECTMIN")) ||
 		  (dat && dat->num < atoi(s))))
-	return 1;
+	return 0;
 
     selectlocalmap(mskeymap);
     noselect = 0;
@@ -681,10 +681,12 @@
 
     getk:
 
-	if (!(cmd = getkeycmd()) || cmd == Th(z_sendbreak) ||
-	    cmd == Th(z_acceptline))
+	if (!(cmd = getkeycmd()) || cmd == Th(z_sendbreak))
 	    break;
-	else if (cmd == Th(z_acceptandhold) ||
+	else if (cmd == Th(z_acceptline)) {
+	    acc = 1;
+	    break;
+	} else if (cmd == Th(z_acceptandhold) ||
 		 cmd == Th(z_acceptandmenucomplete)) {
 	    Menustack s = (Menustack) zhalloc(sizeof(*s));
 
@@ -847,11 +849,16 @@
     selectlocalmap(NULL);
     mselect = -1;
     inselect = 0;
+    if (acc) {
+	menucmp = 0;
+	lastambig = 0;
+	do_single(*(minfo.cur));
+    }
     if (!noselect) {
 	showinglist = -2;
 	zrefresh();
     }
-    return noselect;
+    return (!noselect ^ acc);
 }
 
 /* The widget function. */
diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Wed Jun 30 11:56:59 1999
+++ Src/Zle/zle_tricky.c	Thu Jul  1 11:04:29 1999
@@ -108,7 +108,8 @@
 
 /* != 0 if we are in the middle of a menu completion */
 
-static int menucmp;
+/**/
+int menucmp;
 
 /* Information about menucompletion. */
 
@@ -346,7 +347,8 @@
  * on the second tab, a` la bash, and then automenu kicks in when     *
  * lastambig == 2.                                                    */
 
-static int lastambig;
+/**/
+int lastambig;
 
 /* This says what of the state the line is in when completion is started *
  * came from a previous completion. If the FC_LINE bit is set, the       *
@@ -1058,7 +1060,8 @@
 	dat.matches = amatches;
 	dat.num = nmatches;
 	dat.cur = NULL;
-	runhookdef(MENUSTARTHOOK, (void *) &dat);
+	if (runhookdef(MENUSTARTHOOK, (void *) &dat))
+	    menucmp = 0;
     }
     return ret;
 }

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


             reply	other threads:[~1999-07-01  9:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-01  9:29 Sven Wischnowsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-06-29 14:09 Sven Wischnowsky
1999-06-29 11:26 Andrej Borsenkow
1999-06-29 13:48 ` new menu selection and " Oliver Kiddle

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=199907010929.LAA28695@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).