From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4540 invoked from network); 9 Jan 2009 17:51:21 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 9 Jan 2009 17:51:21 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 16542 invoked from network); 9 Jan 2009 17:51:15 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 9 Jan 2009 17:51:15 -0000 Received: (qmail 3288 invoked by alias); 9 Jan 2009 17:51:10 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26270 Received: (qmail 3274 invoked from network); 9 Jan 2009 17:51:10 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 9 Jan 2009 17:51:10 -0000 Received: from flock1.newmail.ru (flock1.newmail.ru [82.204.219.207]) by bifrost.dotsrc.org (Postfix) with SMTP id AE97D80293D3 for ; Fri, 9 Jan 2009 18:50:53 +0100 (CET) Received: (qmail 15201 invoked from network); 9 Jan 2009 17:50:27 -0000 Received: from unknown (HELO cooker.localnet) (arvidjaar@newmail.ru@91.77.192.120) by smtpd.newmail.ru with SMTP; 9 Jan 2009 17:50:27 -0000 From: Andrey Borzenkov To: zsh-workers@sunsite.dk Subject: [PATCH] allow accept-and-menu-complete work for single word Date: Fri, 9 Jan 2009 20:50:20 +0300 User-Agent: KMail/1.11.0 (Linux/2.6.28-1avb; KDE/4.1.96; i686; ; ) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1274185.4QqLDPXmKU"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200901092050.23470.arvidjaar@newmail.ru> X-Virus-Scanned: ClamAV 0.92.1/8848/Fri Jan 9 14:16:38 2009 on bifrost X-Virus-Status: Clean --nextPart1274185.4QqLDPXmKU Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The patch allows a-a-m-c to work for list of values in single word (e.g.=20 as used by _values). This looks pretty straightforward and apparently=20 does not have any side effects; comments? Index: Completion/Base/Utility/_values =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_values,v retrieving revision 1.9 diff -u -p -r1.9 _values =2D-- Completion/Base/Utility/_values 27 Feb 2007 20:44:01 -0000 1.9 +++ Completion/Base/Utility/_values 9 Jan 2009 17:44:46 -0000 @@ -12,6 +12,8 @@ if compvalues -i "$@"; then local noargs args opts descr action expl sep argsep subc test=3D'*' local oldcontext=3D"$curcontext" =20 + compstate[list_in_word]=3D1 + compvalues -S argsep compvalues -s sep && [[ -n "$sep" ]] && test=3D"[^${(q)sep}]#" =20 Index: Doc/Zsh/compwid.yo =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compwid.yo,v retrieving revision 1.45 diff -u -p -r1.45 compwid.yo =2D-- Doc/Zsh/compwid.yo 18 Oct 2008 19:16:24 -0000 1.45 +++ Doc/Zsh/compwid.yo 9 Jan 2009 17:44:47 -0000 @@ -285,6 +285,13 @@ tt(messages) both kinds of explanation s will be set appropriately on entry to a completion widget and may be changed there. ) +vindex(list_in_word, compstate) +item(tt(list_in_word))( +This controls how accept-and-menu-complete widget handles suffix. If +set to tt(0) (default), suffix will be removed and replaced by space. +If set to tt(1), suffix is preserved so next match will be inserted +in the same word. +) vindex(list_lines, compstate) item(tt(list_lines))( This gives the number of lines that are needed to display the full Index: Src/Zle/compcore.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v retrieving revision 1.98 diff -u -p -r1.98 compcore.c =2D-- Src/Zle/compcore.c 26 Sep 2008 09:11:30 -0000 1.98 +++ Src/Zle/compcore.c 9 Jan 2009 17:44:47 -0000 @@ -325,6 +325,7 @@ do_completion(UNUSED(Hookdef dummy), Com comppatinsert =3D ztrdup("menu"); forcelist =3D 0; haspattern =3D 0; + complistinword =3D 0; complistmax =3D getiparam("LISTMAX"); zsfree(complastprompt); complastprompt =3D ztrdup(((isset(ALWAYSLASTPROMPT) && zmult =3D=3D 1)= || Index: Src/Zle/complete.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/zsh/zsh/Src/Zle/complete.c,v retrieving revision 1.44 diff -u -p -r1.44 complete.c =2D-- Src/Zle/complete.c 15 Nov 2008 21:27:46 -0000 1.44 +++ Src/Zle/complete.c 9 Jan 2009 17:44:47 -0000 @@ -38,6 +38,7 @@ zlong compcurrent, complistmax; /**/ zlong complistlines, + complistinword, compignored; =20 /**/ @@ -1146,6 +1147,7 @@ static struct compparam compkparams[] =3D=20 GSU(unambig_pos_gsu) }, { "insert_positions", PM_SCALAR | PM_READONLY, NULL, GSU(insert_pos_gsu) }, + { "list_in_word", PM_INTEGER, VAL(complistinword), NULL }, { "list_max", PM_INTEGER, VAL(complistmax), NULL }, { "last_prompt", PM_SCALAR, VAL(complastprompt), NULL }, { "to_end", PM_SCALAR, VAL(comptoend), NULL }, @@ -1596,7 +1598,7 @@ setup_(UNUSED(Module m)) compvared =3D compqstack =3D NULL; complastprefix =3D ztrdup(""); complastsuffix =3D ztrdup(""); =2D complistmax =3D 0; + complistmax =3D complistinword =3D 0; hascompmod =3D 1; =20 return 0; Index: Src/Zle/compresult.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/zsh/zsh/Src/Zle/compresult.c,v retrieving revision 1.75 diff -u -p -r1.75 compresult.c =2D-- Src/Zle/compresult.c 7 May 2008 08:53:40 -0000 1.75 +++ Src/Zle/compresult.c 9 Jan 2009 17:44:48 -0000 @@ -1309,21 +1309,23 @@ accept_last(void) lastbrbeg->str[l] =3D ','; lastbrbeg->str[l + 1] =3D '\0'; } else { =2D int l; =2D zlemetacs =3D minfo.pos + minfo.len + minfo.insc; =2D iremovesuffix(' ', 1); =2D l =3D zlemetacs; =2D zlemetacs =3D minfo.pos + minfo.len + minfo.insc - (*(minfo.cur))->qisl; =2D if (zlemetacs < l) =2D foredel(l - zlemetacs, CUT_RAW); =2D else if (zlemetacs > zlemetall) =2D zlemetacs =3D zlemetall; =2D inststrlen(" ", 1, 1); + if (!complistinword) { + int l; + + iremovesuffix(' ', 1); + l =3D zlemetacs; + zlemetacs =3D minfo.pos + minfo.len + minfo.insc - (*(minfo.cur))- >qisl; + if (zlemetacs < l) + foredel(l - zlemetacs, CUT_RAW); + else if (zlemetacs > zlemetall) + zlemetacs =3D zlemetall; + inststrlen(" ", 1, 1); + } minfo.insc =3D minfo.len =3D 0; minfo.pos =3D zlemetacs; minfo.we =3D 1; =2D } + } =20 if (!wasmeta) unmetafy_line(); --nextPart1274185.4QqLDPXmKU Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEABECAAYFAklnjl8ACgkQR6LMutpd94wbOgCgzQOg7dukdparmU0kZDvC36M1 sZEAoKkbNdDOMAMKbZv05Q1hHkvGUmPY =6/Dc -----END PGP SIGNATURE----- --nextPart1274185.4QqLDPXmKU--