zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH] _hg completion: Complete bookmark names for -r
Date: Tue, 27 Jan 2015 10:05:43 +0000	[thread overview]
Message-ID: <20150127100543.GC1966@tarsus.local2> (raw)

[-- Attachment #1: Type: text/plain, Size: 640 bytes --]

Patch to make 'hg checkout <TAB>' complete bookmark names in addition to
tag names.

This patch also modifies the parsing of 'hg tags' in the same context in
two ways.  It employs --quiet to simplify the hg output being parsed,
and stops using _describe, which makes tag names containing backslashes
complete correctly.  (The problem is that _describe parses colons and
backslashes within its arguments, and hg tag names were passed to
_describe without escaping.  Only backslashes may trigger the problem
because hg does not permit tag names to have colons.)

Cheers,

Daniel
(In the above, 'tag names' means hg tags, not zshcompsys tags)

[-- Attachment #2: 0001-_hg-completion-Complete-bookmark-names-for-r.patch --]
[-- Type: text/x-patch, Size: 1323 bytes --]

>From 3da817ab8b083587b9350b5d8e1fac423c900ffd Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@daniel.shahaf.name>
Date: Sun, 25 Jan 2015 11:22:18 +0000
Subject: [PATCH] _hg completion: Complete bookmark names for -r

While there, simplify `hg tags` parsing.
---
 Completion/Unix/Command/_hg | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg
index c18500b..e7c21b9 100644
--- a/Completion/Unix/Command/_hg
+++ b/Completion/Unix/Command/_hg
@@ -162,15 +162,24 @@ _hg_revrange() {
   _hg_tags "$@"
 }
 
-_hg_tags() {
-  typeset -a tags
-  local tag rev
+_hg_tags_internal() {
+  local expl
+  typeset -a hgtags
+  hgtags=( ${(f)"$(_hg_cmd tags -q 2>/dev/null)"} )
+  _wanted tags expl 'tags' compadd -a - hgtags
+}
 
-  _hg_cmd tags 2> /dev/null | while read tag
-  do
-    tags+=(${tag/ #    [0-9]#:*})
-  done
-  (( $#tags )) && _describe -t tags 'tags' tags
+_hg_bookmarks_internal() {
+  local expl
+  typeset -a hgbookmarks
+  hgbookmarks=( ${(f)"$(_hg_cmd bookmarks -q 2>/dev/null)"} )
+  _wanted bookmarks expl 'bookmarks' compadd -a - hgbookmarks
+}
+
+_hg_tags() {
+  _alternative \
+    'bookmarks:bookmark:_hg_bookmarks_internal' \
+    'tags:tag:_hg_tags_internal'
 }
 
 # likely merge candidates
-- 
1.9.1


                 reply	other threads:[~2015-01-27 10:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20150127100543.GC1966@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --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).