zsh-workers
 help / color / mirror / code / Atom feed
From: dana <dana@dana.is>
To: Zsh workers <zsh-workers@zsh.org>
Cc: Oliver Kiddle <okiddle@yahoo.co.uk>
Subject: Re: [PATCH] Completion: Improve _man (2)
Date: Mon, 11 Jun 2018 05:48:33 -0500	[thread overview]
Message-ID: <2BD8008C-D6F4-4B4A-AF05-7EE80ADB0E47@dana.is> (raw)
In-Reply-To: <B8768D9A-07D9-46D8-B0C0-CE78FBE9079C@dana.is>

Hi Oliver,

Here are some fixes per your earlier feedback.

I updated the section-directory glob to allow a compression/locale 'extension';
as i said, i've never actually seen this myself, but your theory seems
plausible, and it shouldn't hurt anything on other systems.

I switched to _describe for completing sections, though i didn't use the exact
suggestion you gave because sect_descs is used farther down in the function and
i would have had to change stuff there as well.

I did NOT change the _arguments return thing, because frankly i don't really
understand the expected results for that prefix-needed configuration, and i
didn't want to break anything down-function in my ignorance. :/

dana


diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man
index 4cba9d625..11c2fab7f 100644
--- a/Completion/Unix/Command/_man
+++ b/Completion/Unix/Command/_man
@@ -109,7 +109,7 @@ _man() {
       '--warnings=[enable specified groff warnings]:groff warnings'
       '(-a --all --regex)--wildcard[treat page name as shell glob]'
       # @todo Could enumerate these
-      '(-X --gxditview)'{-X-,--gxditview=-}'[display output in gxditview using specified DPI (default: 75)]::DPI'
+      '(-X --gxditview)'{-X-,--gxditview=-}'[display output in gxditview using specified DPI]::resolution (DPI) [75]'
       # @todo Post-process how?
       '(-t --troff -Z --ditroff)'{-Z,--ditroff}'[post-process output for chosen device]'
     )
@@ -232,7 +232,7 @@ _man() {
 
   if [[ $sect = (<->*|[lnopx]) || $sect = *\|* ]]; then
     sects=( ${(s.|.)sect} )
-    dirs=( $^_manpath/(sman|man|cat)${^sects}/ )
+    dirs=( $^_manpath/(sman|man|cat)${^sects}(|.*)/ )
     sect=${(j<|>)sects}
     [[ $sect == *'|'* ]] && sect="($sect)"
     awk="\$2 == \"$sect\" {print \$1}"
@@ -247,7 +247,7 @@ _man() {
 
   # Solaris 11 and on have a man-index directory that doesn't contain manpages
   dirs=( ${dirs:#*/man-index/} )
-  sects=( ${(o)${dirs##*(man|cat)}%/} )
+  sects=( ${(o)${${dirs##*(man|cat)}%.*}%/} )
 
   # If we've got this far, we can build our look-up table for descriptions of
   # the more common sections. Unless otherwise labelled, the more specific ones
@@ -297,6 +297,11 @@ _man() {
     # Add OS-specific stuff that's too risky for or overrides the general list
     [[ $OSTYPE == darwin*  ]] && sect_descs+=( n 'Tcl/Tk features' )
     [[ $OSTYPE == openbsd* ]] && sect_descs+=( 3p 'Perl features' )
+    # @todo Oracle Solaris 11.4 adopts the BSD/Linux structure, making many of
+    # these inaccurate — this should be handled accordingly in the future. If
+    # OSTYPE isn't helpful (since other Solaris descendants may not follow
+    # suit), we could perhaps use the presence of SysV-style sections under
+    # _manpath as the determinant
     [[ $OSTYPE == solaris* ]] && sect_descs+=(
       1t  'Tcl/Tk features'
       3m  'mathematical library functions'
@@ -320,21 +325,22 @@ _man() {
     local -a specs
 
     (( $#sects )) || {
-      _message 'manual section'
+      _message -e sections 'manual section'
       return 1
     }
 
     # Build specs from descriptions
     for s in $sects; do
-      specs+=( "${s}[${(b)sect_descs[$s]}]" )
+      specs+=( "${s}:${(b)sect_descs[$s]}" )
     done
+    specs=( ${specs%:} )
 
     if [[ $variant == (darwin|dragonfly|freebsd|linux)* ]]; then
-      _values -s : 'manual section' $specs
+      _sequence -s : _describe -t sections 'manual section' specs
     elif [[ $variant == solaris* ]]; then
-      _values -s , 'manual section' $specs
+      _sequence -s , _describe -t sections 'manual section' specs
     else
-      _values 'manual section' $specs
+      _describe -t sections 'manual section' specs
     fi
     return
   }


  reply	other threads:[~2018-06-11 10:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-10  6:06 [PATCH] Completion: Improve _man dana
2018-06-10 13:07 ` Oliver Kiddle
2018-06-10 14:02   ` dana
2018-06-11 10:48     ` dana [this message]
2018-06-14  9:50       ` [PATCH] Completion: Improve _man (2) Daniel Shahaf
2018-06-14 10:20         ` dana
2018-06-15 13:59           ` [PATCH] Completion: Improve _man (3) dana
2018-06-15 14:05             ` Daniel Shahaf
2018-06-15 14:21               ` dana
2018-06-15 14:39                 ` Mikael Magnusson
2018-06-15 14:55                   ` Daniel Shahaf
2018-06-15 15:14                     ` dana
2018-06-15 15:36                       ` Peter Stephenson
2018-06-15 17:27                     ` Mikael Magnusson
2018-06-15 14:47                 ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2BD8008C-D6F4-4B4A-AF05-7EE80ADB0E47@dana.is \
    --to=dana@dana.is \
    --cc=okiddle@yahoo.co.uk \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).