# gitk: can't reload commits with new key binding

11 messages from 2012-09-30 to 2012-10-21. Participants: SZEDER Gábor, Andrew Wong, Junio C Hamano, Paul Mackerras.
Thread: https://gitlist.dev/t/31691

## SZEDER Gábor, 2012-09-30 10:19

Subject: gitk: can't reload commits with new key binding
Message-ID: <20120930101932.GA15672@goldbirke>
URL: https://gitlist.dev/e/20120930101932.GA15672%40goldbirke

```
Hi,

a135f214 (gitk: Avoid Meta1-F5, 2012-04-07) changed the key binding
for reloading commits to shift-F5, but this new key binding doesn't
seem to be working here, because it doesn't call reloadcommits().
Choosing the reload menu item works.  Shift-F5 works properly in other
applications.

Any ideas?

Thanks,
Gábor

```

## Andrew Wong, 2012-10-01 15:26

Subject: Re: gitk: can't reload commits with new key binding
Message-ID: <1349105191-31681-1-git-send-email-andrew.kw.w@gmail.com>
URL: https://gitlist.dev/e/1349105191-31681-1-git-send-email-andrew.kw.w%40gmail.com
In-Reply-To: <20120930101932.GA15672@goldbirke>

```
Sorry, my previous "git send-email" screwed up. Resending the email again.

I was running into the same issue too. It turns out that on some machines
Shift-F5 is mapped to Shift-XF86_Switch_VT_5. My patch includes a workaround.
The same workaround was used for Shift-F4.

Andrew Wong (1):
  gitk: Add workaround for system where Shift-F5 mapped to
    Shift-XF86_Switch_VT_5

 gitk-git/gitk | 1 +
 1 file changed, 1 insertion(+)

-- 
1.7.12.1.382.gb0576a6

```

## Andrew Wong, 2012-10-01 15:26

Subject: [PATCH] gitk: Add workaround for system where Shift-F5 mapped to Shift-XF86_Switch_VT_5
Message-ID: <1349105191-31681-2-git-send-email-andrew.kw.w@gmail.com>
URL: https://gitlist.dev/e/1349105191-31681-2-git-send-email-andrew.kw.w%40gmail.com
In-Reply-To: <1349105191-31681-1-git-send-email-andrew.kw.w@gmail.com>

```
The same workaround was used for Shift-F4 in:
  cea07cf8dc9b3677e0c50433c0d72bce83adbdc7

Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
---
 gitk-git/gitk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index d93bd99..698b84a 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2496,6 +2496,7 @@ proc makewindow {} {
     bindkey f nextfile
     bind . <F5> updatecommits
     bind . <Shift-F5> reloadcommits
+    catch { bind . <Shift-Key-XF86_Switch_VT_5> reloadcommits }
     bind . <F2> showrefs
     bind . <Shift-F4> {newview 0}
     catch { bind . <Shift-Key-XF86_Switch_VT_4> {newview 0} }
-- 
1.7.12.1.382.gb0576a6

```

## Junio C Hamano, 2012-10-01 17:27

Subject: Re: [PATCH] gitk: Add workaround for system where Shift-F5 mapped to Shift-XF86_Switch_VT_5
Message-ID: <7vwqzacdb7.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vwqzacdb7.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1349105191-31681-2-git-send-email-andrew.kw.w@gmail.com>

```
Andrew Wong <andrew.kw.w@gmail.com> writes:

> The same workaround was used for Shift-F4 in:
>   cea07cf8dc9b3677e0c50433c0d72bce83adbdc7
>
> Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
> ---
>  gitk-git/gitk | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/gitk-git/gitk b/gitk-git/gitk
> index d93bd99..698b84a 100755
> --- a/gitk-git/gitk
> +++ b/gitk-git/gitk
> @@ -2496,6 +2496,7 @@ proc makewindow {} {
>      bindkey f nextfile
>      bind . <F5> updatecommits
>      bind . <Shift-F5> reloadcommits
> +    catch { bind . <Shift-Key-XF86_Switch_VT_5> reloadcommits }
>      bind . <F2> showrefs
>      bind . <Shift-F4> {newview 0}
>      catch { bind . <Shift-Key-XF86_Switch_VT_4> {newview 0} }

Wouldn't it make more sense to have a small helper function to wrap
binding both <Shift-Fn> and <Shift-Key-XF86_Switch_VT_n> to the same
thing and have F4 and F5 binding use that to avoid repetition?

```

## Andrew Wong, 2012-10-02 15:04

Subject: [PATCH v2 0/2] Re: gitk: can't reload commits with new key binding
Message-ID: <1349190285-7788-1-git-send-email-andrew.kw.w@gmail.com>
URL: https://gitlist.dev/e/1349190285-7788-1-git-send-email-andrew.kw.w%40gmail.com
In-Reply-To: <7vwqzacdb7.fsf@alter.siamese.dyndns.org>

```
Refactored the code for binding modified function keys as Junio suggested.

Andrew Wong (2):
  gitk: Refactor code for binding modified function keys
  gitk: Use bindshiftfunctionkey to bind Shift-F5

 gitk | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

-- 
1.7.12.1.382.gb0576a6

```

## Andrew Wong, 2012-10-02 15:04

Subject: [PATCH v2 1/2] gitk: Refactor code for binding modified function keys
Message-ID: <1349190285-7788-2-git-send-email-andrew.kw.w@gmail.com>
URL: https://gitlist.dev/e/1349190285-7788-2-git-send-email-andrew.kw.w%40gmail.com
In-Reply-To: <1349190285-7788-1-git-send-email-andrew.kw.w@gmail.com>

```
The function includes a workaround for systems where F* keys are mapped
to XF86_Switch_VT_* when modifiers are used.

Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
---
 gitk | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gitk b/gitk
index 379582a..f8f89a5 100755
--- a/gitk
+++ b/gitk
@@ -2503,8 +2503,7 @@ proc makewindow {} {
     bind . <F5> updatecommits
     bind . <Shift-F5> reloadcommits
     bind . <F2> showrefs
-    bind . <Shift-F4> {newview 0}
-    catch { bind . <Shift-Key-XF86_Switch_VT_4> {newview 0} }
+    bindmodfunctionkey Shift 4 {newview 0}
     bind . <F4> edit_or_newview
     bind . <$M1B-q> doquit
     bind . <$M1B-f> {dofind 1 1}
@@ -2653,6 +2652,11 @@ proc bindkey {ev script} {
     }
 }
 
+proc bindmodfunctionkey {mod n script} {
+    bind . <$mod-F$n> $script
+    catch { bind . <$mod-XF86_Switch_VT_$n> $script }
+}
+
 # set the focus back to the toplevel for any click outside
 # the entry widgets
 proc click {w} {
-- 
1.7.12.1.382.gb0576a6

```

## Andrew Wong, 2012-10-02 15:04

Subject: [PATCH v2 2/2] gitk: Use bindshiftfunctionkey to bind Shift-F5
Message-ID: <1349190285-7788-3-git-send-email-andrew.kw.w@gmail.com>
URL: https://gitlist.dev/e/1349190285-7788-3-git-send-email-andrew.kw.w%40gmail.com
In-Reply-To: <1349190285-7788-1-git-send-email-andrew.kw.w@gmail.com>

```
Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
---
 gitk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gitk b/gitk
index f8f89a5..d53fdb2 100755
--- a/gitk
+++ b/gitk
@@ -2501,7 +2501,7 @@ proc makewindow {} {
     bindkey ? {dofind -1 1}
     bindkey f nextfile
     bind . <F5> updatecommits
-    bind . <Shift-F5> reloadcommits
+    bindmodfunctionkey Shift 5 reloadcommits
     bind . <F2> showrefs
     bindmodfunctionkey Shift 4 {newview 0}
     bind . <F4> edit_or_newview
-- 
1.7.12.1.382.gb0576a6

```

## Andrew Wong, 2012-10-07 21:18

Subject: Re: [PATCH v2 0/2] Re: gitk: can't reload commits with new key binding
Message-ID: <5071F1A3.5070502@gmail.com>
URL: https://gitlist.dev/e/5071F1A3.5070502%40gmail.com
In-Reply-To: <1349190285-7788-1-git-send-email-andrew.kw.w@gmail.com>

```
Could we look into getting this patch into git/gitk?

On 10/02/12 11:04, Andrew Wong wrote:
> Refactored the code for binding modified function keys as Junio suggested.
>
> Andrew Wong (2):
>   gitk: Refactor code for binding modified function keys
>   gitk: Use bindshiftfunctionkey to bind Shift-F5
>
>  gitk | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>

```

## SZEDER Gábor, 2012-10-08 21:05

Subject: Re: [PATCH v2 0/2] Re: gitk: can't reload commits with new key binding
Message-ID: <20121008210555.GM951@goldbirke>
URL: https://gitlist.dev/e/20121008210555.GM951%40goldbirke
In-Reply-To: <1349190285-7788-1-git-send-email-andrew.kw.w@gmail.com>

```
Hi,

(Sorry for the delayed reply, was out of town.)


On Tue, Oct 02, 2012 at 11:04:43AM -0400, Andrew Wong wrote:
> Refactored the code for binding modified function keys as Junio suggested.
> 
> Andrew Wong (2):
>   gitk: Refactor code for binding modified function keys
>   gitk: Use bindshiftfunctionkey to bind Shift-F5
> 

Thanks, this series solves the problem for me.


Best,
Gábor

```

## Andrew Wong, 2012-10-12 14:17

Subject: Re: [PATCH v2 0/2] Re: gitk: can't reload commits with new key binding
Message-ID: <50782671.9010603@gmail.com>
URL: https://gitlist.dev/e/50782671.9010603%40gmail.com
In-Reply-To: <1349190285-7788-1-git-send-email-andrew.kw.w@gmail.com>

```
Can I get some feedback on these two patches? It'd be great to have them 
merged into gitk. Thanks.


On 10/02/2012 11:04 AM, Andrew Wong wrote:
> Refactored the code for binding modified function keys as Junio suggested.
>
> Andrew Wong (2):
>    gitk: Refactor code for binding modified function keys
>    gitk: Use bindshiftfunctionkey to bind Shift-F5
>
>   gitk | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
>

```

## Paul Mackerras, 2012-10-21 22:19

Subject: Re: [PATCH v2 0/2] Re: gitk: can't reload commits with new key binding
Message-ID: <20121021221901.GA7407@bloggs.ozlabs.ibm.com>
URL: https://gitlist.dev/e/20121021221901.GA7407%40bloggs.ozlabs.ibm.com
In-Reply-To: <1349190285-7788-1-git-send-email-andrew.kw.w@gmail.com>

```
On Tue, Oct 02, 2012 at 11:04:43AM -0400, Andrew Wong wrote:
> Refactored the code for binding modified function keys as Junio suggested.
> 
> Andrew Wong (2):
>   gitk: Refactor code for binding modified function keys
>   gitk: Use bindshiftfunctionkey to bind Shift-F5
> 
>  gitk | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)

Thanks, applied both patches.

Paul.

```
