Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] _less incorrectly completes -" and -#
- X-seq: zsh-workers 49766
- From: "Jun. T" <takimoto-j@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [BUG] _less incorrectly completes -" and -#
- Date: Mon, 21 Feb 2022 22:36:37 +0900
- Archived-at: <https://zsh.org/workers/49766>
- In-reply-to: <59878-1634948764.966966@18Tx.APRj.e74Z>
- List-id: <zsh-workers.zsh.org>
- References: <CAN=4vMoTixQ=XXhos8D92FwMOD3YS0NuLt7Y1aBMWyA8Kcn3rQ@mail.gmail.com> <70628-1601650043.378616@hQ3l.BrEr.w3GB> <59878-1634948764.966966@18Tx.APRj.e74Z>
This is the minor problem I mentioned in the previous post (49765).
> 2021/10/23 9:26, Oliver Kiddle <opk@xxxxxxx> wrote:
>
> This is digging up another fairly old _arguments issue that I meant to
> deal with before:
>
> On 2 Oct 2020, I wrote:
>> Roman Perepelitsa wrote:
>>> Completing `less -` offers `-"` as a candidate. Accepting it literally
>>> inserts `-"`. I think it should offer `-\"` and insert the same.
The patch (commit 4e9d00) has solved this problem, but a few problems remain.
zsh[1]% less -\"<TAB><TAB>
The 1st TAB inserts a space, and the 2nd TAB offers list of input files,
but what is expected is a message "quoting characters".
zsh[2]% less -\"cc -<TAB>
this still offers --quote and -"
zsh[3]% less -\" cc -<TAB>
this gives "No match for: 'file'"
Since ca_parse_line() (computil.c:2009) does not remove the escape from the -\"
on the command line (see line 2080 and below), it seems it is not recognized as
a known option.
If I quote the -\"+ in the spec as '-\"+'
'(-" --quotes)'{'-\"+',--quotes=}'[change quoting character]:quoting characters'
then the above problems seem to be "mostly" solved
(in case [1], for the 1st TAB we also get
-" -- change quoting character
in addition to the correct message).
But with this spec:
zsh[4]% less --quote=cc -<TAB>
this still offers -"
It seems we also need to escape the " in the exclusion list:
'(-\" --quotes)'{'-\"+',--quotes=}'[change quoting character]:quoting characters'
but is this a good way of fixing these problems?
(this patch is against the current master, not including the patch in 49765).
diff --git a/Completion/Unix/Command/_less b/Completion/Unix/Command/_less
index ae912a633..7ba665069 100644
--- a/Completion/Unix/Command/_less
+++ b/Completion/Unix/Command/_less
@@ -80,9 +80,9 @@ _arguments -S -s -A "[-+]*" \
'--no-keypad[disable use of keypad terminal init string]' \
'(-y --max-forw-scroll)'{-y,--max-forw-scroll}'[specify forward scroll limit]' \
'(-z --window)'{-z+,--window=}'[specify scrolling window size]:lines' \
- '(-" --quotes)'{-\"+,--quotes=}'[change quoting character]:quoting characters' \
+ '(-\" --quotes)'{'-\"+',--quotes=}'[change quoting character]:quoting characters' \
'(-~ --tilde)'{-~,--tilde}"[don't display tildes after end of file]" \
- '(-# --shift)'{-\#+,--shift=}"[specify amount to move when scrolling horizontally]:number" \
+ '(-\# --shift)'{'-\#+',--shift=}"[specify amount to move when scrolling horizontally]:number" \
'--file-size[automatically determine the size of the input file]' \
'--incsearch[search file as each pattern character is typed in]' \
'--line-num-width=[set the width of line number field]:width [7]' \
Messages sorted by:
Reverse Date,
Date,
Thread,
Author