From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrew Hyatt Newsgroups: gmane.emacs.bugs Subject: bug#53294: 29.0.50; Indirect font changes incorrectly affecting original buffer Date: Tue, 18 Jan 2022 21:37:59 -0500 Message-ID: References: <835yqkyqzw.fsf@gnu.org> <83lezfybc9.fsf@gnu.org> <83ilujy9fi.fsf@gnu.org> <837dazy2ah.fsf@gnu.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="24625"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 53294@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 19 03:39:24 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 1nA0se-0006E3-2N for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 Jan 2022 03:39:24 +0100 Original-Received: from localhost ([::1]:45684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nA0sc-0002wv-CD for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 18 Jan 2022 21:39:22 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58920) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nA0sI-0002wn-SC for bug-gnu-emacs@gnu.org; Tue, 18 Jan 2022 21:39:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59139) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nA0sI-0000Gj-Iu for bug-gnu-emacs@gnu.org; Tue, 18 Jan 2022 21:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nA0sI-0001gA-E4 for bug-gnu-emacs@gnu.org; Tue, 18 Jan 2022 21:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andrew Hyatt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 Jan 2022 02:39:02 +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.16425598916384 (code B ref 53294); Wed, 19 Jan 2022 02:39:02 +0000 Original-Received: (at 53294) by debbugs.gnu.org; 19 Jan 2022 02:38:11 +0000 Original-Received: from localhost ([127.0.0.1]:52042 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nA0rT-0001es-6D for submit@debbugs.gnu.org; Tue, 18 Jan 2022 21:38:11 -0500 Original-Received: from mail-qv1-f45.google.com ([209.85.219.45]:44595) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nA0rP-0001eO-FR for 53294@debbugs.gnu.org; Tue, 18 Jan 2022 21:38:10 -0500 Original-Received: by mail-qv1-f45.google.com with SMTP id bc19so668676qvb.11 for <53294@debbugs.gnu.org>; Tue, 18 Jan 2022 18:38:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=Jxyb8e6xHydaD8SkCxNXaAcUk1Xo3PyLVXaGdz1L6uM=; b=VEGNtsTrGiWnz8o00oidLNXllq8/JuzDYJEKbR07FJXkxGBw367cqSlBiomLf2IZ9m dLn9oCaoiyoLq4yDPawBi/nWD5NozlIrmAthaP7l2c+zCoSyE54fuDyM80TpOnDNmJPN s//MsnDGnN+n7gH16Q7SP+oNgYe+vatOnPjNLq2zuQp0M4Mq0GuLxUrltEdORK7hfTQk LXClsyON4IE/OWjl3s/r6ZbOk5YxKjPdtCnWl5GJe6vmrJ5pjQgC8gspxBKnCCIDJFj4 5DeerdWBESDYPFE03JQn1YZfcOCTcHEwG8Z/TxqXE2gez9filE2MGx184MOG0SESZ8Ag BBkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=Jxyb8e6xHydaD8SkCxNXaAcUk1Xo3PyLVXaGdz1L6uM=; b=7ivjWbbKo0dhGEjCD/bGqJ2SaFcxiUazwe9YNXIQCb5Po+1TCEL854Oi2wkt2oGxNC rrJD6rFpL2nmRQ8xLZi8hsMPpAZZFwNvZ+0xLE8sv43bgwfjHY0ELDAsCr1aoaXD4bqi Ummdrbeei0k/5mjLnPDKdAJgvQwqhbsT5uNwertLzI2sKVP8jy7s12wkIql/wrn9VbTZ xOlaj5j4lqK2sRCveqO0FyES3uEGgfY91SVQgaa+tmg4GFyF2lV/Y1PMeDfN4jvFnv/j 1s0u/I7xVNY8pcwC7+2JwcaRzBqwmRXQgPMNR8PlElmjalpu5RSPE9VuQEDYLVL7ISWZ 5Pjg== X-Gm-Message-State: AOAM53214Gzdv9fOzufLDU+Eb/D7zOuOMRGd8n325PUQ7FxQCJ5rqg9S DJaN6jGpFcm1vWDim8gKb/Awl9/TUSw= X-Google-Smtp-Source: ABdhPJxumwBO8HG3kN5/D8E6q5OzVyjhTrJdqYYKK5U4j/PqZU+FvytWWIlKwKhX3H/m0uyAushQtg== X-Received: by 2002:a05:6214:2a4d:: with SMTP id jf13mr25729378qvb.28.1642559881229; Tue, 18 Jan 2022 18:38:01 -0800 (PST) Original-Received: from andrews-mbp.lan (pool-173-56-75-166.nycmny.fios.verizon.net. [173.56.75.166]) by smtp.gmail.com with ESMTPSA id u17sm11521208qko.133.2022.01.18.18.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 18:37:59 -0800 (PST) In-Reply-To: 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:224540 Archived-At: --=-=-= Content-Type: text/plain; format=flowed On Mon, Jan 17, 2022 at 09:47 PM Stefan Monnier wrote: >> 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 Makes sense, thanks for the suggestions. I've included the revised patch. --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=text-scale-patch-v3 Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL2xpc3AvZmFjZS1yZW1hcC5lbCBiL2xpc3AvZmFjZS1yZW1hcC5lbAppbmRl eCAwMDU2MGY5ZDJlLi45NWRmZmNhZGQ2IDEwMDY0NAotLS0gYS9saXNwL2ZhY2UtcmVtYXAuZWwK KysrIGIvbGlzcC9mYWNlLXJlbWFwLmVsCkBAIC03MCw2ICs3MCwxMyBAQCBpbnRlcm5hbC1saXNw LWZhY2UtYXR0cmlidXRlcwogICAgOmZvcmVncm91bmQgOmJhY2tncm91bmQgOnN0aXBwbGUgOm92 ZXJsaW5lIDpzdHJpa2UtdGhyb3VnaCA6Ym94CiAgICA6Zm9udCA6aW5oZXJpdCA6Zm9udHNldCA6 ZGlzdGFudC1mb3JlZ3JvdW5kIDpleHRlbmQgOnZlY3Rvcl0pCiAKKyhkZWZ1biBmYWNlLWF0dHJz LS1tYWtlLWluZGlyZWN0LXNhZmUgKCkKKyAgIkRlZXAgY29weSBgZmFjZS1yZW1hcHBpbmctYWxp c3QnIG9uIGNsb25pbmcgZm9yIHNhZmV0eS4iCisgIChzZXRxLWxvY2FsIGZhY2UtcmVtYXBwaW5n LWFsaXN0CisgICAgICAgICAgICAgICh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