From f70615d878b80f9303f7e04daa11cef9e133ac3b Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sun, 31 Jul 2016 12:36:55 +0000 Subject: 38981: _man: Followup to 37634: unbreak OpenBSD 'man 3p' and Linux $MANSECT. The breakage was reported in 38516. --- Completion/Unix/Command/_man | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'Completion/Unix/Command/_man') diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man index 0534db753..e892bb263 100644 --- a/Completion/Unix/Command/_man +++ b/Completion/Unix/Command/_man @@ -44,15 +44,21 @@ _man() { if [[ $OSTYPE = solaris* ]]; then sect=${${words[(R)-s*]#-s}:-$words[$words[(i)-s]+1]} elif [[ -n ${sect:=$words[$words[(i)-S]+1]} || -n ${sect:=$MANSECT} ]]; then - if [[ $sect != ${sect::="${sect//:/|}"} ]]; then - sect="($sect)" - fi + sect="${sect//:/|}" + sect="${sect//,/|}" elif (( CURRENT > 2 )); then sect=$words[2] fi - if [[ $sect = (<->*|1M|l|n) || $sect = \(*\|*\) ]]; then - dirs=( $^_manpath/(sman|man|cat)${~sect%%[^0-9]#}/ ) + if [[ $sect = (<->*|1M|l|n) || $sect = *\|* ]]; then + () { + local -a sects=( ${(s.|.)sect} ) + if [[ $sect != (l|n) ]]; then + sects=( ${sects%%[^0-9]#} ) + fi + dirs=( $^_manpath/(sman|man|cat)${^sects}*/ ) + } + if [[ $sect == *\|* ]]; then sect="($sect)"; fi awk="\$2 == \"$sect\" {print \$1}" else dirs=( $^_manpath/(sman|man|cat)*/ ) -- cgit v1.2.3 From a5a9fc7a5fc50db278f7d17eb8d2ae78f3edc768 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 4 Aug 2016 15:54:23 +0000 Subject: 38993: _man: Drop (b): it's incorrect when $sect contains '|'. --- ChangeLog | 3 +++ Completion/Unix/Command/_man | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'Completion/Unix/Command/_man') diff --git a/ChangeLog b/ChangeLog index dc06dbe50..87a462ef6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2016-08-05 Daniel Shahaf + * 38993: Completion/Unix/Command/_man: Drop (b): it's incorrect + when $sect contains '|'. + * 38991: Src/exec.c, Test/C04funcdef.ztst: Make 'whence -v autoloaded-function' shows the defining filename. diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man index e892bb263..ef17ad8ee 100644 --- a/Completion/Unix/Command/_man +++ b/Completion/Unix/Command/_man @@ -37,7 +37,10 @@ _man() { mrd=(${^_manpath/\%L/${LANG:-En_US.ASCII}}/mandb(N)) - # $sect is from the command line, the "3p" in "man 3p memcpy" + # $sect is from the command line, the "3p" in "man 3p memcpy". + # It may also be a |-joined (and later in the code "()"-enclosed) list of + # section names. + # TODO: disentangle this to always be an array. # $sect_dirname is from the filesystem, the "3" in "/usr/share/man/man3" # These are used by _man_pages local sect sect_dirname @@ -117,7 +120,7 @@ _man_pages() { fi pages=( ${(M)dirs:#*$sect_dirname/} ) - compfiles -p pages '' '' "$matcher" '' dummy "*${(b)sect}*" + compfiles -p pages '' '' "$matcher" '' dummy "*${sect}*" pages=( ${^~pages}(N:t) ) (($#mrd)) && pages[$#pages+1]=($(awk $awk $mrd)) -- cgit v1.2.3 From 71f1653020563696b162753539137e355f585c4d Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 4 Aug 2016 15:54:24 +0000 Subject: 38994: _man: Fix two bugs when completing manpage filenames in separate-sections mode. - No longer glob all files (the (-g)-less _path_files was virtually always called, by at least one of the multiple calls to _man_pages). - Actually separate sections (by propagating $expl). --- ChangeLog | 3 +++ Completion/Unix/Command/_man | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'Completion/Unix/Command/_man') diff --git a/ChangeLog b/ChangeLog index 87a462ef6..82178dfdc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2016-08-05 Daniel Shahaf + * 38994: Completion/Unix/Command/_man: Fix two bugs when + completing manpage filenames in separate-sections mode. + * 38993: Completion/Unix/Command/_man: Drop (b): it's incorrect when $sect contains '|'. diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man index ef17ad8ee..ffe53be5e 100644 --- a/Completion/Unix/Command/_man +++ b/Completion/Unix/Command/_man @@ -87,6 +87,13 @@ _man() { done (( ret )) || return 0 done + ## To fall back to other sections' manpages when completing filenames, like + ## the 'else' codepath does: + # + # if (( ret )) && [[ $PREFIX$SUFFIX == */* ]]; then + # sect_dirname= + # _wanted manuals expl 'manual page' _man_pages && return + # fi return 1 else @@ -105,9 +112,13 @@ _man_pages() { # Easy way to test for versions of man that allow file names. # This can't be a normal man page reference. # Try to complete by glob first. - _path_files -g "*$suf" && return - _path_files - return + if [[ -n $sect_dirname ]]; then + _path_files -g "*.*$sect_dirname*(|.gz|.bz2|.Z|.lzma)" "$expl[@]" + else + _path_files -g "*$suf" "$expl[@]" && return + _path_files "$expl[@]" + fi + return $? fi zparseopts -E M+:=matcher -- cgit v1.2.3 From dfae92c483e78119222d48e924f3f338053eaa93 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 4 Aug 2016 15:54:26 +0000 Subject: 38996: _man: Support _correct_word. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since compfiles is undocumented, avoid its use altogether, replacing it by a construct that blackbox analysis suggests to be equivalent. The compfiles call being removed effected the following change (when completing «man -S 8:1 getc»): BEFORE THE CALL: typeset -a pages=( /home/daniel/prefix/zsh/share/man/man1/ /usr/share/man/man8/ /usr/share/man/man1/ ) AFTER THE CALL: typeset -a pages=( '/home/daniel/prefix/zsh/share/man/man1/getc*(8|1)*' '/usr/share/man/man8/getc*(8|1)*' '/usr/share/man/man1/getc*(8|1)*' ) This patch effects the same transformation (modulo doubling the final slash). Any -M parameter will be passed to compadd. --- ChangeLog | 2 ++ Completion/Unix/Command/_man | 13 ++----------- 2 files changed, 4 insertions(+), 11 deletions(-) (limited to 'Completion/Unix/Command/_man') diff --git a/ChangeLog b/ChangeLog index 82178dfdc..5ab0f3b7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2016-08-05 Daniel Shahaf + * 38996: Completion/Unix/Command/_man: Support _correct_word. + * 38994: Completion/Unix/Command/_man: Fix two bugs when completing manpage filenames in separate-sections mode. diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man index ffe53be5e..ae6ac38cc 100644 --- a/Completion/Unix/Command/_man +++ b/Completion/Unix/Command/_man @@ -103,7 +103,7 @@ _man() { } _man_pages() { - local matcher pages dummy sopt + local pages sopt # What files corresponding to manual pages can end in. local suf='.((?|<->*)(|.gz|.bz2|.Z|.lzma))' @@ -121,17 +121,8 @@ _man_pages() { return $? fi - zparseopts -E M+:=matcher - - if (( $#matcher )); then - matcher=( ${matcher:#-M} ) - matcher="$matcher" - else - matcher= - fi - pages=( ${(M)dirs:#*$sect_dirname/} ) - compfiles -p pages '' '' "$matcher" '' dummy "*${sect}*" + pages=( ${^pages}/"*$sect${sect:+"*"}" ); pages=( ${^~pages}(N:t) ) (($#mrd)) && pages[$#pages+1]=($(awk $awk $mrd)) -- cgit v1.2.3 From 999e1ac64e69d552ab169ede3dd411b1afa1bce4 Mon Sep 17 00:00:00 2001 From: Danek Duvall Date: Tue, 6 Sep 2016 11:06:14 -0700 Subject: 39194: _man (Solaris): Ignore man-index. Support multiple sections in the -s flag's argument. --- ChangeLog | 5 +++++ Completion/Unix/Command/_man | 3 +++ 2 files changed, 8 insertions(+) (limited to 'Completion/Unix/Command/_man') diff --git a/ChangeLog b/ChangeLog index 36d1fb608..eee877101 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-09-07 Danek Duvall + + * 39194: Completion/Unix/Command/_man: _man (Solaris): Ignore + man-index. Support multiple sections in the -s flag's argument. + 2016-09-07 Oliver Kiddle * unposted: Completion/Unix/Command/_rm: fix to use ;| diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man index ae6ac38cc..b2aaeaf7e 100644 --- a/Completion/Unix/Command/_man +++ b/Completion/Unix/Command/_man @@ -46,6 +46,7 @@ _man() { local sect sect_dirname if [[ $OSTYPE = solaris* ]]; then sect=${${words[(R)-s*]#-s}:-$words[$words[(i)-s]+1]} + sect="${sect//,/|}" elif [[ -n ${sect:=$words[$words[(i)-S]+1]} || -n ${sect:=$MANSECT} ]]; then sect="${sect//:/|}" sect="${sect//,/|}" @@ -67,6 +68,8 @@ _man() { dirs=( $^_manpath/(sman|man|cat)*/ ) awk='{print $1}' fi + # Solaris 11 and on have a man-index directory that doesn't contain manpages + dirs=( ${dirs:#*/man-index/} ) if [[ $OSTYPE = solaris* && ( $words[CURRENT] = -s* || $words[CURRENT-1] == -s ) ]]; then [[ $words[CURRENT] = -s* ]] && compset -P '-s' sects=( ${(o)${dirs##*(man|cat)}%/} ) -- cgit v1.2.3