* completion for "info -f" does not work @ 2022-03-15 17:13 Vincent Lefevre 2022-03-15 18:05 ` Peter Stephenson 0 siblings, 1 reply; 12+ messages in thread From: Vincent Lefevre @ 2022-03-15 17:13 UTC (permalink / raw) To: zsh-workers 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). As documented: -f, --file=MANUAL specify Info manual to visit Tested with zsh 5.8.1 on Debian/unstable and with the git repository. Debian bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1007188 -- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: completion for "info -f" does not work 2022-03-15 17:13 completion for "info -f" does not work Vincent Lefevre @ 2022-03-15 18:05 ` Peter Stephenson 2022-03-16 8:46 ` Jun T 0 siblings, 1 reply; 12+ messages in thread From: Peter Stephenson @ 2022-03-15 18:05 UTC (permalink / raw) To: Vincent Lefevre, zsh-workers > 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: completion for "info -f" does not work 2022-03-15 18:05 ` Peter Stephenson @ 2022-03-16 8:46 ` Jun T 2022-03-16 15:06 ` Peter Stephenson 2022-03-18 13:59 ` Vincent Lefevre 0 siblings, 2 replies; 12+ messages in thread From: Jun T @ 2022-03-16 8:46 UTC (permalink / raw) To: zsh-workers > 2022/03/16 3:05, Peter Stephenson <p.w.stephenson@ntlworld.com> wrote: > > + if [[ $PREFIX = (./|../|/)* ]]; then > + files=( $^infopath/*.info(|.gz|.bz2)(-.:t:s/.gz//:s/.bz2//:r) ) > + tags=(files) > + items=() > + else (snip) > + _requested files expl 'file' && _files -g '*.info(|.gz|.bz2)' 'info -f' accept any (relative or absolute) pathnames. For example, info -f foo/bar.info works; we need not type ./foo/bar.info. So the pattern (./|../|/)* is to restrictive, I think. # And if tags is set only to (files), we need not set the array files. For the -f option, isn't it simpler just to use the action _files -g "*.info(|.gz|.bz2)" instead of ->infofiles ? Specs for 'tkinfo' command (I don't know this command) have '-file:info file:->infofiles' but I _guess_ ->infofiles can be replaced in the same way. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: completion for "info -f" does not work 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-18 13:59 ` Vincent Lefevre 1 sibling, 2 replies; 12+ messages in thread From: Peter Stephenson @ 2022-03-16 15:06 UTC (permalink / raw) To: zsh-workers > On 16 March 2022 at 08:46 Jun T <takimoto-j@kba.biglobe.ne.jp> wrote: > > 2022/03/16 3:05, Peter Stephenson <p.w.stephenson@ntlworld.com> wrote: > > > > + if [[ $PREFIX = (./|../|/)* ]]; then > > + files=( $^infopath/*.info(|.gz|.bz2)(-.:t:s/.gz//:s/.bz2//:r) ) > > + tags=(files) > > + items=() > > + else > (snip) > > + _requested files expl 'file' && _files -g '*.info(|.gz|.bz2)' > > 'info -f' accept any (relative or absolute) pathnames. For example, > info -f foo/bar.info > works; we need not type ./foo/bar.info. > So the pattern (./|../|/)* is to restrictive, I think. > # And if tags is set only to (files), we need not set the array files. > > For the -f option, isn't it simpler just to use the action > _files -g "*.info(|.gz|.bz2)" > instead of > ->infofiles ? For "info", at least, it will complete files in the info area as well as local files, so at the least we're looking at combining the two types. Hmm, maybe just adding "." to the info path to search is OK? But I don't know if that handles absolute filenames. pws ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: completion for "info -f" does not work 2022-03-16 15:06 ` Peter Stephenson @ 2022-03-16 15:13 ` Bart Schaefer 2022-03-16 15:28 ` Jun. T 1 sibling, 0 replies; 12+ messages in thread From: Bart Schaefer @ 2022-03-16 15:13 UTC (permalink / raw) To: Peter Stephenson; +Cc: Zsh hackers list On Wed, Mar 16, 2022 at 8:07 AM Peter Stephenson <p.w.stephenson@ntlworld.com> wrote: > > > On 16 March 2022 at 08:46 Jun T <takimoto-j@kba.biglobe.ne.jp> wrote: > > > > So the pattern (./|../|/)* is to restrictive, I think. > > Hmm, maybe just adding "." to the info path to search is OK? What about adding $words[CURRENT]:h when $words[CURRENT] contains a "/" ? ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: completion for "info -f" does not work 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 1 sibling, 1 reply; 12+ messages in thread From: Jun. T @ 2022-03-16 15:28 UTC (permalink / raw) To: zsh-workers > 2022/03/17 0:06, Peter Stephenson <p.w.stephenson@ntlworld.com> wrote: > >> On 16 March 2022 at 08:46 Jun T <takimoto-j@kba.biglobe.ne.jp> wrote: >>> 2022/03/16 3:05, Peter Stephenson <p.w.stephenson@ntlworld.com> wrote: >>> >>> + if [[ $PREFIX = (./|../|/)* ]]; then >>> + files=( $^infopath/*.info(|.gz|.bz2)(-.:t:s/.gz//:s/.bz2//:r) ) >>> + tags=(files) >>> + items=() >>> + else >> (snip) >>> + _requested files expl 'file' && _files -g '*.info(|.gz|.bz2)' >> >> 'info -f' accept any (relative or absolute) pathnames. For example, >> info -f foo/bar.info >> works; we need not type ./foo/bar.info. >> So the pattern (./|../|/)* is to restrictive, I think. >> # And if tags is set only to (files), we need not set the array files. >> >> For the -f option, isn't it simpler just to use the action >> _files -g "*.info(|.gz|.bz2)" >> instead of >> ->infofiles ? > > For "info", at least, it will complete files in the info area as well > as local files, so at the least we're looking at combining the two > types. I feel just '_files -g "*.info(|.gz|.bz2)"' is enough for 'info -f'. But if we want to combine it with files in infopath, we need to set tags=(files info-files), am I right? ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: completion for "info -f" does not work 2022-03-16 15:28 ` Jun. T @ 2022-03-17 16:29 ` Peter Stephenson 0 siblings, 0 replies; 12+ messages in thread From: Peter Stephenson @ 2022-03-17 16:29 UTC (permalink / raw) To: zsh-workers > On 16 March 2022 at 15:28 "Jun. T" <takimoto-j@kba.biglobe.ne.jp> wrote: > > 2022/03/17 0:06, Peter Stephenson <p.w.stephenson@ntlworld.com> wrote: > > > >> On 16 March 2022 at 08:46 Jun T <takimoto-j@kba.biglobe.ne.jp> wrote: > >>> 2022/03/16 3:05, Peter Stephenson <p.w.stephenson@ntlworld.com> wrote: > >>> > >>> + if [[ $PREFIX = (./|../|/)* ]]; then > >>> + files=( $^infopath/*.info(|.gz|.bz2)(-.:t:s/.gz//:s/.bz2//:r) ) > >>> + tags=(files) > >>> + items=() > >>> + else > >> (snip) > >>> + _requested files expl 'file' && _files -g '*.info(|.gz|.bz2)' > > I feel just '_files -g "*.info(|.gz|.bz2)"' is enough for 'info -f'. > But if we want to combine it with files in infopath, we need to set > tags=(files info-files), am I right? Yes, something like the following might do it. I can see info -f is a roundabout way of completing via the info path, but it does work, so we might as well support it. pws diff --git a/Completion/Unix/Command/_texinfo b/Completion/Unix/Command/_texinfo index 7dfa32e45..39f8cd1b5 100644 --- a/Completion/Unix/Command/_texinfo +++ b/Completion/Unix/Command/_texinfo @@ -41,7 +41,7 @@ case $service in '(: -)'{-k+,--apropos=}'[look up string in indices]:search string: ' \ \*{-d+,--directory=}'[add directory to infopath]:info dir:_files -/' \ '--dribble=[record keystrokes]:file with keystrokes:_files' \ - '(-f --file 1)'{-f+,--file=}'[specify Info manual to visit]:info manual:->infofiles' \ + '(-f --file 1)'{-f+,--file=}'[specify Info manual to visit]:info manual:->infofiles+' \ '(: - -h --help)'{-h,--help}'[display usage]' \ '(-o --output -O)--index-search=[search for matching index entry]:search string:->index-entries' \ '(--index-search -o --output -O)'{-o+,--output=}'[dump selected nodes to filename]:filename:_files -g "*(-.)"' \ @@ -289,7 +289,11 @@ if [[ -n $state ]]; then items=( ${${${(M)${(f)"$(_call_program menu-items info -o-)"}:#(#s)\* *: \(*}#??}%%\)*} ) files+=( ${items##*\(} ) tags=( info-files ) - if [[ $state != infofiles ]]; then + if [[ $state = infofiles+ ]]; then + # local files allowed + tags+=(files) + fi + if [[ $state != infofiles* ]]; then tags+=( menu-items ) items=( ${items%:*} ) fi @@ -317,6 +321,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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: completion for "info -f" does not work 2022-03-16 8:46 ` Jun T 2022-03-16 15:06 ` Peter Stephenson @ 2022-03-18 13:59 ` Vincent Lefevre 2022-03-18 14:09 ` Vincent Lefevre 2022-03-22 9:35 ` Peter Stephenson 1 sibling, 2 replies; 12+ messages in thread From: Vincent Lefevre @ 2022-03-18 13:59 UTC (permalink / raw) To: zsh-workers On 2022-03-16 17:46:28 +0900, Jun T wrote: > 'info -f' accept any (relative or absolute) pathnames. Well, not exactly. It seems that the rule for "info -f" is that if the argument does not have a slash, then the usual info path is used (with no fallback if nothing is found, i.e. an existing pathname in the current directory will be ignored), otherwise the argument is regarded as a pathname. However, a set of suffixes are tried: zira% strace info -f /blah |& grep /blah execve("/usr/bin/info", ["info", "-f", "/blah"], 0x7ffe463ed830 /* 135 vars */) = 0 newfstatat(AT_FDCWD, "/blah.info", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.info.gz", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.info.lz", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.info.xz", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.info.bz2", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.info.z", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.info.lzma", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.info.Z", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.info.Y", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah-info", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah-info.gz", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah-info.lz", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah-info.xz", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah-info.bz2", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah-info.z", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah-info.lzma", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah-info.Z", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah-info.Y", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah/index", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah/index.gz", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah/index.lz", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah/index.xz", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah/index.bz2", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah/index.z", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah/index.lzma", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah/index.Z", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah/index.Y", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.inf", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.inf.gz", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.inf.lz", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.inf.xz", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.inf.bz2", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.inf.z", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.inf.lzma", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.inf.Z", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.inf.Y", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.gz", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.lz", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.xz", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.bz2", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.z", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.lzma", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.Z", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/blah.Y", 0x7ffe9d145a20, 0) = -1 ENOENT (No such file or directory) write(2, "/blah: No such file or directory", 32/blah: No such file or directory) = 32 Note: The ".inf" ones are probably for the MS-DOS filenames. They are probably never seen under Unix, at least nowadays. So, if there is a file /path/to/foo.info (possibly with an extension corresponding to compression), then the completion should work as follows: /path/to/f[Tab] gives /path/to/foo and /path/to/foo.[Tab] gives /path/to/foo.info (info supports both /path/to/foo and /path/to/foo.info, the former form being preferred). -- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: completion for "info -f" does not work 2022-03-18 13:59 ` Vincent Lefevre @ 2022-03-18 14:09 ` Vincent Lefevre 2022-03-22 9:46 ` Jun T 2022-03-22 9:35 ` Peter Stephenson 1 sibling, 1 reply; 12+ messages in thread From: Vincent Lefevre @ 2022-03-18 14:09 UTC (permalink / raw) To: zsh-workers On 2022-03-18 14:59:53 +0100, Vincent Lefevre wrote: > On 2022-03-16 17:46:28 +0900, Jun T wrote: > > 'info -f' accept any (relative or absolute) pathnames. > > Well, not exactly. It seems that the rule for "info -f" is that > if the argument does not have a slash, then the usual info path > is used (with no fallback if nothing is found, i.e. an existing > pathname in the current directory will be ignored), otherwise > the argument is regarded as a pathname. This can be tested as follows: zira% touch for-test-only.info zira% info -f for-test-only info: for-test-only: No such file or directory zira% info -f for-test-only.info info: for-test-only.info: No such file or directory zira% info -f ./for-test-only zira% info -f ./for-test-only.info zira% info for-test-only info: No menu item 'for-test-only' in node '(dir)Top' zira% info for-test-only.info info: No menu item 'for-test-only.info' in node '(dir)Top' zira% info ./for-test-only zira% info ./for-test-only.info zira% An absence of error means that the file was opened. Without "-f", the rules seem to be the same, except that info also checks menu items. -- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: completion for "info -f" does not work 2022-03-18 14:09 ` Vincent Lefevre @ 2022-03-22 9:46 ` Jun T 2022-03-22 13:32 ` Vincent Lefevre 0 siblings, 1 reply; 12+ messages in thread From: Jun T @ 2022-03-22 9:46 UTC (permalink / raw) To: zsh-workers > 2022/03/18 23:09, Vincent Lefevre <vincent@vinc17.net> wrote: > > On 2022-03-18 14:59:53 +0100, Vincent Lefevre wrote: >> On 2022-03-16 17:46:28 +0900, Jun T wrote: >>> 'info -f' accept any (relative or absolute) pathnames. >> >> Well, not exactly. It seems that the rule for "info -f" is that >> if the argument does not have a slash, then the usual info path >> is used (with no fallback if nothing is found, i.e. an existing >> pathname in the current directory will be ignored), otherwise >> the argument is regarded as a pathname. > > This can be tested as follows: > > zira% touch for-test-only.info > zira% info -f for-test-only > info: for-test-only: No such file or directory I can't reproduce this. Which version of info are you using? % info --version info (GNU texinfo) 6.7 % touch for-test-only.info % info -w -f for-test-only ././for-test-only.info info command has an (undocumented) option -x for setting the debug level. % info -x 1 -f for-test-only # use -x 2 for more verbose output info: looking for file "for-test-only" info: looking for file for-test-only in /usr/share/info info: looking for file for-test-only in /home/takimoto/.local/share/info info: looking for file for-test-only in . info: found file ./for-test-only.info PS I've surprised that 'info for-test-only' (without -f) also gives the same result. So I wonder what is the difference between 'info foo ...' and 'info -f foo ...' ? ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: completion for "info -f" does not work 2022-03-22 9:46 ` Jun T @ 2022-03-22 13:32 ` Vincent Lefevre 0 siblings, 0 replies; 12+ messages in thread From: Vincent Lefevre @ 2022-03-22 13:32 UTC (permalink / raw) To: zsh-workers On 2022-03-22 18:46:13 +0900, Jun T wrote: > > zira% touch for-test-only.info > > zira% info -f for-test-only > > info: for-test-only: No such file or directory > > I can't reproduce this. Which version of info are you using? info (GNU texinfo) 6.8 from the info 6.8-4+b1 Debian package (Debian/unstable). But I've just found that this is due to my INFOPATH environment variable, which is set to "$HOME/share/info". See below. > info command has an (undocumented) option -x for setting the > debug level. > > % info -x 1 -f for-test-only # use -x 2 for more verbose output > info: looking for file "for-test-only" > info: looking for file for-test-only in /usr/share/info > info: looking for file for-test-only in /home/takimoto/.local/share/info > info: looking for file for-test-only in . > info: found file ./for-test-only.info cventin% info -x 1 -f for-test-only info: looking for file "for-test-only" info: looking for file for-test-only in /home/vlefevre/share/info info: looking for file for-test-only in /usr/share/info info: for-test-only: No such file or directory cventin% unset INFOPATH cventin% info -x 1 -f for-test-only info: looking for file "for-test-only" info: looking for file for-test-only in /usr/share/info info: looking for file for-test-only in /home/vlefevre/share/info info: looking for file for-test-only in . info: found file ./for-test-only.info This actually behaves as documented: Directories specified in the environment variable 'INFOPATH' are added to the directories specified with '--directory', if any. The value of 'INFOPATH' is a list of directories usually separated by a colon; on MS-DOS/MS-Windows systems, the semicolon is used. If the value of 'INFOPATH' ends with a colon (or semicolon on MS-DOS/MS-Windows), the initial list of directories is constructed by appending the build-time default to the value of 'INFOPATH'. If you do not define 'INFOPATH', Info uses a default path defined when Info was built as the initial list of directories. Regardless of whether 'INFOPATH' is defined, the default documentation directory defined when Info was built is added to the search path. If you do not want this directory to be included, set the 'infopath-no-defaults' variable to 'On' (*note infopath-no-defaults::). (BTW, I'm wondering whether there could be a security issue with "." in the default info path.) > PS > I've surprised that 'info for-test-only' (without -f) also gives the > same result. So I wonder what is the difference between 'info foo ...' > and 'info -f foo ...' ? It seems that without "-f", info first looks for menu items and converts the argument to a filename prefix as with -f: Example: cventin% info -x 1 -f ls info: looking for file "ls" info: looking for file ls in /home/vlefevre/share/info info: looking for file ls in /usr/share/info info: ls: No such file or directory cventin% info -x 1 ls info: found file /home/vlefevre/share/info/dir info: found file /usr/share/info/dir info: looking for file "coreutils" info: looking for file coreutils in /home/vlefevre/share/info info: looking for file coreutils in /usr/share/info info: found file /usr/share/info/coreutils.info.gz Here, the error message is different: cventin% info -x 1 -f does-not-exist info: looking for file "does-not-exist" info: looking for file does-not-exist in /home/vlefevre/share/info info: looking for file does-not-exist in /usr/share/info info: does-not-exist: No such file or directory cventin% info -x 1 does-not-exist info: found file /home/vlefevre/share/info/dir info: found file /usr/share/info/dir info: looking for file "does-not-exist" info: looking for file does-not-exist in /home/vlefevre/share/info info: looking for file does-not-exist in /usr/share/info info: No menu item 'does-not-exist' in node '(dir)Top' -- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: completion for "info -f" does not work 2022-03-18 13:59 ` Vincent Lefevre 2022-03-18 14:09 ` Vincent Lefevre @ 2022-03-22 9:35 ` Peter Stephenson 1 sibling, 0 replies; 12+ messages in thread From: Peter Stephenson @ 2022-03-22 9:35 UTC (permalink / raw) To: Vincent Lefevre, zsh-workers > On 18 March 2022 at 13:59 Vincent Lefevre <vincent@vinc17.net> wrote: > On 2022-03-16 17:46:28 +0900, Jun T wrote: > > 'info -f' accept any (relative or absolute) pathnames. > > Well, not exactly. It seems that the rule for "info -f" is that > if the argument does not have a slash, then the usual info path > is used (with no fallback if nothing is found, i.e. an existing > pathname in the current directory will be ignored), otherwise > the argument is regarded as a pathname. So we can require a slash before adding the raw file completion. pws diff --git a/Completion/Unix/Command/_texinfo b/Completion/Unix/Command/_texinfo index 7dfa32e45..2f5d0f91f 100644 --- a/Completion/Unix/Command/_texinfo +++ b/Completion/Unix/Command/_texinfo @@ -41,7 +41,7 @@ case $service in '(: -)'{-k+,--apropos=}'[look up string in indices]:search string: ' \ \*{-d+,--directory=}'[add directory to infopath]:info dir:_files -/' \ '--dribble=[record keystrokes]:file with keystrokes:_files' \ - '(-f --file 1)'{-f+,--file=}'[specify Info manual to visit]:info manual:->infofiles' \ + '(-f --file 1)'{-f+,--file=}'[specify Info manual to visit]:info manual:->infofiles+' \ '(: - -h --help)'{-h,--help}'[display usage]' \ '(-o --output -O)--index-search=[search for matching index entry]:search string:->index-entries' \ '(--index-search -o --output -O)'{-o+,--output=}'[dump selected nodes to filename]:filename:_files -g "*(-.)"' \ @@ -289,7 +289,11 @@ if [[ -n $state ]]; then items=( ${${${(M)${(f)"$(_call_program menu-items info -o-)"}:#(#s)\* *: \(*}#??}%%\)*} ) files+=( ${items##*\(} ) tags=( info-files ) - if [[ $state != infofiles ]]; then + if [[ $state = infofiles+ && $PREFIX$SUFFX = */* ]]; then + # local files allowed + tags+=(files) + fi + if [[ $state != infofiles* ]]; then tags+=( menu-items ) items=( ${items%:*} ) fi @@ -317,6 +321,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 ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2022-03-22 13:32 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-03-15 17:13 completion for "info -f" does not work Vincent Lefevre 2022-03-15 18:05 ` Peter Stephenson 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
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).