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

Re: [FEATURE][PATCH] Complete local executables with ./ prefix, if prefix-needed is false



Bart Schaefer wrote:
> > The fake style is looked up in _description so a dummy call to it is one
> > option. The patch below adds that but I'd be interested in any thoughts
> > on that.
>
> Is it going to matter that this happens before command-path is
> consulted?  And before the defs array is passed to _alternative?

I don't think so, other than the point I already mentioned about the
return status from _command_names not accounting for the fake matches.
fake is usually handled early because _description needs to be called
before compadd.

> > path=( $cmdpath:A ) when the command-path style is set. That resolves

> Does that have any unexpected interaction with PATH_DIRS ?

Not with the actual path_dirs functionality because of path being
local in the function. In terms of completion down in _path_commands
that still works. It ought to filter out "." from $path anyway to
avoid duplicated completions. It also doesn't add a / suffix for
the directories and didn't account for symlinks to executables. So
I've included a patch against the completion handling for path_dirs.
:A will subvert the filtering of "." but the effect is very minor.
I'm unsure whether command-path should perhaps be looked up before
the $path[(r).] check in _command_names.

Oliver

diff --git a/Completion/Unix/Type/_path_commands b/Completion/Unix/Type/_path_commands
index 66795ae0f..4d5a6c5af 100644
--- a/Completion/Unix/Type/_path_commands
+++ b/Completion/Unix/Type/_path_commands
@@ -87,18 +87,19 @@ fi
 # 'if' block move up to the "_command_names -" branch of _command_names?
 if [[ -o path_dirs ]]; then
   local -a path_dirs
-  path_dirs=(${^path}/*(/N:t))
-  (( ${#path_dirs} )) &&
-  _wanted path-dirs expl 'directory in path' compadd "$@" -a path_dirs && ret=0
 
   if [[ $PREFIX$SUFFIX = */* ]]; then
+    path_dirs=( ${path:#.} )
     # Find command from path, not hashed
-    _wanted commands expl 'external command' _path_files -W path -g '*(*)' &&
-    ret=0
+    _wanted commands expl 'external command' _path_files -W path_dirs -g '*(-*)' && ret=0
+  else
+    path_dirs=(${^path}/*(/N:t))
+    (( ${#path_dirs} )) &&
+        _wanted path-dirs expl 'directory in path' compadd "$@" -S / -a path_dirs && ret=0
   fi
 fi
 
-return $ret
+return ret
 }
 
 _path_commands "$@"




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