From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 1d1548f0 for ; Sat, 4 Jan 2020 00:11:04 +0000 (UTC) Received: (qmail 14231 invoked by alias); 4 Jan 2020 00:10:57 -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: List-Unsubscribe: X-Seq: 45222 Received: (qmail 8859 invoked by uid 1010); 4 Jan 2020 00:10:57 -0000 X-Qmail-Scanner-Diagnostics: from mail-yb1-f196.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25677. spamassassin: 3.4.2. Clear:RC:0(209.85.219.196):SA:0(-1.9/5.0):. Processed in 2.560013 secs); 04 Jan 2020 00:10:57 -0000 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.219.196 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=b5IN7GD86ij87//c7bNWGXh8NMgWmrmRhJto/r12jPs=; b=CbuqY41GZfS/N+bwCurbSKUezEkMwP4ufJNOtYPDTljQHNE1MBkkPaIr4TiLmf3d6/ n2wMv5bKQEASd4SKIZvUskOvCcWcTJJFhHxo1Zw4Dh1wXT027pphMy1LYsPk92DQpOMh F+WFukoq1Go0VjEiCbdLPDulsFQOR41H4ROIcPDbiB5nc6nd9kFnekPkpdpioWFmbcoo weWAjFd0zNBFV63akDegv9kD3m/1/aVfRC9kn1v59FIm0yDYZgIunGyNvLTphVJ6ZyDJ VYYu2GyK8KHxYpgYgaWqNSW9C5LQNXAEovC75gZrVIeX1HPVBFPiPUeUneVK6mp5tbCz zRmQ== X-Gm-Message-State: APjAAAV2q7paVIhn74G9gEUBW7rYpA4SlqldtkpTMuw78YCAJLU49wu2 pZ2KnSt0E3hkrU8PPn5QQaoLW+AXaoJPFQ== X-Google-Smtp-Source: APXvYqzR86LEbnj6Y2stsS6vtZxJ09nkTn6m76PJ/Y5s5/nKXCOfR7vUhXVhIcFo1Jghp695yXczow== X-Received: by 2002:a25:8212:: with SMTP id q18mr64734240ybk.511.1578096620283; Fri, 03 Jan 2020 16:10:20 -0800 (PST) From: dana Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: [PATCH] Improve _man file-path completion Message-Id: <83C0ABA0-99A5-4DAD-98D6-DBB919F61E24@dana.is> Date: Fri, 3 Jan 2020 18:12:28 -0600 To: Zsh hackers list X-Mailer: Apple Mail (2.3445.104.11) 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 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) dana diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man index 41ae85a1f..d4cbbb9ba 100644 --- a/Completion/Unix/Command/_man +++ b/Completion/Unix/Command/_man @@ -376,7 +376,13 @@ _man() { return } =20 - if zstyle -t ":completion:${curcontext}:manuals" separate-sections; = then + # Don't separate sections when we're completing a file path. = Otherwise, the + # user may see directories repeated a million times (once for each = section) + # when navigating through the file system + if + [[ $PREFIX$SUFFIX !=3D */* ]] && + zstyle -t ":completion:${curcontext}:manuals" separate-sections + then local d ret=3D1 =20 (( $#sects )) || return 1 @@ -392,15 +398,9 @@ _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 =3D=3D */* ]]; then - # sect_dirname=3D - # _wanted manuals expl 'manual page' _man_pages && return - # fi =20 return 1 + else sect_dirname=3D _wanted manuals expl 'manual page' _man_pages @@ -414,14 +414,14 @@ _man_pages() { local suf=3D'.((?|<->*|ntcl)(|.gz|.bz2|.z|.Z|.lzma))' =20 if [[ $PREFIX$SUFFIX =3D */* ]]; then - # 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. + # This can be used to glob for an individual section's pages, which = is + # useful for separate-sections. But the effect is irritating when = navigating + # through sub-directories; see above if [[ -n $sect_dirname ]]; then - _path_files -g "*.*$sect_dirname*(|.gz|.bz2|.z|.Z|.lzma)" = "$expl[@]" + _files -g "*.*$sect_dirname*(|.gz|.bz2|.z|.Z|.lzma)" "$expl[@]" else - _path_files -g "*$suf" "$expl[@]" && return - _path_files "$expl[@]" + _files -g "*$suf" "$expl[@]" && return + _files "$expl[@]" fi return $? fi