help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Diff could also show the changes within lines


From: Sebastien Vauban
Subject: Re: Diff could also show the changes within lines
Date: Mon, 10 Feb 2014 16:55:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt)

Hello Michael,

Michael Heerdegen wrote:
> "Sebastien Vauban" writes:
>
>> Now, while it's still being called, and still going in the `while' loop,
>> it does not refine any hunk anymore...
>
> Did you try to edebug (this looks like a good exercise in debugging!)?

I did, in a minimal Emacs configuration:

--8<---------------cut here---------------start------------->8---
(load-theme 'leuven t)

;; mode for viewing/editing context diffs
(with-eval-after-load "diff-mode"

  (defun my-diff-make-fine-diffs ()
    "Enable Diff Auto Refine mode."
    (interactive)
    (message ">>> BEGIN <<<")
    (let (diff-auto-refine-mode)
      (condition-case nil
          (save-excursion
            (goto-char (point-min))
            (while (not (eobp))
              (diff-hunk-next)
              (diff-refine-hunk)
              (message ">> I've refined the next hunk... <<")))
        (error nil))
      (run-at-time 0.0 nil
                   (lambda ()
                     (if (eq major-mode 'diff-mode)
                         ;; put back the cursor only if still in a Diff buffer
                         ;; after the delay
                         (goto-char (point-min))))))
    (message ">>> END <<<"))

  (defun my--diff-make-fine-diffs-if-necessary ()
    "Auto-refine only the regions of 14,000 bytes or less."
    ;; check for auto-refine limit
    (unless (> (buffer-size) 14000)
      (my-diff-make-fine-diffs)))

  (add-hook 'diff-mode-hook
            'my--diff-make-fine-diffs-if-necessary))
--8<---------------cut here---------------end--------------->8---

Weirdly enough, it does not work when done automatically, well when done
interactively...

In *all* cases, I see (in the *Messages* buffer):

--8<---------------cut here---------------start------------->8---
>>> BEGIN <<<
>> I've refined the next hunk... << [2 times]
>>> END <<<
--8<---------------cut here---------------end--------------->8---

... so, even when done by the hook, I see those messages, as if the
refining was done, but it's not visible in the Diff buffer, as you can
see on http://screencast.com/t/e7et4xeO.

When Edebugging, or when going to the *vc-diff* buffer and calling M-x
my-diff-make-fine-diffs, the same messages appear in the *Messages*
buffer, but the buffer is well colored differently, as you can see on
http://screencast.com/t/K2VdxlF2fMld.

So, I don't understand anything anymore... and don't know how to
proceed to further debug this...

Side (though important) question: when Edebugging, as soon as I step
through the function, the *vc-diff* buffer disappears from my
sight.  I always have to switch to it, and check what changed, to see
what's going on.  Is there a way to make the buffer (on which the code
is applied) stay visible during the stepping session?

Best regards,
  Seb

-- 
Sebastien Vauban


reply via email to

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