Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [BUG] _less incorrectly completes -" and -#



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