From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19361 invoked by alias); 26 Jul 2017 14:55:18 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41467 Received: (qmail 27288 invoked from network); 26 Jul 2017 14:55:17 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.25):SA:0(-0.7/5.0):. Processed in 1.900476 secs); 26 Jul 2017 14:55:17 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=8zwWShl8vcVcZDTLKA Sl2wYFpBbI0Y0sSlU7NwPWzKU=; b=S6J7rPISuoxhyqd8lj7jy/dOIeR+ZIQqC9 kTsCXRATDUD66OWhg27nlH2QjSsfFPsJfIZ+H9w7RVmZ+3VB/AS4GSPGcXC8ZOIF OT4njZiRsApN7nGCMEtE1ofViOp1Cd2GiscKM354S8lCVMtouWs0eGuaZ4byDukV 8jDlAvdj2zyFJM0F2djZtUSV7MTKvoZN3Tn6/8mW6slH3YtR0GJgtDf/cMbAD22c p3bthWq947Pt99Ki21F7Vl8sT//rAOIX7COLM/8EGhcWU8PJG59ijPvXgWTU07Vw LI+e2XJM2kfwh14nRO1YTCBUoaH/UT7FoHqePPG/SJ94hwLL2P3g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=8zwWShl8vcVcZDTLKA Sl2wYFpBbI0Y0sSlU7NwPWzKU=; b=sIu0bfxh1hepil4oCAtCiQdtQ15Lad3an/ 0lMJITIKyleaJfIL050fWNvFtoyfcoF/gfO2dsH2kCf9cUTrw33zFXSovuxxARwL ry1Ey4DEKnh0xzC1El15m/EEabP8HWUa7NOChb96328necw/PzNeWrhaoH2njLrG Mf5RGyUpIFyoamVhEdwjRNpAqgTJfWo1E9yml2FsAMweUPPaMUlb3mINlzYcM94W 77BVXdT8/UhjjI3c7sBOWJtUdjflWUd8JchQAytu79fMgegIzHi41/PULm22Hzjy 8Y/K9i/OhgYwbDOzCGXC+mgUTRX0eRIY8lkfyQJpoYjYW/IdlOkQ== X-ME-Sender: X-Sasl-enc: O4Z/7AgfPGxMeSKhv5f9l2ghGGZxtqpMHcIICLF1clCT 1501080906 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH] Correct completion of 'tmux new '. Date: Wed, 26 Jul 2017 14:55:03 +0000 Message-Id: <20170726145503.9521-1-danielsh@tarpaulin.shahaf.local2> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reference: window_pane_spawn() in tmux 2.5. Also, document _cmdstring and _precommand. --- I think this implements all feedback from the previous thread. I noticed two related issues: 1. % sh -c 'rsync --dele removes the leading quote. 2. % sh -c '/usr/bin/rsyn adds the «c» (since "/usr/bin/rsync" is the unique completion) but doesn't add space afterwards. Cheers, Daniel Completion/Unix/Command/_tmux | 2 +- Completion/Unix/Type/_cmdambivalent | 17 +++++++++++++++++ Doc/Zsh/compsys.yo | 21 +++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Completion/Unix/Type/_cmdambivalent diff --git a/Completion/Unix/Command/_tmux b/Completion/Unix/Command/_tmux index 0917da604..5f5bea922 100644 --- a/Completion/Unix/Command/_tmux +++ b/Completion/Unix/Command/_tmux @@ -526,7 +526,7 @@ _tmux-new-session() { '-t+[specify target session]:session:__tmux-sessions' \ '-x[specify width]:width' \ '-y[specify height]:height' \ - '*:: :_cmdstring' + '*:: :_cmdambivalent' } _tmux-new-window() { diff --git a/Completion/Unix/Type/_cmdambivalent b/Completion/Unix/Type/_cmdambivalent new file mode 100644 index 000000000..1f15d11ab --- /dev/null +++ b/Completion/Unix/Type/_cmdambivalent @@ -0,0 +1,17 @@ +#autoload + +if (( CURRENT == 1 && ${#words} == 1 )); then + # Heuristics to decide whether to complete for system() or for execl(). + local space=' ' + if (( ${${words[CURRENT]}[(I)$space]} )); then + _cmdstring + elif [[ ${${compstate[all_quotes]}[1]} == (\'|\") ]]; then + _cmdstring + else + _command_names -e + fi +elif (( CURRENT == 1 )); then + _command_names -e +else + _normal +fi diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 47b07e85e..36afd7305 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -3014,6 +3014,22 @@ tt(-n), tt(-F), tt(-X) are passed to tt(compadd). See tt(_description) for a description of var(tag) and var(descr). ) +findex(_cmdambivalent) +item(tt(_cmdambivalent))( +Completes the remaining positional arguments as an external command. +The external command and its arguments are completed as separate arguments +(in a manner appropriate for completing tt(/usr/bin/env)) +if there are two or more remaining positional arguments on the command line, +and as a quoted command string (in the manner of tt(system+LPAR()...+RPAR())) otherwise. +See also tt(_cmdstring) and tt(_precommand). + +This function takes no arguments. +) +findex(_cmdstring) +item(tt(_cmdstring))( +Completes an external command as a single argument, as for +tt(system+LPAR()...+RPAR()). +) findex(_complete) item(tt(_complete))( This completer generates all possible completions in a context-sensitive @@ -3214,6 +3230,11 @@ tt(old-menu), see ifzman(the section `Completion System Configuration' above)\ ifnzman(noderef(Completion System Configuration)). ) +findex(_precommand) +item(tt(_precommand))( +Complete an external command in word-separated arguments, as for +tt(exec) and tt(/usr/bin/env). +) findex(_prefix) item(tt(_prefix))( This completer can be used to try completion with the suffix (everything