zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Yuri D'Elia <wavexx@thregr.org>
Cc: Zsh workers <zsh-workers@zsh.org>
Subject: PATCH: Re: widget special PREFIX variable and cursor position with complete_in_word
Date: Thu, 27 Feb 2014 16:02:01 +0100	[thread overview]
Message-ID: <23244.1393513321@thecus.kiddle.eu> (raw)
In-Reply-To: <lek81q$tdt$2@ger.gmane.org>

Yuri D'Elia wrote:
> I would definitely like this as a general addition to the main completer.
> 
> It just needs a customizable color for the match.

This patch adds a 'show-ambiguity' style. The value is the colour to
use.

One thing I've noticed is that the patterns specified with ZLS_COLORS
will also match descriptions. This can be annoying if the -- separator
(or whatever you configure the list-separator style to) matches for the
ambiguity. It is actually a nice feature if you include something like
'=(#b)(--) (*)==32=3' in list-colors. Given that there is syntax for
selecting matches by tag group, I wonder if something could be easily
added for the descriptions. I'm not sure what syntax would make sense.

Oliver

diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete
index 8dd781d..e881ea6 100644
--- a/Completion/Base/Core/_main_complete
+++ b/Completion/Base/Core/_main_complete
@@ -334,6 +334,14 @@ elif [[ nm -eq 0 && -z "$_comp_mesg" &&
   compadd -x "$mesg"
 fi
 
+if zstyle -s ":completion:${curcontext}:" show-ambiguity tmp; then
+  local prefix=${${compstate[unambiguous]}[1,${compstate[unambiguous_cursor]}-1]}
+  local toquote='[=\(\)\|~^?*[\]#<>]'
+  [[ $tmp = (yes|true|on) ]] && tmp=4
+  [[ -n $prefix ]] &&
+    _comp_colors+=( "=(#i)${prefix[1,-2]//?/(}${prefix[1,-2]//(#m)?/${MATCH/$~toquote/\\$MATCH}|)}${prefix[-1]//(#m)$~toquote/\\$MATCH}(#b)(?|)*==$tmp" )
+fi
+
 [[ "$_comp_force_list" = always ||
    ( "$_comp_force_list" = ?*  && nm -ge _comp_force_list ) ]] &&
     compstate[list]="${compstate[list]//messages} force"
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index c304461..5a5e619 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -2440,6 +2440,15 @@ completing words for the dict command. It allows words from different
 dictionary databases to be added separately.
 The default for this style is `false'.
 )
+kindex(show-ambiguity, completion style)
+item(tt(show-ambiguity))(
+If the tt(zsh/complist) module is loaded, this style can be used to
+highlight the first ambiguous character in completion lists. The
+value is either a color indication such as those supported by the
+tt(list-colors) style or, with a value of tt(true), a default of
+underlining is selected. The highlighting is only applied if the
+completion display strings correspond to the actual matches.
+)
 kindex(show-completer, completion style)
 item(tt(show-completer))(
 Tested whenever a new completer is tried.  If it is true, the completion


  parent reply	other threads:[~2014-02-27 15:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <ldgnl5$fo8$1@ger.gmane.org>
     [not found] ` <140212214707.ZM25929@torch.brasslantern.com>
     [not found]   ` <ldii13$jg7$1@ger.gmane.org>
     [not found]     ` <140213092531.ZM26966@torch.brasslantern.com>
     [not found]       ` <ldj21h$9dj$1@ger.gmane.org>
     [not found]         ` <140213223438.ZM27375@torch.brasslantern.com>
     [not found]           ` <13128.1392379014@thecus.kiddle.eu>
     [not found]             ` <ldl3u8$302$1@ger.gmane.org>
     [not found]               ` <13979.1392388765@thecus.kiddle.eu>
     [not found]                 ` <ldlddn$s7r$1@ger.gmane.org>
     [not found]                   ` <15748.1392413785@thecus.kiddle.eu>
     [not found]                     ` <ldsqrp$ndo$1@ger.gmane.org>
     [not found]                       ` <12657.1392655814@thecus.kiddle.eu>
     [not found]                         ` <ldtice$ntg$1@ger.gmane.org>
     [not found]                           ` <16810.1392737023@thecus.kiddle.eu>
     [not found]                             ` <le00gb$rfp$1@ger.gmane.org>
     [not found]                               ` <19322.1392746842@thecus.kiddle.eu>
     [not found]                                 ` <le0d7h$al$1@ger.gmane.org>
     [not found]                                   ` <12895.1393360892@thecus.kiddle.eu>
     [not found]                                     ` <lek7vc$tdt$1@ger.gmane.org>
     [not found]                                       ` <lekvso$udp$1@ger.gmane.org>
2014-02-26 23:00                                         ` Oliver Kiddle
2014-02-27 11:20                                           ` Yuri D'Elia
     [not found]                                     ` <lek81q$tdt$2@ger.gmane.org>
2014-02-27 15:02                                       ` Oliver Kiddle [this message]
2014-02-27 17:02                                         ` PATCH: " Yuri D'Elia

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=23244.1393513321@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --cc=wavexx@thregr.org \
    --cc=zsh-workers@zsh.org \
    /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).