I found out that magit-ediff-dwim
cannot "read my mind" in a diff buffer when the point is on a hunk.
Intuitively, I would expect this command to need only two things to guess what I mean: a file (e.g. the file of the hunk at point) and either a revision or a range. In a revision buffer, magit-ediff-dwim
correctly guesses which revision ediff should use.
When visiting arbitrary diffs however, the function does not guess that "what I mean" is starting an ediff session using the same range as the one which defines the diff buffer.
Some scenarios to reproduce:
d r foo..bar
will spawn a diff buffer showing changes between revisionsfoo
andbar
;d d
when point is on branchbaz
in the refs buffer will spawn a diff buffer showing changes from the current branch tobaz
;d d
in the log buffer when the region spans commitsfoo
tobar
will spawn a diff buffer showing changes between revisionsfoo
andbar
.
In each of these situations, if I set the point on a hunk and call magit-ediff-dwim
, the function fails to read my mind.
I poked around magit-diff.el
and magit-ediff.el
and found that I could help magit read my mind by adding the following to magit-diff--dwim
:
@@ -616,6 +616,8 @@ If no DWIM context is found, nil is retu
(cons 'commit magit-buffer-refname))
((derived-mode-p 'magit-revision-mode)
(cons 'commit (car magit-refresh-args)))
+ ((derived-mode-p 'magit-diff-mode)
+ (nth 0 magit-refresh-args))
(t
(magit-section-case
([* unstaged] 'unstaged)
Disclaimer: I am not an E?Lisp developer by any means. I just threw the above together after looking up a few symbols' documentation or message
ing their value when trying to wrap my head around what was happening.
Onto questions.
- Am I missing something that would explain why
magit-ediff-dwim
should not read my mind in diff buffers, although it can in rev buffers? - Is this worth creating an issue on the Github tracker?
- Is the patch above sound? I figure maybe it is not appropriate to poke around
magit-refresh-args
, or maybe another case could be added to themagit-section-case
switch below.
Version: 20151118.241
from MELPA.
Additional disclaimer: sorry if I sound like I am complaining - magit is a wonderful piece of software that makes version control a very pleasant experience.