zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: "Nikolay Aleksandrovich Pavlov (ZyX)" <kp-pav@yandex.ru>
Cc: zsh-workers <zsh-workers@zsh.org>
Subject: Re: Regression: broken completion on modification time
Date: Sat, 18 Jun 2016 00:02:52 +0200	[thread overview]
Message-ID: <19379.1466200972@thecus.kiddle.eu> (raw)
In-Reply-To: <706581466190613@web21m.yandex.ru>

"Nikolay Aleksandrovich Pavlov (ZyX)" wrote:
>
> I would say “yes” just to check what possibilities is it talking about. Question is why would I hit `<Tab>` in first place: if I did not see this discussion I would not ever suggest that completing a (mostly) numeric and in any case very short argument to `m` has any sense.

It may not be useful to "complete" short things but the descriptions can
be very useful. There's quite a few cases where this is done, e.g.:
  printf '%<tab>
  : ${(<tab>
  !!:<tab>

> Also if I write `ls *(m)` with cursor after `m` and hit `<Tab>` I get “Completing: digit (invalid time specifier)” (nothing if I use `autoload compinit ; compinit` in `zsh -f`, or “Completing: `files'” with no list after `unsetopt completeinword`):

Stripping suffixes is easily forgotten when writing completion functions
and this was one such case. Patch below should fix this and make
it indicate the default of "days" when there is no time specifier.

With `unsetopt completeinword', you have the equivalent of moving the
cursor to the end of the word. *(m) is an invalid glob matching no
files. You might also want to consider using the _prefix completer which
ignores the entire suffix.

> Particularly, the most failing thing is `ls foo{bar<Tab>}`: this usually either does nothing or expands immediately if I already happened to write a comma.

Are you using the _expand completer or the default expand-or-complete
widget to do expansion.

Braces are largely handled by internal C code: _prefix doesn't seem able
to help here. You can prevent the expansion with something like:
  zstyle -e ':completion:*::::' completer \
    'reply=( _oldlist _complete ); (( $#SUFFIX )) || reply[1]+=( _expand )'

Oliver

diff --git a/Completion/Unix/Type/_files b/Completion/Unix/Type/_files
index fe0780a..6987824 100644
--- a/Completion/Unix/Type/_files
+++ b/Completion/Unix/Type/_files
@@ -7,6 +7,7 @@ local ret=1
 # we don't want to complete them multiple times (for each file pattern).
 if _have_glob_qual $PREFIX; then
   compset -p ${#match[1]}
+  compset -S '[^\)\|\~]#(|\))'
   if [[ $_comp_caller_options[extendedglob] == on ]] && compset -P '\#'; then
     _globflags && ret=0
   else
diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files
index 14c4cc7..6a1e89f 100644
--- a/Completion/Unix/Type/_path_files
+++ b/Completion/Unix/Type/_path_files
@@ -17,6 +17,7 @@ local -a match mbegin mend
 if _have_glob_qual $PREFIX; then
   local ret=1
   compset -p ${#match[1]}
+  compset -S '[^\)\|\~]#(|\))'
   if [[ $_comp_caller_options[extendedglob] == on ]] && compset -P '\#'; then
     _globflags && ret=0
   else
diff --git a/Completion/Zsh/Type/_globquals b/Completion/Zsh/Type/_globquals
index 2523eb3..ed9c008 100644
--- a/Completion/Zsh/Type/_globquals
+++ b/Completion/Zsh/Type/_globquals
@@ -125,7 +125,7 @@ while [[ -n $PREFIX ]]; do
         alts+=("senses:sense:compadd -E 0 -d sdisp -S '' - + '' -")
       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 ""' )
+      alts+=('digits:digit ('${${specmap[(K)${timespec:-d}]}:-invalid time specifier}'):_dates -f ${${timespec/[-+]/d}:-d} -S ""' )
       _alternative $alts
       return
     fi


  reply	other threads:[~2016-06-17 22:08 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
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 [this message]
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=19379.1466200972@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --cc=kp-pav@yandex.ru \
    --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).