zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Fredrik Ax <fredrik@axnet.nu>
Cc: zsh-users@zsh.org, zsh-workers@zsh.org
Subject: Re: completion ( compctl ) does not trigger for command names containing dashes
Date: Wed, 3 May 2023 10:13:15 -0700	[thread overview]
Message-ID: <CAH+w=7YoDS+4-RNbrfDD=B6+QJydARkOBNx7J58e6KoLtgzQqw@mail.gmail.com> (raw)
In-Reply-To: <CANPa6YCGPfzm29R+DN9P7-Pkx7Tkv9zf1HLueHTSPMv1aXUrOQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 537 bytes --]

On Wed, May 3, 2023 at 2:59 AM Fredrik Ax <fredrik@axnet.nu> wrote:
>
> zshprompt% compctl -k '(arg1 arg2 arg3)' with-dash
>
> # typing 'with-dash ' and hitting [Tab] once:
> zshprompt% with-dash
> file2.txt    myfile1.txt

This dates back to the tokenization of hyphens to fix bugs in [a-z]
types of patterns.  The ancient code in compctl is using the raw
command string and therefore looking for completions for
$'with\233-dash' rather than 'with-dash'.

See if this (attached) fixes it without breaking anything else.

[-- Attachment #2: compctl-dash.txt --]
[-- Type: text/plain, Size: 452 bytes --]

diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index 690cf6efb..6ceb5d87f 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -1315,6 +1315,8 @@ get_comp_string(void)
 	    ins = (tok == REPEAT ? 2 : (tok != STRING && tok != TYPESET));
 	    zsfree(cmdstr);
 	    cmdstr = ztrdup(tokstr);
+	    untokenize(cmdstr);
+	    remnulargs(cmdstr);
 	    cmdtok = tok;
 	    /*
 	     * If everything before is a redirection, or anything

  reply	other threads:[~2023-05-03 17:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-03  9:59 Fredrik Ax
2023-05-03 17:13 ` Bart Schaefer [this message]
2023-05-04  7:52   ` Fredrik Ax
2023-05-04 10:36   ` Fredrik Ax
2023-05-04 14:44     ` Bart Schaefer
2023-05-07  9:41       ` Fredrik Ax

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='CAH+w=7YoDS+4-RNbrfDD=B6+QJydARkOBNx7J58e6KoLtgzQqw@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=fredrik@axnet.nu \
    --cc=zsh-users@zsh.org \
    --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).