# [PATCH 2/2] git-gui blame add more common search hotkeys

3 messages from 2011-07-16 to 2011-07-20. Participants: David Fries, Pat Thoyts.
Thread: https://gitlist.dev/t/27828

## David Fries, 2011-07-16 16:59

Subject: [PATCH 2/2] git-gui blame add more common search hotkeys
Message-ID: <20110716165945.GA9722@spacedout.fries.net>
URL: https://gitlist.dev/e/20110716165945.GA9722%40spacedout.fries.net

```
add slash and Control-S to bring up search
enter, n, Shift-Enter, Shift-n to to go the next and previous entries

search hotkey return is find_next shift prev

Signed-off-by: David Fries <David@Fries.net>

---
 git-gui/lib/blame.tcl  |    4 ++++
 git-gui/lib/search.tcl |    4 +++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/git-gui/lib/blame.tcl b/git-gui/lib/blame.tcl
index 062091b..cc8c0ba 100644
--- a/git-gui/lib/blame.tcl
+++ b/git-gui/lib/blame.tcl
@@ -352,9 +352,13 @@ constructor new {i_commit i_path i_jump} {
 	bind $w_cviewer <Button-1>   [list focus $w_cviewer]
 	bind $w_file    <Visibility> [cb _focus_search $w_file]
 	bind $top       <F7>         [list searchbar::show $finder]
+	bind $top       <Key-slash>  [list searchbar::show $finder]
+	bind $top    <Control-Key-s> [list searchbar::show $finder]
 	bind $top       <Escape>     [list searchbar::hide $finder]
 	bind $top       <F3>         [list searchbar::find_next $finder]
+	bind $top       <Key-n>      [list searchbar::find_next $finder]
 	bind $top       <Shift-F3>   [list searchbar::find_prev $finder]
+	bind $top    <Shift-Key-n>   [list searchbar::find_prev $finder]
 	bind $top    <Control-Key-g> [list linebar::show $gotoline]
 	catch { bind $top <Shift-Key-XF86_Switch_VT_3> [list searchbar::find_prev $finder] }
 
diff --git a/git-gui/lib/search.tcl b/git-gui/lib/search.tcl
index 7fdbf87..ef3486f 100644
--- a/git-gui/lib/search.tcl
+++ b/git-gui/lib/search.tcl
@@ -35,6 +35,8 @@ constructor new {i_w i_text args} {
 	grid remove $w
 
 	trace add variable searchstring write [cb _incrsearch_cb]
+	bind $w.ent <Return> [cb find_next]
+	bind $w.ent <Shift-Return> [cb find_prev]
 	
 	bind $w <Destroy> [list delete_this $this]
 	return $this
@@ -196,4 +198,4 @@ method scrolled {} {
 	}
 }
 
-}
\ No newline at end of file
+}
-- 
1.7.2.5

```

## Pat Thoyts, 2011-07-19 14:35

Subject: Re: [PATCH 2/2] git-gui blame add more common search hotkeys
Message-ID: <87sjq2cp8t.fsf@fox.patthoyts.tk>
URL: https://gitlist.dev/e/87sjq2cp8t.fsf%40fox.patthoyts.tk
In-Reply-To: <20110716165945.GA9722@spacedout.fries.net>

```
David Fries <david@fries.net> writes:

>add slash and Control-S to bring up search
>enter, n, Shift-Enter, Shift-n to to go the next and previous entries
>
>search hotkey return is find_next shift prev
>
>Signed-off-by: David Fries <David@Fries.net>
>

Thank you for this. It looks like a useful feature and I'll apply this
to git-gui with some modifications. Note that Paul Mackerras is the
maintainer of gitk not git-gui.

It is worth putting a bit more detail into the commit message as in
general that is all the context a maintainer has to decide what the
patch is doing and how it should be tested. In this case I'll replace it
with the following:

   git-gui: Add keyboard shortcuts for search and goto commands in blame
   view.

   Use forward-slash or Control-S to bring up the search dialog.
   In the blame view, Enter or 'n' jump to the next selected region
   while
   Shift-Enter or Shift-n will jump to the previous selected region.
   Within the search control, hitting Enter will now jump to the next
   matching
   region.

   Signed-off-by: David Fries <David@Fries.net>
   Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>

That aside, the goto-line feature works fine for me. I don't think the
n, Shift-n binding is working though. When I have the focus in the blame
window and enter 'n' it tries to add an 'n' to the text in the search
box. The use of Enter and Shift-Enter makes sense and works as I
expect. So I will drop the 'n' and 'Shift-n' bindings I think.

The -accelerator field on a menu specifies the text to show. Its more
usual to show "Ctrl-G" than "Control-Key-G" here so I'll adjust that as
well. The 'bind' command actually ties up the key binding to the menu
action.

With the above changes, I'll apply this to git-gui's master (which lives
at repo.or.cz/git-gui.git) and it will get merged into git on the next
merge.

Cheers,
Pat Thoyts

-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD

```

## David Fries, 2011-07-20 02:56

Subject: Re: [PATCH 2/2] git-gui blame add more common search hotkeys
Message-ID: <20110720025601.GE26701@spacedout.fries.net>
URL: https://gitlist.dev/e/20110720025601.GE26701%40spacedout.fries.net
In-Reply-To: <87sjq2cp8t.fsf@fox.patthoyts.tk>

```
On Tue, Jul 19, 2011 at 03:35:30PM +0100, Pat Thoyts wrote:
> David Fries <david@fries.net> writes:
> 
> That aside, the goto-line feature works fine for me. I don't think the
> n, Shift-n binding is working though. When I have the focus in the blame
> window and enter 'n' it tries to add an 'n' to the text in the search
> box. The use of Enter and Shift-Enter makes sense and works as I
> expect. So I will drop the 'n' and 'Shift-n' bindings I think.

I have some 6000 some line files that I was preparing change sets
and was needing to jump to a specific line.  That's what prompted me
to add the goto feature, I just went ahead and added the search
hotkeys while I was in looking at it.  I apparently didn't do enough
testing on the search, it's <Key-N> not the <Shift-Key-n> that I had
in there.  The n and N only work when the search bar is dismissed with
escape or something.  I'm more used to vi's searching where the search
field is dismissed with return and there isn't a search field left to
add to.  I'm fine with dropping the n/N bindings.

> The -accelerator field on a menu specifies the text to show. Its more
> usual to show "Ctrl-G" than "Control-Key-G" here so I'll adjust that as
> well. The 'bind' command actually ties up the key binding to the menu
> action.
> 
> With the above changes, I'll apply this to git-gui's master (which lives
> at repo.or.cz/git-gui.git) and it will get merged into git on the next
> merge.

Sounds good, thanks for merging it.

-- 
David Fries <david@fries.net>    PGP pub CB1EE8F0
http://fries.net/~david/

```
