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..barwill spawn a diff buffer showing changes between revisions
d dwhen point is on branch
bazin the refs buffer will spawn a diff buffer showing changes from the current branch to
d din the log buffer when the region spans commits
barwill spawn a diff buffer showing changes between revisions
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-ediff.el and found that I could help magit read my mind by adding the following to
@@ -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
messageing their value when trying to wrap my head around what was happening.
- Am I missing something that would explain why
magit-ediff-dwimshould 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 the
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.