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

PATCH: _globquals: Say what the digit is when completing time qualifiers, add d



Added the d flag, and moved locals to top to get rid of anon function.
It seems the scoping conflicts with compset -P somehow. I didn't notice
at first that with my previous patch, *(mM<tab> would no longer output
the +- hints, as you can see in the previous mail. Now it works:

% *(mM<tab>
=== sense
+  -- more than
-  -- less than
=== digit (months)


---
 Completion/Zsh/Type/_globquals |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/Completion/Zsh/Type/_globquals b/Completion/Zsh/Type/_globquals
index 778dfa8..9de7742 100644
--- a/Completion/Zsh/Type/_globquals
+++ b/Completion/Zsh/Type/_globquals
@@ -1,7 +1,8 @@
 #autoload
 
-local state=qual expl char delim
+local state=qual expl char delim timespec
 local -a alts
+local -A specmap
 
 while [[ -n $PREFIX ]]; do
   char=$PREFIX[1]
@@ -111,18 +112,19 @@ while [[ -n $PREFIX ]]; do
     ;;
 
     ([amc])
-    if ! compset -P '([Mwhms]|)([-+]|)<->'; then
+    if ! compset -P '([Mwhmsd]|)([-+]|)<->'; then
       # complete/skip relative time spec
       alts=()
-      if ! compset -P '[Mwhms]' && [[ -z $PREFIX ]]; then
-        alts+=(
-          "time-specifiers:time specifier:\
-((M\:months w\:weeks h\:hours m:\minutes s\:seconds))")
+      timespec=$PREFIX[1]
+      if ! compset -P '[Mwhmsd]' && [[ -z $PREFIX ]]; then
+        alts+=("time-specifiers:time specifier:\
+((M\:months w\:weeks h\:hours m:\minutes s\:seconds d\:days))")
       fi
       if ! compset -P '[-+]' && [[ -z $PREFIX ]]; then
         alts+=("senses:sense:((-\:less\ than +\:more\ than))")
       fi
-      alts+=('digits:digit: ')
+      specmap=( M months w weeks h hours m minutes s seconds '(|+|-|d)' days)
+      alts+=('digits:digit ('${${specmap[(K)$timespec]}:-invalid time specifier}'):' )
       _alternative $alts
       return
     fi
-- 
1.7.5.4



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