about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2009-12-05 17:38:23 +0000
committerClint Adams <clint@users.sourceforge.net>2009-12-05 17:38:23 +0000
commite6e2c7f3f809e4b6a4055593118105c90b142d03 (patch)
tree9aa62cda5d8193c3ca59a6ec00d142a6450d1842
parent80b3e8886090837a20236deab83bf0b8660b97d8 (diff)
downloadzsh-e6e2c7f3f809e4b6a4055593118105c90b142d03.tar.gz
zsh-e6e2c7f3f809e4b6a4055593118105c90b142d03.tar.xz
zsh-e6e2c7f3f809e4b6a4055593118105c90b142d03.zip
Frank Terbeck: 27458: set-option -w completion.
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Unix/Command/_tmux52
2 files changed, 32 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index 292b65531..5cefc9f3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2009-12-05  Clint Adams  <clint@zsh.org>
 
+	* Frank Terbeck: 27458: Completion/Unix/Command/_tmux:
+	set-option -w completion.
+
 	* Ingmar Vanhassel: 27457: Completion/Zsh/Command/_precommand:
 	add hilite as a precommand.
 
@@ -12438,5 +12441,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.4832 $
+* $Revision: 1.4833 $
 *****************************************************
diff --git a/Completion/Unix/Command/_tmux b/Completion/Unix/Command/_tmux
index 481a34bf9..60092ae88 100644
--- a/Completion/Unix/Command/_tmux
+++ b/Completion/Unix/Command/_tmux
@@ -837,27 +837,19 @@ function _tmux-set-environment() {
 
 function _tmux-set-option() {
     [[ -n ${tmux_describe} ]] && print "Set a session option" && return
+    local mode
     local -a args
     args=(
         '-a[Append to string options]'
         '-g[Set a global session option]'
         '-u[Unset a non-global option]'
+        '-w[Change window (not session) options]'
         '-t[Choose a target session]:target session:__tmux-sessions'
         '*:: :->name_or_value'
     )
+    __tmux-got-option-already -w && mode=window || mode=session
     _arguments -C ${args}
-
-    case ${state} in
-        name_or_value)
-            if (( CURRENT == 1 )); then
-                __tmux-options
-            elif (( CURRENT == 2 )); then
-                __tmux-option-guard 'session' ${words[1]}
-            else
-                __tmux-nothing-else
-            fi
-            ;;
-    esac
+    __tmux-options-complete ${mode} ${state}
 }
 
 function _tmux-set-window-option() {
@@ -871,18 +863,7 @@ function _tmux-set-window-option() {
         '*:: :->name_or_value'
     )
     _arguments -C ${args}
-
-    case ${state} in
-        name_or_value)
-            if (( CURRENT == 1 )); then
-                __tmux-window-options
-            elif (( CURRENT == 2 )); then
-                __tmux-option-guard 'window' ${words[1]}
-            else
-                __tmux-nothing-else
-            fi
-            ;;
-    esac
+    __tmux-options-complete window ${state}
 }
 
 function _tmux-show-buffer() {
@@ -1133,6 +1114,11 @@ function __tmux-get-optarg() {
     done
 }
 
+function __tmux-got-option-already() {
+    [[ -n ${(M)words:#$1} ]] && return 0
+    return 1
+}
+
 function __tmux-key-tables() {
     local expl
     local -a tables
@@ -1326,6 +1312,24 @@ function __tmux-options() {
     _describe -t tmux-options 'tmux option' tmux_options
 }
 
+function __tmux-options-complete() {
+    local mode="$1" state="$2"
+
+    case ${state} in
+        name_or_value)
+            if (( CURRENT == 1 )) && [[ ${mode} == 'session' ]]; then
+                __tmux-options
+            elif (( CURRENT == 1 )) && [[ ${mode} == 'window' ]]; then
+                __tmux-window-options
+            elif (( CURRENT == 2 )); then
+                __tmux-option-guard ${mode} ${words[1]}
+            else
+                __tmux-nothing-else
+            fi
+            ;;
+    esac
+}
+
 function __tmux-panes() {
     local expl line
     local -i num