From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#53294: 29.0.50; Indirect font changes incorrectly affecting original buffer Date: Mon, 17 Jan 2022 21:47:30 -0500 Message-ID: References: <835yqkyqzw.fsf@gnu.org> <83lezfybc9.fsf@gnu.org> <83ilujy9fi.fsf@gnu.org> <837dazy2ah.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29706"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Eli Zaretskii , 53294@debbugs.gnu.org To: Andrew Hyatt Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 18 03:48:37 2022 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 1n9eY0-0007U9-8C for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 18 Jan 2022 03:48:36 +0100 Original-Received: from localhost ([::1]:59196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9eXz-0008WS-6U for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 Jan 2022 21:48:35 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:59204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9eXS-0008W1-5l for bug-gnu-emacs@gnu.org; Mon, 17 Jan 2022 21:48:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n9eXR-0007Tf-NE for bug-gnu-emacs@gnu.org; Mon, 17 Jan 2022 21:48:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n9eXR-0006Xu-Ln for bug-gnu-emacs@gnu.org; Mon, 17 Jan 2022 21:48:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 Jan 2022 02:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53294 X-GNU-PR-Package: emacs Original-Received: via spool by 53294-submit@debbugs.gnu.org id=B53294.164247406125046 (code B ref 53294); Tue, 18 Jan 2022 02:48:01 +0000 Original-Received: (at 53294) by debbugs.gnu.org; 18 Jan 2022 02:47:41 +0000 Original-Received: from localhost ([127.0.0.1]:48508 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n9eX6-0006Vs-Sb for submit@debbugs.gnu.org; Mon, 17 Jan 2022 21:47:41 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:63011) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n9eX5-0006V8-3P for 53294@debbugs.gnu.org; Mon, 17 Jan 2022 21:47:39 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 1C2614424F6; Mon, 17 Jan 2022 21:47:33 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id A5BCD4406DB; Mon, 17 Jan 2022 21:47:31 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1642474051; bh=M/J1Z8YMQ6xMAqi8rbxCm833t5G6SgSitPWZzqLCGjg=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=eCZGfMyDgsof9bYSdHwHa6Sz5j/+nT82mnfubR/kj1IBrOLecTc5QWqf2zuH/6QgK GaaBV8fLDXzi/86aBDlMfLD9+VYf5aO2gdY8ed751GT3vW8TRWpWMFNTlJX9n8HNzz uTsfEiRolW2onOg32zFb+zxNpzTDo2o2bB/Q/Ojyta06/c06rOkfrKxuLFQPKryysR ZHK5K+nLCWBn/MUJnQG6/PyH/dsun3c8Phq8Wt1n2gM1F/iYPEN7tiNqnI/cyEN0zo 2EGB2dPgIefJFis3uYCDwotzGDpLjI22ZrXIiVsxulZZDSbQjbmE+HY71MWmlIUPgo hLO29E4scrvlA== Original-Received: from pastel (unknown [216.154.30.173]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 7769D12023B; Mon, 17 Jan 2022 21:47:31 -0500 (EST) In-Reply-To: (Andrew Hyatt's message of "Mon, 17 Jan 2022 21:24:24 -0500") 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:224490 Archived-At: > That sounds reasonable, I can do that. In fact, I just did this based on > your suggestions, and it does work well. The only weird thing is that I had > to pull `clone-indirect-buffer-hook' into the c code, because that's where > `make-indirect-buffer' is. You could leave the `defvar` in Lisp and only pull the DEFSYM, but yes, you need to pull at least part of it into C. > Let me know if that seems wrong. Nope. > I've attached the patch, please let me know if there is an issue. I have > commit access, so I can just commit it myself after your OK (if so, I'll > wait for a week or so to see if Eli has a comment as well before checkin). Comments below, thanks, Stefan > diff --git a/lisp/face-remap.el b/lisp/face-remap.el > index 00560f9d2e..fc0edb7119 100644 > --- a/lisp/face-remap.el > +++ b/lisp/face-remap.el > @@ -70,6 +70,14 @@ internal-lisp-face-attributes > :foreground :background :stipple :overline :strike-through :box > :font :inherit :fontset :distant-foreground :extend :vector]) > > +(defun face-attrs--make-indirect-safe () > + "Do a deep copy of `face-remapping-alist' to keep the original buffer safe." > + (setq-local face-remapping-alist > + (copy-tree > + (buffer-local-value 'face-remapping-alist (buffer-base-buffer))))) I think `mapcar #'copy-sequence` is slightly more correct than `copy-tree`, and you shouldn't need (buffer-local-value 'face-remapping-alist (buffer-base-buffer)) because that buffer's value should already have been copied to the current buffer. > @@ -912,6 +912,10 @@ DEFUN ("make-indirect-buffer", Fmake_indirect_buffer, Smake_indirect_buffer, > Fset (intern ("buffer-save-without-query"), Qnil); > Fset (intern ("buffer-file-number"), Qnil); > Fset (intern ("buffer-stale-function"), Qnil); > + /* Cloned buffers need extra setup, to do things such as deep > + variable copies for list variables that might be mangled due > + to destructive operations in the indirect buffer. */ > + safe_run_hooks (Qclone_indirect_buffer_hook); I think you want to use just `run_hook` here because there's no need to catch errors. More importantly, you need to remove the corresponding `run-hook` from `clone-indirect-buffer`. Stefan