zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Vincent Lefevre <vincent@vinc17.net>, zsh-workers@zsh.org
Subject: Re: completion for "info -f" does not work
Date: Tue, 15 Mar 2022 18:05:22 +0000 (GMT)	[thread overview]
Message-ID: <65163150.28923.1647367522118@mail2.virginmedia.com> (raw)
In-Reply-To: <20220315171305.GB617047@zira.vinc17.org>


> On 15 March 2022 at 17:13 Vincent Lefevre <vincent@vinc17.net> wrote:
> 
> 
> In a directory where there is a file with the .info extension:
> 
> zira% autoload -U compinit
> zira% compinit
> zira% info -f ./
> 
> If I type [TAB], I don't get any completion. It should complete
> on the .info files (at least).

I guess this could be a fairly straightforward alternative to the
gory file munging, something like the following?

pws

diff --git a/Completion/Unix/Command/_texinfo b/Completion/Unix/Command/_texinfo
index 7dfa32e45..f169cba63 100644
--- a/Completion/Unix/Command/_texinfo
+++ b/Completion/Unix/Command/_texinfo
@@ -280,18 +280,25 @@ if [[ -n $state ]]; then
 
   [[ -z $file ]] && file=${opt_args[-f]:-$line[1]}
   if [[ $state = info* ]]; then
-    local -aU files=( $^infopath/*.info(|.gz|.bz2)(-.:t:s/.gz//:s/.bz2//:r) )
-    local items
-    if (( ! $#files )); then
-      _info_retrieve_nodes
-      files=( ${(P)cache%%:*} )
-    fi
-    items=( ${${${(M)${(f)"$(_call_program menu-items info -o-)"}:#(#s)\* *: \(*}#??}%%\)*} )
-    files+=( ${items##*\(} )
-    tags=( info-files )
-    if [[ $state != infofiles ]]; then
-      tags+=( menu-items )
-      items=( ${items%:*} )
+    local -aU files
+    if [[ $PREFIX = (./|../|/)* ]]; then
+      files=( $^infopath/*.info(|.gz|.bz2)(-.:t:s/.gz//:s/.bz2//:r) )
+      tags=(files)
+      items=()
+    else
+      files=( $^infopath/*.info(|.gz|.bz2)(-.:t:s/.gz//:s/.bz2//:r) )
+      local items
+      if (( ! $#files )); then
+	_info_retrieve_nodes
+	files=( ${(P)cache%%:*} )
+      fi
+      items=( ${${${(M)${(f)"$(_call_program menu-items info -o-)"}:#(#s)\* *: \(*}#??}%%\)*} )
+      files+=( ${items##*\(} )
+      tags=( info-files )
+      if [[ $state != infofiles ]]; then
+        tags+=( menu-items )
+        items=( ${items%:*} )
+      fi
     fi
   elif [[ $state = nodes ]]; then
     tags=( menu-items )
@@ -317,6 +324,7 @@ if [[ -n $state ]]; then
     _requested menu-items expl 'menu item' compadd -M 'm:{a-zA-Z}={A-Za-z}' -a items && ret=0
     _requested -x index-entries expl 'index entry' compadd -M 'm:{a-zA-Z}={A-Za-z}' -a items && ret=0
     _requested info-nodes expl 'node' compadd -M 'm:{a-zA-Z}={A-Za-z}' ${nodes#*:} && ret=0
+    _requested files expl 'file' && _files -g '*.info(|.gz|.bz2)'
 
     (( ret )) || break
   done


  reply	other threads:[~2022-03-15 18:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15 17:13 Vincent Lefevre
2022-03-15 18:05 ` Peter Stephenson [this message]
2022-03-16  8:46   ` Jun T
2022-03-16 15:06     ` Peter Stephenson
2022-03-16 15:13       ` Bart Schaefer
2022-03-16 15:28       ` Jun. T
2022-03-17 16:29         ` Peter Stephenson
2022-03-18 13:59     ` Vincent Lefevre
2022-03-18 14:09       ` Vincent Lefevre
2022-03-22  9:46         ` Jun T
2022-03-22 13:32           ` Vincent Lefevre
2022-03-22  9:35       ` Peter Stephenson

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=65163150.28923.1647367522118@mail2.virginmedia.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=vincent@vinc17.net \
    --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).