branch: elpa/magit
commit bf8fec3d8558e6fcde2a4fa98b65a70113295ab4
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit-diff-on-removed-line-p: Use magit-diff-visit-previous-blob
In [1: 9b4ce73f74] we stopped respecting the value of this variable.
1: 2025-07-30 9b4ce73f74a3a9dda769ade9fa52b59214f085dc
magit-diff-on-removed-line-p: New function
---
docs/magit.org | 17 ++++++++++-------
docs/magit.texi | 17 ++++++++++-------
lisp/magit-diff.el | 6 ++++--
3 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/docs/magit.org b/docs/magit.org
index 7c851be4447..bc18853ec0e 100644
--- a/docs/magit.org
+++ b/docs/magit.org
@@ -4105,14 +4105,17 @@ argument.
- User Option: magit-diff-visit-previous-blob ::
This option controls whether ~magit-diff-visit-file~ may visit the
- previous blob. When this is ~t~ (the default) and point is on a
- removed line in a diff for a committed change, then
- ~magit-diff-visit-file~ visits the blob from the last revision which
- still had that line.
+ previous blob.
- Currently this is only supported for committed changes, for staged
- and unstaged changes ~magit-diff-visit-file~ always visits the file in
- the working tree.
+ When this is ~t~ (the default) and point is on a removed line, then
+ ~magit-diff-visit-file~ visits the blob from the old/left commit,
+ which still has that line, instead of going to the new/right blob,
+ which removes that line.
+
+ Setting this to ~nil~ is discouraged. Instead place the cursor on an
+ added or context line, or on the heading, if you want to visit the
+ new/right side. That way you don't lose the ability to visit the
+ old/left side.
** Blaming
diff --git a/docs/magit.texi b/docs/magit.texi
index e17caec4842..1063204d5c7 100644
--- a/docs/magit.texi
+++ b/docs/magit.texi
@@ -4833,14 +4833,17 @@ except that they display the blob or file in another
window or frame.
@defopt magit-diff-visit-previous-blob
This option controls whether @code{magit-diff-visit-file} may visit the
-previous blob. When this is @code{t} (the default) and point is on a
-removed line in a diff for a committed change, then
-@code{magit-diff-visit-file} visits the blob from the last revision which
-still had that line.
+previous blob.
-Currently this is only supported for committed changes, for staged
-and unstaged changes @code{magit-diff-visit-file} always visits the file in
-the working tree.
+When this is @code{t} (the default) and point is on a removed line, then
+@code{magit-diff-visit-file} visits the blob from the old/left commit,
+which still has that line, instead of going to the new/right blob,
+which removes that line.
+
+Setting this to @code{nil} is discouraged. Instead place the cursor on an
+added or context line, or on the heading, if you want to visit the
+new/right side. That way you don't lose the ability to visit the
+old/left side.
@end defopt
@node Blaming
diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index a4db223be00..baa4253cc3e 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -3567,9 +3567,11 @@ last (visual) lines of the region."
(> (magit-point) content)))
(defun magit-diff-on-removed-line-p ()
- "Return t if point is on a removed line inside the body of a hunk."
+ "Return t if point is on a removed line inside the body of a hunk.
+If `magit-diff-visit-previous-blob' is nil, then always return nil."
(let ((section (magit-current-section)))
- (and (cl-typep section 'magit-hunk-section)
+ (and magit-diff-visit-previous-blob
+ (cl-typep section 'magit-hunk-section)
(not (oref section combined))
(= (char-after (pos-bol)) ?-))))