From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#39190: 28.0.50; two buffers with same buffer-file-name (diff-syntax-fontify-props) Date: Mon, 03 Feb 2020 01:41:47 +0200 Organization: LINKOV.NET Message-ID: <87v9ooeev8.fsf@mail.linkov.net> References: <875zh73dg8.fsf@betli.tmit.bme.hu> <8736c921s6.fsf@mail.linkov.net> <875zh13e5d.fsf@mail.linkov.net> <87h80iqafm.fsf@betli.tmit.bme.hu> <87ftg0fnyb.fsf@mail.linkov.net> <87d0b3qz3m.fsf@betli.tmit.bme.hu> <871rrhkgkm.fsf@mail.linkov.net> <87v9os914e.fsf@betli.tmit.bme.hu> <87a764y35u.fsf@mail.linkov.net> <87r1zd8gvx.fsf@betli.tmit.bme.hu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="2523"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 39190@debbugs.gnu.org, Felician Nemeth To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 03 00:45:14 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 1iyOvQ-0000Te-VQ for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 Feb 2020 00:45:13 +0100 Original-Received: from localhost ([::1]:60528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyOvP-0002dS-Jv for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 02 Feb 2020 18:45:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54357) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyOvH-0002dI-RT for bug-gnu-emacs@gnu.org; Sun, 02 Feb 2020 18:45:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyOvG-0002dU-NL for bug-gnu-emacs@gnu.org; Sun, 02 Feb 2020 18:45:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34768) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyOvG-0002bo-Ba for bug-gnu-emacs@gnu.org; Sun, 02 Feb 2020 18:45:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iyOvG-0008Ua-9d for bug-gnu-emacs@gnu.org; Sun, 02 Feb 2020 18:45:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 02 Feb 2020 23:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39190 X-GNU-PR-Package: emacs Original-Received: via spool by 39190-submit@debbugs.gnu.org id=B39190.158068709032615 (code B ref 39190); Sun, 02 Feb 2020 23:45:02 +0000 Original-Received: (at 39190) by debbugs.gnu.org; 2 Feb 2020 23:44:50 +0000 Original-Received: from localhost ([127.0.0.1]:40741 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iyOv4-0008Tz-7N for submit@debbugs.gnu.org; Sun, 02 Feb 2020 18:44:50 -0500 Original-Received: from caracal.birch.relay.mailchannels.net ([23.83.209.30]:34491) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iyOv1-0008Tq-Ra for 39190@debbugs.gnu.org; Sun, 02 Feb 2020 18:44:49 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 5BF2C600912; Sun, 2 Feb 2020 23:44:46 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a46.g.dreamhost.com (100-96-217-4.trex.outbound.svc.cluster.local [100.96.217.4]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id DC85A600840; Sun, 2 Feb 2020 23:44:45 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a46.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.5); Sun, 02 Feb 2020 23:44:46 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Exultant-Irritate: 2e3ec9f63a86942c_1580687086146_1927022480 X-MC-Loop-Signature: 1580687086146:2162772103 X-MC-Ingress-Time: 1580687086146 Original-Received: from pdx1-sub0-mail-a46.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a46.g.dreamhost.com (Postfix) with ESMTP id 98AC780004; Sun, 2 Feb 2020 15:44:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=ag0qfTPl7YbhBeC9Du/NjiF5Ve0=; b= Z2Gvdpk+xwGOuqjg2dzdbLSXw4RV6c16mGe5WkDQUiCVbaETfG6E62aKkCmkhKIg yalam+92CJvOz96I1yITYA7aknCHT8s6mX6njU5ME40PwiYJCMPF2hQhemA0KbIY b8xYEiru6JL75EBGKfjd/dClgWWGwshOdrXSjLhr88M= Original-Received: from mail.jurta.org (m91-129-105-126.cust.tele2.ee [91.129.105.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a46.g.dreamhost.com (Postfix) with ESMTPSA id 117E380024; Sun, 2 Feb 2020 15:44:37 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a46 In-Reply-To: (Stefan Monnier's message of "Sun, 02 Feb 2020 08:50:07 -0500") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedugedrgeeigdduvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffuohhfffgjkfgfgggtsehmtderredtredtnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecukfhppeeluddruddvledruddthedruddvieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddthedruddviedprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopehmohhnnhhivghrsehirhhordhumhhonhhtrhgvrghlrdgtrg 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: 209.51.188.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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:175621 Archived-At: --=-=-= Content-Type: text/plain >> vc-find-revision-no-save also calls set-auto-mode. So, I don't know if >> the following patch is correct, but together with your patch it does >> solve the original issue. >> >> diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el >> index f64b6c0631..c50ba132e7 100644 >> --- a/lisp/vc/vc.el >> +++ b/lisp/vc/vc.el >> @@ -2098,7 +2098,7 @@ vc-find-revision-no-save >> ;; For non-interactive, skip any questions >> (let ((enable-local-variables :safe) ;; to find `mode:' >> (buffer-file-name file)) >> - (ignore-errors (set-auto-mode))) >> + (ignore-errors (delay-mode-hooks (set-auto-mode)))) >> (normal-mode)) >> (set-buffer-modified-p nil) >> (setq buffer-read-only t)) > > How 'bout we first consolidate the two cases into one by introducing > a new function `set-auto-mode-for-filename` that both > vc-find-revision-no-save and diff-mode can use? Actually vc-find-revision-no-save when called as a command (e.g. by the key 'f' from log-view) still should run hooks because the buffer it creates is not internal. Only its call from diff-syntax-fontify-hunk should not run hooks: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=delay-mode-hooks.patch diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 2dbab80208..9cdd732923 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2635,11 +2635,11 @@ diff-syntax-fontify-hunk ;; Don't re-initialize the buffer (which would throw ;; away the previous fontification work). (setq file nil) - (setq buffer (ignore-errors + (setq buffer (ignore-errors (delay-mode-hooks (vc-find-revision-no-save file revision diff-vc-backend - (get-buffer-create buffer-name))))) + (get-buffer-create buffer-name)))))) (when buffer (with-current-buffer buffer (diff-syntax-fontify-props file text line-nb)))))))) @@ -2719,7 +2719,7 @@ diff-syntax-fontify-props (cl-assert (null buffer-file-name)) (let ((enable-local-variables :safe) ;; to find `mode:' (buffer-file-name file)) - (set-auto-mode) + (delay-mode-hooks (set-auto-mode)) ;; FIXME: Is this really worth the trouble? (when (and (fboundp 'generic-mode-find-file-hook) (memq #'generic-mode-find-file-hook diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el index a6be04e313..e629674ea6 100644 --- a/lisp/gnus/mm-view.el +++ b/lisp/gnus/mm-view.el @@ -497,7 +497,7 @@ mm-display-inline-fontify (let ((auto-mode-alist (delq (rassq 'doc-view-mode-maybe auto-mode-alist) (copy-sequence auto-mode-alist)))) - (set-auto-mode) + (delay-mode-hooks (set-auto-mode)) (setq mode major-mode))) ;; Do not fontify if the guess mode is fundamental. (unless (eq major-mode 'fundamental-mode) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 1a34456340..741ed73905 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -1395,7 +1395,7 @@ xref--collect-matches (inhibit-message t) message-log-max) (ignore-errors - (set-auto-mode t))) + (delay-mode-hooks (set-auto-mode t)))) (setq-local xref--temp-buffer-file-name file) (setq-local inhibit-read-only t) (erase-buffer)) --=-=-=--