diff mbox series

Add hotkey to toggle "Amend Last Commit" radio selector

Message ID 20190902195618.3820-1-birger.sp@gmail.com (mailing list archive)
State New, archived
Headers show
Series Add hotkey to toggle "Amend Last Commit" radio selector | expand

Commit Message

Birger Skogeng Pedersen Sept. 2, 2019, 7:56 p.m. UTC
Selecting whether to do a "New Commit" or "Amend Last Commit" does not have
a hotkey.

With this patch, the user may toggle between the two options with
CTRL/CMD+e.

Signed-off-by: Birger Skogeng Pedersen <birger.sp@gmail.com>
---
 git-gui.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Bert Wesarg Sept. 3, 2019, 8:52 a.m. UTC | #1
Birger,

On Mon, Sep 2, 2019 at 9:56 PM Birger Skogeng Pedersen
<birger.sp@gmail.com> wrote:
>
> Selecting whether to do a "New Commit" or "Amend Last Commit" does not have
> a hotkey.
>
> With this patch, the user may toggle between the two options with
> CTRL/CMD+e.

David A. (in Cc from git-cola) suggested, that we try to re-use
existing key bindings in Git GUIs. Here is Git-Cola hotkeys:

http://git-cola.github.io/share/doc/git-cola/hotkeys.html

and this indicates, that it already uses CTRL+m for "amend". Though
I'm unsure if this is a toggle like in git-gui or a one-shot. David
A., can you please clarify?

>
> Signed-off-by: Birger Skogeng Pedersen <birger.sp@gmail.com>
> ---
>  git-gui.sh | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/git-gui.sh b/git-gui.sh
> index 5bc21b8..14be1e0 100755
> --- a/git-gui.sh
> +++ b/git-gui.sh
> @@ -2640,6 +2640,16 @@ proc show_less_context {} {
>         }
>  }
>
> +proc toggle_commit_type {} {
> +       global selected_commit_type
> +       if {[string match amend* $selected_commit_type]} {
> +               set selected_commit_type new
> +       } else {
> +               set selected_commit_type amend
> +       }
> +       do_select_commit_type
> +}
> +
>  ######################################################################
>  ##
>  ## ui construction
> @@ -3843,6 +3853,7 @@ bind .   <$M1B-Key-equal> {show_more_context;break}
>  bind .   <$M1B-Key-plus> {show_more_context;break}
>  bind .   <$M1B-Key-KP_Add> {show_more_context;break}
>  bind .   <$M1B-Key-Return> do_commit
> +bind .   <$M1B-Key-e> toggle_commit_type

The commit type has also a two toggle menu entries (under "Commit")
they should now also indicate the key binding.
disable

Though how to express a toggle keybinding in the menu? I don't know if
you can assign the same keybinding to the same menu entry. Maybe we
need to add/remove the keybinding depending on the current mode.

Bert

>  foreach i [list $ui_index $ui_workdir] {
>         bind $i <Button-1>       { toggle_or_diff click %W %x %y; break }
>         bind $i <$M1B-Button-1>  { add_one_to_selection %W %x %y; break }
> --
> 2.21.0.windows.1
>
Bert Wesarg Sept. 3, 2019, 10:25 a.m. UTC | #2
David,

On Tue, Sep 3, 2019 at 10:52 AM Bert Wesarg <bert.wesarg@googlemail.com> wrote:
>
> Birger,
>
> On Mon, Sep 2, 2019 at 9:56 PM Birger Skogeng Pedersen
> <birger.sp@gmail.com> wrote:
> >
> > Selecting whether to do a "New Commit" or "Amend Last Commit" does not have
> > a hotkey.
> >
> > With this patch, the user may toggle between the two options with
> > CTRL/CMD+e.
>
> David A. (in Cc from git-cola) suggested, that we try to re-use
> existing key bindings in Git GUIs. Here is Git-Cola hotkeys:
>
> http://git-cola.github.io/share/doc/git-cola/hotkeys.html
>
> and this indicates, that it already uses CTRL+m for "amend". Though
> I'm unsure if this is a toggle like in git-gui or a one-shot. David
> A., can you please clarify?

git-gui already assigns CTRL+m to "Local mergeā€¦"

sorry. I think trying to synchronize the keybindings seems impossible.

Bert

>
> >
> > Signed-off-by: Birger Skogeng Pedersen <birger.sp@gmail.com>
> > ---
> >  git-gui.sh | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/git-gui.sh b/git-gui.sh
> > index 5bc21b8..14be1e0 100755
> > --- a/git-gui.sh
> > +++ b/git-gui.sh
> > @@ -2640,6 +2640,16 @@ proc show_less_context {} {
> >         }
> >  }
> >
> > +proc toggle_commit_type {} {
> > +       global selected_commit_type
> > +       if {[string match amend* $selected_commit_type]} {
> > +               set selected_commit_type new
> > +       } else {
> > +               set selected_commit_type amend
> > +       }
> > +       do_select_commit_type
> > +}
> > +
> >  ######################################################################
> >  ##
> >  ## ui construction
> > @@ -3843,6 +3853,7 @@ bind .   <$M1B-Key-equal> {show_more_context;break}
> >  bind .   <$M1B-Key-plus> {show_more_context;break}
> >  bind .   <$M1B-Key-KP_Add> {show_more_context;break}
> >  bind .   <$M1B-Key-Return> do_commit
> > +bind .   <$M1B-Key-e> toggle_commit_type
>
> The commit type has also a two toggle menu entries (under "Commit")
> they should now also indicate the key binding.
> disable
>
> Though how to express a toggle keybinding in the menu? I don't know if
> you can assign the same keybinding to the same menu entry. Maybe we
> need to add/remove the keybinding depending on the current mode.
>
> Bert
>
> >  foreach i [list $ui_index $ui_workdir] {
> >         bind $i <Button-1>       { toggle_or_diff click %W %x %y; break }
> >         bind $i <$M1B-Button-1>  { add_one_to_selection %W %x %y; break }
> > --
> > 2.21.0.windows.1
> >
Bert Wesarg Sept. 3, 2019, 4:20 p.m. UTC | #3
Birger,

On Tue, Sep 3, 2019 at 10:52 AM Bert Wesarg <bert.wesarg@googlemail.com> wrote:
>
> Birger,
>
> On Mon, Sep 2, 2019 at 9:56 PM Birger Skogeng Pedersen
> <birger.sp@gmail.com> wrote:
> >
> > Selecting whether to do a "New Commit" or "Amend Last Commit" does not have
> > a hotkey.
> >
> > With this patch, the user may toggle between the two options with
> > CTRL/CMD+e.
>
> David A. (in Cc from git-cola) suggested, that we try to re-use
> existing key bindings in Git GUIs. Here is Git-Cola hotkeys:
>
> http://git-cola.github.io/share/doc/git-cola/hotkeys.html
>
> and this indicates, that it already uses CTRL+m for "amend". Though
> I'm unsure if this is a toggle like in git-gui or a one-shot. David
> A., can you please clarify?
>
> >
> > Signed-off-by: Birger Skogeng Pedersen <birger.sp@gmail.com>
> > ---
> >  git-gui.sh | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/git-gui.sh b/git-gui.sh
> > index 5bc21b8..14be1e0 100755
> > --- a/git-gui.sh
> > +++ b/git-gui.sh
> > @@ -2640,6 +2640,16 @@ proc show_less_context {} {
> >         }
> >  }
> >
> > +proc toggle_commit_type {} {
> > +       global selected_commit_type
> > +       if {[string match amend* $selected_commit_type]} {
> > +               set selected_commit_type new
> > +       } else {
> > +               set selected_commit_type amend
> > +       }
> > +       do_select_commit_type
> > +}
> > +
> >  ######################################################################
> >  ##
> >  ## ui construction
> > @@ -3843,6 +3853,7 @@ bind .   <$M1B-Key-equal> {show_more_context;break}
> >  bind .   <$M1B-Key-plus> {show_more_context;break}
> >  bind .   <$M1B-Key-KP_Add> {show_more_context;break}
> >  bind .   <$M1B-Key-Return> do_commit
> > +bind .   <$M1B-Key-e> toggle_commit_type
>
> The commit type has also a two toggle menu entries (under "Commit")
> they should now also indicate the key binding.
> disable
>
> Though how to express a toggle keybinding in the menu? I don't know if
> you can assign the same keybinding to the same menu entry. Maybe we
> need to add/remove the keybinding depending on the current mode.

that works. I squashed this into your commit and pushed to GitHub
(sorry, still no path-per-mail)

https://github.com/bertwesarg/git-gui/commit/245bb9944e3d1c6b266c58b56d316f283ed3516b

Bert

>
> Bert
>
> >  foreach i [list $ui_index $ui_workdir] {
> >         bind $i <Button-1>       { toggle_or_diff click %W %x %y; break }
> >         bind $i <$M1B-Button-1>  { add_one_to_selection %W %x %y; break }
> > --
> > 2.21.0.windows.1
> >
diff mbox series

Patch

diff --git a/git-gui.sh b/git-gui.sh
index 5bc21b8..14be1e0 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -2640,6 +2640,16 @@  proc show_less_context {} {
 	}
 }
 
+proc toggle_commit_type {} {
+	global selected_commit_type
+	if {[string match amend* $selected_commit_type]} {
+		set selected_commit_type new
+	} else {
+		set selected_commit_type amend
+	}
+	do_select_commit_type
+}
+
 ######################################################################
 ##
 ## ui construction
@@ -3843,6 +3853,7 @@  bind .   <$M1B-Key-equal> {show_more_context;break}
 bind .   <$M1B-Key-plus> {show_more_context;break}
 bind .   <$M1B-Key-KP_Add> {show_more_context;break}
 bind .   <$M1B-Key-Return> do_commit
+bind .   <$M1B-Key-e> toggle_commit_type
 foreach i [list $ui_index $ui_workdir] {
 	bind $i <Button-1>       { toggle_or_diff click %W %x %y; break }
 	bind $i <$M1B-Button-1>  { add_one_to_selection %W %x %y; break }