Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: completion of dates



Bart wrote:
> so I suspect you're going to need to elaborate on your zstyle settings
> if you want Oliver to debug this further.

I think I've finally guessed what the likely cause is: a file-patterns
style. _globquals then gets called for each of the file patterns that is
completed together. That is a bug in _files/_path_files.

In the past, this wasn't apparent because completion normally removes
duplicates. I used an unsorted group because I think it is better
to order the time specifiers in duration order (and I did that in a
slightly hacky way because it is in _alternative). _dates absolutely
needs to use unsorted groups with no deduplication. And having it called
three times is not useful.

I think the solution is to move the glob qualifier handling from the
beginning of _path_files to the beginning of _files. It can then be
done before the file-patterns are processed and so done once only. The
disadvantage is that glob qualifier completion wouldn't then work with
_path_files. However, _path_files is typically used instead of _files in
the type of situations where glob qualifiers aren't applicable.

Any thoughts on that solution or other ideas?

> } ---- sense

I'm not sure I really like that description. Alternatives that come to
mind include 'time span' and 'time range'. But changing the tag might break
someone's tag-order style.

> Completing Completing digit (days)

I use %B%d%b for that style so didn't notice that effect. Thanks for
pointing me in the right direction. It isn't simple to use _message -e
with reused descriptions from "$@" so the patch below takes the manual
approach.

Oliver

diff --git a/Completion/Unix/Type/_dates b/Completion/Unix/Type/_dates
index 486a2c2..83397b4 100644
--- a/Completion/Unix/Type/_dates
+++ b/Completion/Unix/Type/_dates
@@ -13,14 +13,14 @@
 
 local -a disp cand expl
 local userformat format spacer=1 spacing month monstart skip match
-local d day daysecs extra preclude r ri col explain
+local d day daysecs extra preclude r ri col
 local -a starts skips
 local -i start now mult
 local -i columns=$(( (COLUMNS+4) / 32 )) rows=LINES-4 offset=0
 local -a days=( Mo Tu We Th Fr Sa Su )
 local future mlabel mfmt mlabels
 
-zparseopts -D -K -E f:=format F=future X:=explain
+zparseopts -D -K -E f:=format F=future
 (( future = $#future ? 1 : -1 ))
 zstyle -s ':completion:$curcontext:dates' date-format userformat
 format=${userformat:-${format[2]:-%F}}
@@ -33,9 +33,12 @@ done
 (( rows = rows / 8 ))
 zmodload -i zsh/datetime || rows=0
 
-_message -e dates ${explain[2]:-date}
-(( rows )) || return
+_tags dates || return 0
+_comp_mesg=yes
 _description -2V -x dates expl date
+compadd "${@:/-X/-x}" "$expl[@]" -
+[[ -n $PREFIX$SUFFIX ]] && return 0
+(( rows )) || return 0
 compstate[list]='packed rows'
 
 if [[ $WIDGET = _next_tags ]]; then



Messages sorted by: Reverse Date, Date, Thread, Author