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

Re: [PATCH] Improve _man file-path completion



dana wrote on Fri, Jan 03, 2020 at 18:12:28 -0600:
> This has been annoying me for a little while. Since we glob for man pages with
> _path_files, it's not possible to navigate through sub-directories when
> completing file paths. Just using _files fixes that, but then when you have
> separate-sections on you get like:
> 
>   % man /usr/local/l<TAB>
>   completing manual page, section 1:
>   lib/  libexec/  local/
>   completing manual page, section 2:
>   lib/  libexec/  local/
>   completing manual page, section 3:
>   lib/  libexec/  local/
>   ...
> 
> Separating by-path pages into sections is nice, but the only way i can think
> of to make it work well with directory navigation is to do the globbing
> 'manually' first and decide what to insert based on that, and that's a bigger
> job. (But let me know if you have any better ideas)

How about this (relative to master)?  It fixes your original problem but
retains the separate-sections behaviour for man pages specified by filename.

diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man
index 41ae85a1f..bee7be410 100644
--- a/Completion/Unix/Command/_man
+++ b/Completion/Unix/Command/_man
@@ -381,8 +381,9 @@ _man() {
 
     (( $#sects )) || return 1
 
-    _tags manuals.${^sects}
+    _tags files manuals.${^sects}
     while _tags; do
+      _requested files expl "subdirectories" _files -/ && ret=0
       for sect_dirname in $sects; do
         d=$sect_dirname
         (( $+sect_descs[$d] )) && d+=" (${sect_descs[$d]})"

Aside:

    % compdef _f f
    % _f() _files -/
    % f Util/<TAB>
.
offers files, rather than nothing.  Bug?



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