aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2025-09-27 09:14:58 +0200
committerJonas Bernoulli <jonas@bernoul.li>2025-09-27 09:14:58 +0200
commite26f60b5aaa3ca0f71ac282018ce9c7d7a457c08 (patch)
tree31a633547f5c45405594f58b127c16dca98db8da
parentafa417fec7f3178b3f38fb14b07b713506cc230d (diff)
magit-jump-to-revision-diffstat: Jump to diffstat file from hunk
Before the menu `magit-revision-jump' was added, when point is on a file in a diff "j" (`magit-jump-to-diffstat-or-diff') jumped to the respective file within the diffstat. For `magit-diff-mode' it still does that. In `magit-revision-mode' "j" is now bound to `magit-revision-jump', with partially shadows the above behavior. To continue to allow quickly jumping between a file in a revision diff and the same file listed in the diffstat, `magit-revision-jump' pivots to calling `magit-jump-to-diffstat-or-diff' when invoked in those locations. The hope was that would preserve enough of the old behavior to make everyone happy. I.e., on a file jump to the other place that file is listed (as before), everywhere else (or with a prefix argument) show the menu, letting the user explicitly choose where to jump to this time around (previously this would have jumped to the diffstat). Users who want the old behavior back can do: (keymap-unset magit-revision-mode-map "j" t) Instead of adding a more explicit knob to restore the old behavior, this commit improves a variation: If `magit-jump-revision-diffstat' is invoked on a hunk (via "j s"), that now goes to the respective file in the diffstat, instead of to the heading of the diffstat itself. The hope is that going to a more precise location outweighs the added cost of having to press "j s" instead of just "j" to go to the diffstat. Do the same for `magit-jump-to-revision-diffstat', so that those users, who remove the new binding in `magit-revision-mode-map', can benefit too. Now let's just hope nobody dislikes going to the file heading instead of to the diffstat heading. Closes #5442.
-rw-r--r--CHANGELOG3
-rw-r--r--lisp/magit-diff.el11
2 files changed, 12 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 5b47f4b..82b8c63 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,9 @@
- A form from the ~cond-let~ library made it into the autoloads file,
where that library isn't being loaded. #5451
+- Improved commands for jumping to specific sections in revision
+ buffers. #5442
+
* v4.4.0 2025-09-09
- At least Emacs 28.1 is required now. Emacs 30.1 was released
diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 5e5522a..a112bf5 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -2005,8 +2005,13 @@ like 'magit-jump-to-diffstat-or-diff'."
(oref magit-root-section children))
(interactive "P")
(cond-let
- ([section (cl-find-if (##eq (oref % type) 'diffstat)
- (oref magit-root-section children))]
+ ([section (magit-get-section
+ (append (magit-section-case
+ (file `((file . ,(oref it value)) (diffstat)))
+ (hunk `((file . ,(magit-section-parent-value it))
+ (diffstat)))
+ (t '((diffstat))))
+ (magit-section-ident magit-root-section)))]
(goto-char (oref section start))
(when expand
(with-local-quit (magit-section-show section))
@@ -2038,6 +2043,8 @@ section or a child thereof."
(append (magit-section-case
([file diffstat] `((file . ,(oref it value))))
(file `((file . ,(oref it value)) (diffstat)))
+ (hunk `((file . ,(magit-section-parent-value it))
+ (diffstat)))
(t '((diffstat))))
(magit-section-ident magit-root-section)))]
(goto-char (oref section start))