All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/4] Re-spin rr/completion-branch-config
@ 2014-01-05 10:18 Ramkumar Ramachandra
  2014-01-05 10:18 ` [PATCH v4 1/4] zsh completion: find matching custom bash completion Ramkumar Ramachandra
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ramkumar Ramachandra @ 2014-01-05 10:18 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

Hi Junio et al,

Most significantly, [2/4] no longer duplicates __gitcompadd () in
__gitcomp_nl_append (). Other than that, the commit messages for the
other patches are improved.

Thanks.

Ramkumar Ramachandra (4):
  zsh completion: find matching custom bash completion
  completion: introduce __gitcomp_nl_append ()
  completion: fix branch.autosetup(merge|rebase)
  completion: fix remote.pushdefault

 contrib/completion/git-completion.bash | 24 ++++++++++++++++++++----
 contrib/completion/git-completion.zsh  | 10 +++++++++-
 2 files changed, 29 insertions(+), 5 deletions(-)

-- 
1.8.5.2.227.g53f3478

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

* [PATCH v4 1/4] zsh completion: find matching custom bash completion
  2014-01-05 10:18 [PATCH v4 0/4] Re-spin rr/completion-branch-config Ramkumar Ramachandra
@ 2014-01-05 10:18 ` Ramkumar Ramachandra
  2014-01-05 10:18 ` [PATCH v4 2/4] completion: introduce __gitcomp_nl_append () Ramkumar Ramachandra
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ramkumar Ramachandra @ 2014-01-05 10:18 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

If zsh completion is being read from a location that is different from
system-wide default, it is likely that the user is trying to use a
custom version, perhaps closer to the bleeding edge, installed in her
own directory. We will more likely to find the matching bash completion
script in the same directory than in those system default places.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 contrib/completion/git-completion.zsh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index fac5e71..6fca145 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -30,10 +30,10 @@ if [ -z "$script" ]; then
 	local -a locations
 	local e
 	locations=(
+		$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
 		'/etc/bash_completion.d/git' # fedora, old debian
 		'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
 		'/usr/share/bash-completion/git' # gentoo
-		$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
 		)
 	for e in $locations; do
 		test -f $e && script="$e" && break
-- 
1.8.5.2.227.g53f3478

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

* [PATCH v4 2/4] completion: introduce __gitcomp_nl_append ()
  2014-01-05 10:18 [PATCH v4 0/4] Re-spin rr/completion-branch-config Ramkumar Ramachandra
  2014-01-05 10:18 ` [PATCH v4 1/4] zsh completion: find matching custom bash completion Ramkumar Ramachandra
@ 2014-01-05 10:18 ` Ramkumar Ramachandra
  2014-01-05 10:18 ` [PATCH v4 3/4] completion: fix branch.autosetup(merge|rebase) Ramkumar Ramachandra
  2014-01-05 10:18 ` [PATCH v4 4/4] completion: fix remote.pushdefault Ramkumar Ramachandra
  3 siblings, 0 replies; 5+ messages in thread
From: Ramkumar Ramachandra @ 2014-01-05 10:18 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

There are situations where multiple classes of completions possible. For
example

  branch.<TAB>

should try to complete

  branch.master.
  branch.autosetupmerge
  branch.autosetuprebase

The first candidate has the suffix ".", and the second/ third candidates
have the suffix " ". To facilitate completions of this kind, create a
variation of __gitcomp_nl () that appends to the existing list of
completion candidates, COMPREPLY.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 contrib/completion/git-completion.bash | 22 ++++++++++++++++++----
 contrib/completion/git-completion.zsh  |  8 ++++++++
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 51c2dd4..20febff 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -178,9 +178,9 @@ _get_comp_words_by_ref ()
 }
 fi
 
-__gitcompadd ()
+__gitcompappend ()
 {
-	local i=0
+	local i=${#COMPREPLY[@]}
 	for x in $1; do
 		if [[ "$x" == "$3"* ]]; then
 			COMPREPLY[i++]="$2$x$4"
@@ -188,6 +188,12 @@ __gitcompadd ()
 	done
 }
 
+__gitcompadd ()
+{
+	COMPREPLY=()
+	__gitcompappend "$@"
+}
+
 # Generates completion reply, appending a space to possible completion words,
 # if necessary.
 # It accepts 1 to 4 arguments:
@@ -218,6 +224,14 @@ __gitcomp ()
 	esac
 }
 
+# Variation of __gitcomp_nl () that appends to the existing list of
+# completion candidates, COMPREPLY.
+__gitcomp_nl_append ()
+{
+	local IFS=$'\n'
+	__gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }"
+}
+
 # Generates completion reply from newline-separated possible completion words
 # by appending a space to all of them.
 # It accepts 1 to 4 arguments:
@@ -229,8 +243,8 @@ __gitcomp ()
 #    appended.
 __gitcomp_nl ()
 {
-	local IFS=$'\n'
-	__gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
+	COMPREPLY=()
+	__gitcomp_nl_append "$@"
 }
 
 # Generates completion reply with compgen from newline-separated possible
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 6fca145..6b77968 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -76,6 +76,14 @@ __gitcomp_nl ()
 	compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
 }
 
+__gitcomp_nl_append ()
+{
+	emulate -L zsh
+
+	local IFS=$'\n'
+	compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
+}
+
 __gitcomp_file ()
 {
 	emulate -L zsh
-- 
1.8.5.2.227.g53f3478

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

* [PATCH v4 3/4] completion: fix branch.autosetup(merge|rebase)
  2014-01-05 10:18 [PATCH v4 0/4] Re-spin rr/completion-branch-config Ramkumar Ramachandra
  2014-01-05 10:18 ` [PATCH v4 1/4] zsh completion: find matching custom bash completion Ramkumar Ramachandra
  2014-01-05 10:18 ` [PATCH v4 2/4] completion: introduce __gitcomp_nl_append () Ramkumar Ramachandra
@ 2014-01-05 10:18 ` Ramkumar Ramachandra
  2014-01-05 10:18 ` [PATCH v4 4/4] completion: fix remote.pushdefault Ramkumar Ramachandra
  3 siblings, 0 replies; 5+ messages in thread
From: Ramkumar Ramachandra @ 2014-01-05 10:18 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

When attempting to complete

  $ git config branch.auto<TAB>

'autosetupmerge' and 'autosetuprebase' don't come up. This is because
"$cur" is matched with "branch.*" and a list of branches are
completed. Add 'autosetupmerge', 'autosetuprebase' as candidates for
completion too, using __gitcomp_nl_append ().

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 contrib/completion/git-completion.bash | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 20febff..a57bcbe 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1841,6 +1841,7 @@ _git_config ()
 	branch.*)
 		local pfx="${cur%.*}." cur_="${cur#*.}"
 		__gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
+		__gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
 		return
 		;;
 	guitool.*.*)
-- 
1.8.5.2.227.g53f3478

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

* [PATCH v4 4/4] completion: fix remote.pushdefault
  2014-01-05 10:18 [PATCH v4 0/4] Re-spin rr/completion-branch-config Ramkumar Ramachandra
                   ` (2 preceding siblings ...)
  2014-01-05 10:18 ` [PATCH v4 3/4] completion: fix branch.autosetup(merge|rebase) Ramkumar Ramachandra
@ 2014-01-05 10:18 ` Ramkumar Ramachandra
  3 siblings, 0 replies; 5+ messages in thread
From: Ramkumar Ramachandra @ 2014-01-05 10:18 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

When attempting to complete

  $ git config remote.push<TAB>

'pushdefault' doesn't come up. This is because "$cur" is matched with
"remote.*" and a list of remotes are completed. Add 'pushdefault' as a
candidate for completion too, using __gitcomp_nl_append ().

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 contrib/completion/git-completion.bash | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index a57bcbe..4fe5ce3 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1884,6 +1884,7 @@ _git_config ()
 	remote.*)
 		local pfx="${cur%.*}." cur_="${cur#*.}"
 		__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
+		__gitcomp_nl_append "pushdefault" "$pfx" "$cur_"
 		return
 		;;
 	url.*.*)
-- 
1.8.5.2.227.g53f3478

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

end of thread, other threads:[~2014-01-05 10:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-05 10:18 [PATCH v4 0/4] Re-spin rr/completion-branch-config Ramkumar Ramachandra
2014-01-05 10:18 ` [PATCH v4 1/4] zsh completion: find matching custom bash completion Ramkumar Ramachandra
2014-01-05 10:18 ` [PATCH v4 2/4] completion: introduce __gitcomp_nl_append () Ramkumar Ramachandra
2014-01-05 10:18 ` [PATCH v4 3/4] completion: fix branch.autosetup(merge|rebase) Ramkumar Ramachandra
2014-01-05 10:18 ` [PATCH v4 4/4] completion: fix remote.pushdefault Ramkumar Ramachandra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.