zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: dana <dana@dana.is>
Cc: Daniel Shahaf <d.s@daniel.shahaf.name>,
	Zsh workers <zsh-workers@zsh.org>
Subject: Re: [PATCH] Completion: Improve _man (3)
Date: Fri, 15 Jun 2018 16:39:36 +0200	[thread overview]
Message-ID: <CAHYJk3SXbwUJUMuEVJkhA+eTtBge5VZQTuQbX0=1G-74PFgEqw@mail.gmail.com> (raw)
In-Reply-To: <64E31285-3F41-4F38-8E70-A42F2F2735AD@dana.is>

On Fri, Jun 15, 2018 at 4:21 PM, dana <dana@dana.is> wrote:
> On 15 Jun 2018, at 09:05, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>>Thanks for the quick turnaround.  With this patch, `man 3 utf<TAB>`,
>>`man 3per utf<TAB>`, and `man 3perll utf<TAB>` all complete to
>>`... utf8`.  That's correct for the first two but wrong for the last one:
>
> Oops, i confused myself looking at the old one. Fixing that actually improves
> the partial matching a lot in general, thanks. Try this, if you don't mind.
>
> @@ -232,7 +245,23 @@ _man() {
>
>    if [[ $sect = (<->*|[lnopx]) || $sect = *\|* ]]; then
>      sects=( ${(s.|.)sect} )
> -    dirs=( $^_manpath/(sman|man|cat)${^sects}(|.*)/ )
> +
> +    # Most man implementations support partial matching of a page's
> +    # (sub-)section name — e.g., `3per` for `3perl`. The (sub-)section name may
> +    # or may not correspond to the directory name (most systems combine
> +    # sub-sections), but we'll assume that if it starts with a number and we're
> +    # not on Solaris (which doesn't support this feature at all) that we can do
> +    # a match against the leading number. This is irritating if you DO want the
> +    # exact sub-section specified, but unfortunately there's no way to determine
> +    # this programmatically — i guess we could add a style to control it
> +    () for 1 {
> +      if [[ $OSTYPE == solaris* || $1 != <->* ]]; then
> +        dirs+=( $^_manpath/(sman|man|cat)$1(|.*)/ )
> +      else
> +        dirs+=( $^_manpath/(sman|man|cat)${1%%[^0-9]#}*/ )
> +      fi
> +    } $sects
> +

Please don't use () for 1 {} a b c style loops in actual scripts, it
is not guaranteed to work. Instead, use () { for 1 { } } a b c which
is the documented syntax.

-- 
Mikael Magnusson


  reply	other threads:[~2018-06-15 14:39 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     ` [PATCH] Completion: Improve _man (2) dana
2018-06-14  9:50       ` 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 [this message]
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='CAHYJk3SXbwUJUMuEVJkhA+eTtBge5VZQTuQbX0=1G-74PFgEqw@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=d.s@daniel.shahaf.name \
    --cc=dana@dana.is \
    --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).