From: Marlon Richert <marlon.richert@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: [PATCH] Don't complete escaped words as aliases
Date: Fri, 12 Nov 2021 23:34:47 +0200 [thread overview]
Message-ID: <CAHLkEDsK3UH7EkJFDxhsrAeSdmcYpceHsdfu7yPG52-jfjL88A@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 111 bytes --]
It doesn't make sense to complete \escaped 'words' as aliases, since
they won't be expanded as aliases either.
[-- Attachment #2: 0001-Don-t-complete-escaped-words-as-aliases.txt --]
[-- Type: text/plain, Size: 1803 bytes --]
From 9c8f1b6e5e3a8f60b151bccd1eea8438a40d6b23 Mon Sep 17 00:00:00 2001
From: Marlon Richert <marlonrichert@users.noreply.github.com>
Date: Fri, 12 Nov 2021 23:24:58 +0200
Subject: [PATCH] Don't complete escaped words as aliases
---
Completion/Zsh/Type/_command_names | 10 +++++++---
Test/Y01completion.ztst | 6 ++++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/Completion/Zsh/Type/_command_names b/Completion/Zsh/Type/_command_names
index b1c35f013..3ed39141d 100644
--- a/Completion/Zsh/Type/_command_names
+++ b/Completion/Zsh/Type/_command_names
@@ -26,11 +26,15 @@ elif (( ${#precommands:|builtin_precommands} )); then
else
[[ "$1" = - ]] && shift
- defs=( "$defs[@]"
+ [[ $words[CURRENT] == ${(Q)words[CURRENT]} ]] &&
+ defs+=(
+ 'aliases:alias:compadd -Qk aliases'
+ 'suffix-aliases:suffix alias:_suffix_alias_files'
+ )
+
+ defs+=(
'builtins:builtin command:compadd -Qk builtins'
"functions:shell function:compadd -k 'functions$ffilt'"
- 'aliases:alias:compadd -Qk aliases'
- 'suffix-aliases:suffix alias:_suffix_alias_files'
'reserved-words:reserved word:compadd -Qk reswords'
'jobs:: _jobs -t'
'parameters:: _parameters -g "^*(readonly|association)*" -qS= -r "\n\t\- =[+"'
diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst
index 882a0adc4..97886b30c 100644
--- a/Test/Y01completion.ztst
+++ b/Test/Y01completion.ztst
@@ -97,6 +97,12 @@
>FI:{file2}
F:regression test workers/42164
+ comptesteval 'alias while='
+ comptest '\while'$'\C-D'
+0:escaped words should not be completed as aliases
+>DESCRIPTION:{reserved word}
+>NO:{while}
+
# Depends on path assignment in comptestinit
comptesteval "path=( $ZTST_srcdir:A )"
comptest $'zt\t'
--
2.30.1 (Apple Git-130)
next reply other threads:[~2021-11-12 21:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-12 21:34 Marlon Richert [this message]
2021-11-13 7:02 ` Mikael Magnusson
2021-11-13 17:11 ` Marlon Richert
2021-11-13 20:59 ` Bart Schaefer
2021-11-14 13:02 ` Oliver Kiddle
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=CAHLkEDsK3UH7EkJFDxhsrAeSdmcYpceHsdfu7yPG52-jfjL88A@mail.gmail.com \
--to=marlon.richert@gmail.com \
--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).