From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleksandr Gavenko Newsgroups: gmane.emacs.bugs Subject: bug#12747: 23.4; diff-auto-refine-mode process only last hunk in diff (must ALL). Date: Sun, 28 Oct 2012 21:38:07 +0200 Organization: Oleksandr Gavenko , http://gavenkoa.users.sf.net Message-ID: <87a9v6bd5s.fsf@gavenkoa.example.com> References: <87y5iqbxqn.fsf@gavenkoa.example.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1351453128 32750 80.91.229.3 (28 Oct 2012 19:38:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 28 Oct 2012 19:38:48 +0000 (UTC) Cc: 12747@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 28 20:38:54 2012 Return-path: Envelope-to: geb-bug-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 1TSYhC-0001bY-Hm for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Oct 2012 20:38:54 +0100 Original-Received: from localhost ([::1]:59103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSYh4-0007jk-G8 for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Oct 2012 15:38:46 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSYh0-0007id-Ph for bug-gnu-emacs@gnu.org; Sun, 28 Oct 2012 15:38:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TSYgz-0000Su-6O for bug-gnu-emacs@gnu.org; Sun, 28 Oct 2012 15:38:42 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSYgz-0000Sq-0r for bug-gnu-emacs@gnu.org; Sun, 28 Oct 2012 15:38:41 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TSYjG-0006rf-Cq for bug-gnu-emacs@gnu.org; Sun, 28 Oct 2012 15:41:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Oleksandr Gavenko Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 28 Oct 2012 19:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12747 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 12747-submit@debbugs.gnu.org id=B12747.135145323826357 (code B ref 12747); Sun, 28 Oct 2012 19:41:02 +0000 Original-Received: (at 12747) by debbugs.gnu.org; 28 Oct 2012 19:40:38 +0000 Original-Received: from localhost ([127.0.0.1]:36945 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSYis-0006r4-5e for submit@debbugs.gnu.org; Sun, 28 Oct 2012 15:40:38 -0400 Original-Received: from mail-lb0-f172.google.com ([209.85.217.172]:41357) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TSYio-0006qs-3R for 12747@debbugs.gnu.org; Sun, 28 Oct 2012 15:40:36 -0400 Original-Received: by mail-lb0-f172.google.com with SMTP id k13so2898500lbo.3 for <12747@debbugs.gnu.org>; Sun, 28 Oct 2012 12:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:organization:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=axlfwv9bMXCcD8TlKIxtgQ/G5aqDG2GI0nT5b0kaVfo=; b=k4TKv6YM7VW+CeiUYErkBKMyg+sYCE2nvtXH0dm+q0N+tJveoUMKlKzNMBJOdJjUuP mOn1oFRTHta1hD2hECfDsDeScmvtYwfurWpKQ5/6ojdbosPBwsHYo9XQTBCvdrbVTvTu vdAUeMcaq3+RnOGXAsUtitCnTSl8cGg/qfYn4D7ogEwNucQo5zc3xRZ3VgvTwx8SzCL/ Sq0cjiGWGpV1mCVEO9PQwiPyzGXlORpap1mEmw1LKEwlMDBPPK815vzRwrKXkQyy08OO oN+ZBvwiCV3g6EAHuz2FO7Vg8Iehp9/xX1AMVV0MTsNaDY/O6DC2AJ4eElRldJF0Xq95 1Uwg== Original-Received: by 10.152.135.41 with SMTP id pp9mr25627182lab.7.1351453091344; Sun, 28 Oct 2012 12:38:11 -0700 (PDT) Original-Received: from localhost ([37.229.16.202]) by mx.google.com with ESMTPS id so7sm2373228lab.0.2012.10.28.12.38.09 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 28 Oct 2012 12:38:10 -0700 (PDT) Original-Received: by localhost (sSMTP sendmail emulation); Sun, 28 Oct 2012 21:38:07 +0200 In-Reply-To: (Stefan Monnier's message of "Sun, 28 Oct 2012 09:54:22 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:66154 Archived-At: On 2012-10-28, Stefan Monnier wrote: >> If I enable diff-auto-refine-mode in all diff-mode buffers: >> (defun my-diff-auto-refine-mode-on () (diff-auto-refine-mode 1)) >> (add-hook 'diff-mode-hook 'my-diff-auto-refine-mode-on) >> I see actions only on last hunk in diff. > > I'm not sure I understand what you mean. `diff-auto-refine-mode' does > not refine-highlight all the hunks at once (quoting the docstring): > > When enabled, Emacs automatically highlights > changes in detail as the user visits hunks. > > "as the user visits the hunks" means that it's only highlighted in > response to "n" and "p" (and a few related operations). > Ok. But it's difficult to understand. For example manual section "22.10 Diff Mode" doesn't say anything about concepts of visiting hunks... I forget add another essential details. I use this functionality with 'C-x v =' (runs the command vc-diff). And got highlighting in detail only for last hunk. Next I save *vc-diff* buffer to file and reopen it. Now I got highlighting in detail only in first hunk. This behaviour frustrate me, until I got understanding of working model from you. > This is not a bug. IIUC you'd like the refinement to be done in any > hunk that is ever displayed, right? Yes. I never use "n" or "p" for moving around *diff* buffer. Just "arrows" and "pages". So in my work-flow 'diff-auto-refine-mode' do nothing... > If so, that is a valid request for enhancement, and I fully agree. That is! Also I would be glad to see alias for: (diff-auto-refine-mode 1) in form: (defun diff-auto-refine-mode-on () (diff-auto-refine-mode 1)) to simplify usage in hooks... > If someone is interested in implementing it, here's how I think it would > have to work: > - add a font-lock-keywords rule in diff-mode which simply registers the > region displayed in a buffer-local var `diff--regions-displayed'. > - have an idle timer that checks `diff--regions-displayed' and refines > all the hunks in those regions (and it should also font-lock those > hunks at the same time, so that if some of the hunk is not yet > displayed and not yet font-locked, displaying it later on won't cause > re-refining the hunk). > Sound very good. FYI I heard about refining in emacs-help: http://thread.gmane.org/gmane.emacs.help/87082/focus=87093 Diff could also show the changes within lines Tom suggest add to 'diff-mode-hook' such code: (save-excursion (goto-char (point-min)) (while (not (eobp)) (diff-hunk-next)))) As exercise I try make some code myself: (defvar diff-auto+-refine-idle-time 2 "Time before highlighting take place XXX") (defvar diff-auto+-refine-idle-timer nil "Timer for highlighting XXX") (defun diff-auto+-refine-action () "TODO how about preventing to process already processed regions??" (when (eq major-mode 'diff-mode) (message "%s: diff-auto+-refine-action" (format-time-string "%M:%S" (current-time))) (diff-refine-hunk))) (defun diff-auto+-refine-mode (&optional arg) "Auto refine current hunk in diff mode." (interactive "P") (if (not arg) (if diff-auto+-refine-idle-timer (diff-auto+-refine-mode -1) (diff-auto+-refine-mode 1)) (if (and (number-or-marker-p arg) (< 0 (prefix-numeric-value arg))) (unless diff-auto+-refine-idle-timer (setq diff-auto+-refine-idle-timer (run-with-idle-timer 2 t 'diff-auto+-refine-action))) (when diff-auto+-refine-idle-timer (cancel-timer diff-auto+-refine-idle-timer) (setq diff-auto+-refine-idle-timer nil))))) which does not use 'font-lock-keywords'. I am inexperience Elisp hacker and don't understand how can >>font-lock-keywords rule registers the region displayed<<. Does this mean register MATCHER with always fail but perform side effect by updating suggested 'diff--regions-displayed' variable? Also I can't found function that return visible to user region to proper highlight all visible hunks instead current... As I have many question which involve teaching of me I ask them in emacs-help: http://permalink.gmane.org/gmane.emacs.help/87474 Function that return visible to user region and performing action on demand. http://permalink.gmane.org/gmane.emacs.help/87472 idle-timer for processing all buffers with selected minor-mode. -- Best regards!