emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: diff-goto-source doesn't work for new files.


From: Óscar Fuentes
Subject: Re: diff-goto-source doesn't work for new files.
Date: Thu, 24 Apr 2008 22:32:56 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (windows-nt)

Óscar Fuentes <address@hidden> writes:

>     (if event (posn-set-point (event-end event)))
>     (let ((rev (not (save-excursion (beginning-of-line) (looking-at 
> "[-<]")))))
>       (destructuring-bind (buf line-offset pos src dst &optional switched)
> !     (diff-find-source-location other-file rev)
>         (pop-to-buffer buf)
>         (goto-char (+ (car pos) (cdr src)))
>         (diff-hunk-status-msg line-offset (diff-xor rev switched) t))))
> --- 1692,1698 ----
>     (if event (posn-set-point (event-end event)))
>     (let ((rev (not (save-excursion (beginning-of-line) (looking-at 
> "[-<]")))))
>       (destructuring-bind (buf line-offset pos src dst &optional switched)
> !     (diff-find-source-location other-file t)
>         (pop-to-buffer buf)
>         (goto-char (+ (car pos) (cdr src)))
>         (diff-hunk-status-msg line-offset (diff-xor rev switched) t))))
>
>
> I suppose that `rev' is there for a good reason, so if anyone can
> explain the logic behind it, I could go further on my attempt at fixing
> the bug.

After carefully reading the code (<g>) things are clearer now:

  ;; When pointing at a removal line, we probably want to jump to
  ;; the old location, and else to the new (i.e. as if reverting).
  ;; This is a convenient detail when using smerge-diff.
...
  (let ((rev (not (save-excursion (beginning-of-line) (looking-at "[-<]")))))

So `rev' means "go to the original file". Then, on the scenario
described on my original post, there is only one file, which acts as the
original, and there is no "new file", as far as diff-mode is
concerned. So the problem now is how to detect that circunstance inside
diff-goto-source (or better, diff-find-source-location) so it always
uses the "old file".

-- 
Oscar





reply via email to

[Prev in Thread] Current Thread [Next in Thread]