zsh-workers
 help / color / mirror / code / Atom feed
* _make doesn't work in dirs with spaces
@ 2011-05-21 18:03 Mikael Magnusson
  2011-05-23  1:10 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Mikael Magnusson @ 2011-05-21 18:03 UTC (permalink / raw)
  To: zsh workers, Michael Hwang

greygjhart reported this on IRC a few days ago.

There's some (q) in there that maybe shouldn't be. Removing the one on
line 176 fixes completing in a directory with spaces, but I'm unsure
of the intention of it, and the others in the file.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: _make doesn't work in dirs with spaces
  2011-05-21 18:03 _make doesn't work in dirs with spaces Mikael Magnusson
@ 2011-05-23  1:10 ` Bart Schaefer
  2011-05-24  1:36   ` Mikael Magnusson
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2011-05-23  1:10 UTC (permalink / raw)
  To: zsh workers

On May 21,  8:03pm, Mikael Magnusson wrote:
}
} There's some (q) in there that maybe shouldn't be. Removing the one on
} line 176 fixes completing in a directory with spaces, but I'm unsure
} of the intention of it, and the others in the file.

The one on line 176 just looks wrong and should probably be removed.

For those on lines 163 an 166, I wonder if they should be (D) ?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: _make doesn't work in dirs with spaces
  2011-05-23  1:10 ` Bart Schaefer
@ 2011-05-24  1:36   ` Mikael Magnusson
  2011-05-24  1:38     ` PATCH: _make: put body in _make() and don't redefine helpers every time Mikael Magnusson
  0 siblings, 1 reply; 4+ messages in thread
From: Mikael Magnusson @ 2011-05-24  1:36 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh workers

On 23 May 2011 03:10, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On May 21,  8:03pm, Mikael Magnusson wrote:
> }
> } There's some (q) in there that maybe shouldn't be. Removing the one on
> } line 176 fixes completing in a directory with spaces, but I'm unsure
> } of the intention of it, and the others in the file.
>
> The one on line 176 just looks wrong and should probably be removed.

Okay, I'll remove this one.

> For those on lines 163 an 166, I wonder if they should be (D) ?

Doing that just made completing make -I/-f <tab> start in / instead of
the current dir. I can't make those two work for any combination of
none, (q) and (D) when the path has spaces, but regular completion
does get fixed by removing the one on 176. Maybe some additional
combination with (Q) is needed on the lines that use $~, but at this
point I'm just guessing.

I also just realized that the completer doesn't complete -options at
all, and it redefines the helper functions every time it's invoked.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 4+ messages in thread

* PATCH: _make: put body in _make() and don't redefine helpers every time
  2011-05-24  1:36   ` Mikael Magnusson
@ 2011-05-24  1:38     ` Mikael Magnusson
  0 siblings, 0 replies; 4+ messages in thread
From: Mikael Magnusson @ 2011-05-24  1:38 UTC (permalink / raw)
  To: zsh-workers

Here's the diff without reindent, full patch below.

+++ b/Completion/Unix/Command/_make
@@ -3,10 +3,6 @@
 # TODO: Based on targets given on the command line, show only variables that
 # are used in those targets and their dependencies.
 
-local prev="$words[CURRENT-1]" file expl tmp is_gnu dir incl match
-local -A TARGETS VARIABLES
-local ret=1
-
 _make-expandVars() {
   local open close var val front ret tmp=$1
 
@@ -149,6 +145,11 @@ _make-findBasedir () {
   print -- $basedir
 }
 
+_make () {
+  local prev="$words[CURRENT-1]" file expl tmp is_gnu dir incl match
+  local -A TARGETS VARIABLES
+  local ret=1
+
 _pick_variant -r is_gnu gnu=GNU unix -v -f
 
 if [[ $is_gnu == gnu ]]
@@ -223,3 +224,6 @@ else
 fi
 
 return ret
+}
+
+_make "$@"



---
 Completion/Unix/Command/_make |  136 +++++++++++++++++++++--------------------
 1 files changed, 70 insertions(+), 66 deletions(-)

diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make
index 322414b..09f44a3 100644
--- a/Completion/Unix/Command/_make
+++ b/Completion/Unix/Command/_make
@@ -3,10 +3,6 @@
 # TODO: Based on targets given on the command line, show only variables that
 # are used in those targets and their dependencies.
 
-local prev="$words[CURRENT-1]" file expl tmp is_gnu dir incl match
-local -A TARGETS VARIABLES
-local ret=1
-
 _make-expandVars() {
   local open close var val front ret tmp=$1
 
@@ -149,77 +145,85 @@ _make-findBasedir () {
   print -- $basedir
 }
 
-_pick_variant -r is_gnu gnu=GNU unix -v -f
-
-if [[ $is_gnu == gnu ]]
-then
-  incl="(-|)include"
-else
-  incl=.include
-fi
-
-if [[ "$prev" == -[CI] ]]
-then
-  _files -W ${(q)$(_make-findBasedir ${words[1,CURRENT-1]})} -/ && ret=0
-elif [[ "$prev" == -[foW] ]]
-then
-  _files -W ${(q)$(_make-findBasedir $words)} && ret=0
-else
-  file="$words[(I)-f]"
-  if (( file ))
+_make () {
+  local prev="$words[CURRENT-1]" file expl tmp is_gnu dir incl match
+  local -A TARGETS VARIABLES
+  local ret=1
+
+  _pick_variant -r is_gnu gnu=GNU unix -v -f
+
+  if [[ $is_gnu == gnu ]]
   then
-    file=${~words[file+1]}
-    [[ $file == [^/]* ]] && file=${(q)$(_make-findBasedir $words)}/$file
-    [[ -r $file ]] || file=
+    incl="(-|)include"
   else
-    local basedir
-    basedir=${(q)$(_make-findBasedir $words)}
-    if [[ $is_gnu == gnu && -r $basedir/GNUmakefile ]]
-    then
-      file=$basedir/GNUmakefile
-    elif [[ -r $basedir/makefile ]]
-    then
-      file=$basedir/makefile
-    elif [[ -r $basedir/Makefile ]]
+    incl=.include
+  fi
+
+  if [[ "$prev" == -[CI] ]]
+  then
+    _files -W ${(q)$(_make-findBasedir ${words[1,CURRENT-1]})} -/ && ret=0
+  elif [[ "$prev" == -[foW] ]]
+  then
+    _files -W ${(q)$(_make-findBasedir $words)} && ret=0
+  else
+    file="$words[(I)-f]"
+    if (( file ))
     then
-      file=$basedir/Makefile
+      file=${~words[file+1]}
+      [[ $file == [^/]* ]] && file=${(q)$(_make-findBasedir $words)}/$file
+      [[ -r $file ]] || file=
     else
-      file=''
+      local basedir
+      basedir=${(q)$(_make-findBasedir $words)}
+      if [[ $is_gnu == gnu && -r $basedir/GNUmakefile ]]
+      then
+        file=$basedir/GNUmakefile
+      elif [[ -r $basedir/makefile ]]
+      then
+        file=$basedir/makefile
+      elif [[ -r $basedir/Makefile ]]
+      then
+        file=$basedir/Makefile
+      else
+        file=''
+      fi
     fi
-  fi
 
-  if [[ -n "$file" ]]
-  then
-    if [[ $is_gnu == gnu ]] && zstyle -t ":completion:${curcontext}:targets" call-command
+    if [[ -n "$file" ]]
+    then
+      if [[ $is_gnu == gnu ]] && zstyle -t ":completion:${curcontext}:targets" call-command
+      then
+        _make-parseMakefile $PWD < <(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" .PHONY 2> /dev/null)
+      else
+        case "$OSTYPE" in
+          freebsd*)
+          _make-parseMakefile $PWD < <(_call_program targets "$words[1]" -nsp -f "$file" .PHONY 2> /dev/null)
+    ;;
+    *)
+          _make-parseMakefile $PWD < $file
+        esac
+      fi
+    fi
+
+    if [[ $PREFIX == *'='* ]]
     then
-      _make-parseMakefile $PWD < <(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" .PHONY 2> /dev/null)
+      # Complete make variable as if shell variable
+      compstate[parameter]="${PREFIX%%\=*}"
+      compset -P 1 '*='
+      _value "$@" && ret=0
     else
-      case "$OSTYPE" in
-        freebsd*)
-        _make-parseMakefile $PWD < <(_call_program targets "$words[1]" -nsp -f "$file" .PHONY 2> /dev/null)
-	;;
-	*)
-        _make-parseMakefile $PWD < $file
-      esac
+      _tags targets variables
+      while _tags
+      do
+        _requested targets expl 'make targets' \
+          compadd -- ${(k)TARGETS} && ret=0
+        _requested variables expl 'make variables' \
+          compadd -S '=' -- ${(k)VARIABLES} && ret=0
+      done
     fi
   fi
 
-  if [[ $PREFIX == *'='* ]]
-  then
-    # Complete make variable as if shell variable
-    compstate[parameter]="${PREFIX%%\=*}"
-    compset -P 1 '*='
-    _value "$@" && ret=0
-  else
-    _tags targets variables
-    while _tags
-    do
-      _requested targets expl 'make targets' \
-        compadd -- ${(k)TARGETS} && ret=0
-      _requested variables expl 'make variables' \
-        compadd -S '=' -- ${(k)VARIABLES} && ret=0
-    done
-  fi
-fi
+  return ret
+}
 
-return ret
+_make "$@"
-- 
1.7.4-rc1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-24  1:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-21 18:03 _make doesn't work in dirs with spaces Mikael Magnusson
2011-05-23  1:10 ` Bart Schaefer
2011-05-24  1:36   ` Mikael Magnusson
2011-05-24  1:38     ` PATCH: _make: put body in _make() and don't redefine helpers every time Mikael Magnusson

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).