From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#32460: 27.0.50; diff-mode sometimes doesn't refine hunks Date: Thu, 16 Aug 2018 23:48:05 +0300 Organization: LINKOV.NET Message-ID: <87zhxmhz4a.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1534455613 14859 195.159.176.226 (16 Aug 2018 21:40:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 16 Aug 2018 21:40:13 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) To: 32460@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 16 23:40:09 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fqQ01-0003lR-5O for geb-bug-gnu-emacs@m.gmane.org; Thu, 16 Aug 2018 23:40:09 +0200 Original-Received: from localhost ([::1]:58228 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqQ27-00017Z-6B for geb-bug-gnu-emacs@m.gmane.org; Thu, 16 Aug 2018 17:42:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqQ1v-00015z-1y for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2018 17:42:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqQ1q-00082M-Ty for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2018 17:42:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47912) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fqQ1q-00082I-QF for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2018 17:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fqQ1q-0003AA-Jc for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2018 17:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 16 Aug 2018 21:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 32460 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.153445566611979 (code B ref -1); Thu, 16 Aug 2018 21:42:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 Aug 2018 21:41:06 +0000 Original-Received: from localhost ([127.0.0.1]:52930 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fqQ0u-000376-UA for submit@debbugs.gnu.org; Thu, 16 Aug 2018 17:41:06 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44107) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fqQ0s-000369-UH for submit@debbugs.gnu.org; Thu, 16 Aug 2018 17:41:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqQ0m-0007ce-VU for submit@debbugs.gnu.org; Thu, 16 Aug 2018 17:40:57 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:42408) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fqQ0m-0007cX-Rv for submit@debbugs.gnu.org; Thu, 16 Aug 2018 17:40:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqQ0m-0000Tp-0L for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2018 17:40:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqQ0i-0007aK-0I for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2018 17:40:55 -0400 Original-Received: from homie-sub3.mail.dreamhost.com ([69.163.253.7]:44685 helo=homiemail-a22.g.dreamhost.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fqQ0h-0007Zh-PA for bug-gnu-emacs@gnu.org; Thu, 16 Aug 2018 17:40:51 -0400 Original-Received: from homiemail-a22.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a22.g.dreamhost.com (Postfix) with ESMTP id 95A06114066 for ; Thu, 16 Aug 2018 14:40:49 -0700 (PDT) Original-Received: from localhost.linkov.net (m91-129-110-6.cust.tele2.ee [91.129.110.6]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by homiemail-a22.g.dreamhost.com (Postfix) with ESMTPSA id E1F5E114065 for ; Thu, 16 Aug 2018 14:40:48 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:149542 Archived-At: --=-=-= Content-Type: text/plain It's difficult to debug a sporadic problem when automatic diff refinement doesn't display refined overlays on some diff hunks occasionally. Looking at the code, it seems there is a possible race condition when diff--font-lock-refined calls diff-hunk-next that sets a timer that later might remove and try to re-add again overlays already added by the direct call of diff--refine-hunk from diff--font-lock-refined. Also diff-hunk-next prevents multiple consequent calls from refining a set of hunks by checking diff--auto-refine-data. To avoid such double refinement, this patch let-binds diff-auto-refine-mode to nil before calling diff-hunk-next for non-interactive navigation (it calls diff--refine-hunk explicitly below): --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=diff-refine.1.patch diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index b91a2ba45a..175687f184 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2077,7 +2088,9 @@ diff--font-lock-refined (point) 'diff--font-lock-refined nil max))) (let* ((min (point)) (beg (or (ignore-errors (diff-beginning-of-hunk)) - (ignore-errors (diff-hunk-next) (point)) + (ignore-errors (let ((diff-auto-refine-mode nil)) + (diff-hunk-next)) + (point)) max))) (while (< beg max) (let ((end @@ -2092,7 +2105,10 @@ diff--font-lock-refined (overlay-put ol 'modification-hooks '(diff--font-lock-refine--refresh)))) (goto-char (max beg end)) - (setq beg (or (ignore-errors (diff-hunk-next) (point)) max))))))) + (setq beg (or (ignore-errors (let ((diff-auto-refine-mode nil)) + (diff-hunk-next)) + (point)) + max))))))) (defun diff--font-lock-refine--refresh (ol _after _beg _end &optional _len) (delete-overlay ol)) --=-=-=--