notes from /dev/null

by Charles Choi 최민수


Mousing with Magit

29 Jun 2023  Charles Choi

One of the more pleasant surprises I have found with Magit is that it can be driven by a mouse, particularly when context-menu-mode in Emacs 28+ is turned on. Some Magit tasks that I’ve found delight in using a mouse for are:

  • Staging/unstaging changes (both hunks and files)
  • Toggling command options, particularly when pushing or pulling

Managing the staging and unstaging of changes is done by raising the context menu over the selected change. Illustrating this is the example below, which shows the file launchutil.py with unstaged changes. Double-clicking on the file (or single-clicking on its left fringe/gutter) will toggle open the list of changes to that file. With the list of changes open, you can use the context menu to stage each hunk individually. By right mouse button clicking on the unstaged file itself, you can select to stage the whole file.

Staging changes in Magit with a mouse.

Note that all main menu selections for the major mode are replicated in the context menu, in this case as a sub-menu under the label Magit. You can filter the context menu so that only the major mode main menu selections are shown when pressing the control key and the right mouse button simultaneously.

Commiting the above changes with a mouse can be done from the Magit menu as shown below. Command options such as --verbose can be selected by clicking on it with the mouse.

Commiting changes in Magit with a mouse.

Once you're happy with the committed changes, you can push your branch up to your repo. The example below shows how to push a new branch with the --force-with-lease option enabled.

Pushing changes in Magit with a mouse.

While Magit's Transient interface is highly tuned for keyboard operation, it’s nice to know that you don’t always have to use it. More often than not I catch myself reaching for the mouse for toggling options now. Try it, you might like it!

References

emacs

 

AboutMastodonInstagramGitHub

Feeds & TagsGet Captee for macOS

Powered by Pelican