One Emacs package that has been with me for a very long time is diff-hl,1 and the reason is not its on-the-fly coloured fringe markers, but the fact that colours stay there when I visit the same buffer later. This is useful since more often than not I end my work day with something still in progress, so the next morning it’s easier to use diff-hl-next-hunk and diff-hl-previous-hunk to move around my unfinished edits.

However, I have put diff-hl aside because there have been some welcome improvements lately on the built-in diff-mode, especially the possibility to edit its buffer contents and commit straight from it.2 I now find myself using C-x v D (vc-root-diff) many times a day, and by using diff-mode more, I have started to appreciate one simple thing that was already available to me but have always ignored, that is the navigation among hunks with diff-hunk-next (n ) and diff-hunk-prev (p ).

The pattern, already become muscle memory, is the following:

  • C-x p p to enter the project I am working on
  • Visit the file I am interested in
  • Hit C-x v =
  • Move with either n or p to the desired hunk
  • Hit RET to jump to the hunk
  • Hit C-x 1 to hide the diff-mode buffer

Easy and quick. I guess one could even speed up the process by using something like recentf-mode, for instance, but I’ll leave that to you wild ELisp explorers.

By the way, after months with VC instead of Magit,3 the combination of vc-dir, vc-git, diff-mode, and shell-command has resulted in one of the most dreaded command any serious Emacs user can think of, one that I cannot even type out of fear of mystical forces coming after me. Let’s just say it involves package-delete and… Dear GNU, they’re already here.

  1. See: diff-hl↩︎

  2. See: ‘C-x v v’ on a diff buffer commits it as a patch (bug#52349)↩︎

  3. My actual focus on VC roughly started last year, see: Rebasing with VC↩︎