zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Don't complete escaped words as aliases
@ 2021-11-12 21:34 Marlon Richert
  2021-11-13  7:02 ` Mikael Magnusson
  0 siblings, 1 reply; 5+ messages in thread
From: Marlon Richert @ 2021-11-12 21:34 UTC (permalink / raw)
  To: Zsh hackers list

[-- 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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-14 13:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-12 21:34 [PATCH] Don't complete escaped words as aliases Marlon Richert
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

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).