From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: David Landell Newsgroups: gmane.emacs.bugs Subject: bug#43651: 27.1; compile.el should not parse its own header for errors Date: Mon, 28 Sep 2020 16:40:45 +0200 Message-ID: <874kniynf6.fsf@xwing.i-did-not-set--mail-host-address--so-tickle-me> References: <87blhrzeez.fsf@xwing.i-did-not-set--mail-host-address--so-tickle-me> <87lfguui8b.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7411"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 43651@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 28 16:41:40 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kMuLT-0001pd-72 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Sep 2020 16:41:39 +0200 Original-Received: from localhost ([::1]:40428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMuLS-0002zP-7h for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Sep 2020 10:41:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kMuKt-0002Mb-6V for bug-gnu-emacs@gnu.org; Mon, 28 Sep 2020 10:41:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42166) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kMuKs-00064S-Ry for bug-gnu-emacs@gnu.org; Mon, 28 Sep 2020 10:41:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kMuKs-0007st-QK for bug-gnu-emacs@gnu.org; Mon, 28 Sep 2020 10:41:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: David Landell Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Sep 2020 14:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43651 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 43651-submit@debbugs.gnu.org id=B43651.160130405930276 (code B ref 43651); Mon, 28 Sep 2020 14:41:02 +0000 Original-Received: (at 43651) by debbugs.gnu.org; 28 Sep 2020 14:40:59 +0000 Original-Received: from localhost ([127.0.0.1]:53710 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMuKo-0007sG-Iv for submit@debbugs.gnu.org; Mon, 28 Sep 2020 10:40:58 -0400 Original-Received: from aibo.runbox.com ([91.220.196.211]:60212) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMuKm-0007s4-TQ for 43651@debbugs.gnu.org; Mon, 28 Sep 2020 10:40:57 -0400 Original-Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1kMuKf-00087H-S5; Mon, 28 Sep 2020 16:40:49 +0200 Original-Received: by submission01.runbox with esmtpsa [Authenticated alias (666394)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1kMuKc-0008Dp-Ry; Mon, 28 Sep 2020 16:40:47 +0200 In-Reply-To: <87lfguui8b.fsf@gnus.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:189208 Archived-At: --=-=-= Content-Type: text/plain Hi, This is actually not restricted to font locking as demonstrated by the test case. My initial report was a bit unclear about that. It also affects settings like: (setq compilation-scroll-output 'first-error) where the jump is done to the header instead of first error. My impression from reading the code is that we would want to avoid running (compilation--parse-region) on the header to avoid problems like this. I am attaching a patch that superficially seems to fix these issues. I have a hard time judging if this fix has any bad side effects or similar though. I am definitely missing a bit of context how the related functions are invoked. In testing of my own package I have seen what seems to be multiple rounds of font locking that erase previous rounds, probably coming from buffer changes in my downstream filter-function. In that setup, the jump to first error has been a more stable way of reproducing. /David --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Don-t-parse-compilation-buffer-header-for-errors.patch >From 4f30436f99537925f4ec83ed759e3ae098f63d3c Mon Sep 17 00:00:00 2001 From: David Landell Date: Sun, 27 Sep 2020 16:52:44 +0200 Subject: [PATCH] Don't parse compilation buffer header for errors * lisp/progmodes/compile.el (compilation-header-size): New var. (compilation--ensure-parse): Init compilation--parsed with start of process output instead of (point-min). (compilation-start): Calculate header size. --- lisp/progmodes/compile.el | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index a408d16e37..4fd2ce88bc 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -1573,7 +1573,7 @@ compilation--ensure-parse ;; grep.el) don't need to flush-parse when they modify the buffer ;; in a way that impacts buffer positions but does not require ;; re-parsing. - (setq compilation--parsed (point-min-marker))) + (setq compilation--parsed (copy-marker (+ (point-min) compilation-header-size)))) (when (< compilation--parsed limit) (let ((start (max compilation--parsed (point-min)))) (move-marker compilation--parsed limit) @@ -1710,6 +1710,9 @@ compilation--update-in-progress-mode-line ;; buffers when it changes from nil to non-nil or vice-versa. (unless compilation-in-progress (force-mode-line-update t))) +(defvar compilation-header-size 0 + "Size of the inserted compilation header.") + ;;;###autoload (defun compilation-start (command &optional mode name-function highlight-regexp) "Run compilation command COMMAND (low level interface). @@ -1810,14 +1813,16 @@ compilation-start (eq compilation-scroll-output 'first-error)) (set (make-local-variable 'compilation-auto-jump-to-next) t)) ;; Output a mode setter, for saving and later reloading this buffer. - (insert "-*- mode: " name-of-mode - "; default-directory: " - (prin1-to-string (abbreviate-file-name default-directory)) - " -*-\n" - (format "%s started at %s\n\n" - mode-name - (substring (current-time-string) 0 19)) - command "\n") + (let ((header (concat "-*- mode: " name-of-mode + "; default-directory: " + (prin1-to-string (abbreviate-file-name default-directory)) + " -*-\n" + (format "%s started at %s\n\n" + mode-name + (substring (current-time-string) 0 19)) + command "\n"))) + (insert header) + (setq compilation-header-size (length header))) (setq thisdir default-directory)) (set-buffer-modified-p nil)) ;; Pop up the compilation buffer. -- 2.17.1 --=-=-=--