Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Add completion suffix highlighting
- X-seq: zsh-workers 27453
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Add completion suffix highlighting
- Date: Fri, 4 Dec 2009 22:53:58 +0100
- 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=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author