From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7125 invoked by alias); 15 Jan 2016 06:26:52 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37634 Received: (qmail 25604 invoked from network); 15 Jan 2016 06:26:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 Date: Fri, 15 Jan 2016 06:26:46 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH] _man: Support subsection names such as '3p' Message-ID: <20160115062646.GA29255@tarsus.local2> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="J2SCkAp4GZ/dPZZf" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) --J2SCkAp4GZ/dPZZf Content-Type: text/plain; charset=utf-8 Content-Disposition: inline On my system I have a /usr/share/man/man3/memcpy.3posix.gz man page. It can be viewed by 'man 3p memcpy', where the section name argument can be any prefix of the "3posix" segment. (The Perl man pages on this system use a similar naming convention, *.3perl.gz) These patches make 'man 3p memcp' work. _man used $sect as a loop variable, stomping on its previous value. The first patch stops stomping on the previous value, but introduces no functional change. The second patch uses the unstomped value and fixes the issue. Cheers, Daniel --J2SCkAp4GZ/dPZZf Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-_man-1-No-functional-change.patch" >>From 5c9a3bbc1a380b45d0db340109ce5477984d43aa Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 14 Jan 2016 15:34:57 +0000 Subject: [PATCH 1/2] _man: Disentangle a local variable that had two distinct semantics. No functional change --- Completion/Unix/Command/_man | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man index 81ac40b..871af48 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)) - local sect + # $sect is from the command line, the "3p" in "man 3p memcpy" + # $sect_dirname is from the filesystem, the "3" in "/usr/share/man/man3" + # These are used by _man_pages + local sect sect_dirname 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 @@ -69,8 +72,8 @@ _man() { _tags manuals.${^sects} while _tags; do - for sect in $sects; do - _requested manuals.$sect expl "manual page, section $sect" _man_pages && + for sect_dirname in $sects; do + _requested manuals.$sect_dirname expl "manual page, section $sect_dirname" _man_pages && ret=0 done (( ret )) || return 0 @@ -78,7 +81,7 @@ _man() { return 1 else - sect= + sect_dirname= _wanted manuals expl 'manual page' _man_pages fi } @@ -107,8 +110,8 @@ _man_pages() { matcher= fi - pages=( ${(M)dirs:#*$sect/} ) - compfiles -p pages '' '' "$matcher" '' dummy '*' + pages=( ${(M)dirs:#*$sect_dirname/} ) + compfiles -p pages '' '' "$matcher" '' dummy "*" pages=( ${^~pages}(N:t) ) (($#mrd)) && pages[$#pages+1]=($(awk $awk $mrd)) @@ -119,11 +122,11 @@ _man_pages() { [[ $OSTYPE = solaris* ]] && sopt='-s ' if ((CURRENT > 2)) || - ! zstyle -t ":completion:${curcontext}:manuals.$sect" insert-sections + ! zstyle -t ":completion:${curcontext}:manuals.$sect_dirname" insert-sections then compadd "$@" - ${pages%$~suf} else - compadd "$@" -P "$sopt$sect " - ${pages%$~suf} + compadd "$@" -P "$sopt$sect_dirname " - ${pages%$~suf} fi } -- 2.1.4 --J2SCkAp4GZ/dPZZf Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-_man-Support-subsection-names-such-as-3p.patch" >>From 8200c0c736076f7aaed99a1b7102287a5af9de5a Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 14 Jan 2016 15:37:43 +0000 Subject: [PATCH 2/2] _man: Support subsection names such as '3p'. --- Completion/Unix/Command/_man | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man index 871af48..0534db7 100644 --- a/Completion/Unix/Command/_man +++ b/Completion/Unix/Command/_man @@ -52,7 +52,7 @@ _man() { fi if [[ $sect = (<->*|1M|l|n) || $sect = \(*\|*\) ]]; then - dirs=( $^_manpath/(sman|man|cat)${~sect}/ ) + dirs=( $^_manpath/(sman|man|cat)${~sect%%[^0-9]#}/ ) awk="\$2 == \"$sect\" {print \$1}" else dirs=( $^_manpath/(sman|man|cat)*/ ) @@ -111,7 +111,7 @@ _man_pages() { fi pages=( ${(M)dirs:#*$sect_dirname/} ) - compfiles -p pages '' '' "$matcher" '' dummy "*" + compfiles -p pages '' '' "$matcher" '' dummy "*${(b)sect}*" pages=( ${^~pages}(N:t) ) (($#mrd)) && pages[$#pages+1]=($(awk $awk $mrd)) -- 2.1.4 --J2SCkAp4GZ/dPZZf--