[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Diff could also show the changes within lines
From: |
Michael Heerdegen |
Subject: |
Re: Diff could also show the changes within lines |
Date: |
Wed, 12 Feb 2014 12:35:19 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
"Sebastien Vauban" <sva-news@mygooglest.com>
writes:
> I did, in a minimal Emacs configuration:
>
> (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))
>
> Weirdly enough, it does not work when done automatically, well when done
> interactively...
>
> In *all* cases, I see (in the *Messages* buffer):
>
> >>> BEGIN <<<
> >> I've refined the next hunk... << [2 times]
> >>> END <<<
>
> ... 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.
My guess is that diff-mode-hook is not a good place to push your
function to. Maybe it is called too early, and the effect is somehow
reverted later. You may try something like
(advice-add
'vc-diff :after
(lambda (&rest _)
(my--diff-make-fine-diffs-if-necessary)))
I wonder if that work's.
> So, I don't understand anything anymore... and don't know how to
> proceed to further debug this...
Have you already tried to (debug-on-entry 'my-diff-make-fine-diffs)? I
wonder how the buffer looks like after `my-diff-make-fine-diffs' is
done. You may try to find out what is going on later.
> 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?
I think it is best to display it just in a different frame after
starting edebug. Yes, it is very aggressive in capturing frames.
Regards,
Michael.
- Diff could also show the changes within lines, Sebastien Vauban, 2014/02/07
- Message not available
- Re: Diff could also show the changes within lines, Sebastien Vauban, 2014/02/10
- Re: Diff could also show the changes within lines,
Michael Heerdegen <=
- Message not available
- Re: Diff could also show the changes within lines, Sebastien Vauban, 2014/02/18
- Re: Diff could also show the changes within lines, Sebastien Vauban, 2014/02/18
- Re: Diff could also show the changes within lines, Sebastien Vauban, 2014/02/18
- Re: Diff could also show the changes within lines, Michael Heerdegen, 2014/02/18
- Message not available
- Re: Diff could also show the changes within lines, Sebastien Vauban, 2014/02/18
- Re: Diff could also show the changes within lines, Michael Heerdegen, 2014/02/18
- Message not available
- Re: Diff could also show the changes within lines, Sebastien Vauban, 2014/02/19
- Re: Diff could also show the changes within lines, Michael Heerdegen, 2014/02/19
- Re: Diff could also show the changes within lines, Stefan Monnier, 2014/02/18
- Re: Diff could also show the changes within lines, Michael Heerdegen, 2014/02/18