about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Cook <illua@users.sourceforge.net>2024-11-11 10:46:08 -0500
committerEric Cook <illua@users.sourceforge.net>2024-11-11 10:46:08 -0500
commit393cb298aaa849bae62e7294fecb1b60d0dd3910 (patch)
tree8072f18b95af72dd264882ace0fc1d917e16219f
parent9b8af0900fd8167543e5786b46e70d3f32d45e2b (diff)
downloadzsh-393cb298aaa849bae62e7294fecb1b60d0dd3910.tar.gz
zsh-393cb298aaa849bae62e7294fecb1b60d0dd3910.tar.xz
zsh-393cb298aaa849bae62e7294fecb1b60d0dd3910.zip
53174: add Completion/Base/Utility/_as_if
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Base/Utility/_as_if10
-rw-r--r--Doc/Zsh/compsys.yo8
3 files changed, 22 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index a0e742244..bdb60cf33 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@
 	* 53144: Completion/Unix/Command/_sysctl:
 	support completion with the dot delimiter on linux
 
+	* Matthew Martin: 53174 + comments:
+	Completion/Base/Utility/_as_if: complete `as if'
+	a different command were being completed
+
 2024-11-05  Bart Schaefer  <schaefer@toltec-ubuntu>
 
 	* 53209 + comments + test: Src/params.c, Test/D04parameter.ztst:
diff --git a/Completion/Base/Utility/_as_if b/Completion/Base/Utility/_as_if
new file mode 100644
index 000000000..c961aaa88
--- /dev/null
+++ b/Completion/Base/Utility/_as_if
@@ -0,0 +1,10 @@
+#autoload
+local words=("$words[@]") CURRENT=$CURRENT
+local _comp_command1 _comp_command2 _comp_command
+
+words[1]=("$@")
+(( CURRENT += $# - 1 ))
+
+_set_command
+
+_dispatch "$_comp_command" "$_comp_command1" "$_comp_command2" -default-
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 77627bacc..9b7f91148 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -4290,6 +4290,14 @@ arguments.  The first describes the first argument as a
 be completed.  The last description gives all other arguments the
 description `var(page number)' but does not offer completions.
 )
+findex(_as_if)
+item(tt(_as_if) var(command) [var(arg) ... ])(
+This function is useful when one command should be completed as if it were
+another command with particular arguments. For example to complete tt(foo) as
+if it were tt(bar --baz), use
+
+example(compdef '_as_if bar --baz' foo)
+)
 findex(_cache_invalid)
 item(tt(_cache_invalid) var(cache_identifier))(
 This function returns status zero if the completions cache corresponding to