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

Re: PATCH: completion of glob qualifiers



On 23 Feb, Peter Stephenson wrote:
> This is mostly useful as a memory jogger rather than actually to save
> you typing a single character.  However, I've added a pretty useless
> function to save you typing a delimiter character.  (The alternative
> was simply to print a message saying "delimiter", which was
> really low tech.)
> 
> It works OK so far but it does raise various issues about related things
> that might be got to work better.  You might run across those.

I've only just noticed this change back in message 24585. Is there any
reason why globbing flags were not completed. This patch adds them.

Note that inside [[ ... ]] conditions, a bracket that is not preceded by
some other character is assumed to be used for grouping of conditions so
this won't work with glob flags at the beginning of a pattern.

One problem possibly due to your original patch is the following;
: */( <tab>
results in the /( being removed. I haven't worked out why but this
doesn't occur with the old zsh that comes with Debian stable.

I've also changed _globquals to use _message -e instead of plain
_message. This applies a tag and allows certain styles (such as fake) to
be used.

Oliver

Index: Completion/Unix/Type/_path_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v
retrieving revision 1.39
diff -u -r1.39 _path_files
--- Completion/Unix/Type/_path_files	29 Oct 2008 21:59:32 -0000	1.39
+++ Completion/Unix/Type/_path_files	7 Nov 2008 12:34:34 -0000
@@ -394,7 +394,11 @@
 		"$tpre/$tsuf" = (#b)((*[^\\]|)(\\\\)#"(#q")([^\)]#) \
 	  ) && -z $compstate[quote] ]]; then
        compset -p ${#match[1]}
-       _globquals
+       if [[ -o extendedglob ]] && compset -P '\#'; then
+         _globflags
+       else
+         _globquals
+       fi
     elif [[ "$tpre$tsuf" = */* ]]; then
       compfiles -P$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" "$sdirs" fake
     elif [[ "$sopt" = *[/f]* ]]; then
Index: Completion/Zsh/Type/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/.distfiles,v
retrieving revision 1.3
diff -u -r1.3 .distfiles
--- Completion/Zsh/Type/.distfiles	15 Mar 2008 23:21:02 -0000	1.3
+++ Completion/Zsh/Type/.distfiles	7 Nov 2008 12:34:34 -0000
@@ -7,6 +7,7 @@
 _directory_stack
 _file_descriptors
 _functions
+_globflags
 _globqual_delims
 _globquals
 _history_modifiers
Index: Completion/Zsh/Type/_globflags
===================================================================
RCS file: Completion/Zsh/Type/_globflags
diff -N Completion/Zsh/Type/_globflags
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Zsh/Type/_globflags	7 Nov 2008 12:34:34 -0000
@@ -0,0 +1,33 @@
+local ret=1
+local -a flags
+
+if compset -P a; then
+  _message -e numbers 'errors'
+  return
+elif compset -P q; then
+  _globquals
+  return
+fi
+
+flags=(
+  'i:case insensitive'
+  'l:lower case characters match uppercase'
+  'I:case sensitive matching'
+  's:match start of string'
+  'e:match end of string'
+)
+[[ $compstate[context] = condition ]] && flags+=(
+  'b:activate backreferences'
+  'B:deactivate backreferences'
+  'm:set reference to entire matched data'
+  'M:deactivate m flag'
+)
+
+_describe -t globflags "glob flag" flags -Q -S ')' && ret=0
+flags=(
+  'a:approximate matching'
+  'q:introduce glob qualifier'
+)
+_describe -t globflags "glob flag" flags -Q -S '' && ret=0
+
+return ret
Index: Completion/Zsh/Type/_globquals
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/_globquals,v
retrieving revision 1.2
diff -u -r1.2 _globquals
--- Completion/Zsh/Type/_globquals	23 Feb 2008 18:34:02 -0000	1.2
+++ Completion/Zsh/Type/_globquals	7 Nov 2008 12:34:34 -0000
@@ -25,7 +25,7 @@
 	return
       elif ! _globqual_delims; then
 	# still completing mode spec
-	_message "mode spec"
+	_message -e modes "mode spec"
 	return
       fi
     fi
@@ -57,7 +57,7 @@
     (d)
     # complete/skip device
     if ! compset -p '[[:digit:]]##'; then
-      _message "device ID"
+      _message -e device-ids "device ID"
       return
     fi
     ;;
@@ -65,7 +65,7 @@
     (l)
     # complete/skip link count
     if ! compset -P '([-+]|)[[:digit:]]##'; then
-      _message "link count"
+      _message -e numbers "link count"
       return
     fi
     ;;



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