From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Diff could also show the changes within lines Date: Wed, 12 Feb 2014 12:35:19 +0100 Message-ID: <87ppms5zt4.fsf@web.de> References: <86y51mx3x2.fsf@somewhere.org> <867g930xoz.fsf@somewhere.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1392204962 5948 80.91.229.3 (12 Feb 2014 11:36:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Feb 2014 11:36:02 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Feb 12 12:36:05 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WDY6k-0000RN-7C for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Feb 2014 12:36:02 +0100 Original-Received: from localhost ([::1]:38445 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDY6j-0002tc-R8 for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Feb 2014 06:36:01 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDY6P-0002mV-Cy for help-gnu-emacs@gnu.org; Wed, 12 Feb 2014 06:35:46 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDY6I-00071S-E7 for help-gnu-emacs@gnu.org; Wed, 12 Feb 2014 06:35:41 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:53472) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDY6I-00071M-39 for help-gnu-emacs@gnu.org; Wed, 12 Feb 2014 06:35:34 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WDY6G-0000Gk-6S for help-gnu-emacs@gnu.org; Wed, 12 Feb 2014 12:35:32 +0100 Original-Received: from ip-90-186-155-199.web.vodafone.de ([90.186.155.199]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Feb 2014 12:35:32 +0100 Original-Received: from michael_heerdegen by ip-90-186-155-199.web.vodafone.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Feb 2014 12:35:32 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 89 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-90-186-155-199.web.vodafone.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:lOaAKUBl8ydDQiMemmAUM7t7AMs= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:96035 Archived-At: "Sebastien Vauban" 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.