zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers <zsh-workers@zsh.org>
Subject: Re: Regression: broken completion on modification time
Date: Wed, 15 Jun 2016 18:32:57 +0200	[thread overview]
Message-ID: <9937.1466008377@thecus.kiddle.eu> (raw)
In-Reply-To: <160614091402.ZM17103@torch.brasslantern.com>

Bart wrote:
> } It should probably at least bail out if the complist module isn't loaded as
> } per this patch. Or have you got any better ideas on what to check for?
>
> You suggested:
> > Looking for select in $_def_menu_style 

I tried a number of combinations to see if this would work. It falls
down where the menu-select widget is used directly. Checking for
$WIDGET wouldn't help with that because the menu-select widget doesn't
cause all the completion functions to run, it just turns on menu
selection with whatever completion list we already have.

Another option would be to set a different value for compstate[list] so
users with default setup get a calendar listed: menu selection is not
actually needed for the calendar to display. I'm not sure this is
especially helpful, however, because it is only by using menu selection
to select a specific date that the function is useful.

> There's also the issue noted in workers/35770 (hopefully zsh.org is back
> up) where the substitution of the descriptions for the actual values
> (e.g. before/since for -/+) is confusing if the "format" style is not
> set and the layout is poor when the "group-name" style is not set.

Not having group-name set results in poor format in general.

Looking back at that mail, the complaint is that it does not tell you
"what the syntax is without selecting the entry itself". I prefer
to keep things compact to allow space for the calendar. How about
using a style such as the following. We have an extra-verbose style in
_path_commands and this uses that though I could be persuaded to use
just verbose. I'll allow time for comments before doing anything for
_find.

Oliver

diff --git a/Completion/Zsh/Type/_globquals b/Completion/Zsh/Type/_globquals
index 2523eb3..4eca7ba 100644
--- a/Completion/Zsh/Type/_globquals
+++ b/Completion/Zsh/Type/_globquals
@@ -1,7 +1,7 @@
 #autoload
 
 local state=qual expl char delim timespec
-local -a alts tdisp sdisp
+local -a alts tdisp sdisp tmatch smatch
 local -A specmap
 
 while [[ -n $PREFIX ]]; do
@@ -118,11 +118,26 @@ while [[ -n $PREFIX ]]; do
       timespec=$PREFIX[1]
       if ! compset -P '[Mwhmsd]' && [[ -z $PREFIX ]]; then
 	tdisp=( seconds minutes hours days weeks Months )
-        alts+=( "time-specifiers:time specifier:compadd -E 0 -d tdisp -S '' - s m h d w M" )
+	tmatch=( s m h d w M )
+	if zstyle -t ":completion:${curcontext}:time-specifiers" extra-verbose; then
+	  zstyle -s ":completion:${curcontext}:time-specifiers" list-separator sep || sep=--
+          print -v tdisp -f "%s ${sep//(#m)[%\\]/$MATCH$MATCH} %s\0" ${tmatch:^^tdisp}
+	  tdisp=( ${(0)tdisp} )
+	fi
+	alts+=( "time-specifiers:time specifier:compadd -E 0 -d tdisp -S '' -a tmatch" )
       fi
       if ! compset -P '[-+]' && [[ -z $PREFIX ]]; then
 	sdisp=( before exactly since )
-        alts+=("senses:sense:compadd -E 0 -d sdisp -S '' - + '' -")
+	smatch=( - '' + )
+	if zstyle -t ":completion:${curcontext}:senses" extra-verbose; then
+	  zstyle -s ":completion:${curcontext}:senses" list-separator sep || sep=--
+	  sdisp=( "- $sep before" "+ $sep since" )
+	  smatch=( - + )
+	else
+	  sdisp=( before exactly since )
+	  smatch=( - '' + )
+	fi
+        alts+=( "senses:sense:compadd -E 0 -d sdisp -S '' -a smatch" )
       fi
       specmap=( M months w weeks h hours m minutes s seconds '(|+|-|d)' days)
       alts+=('digits:digit ('${${specmap[(K)$timespec]}:-invalid time specifier}'):_dates -f ${${timespec/[-+]/d}:-d} -S ""' )


  reply	other threads:[~2016-06-15 16:40 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-12 20:32 Dima Kogan
2016-06-13  0:47 ` Bart Schaefer
2016-06-13  1:37   ` Dima Kogan
2016-06-13 22:00   ` Oliver Kiddle
2016-06-14 16:14     ` Bart Schaefer
2016-06-15 16:32       ` Oliver Kiddle [this message]
2016-06-15 23:24         ` Daniel Shahaf
2016-06-17 16:19           ` Oliver Kiddle
2016-06-17 18:11             ` Bart Schaefer
2016-06-17 19:10               ` Nikolay Aleksandrovich Pavlov (ZyX)
2016-06-17 22:02                 ` Oliver Kiddle
2016-06-17 22:20                   ` Nikolay Aleksandrovich Pavlov (ZyX)
2016-06-17 22:33                 ` Bart Schaefer
2016-06-17 22:49                   ` Nikolay Aleksandrovich Pavlov (ZyX)
2016-06-17 23:00                     ` Bart Schaefer
2016-06-17 23:50               ` Oliver Kiddle
2016-06-19 16:04                 ` Bart Schaefer
2016-06-21  1:41             ` Daniel Shahaf
2016-06-21 14:31               ` 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=9937.1466008377@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --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).