From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8707 invoked by alias); 4 Dec 2009 21:54:06 -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: 27453 Received: (qmail 27765 invoked from network); 4 Dec 2009 21:54:03 -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.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 74.125.78.144 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=Iza/sMzpiYbPNnaVl9+zG6DGcrB5re3VQXDw5+CT0Dw=; b=obPhRYQZl58QFyiQCXZaCuv7mFfQ/+etBLGKfuEm4fuC2dmZ6Osd9bBO7ryWbypTAF rkhHtGtmQrW9T7ycNKn6i4X9BU/qPfZVmsne4jhuxvSphQ3J8izJ0aCYqdf/9edl6PNl 2UT7GkPzmQ3RLkytlfoQ9xVv/xHHz/lvv1V+M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=E9tqiS0Z8lvEhYPf0gKkc/EHrSjtwhDn3k2qa3vBJrM8kdMYzJYZS9s9VCj9mRs7Tf JB0T6lUAvBRF5Bj8ptVxe85oNX8/6LHrmFSFEtkXJWNCJgWPFzeWmTpWKPIUwQ2+0rm/ 8utW0T2pKpoaj0GfBNnV43ZRzEi13YXu48ZX8= MIME-Version: 1.0 Date: Fri, 4 Dec 2009 22:53:58 +0100 Message-ID: <237967ef0912041353g2ff47fa8m9dd274ed8b37511@mail.gmail.com> Subject: Add completion suffix highlighting From: Mikael Magnusson To: zsh workers Content-Type: text/plain; charset=UTF-8 I have a friend who just started using zsh a while ago, and she complained about / being removed when she pressed enter after completing a directory to rsync. Apparently rsync behaves differently with and without the / in place. We tried setting ZLE_REMOVE_SUFFIX_CHARS to nothing and using zle auto-suffix-retain in an accept-line hook, but then we realized it would be better if you could tell more easily if the suffix would be removed or not. So I whipped this up and somehow it worked on the first try (no guarantees though :). Given my poor track record of posting patches via email, here is a link to the patch, and I'll just paste in the essence of the patch for reference. http://mika.l3ib.org/0001-Add-region-highlighting-for-completion-suffixes.patch I'm not sure if the reference in the man page needs to be more specific, or point somewhere completely different. Or if this is at all a good idea, it seems to work and be useful though. diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index c849d9b..e99cbb3 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -247,8 +247,9 @@ struct region_highlight *region_highlights; * for the first few elements of region_highlights. * 0: region between point and mark * 1: isearch region + * 2: suffix */ -#define N_SPECIAL_HIGHLIGHTS (2) +#define N_SPECIAL_HIGHLIGHTS (3) /* * Number of elements in region_highlights. * This includes the special elements above. @@ -340,6 +341,7 @@ zle_set_highlight(void) int special_atr_on_set = 0; int region_atr_on_set = 0; int isearch_atr_on_set = 0; + int suffix_atr_on_set = 0; struct region_highlight *rhp; special_atr_on = default_atr_on = 0; @@ -373,6 +375,9 @@ zle_set_highlight(void) } else if (strpfx("isearch:", *atrs)) { match_highlight(*atrs + 8, &(region_highlights[1].atr)); isearch_atr_on_set = 1; + } else if (strpfx("suffix:", *atrs)) { + match_highlight(*atrs + 7, &(region_highlights[2].atr)); + suffix_atr_on_set = 1; } } } @@ -384,6 +389,8 @@ zle_set_highlight(void) region_highlights[0].atr = TXTSTANDOUT; if (!isearch_atr_on_set) region_highlights[1].atr = TXTUNDERLINE; + if (!suffix_atr_on_set) + region_highlights[2].atr = TXTBOLDFACE; allocate_colour_buffer(); } @@ -1076,6 +1083,13 @@ zrefresh(void) } else { region_highlights[1].start = region_highlights[1].end = -1; } + /* check for an active completion suffix */ + if (suffixnoinslen) { + region_highlights[2].start = zlecs - suffixnoinslen; + region_highlights[2].end = zlecs; + } else { + region_highlights[2].start = region_highlights[2].end = -1; + } if (clearlist && listshown > 0) { if (tccan(TCCLEAREOD)) { -- Mikael Magnusson