From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id AK+jG+YLqGKIMAEAbAwnHQ (envelope-from ) for ; Tue, 14 Jun 2022 06:17:42 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id gB2cG+YLqGJe6AAA9RJhRA (envelope-from ) for ; Tue, 14 Jun 2022 06:17:42 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 31F5815A15 for ; Tue, 14 Jun 2022 06:17:42 +0200 (CEST) Received: from localhost ([::1]:57436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o0xzp-0001SX-7x for larch@yhetil.org; Tue, 14 Jun 2022 00:17:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o0xyy-0001S6-OG for emacs-orgmode@gnu.org; Tue, 14 Jun 2022 00:16:48 -0400 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]:36762) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o0xyx-0001UE-2y for emacs-orgmode@gnu.org; Tue, 14 Jun 2022 00:16:48 -0400 Received: by mail-qv1-xf2a.google.com with SMTP id 43so5740182qvb.3 for ; Mon, 13 Jun 2022 21:16:46 -0700 (PDT) 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=d+ad6xL2BZKlbbMnIa0tuGc5LdpkOJSQM/RWgHykS6E=; b=gR68lglEiHrgJ7iMSvL38/bsuiaA2VE3s3pZ39IK9Y8FGljHZ0APwVWXOK6xtc7SkD BZqtj+9HiJe7cHiHE01DVWS03kilSWLFsREuTFjPk61uypJLdCBYh+vuHJXeU5qi+H8h tsGghTzKjQO5Q1qLXd3Sp7BCKllY73IEFCEDf2E7E3VZzYR8dfpZfd6VNo70OFcCAw3Y oK9fjHZOvgohffPYDs8JdvXvKgvzfv1MRIS2NOkwNzJSdnhertMWktpcCNk7hVnTH8mM jN4yVMq8jl3VNMEWkeYVVM4vzVKokHTlbDzLt3/hHuBSEgx2Pg427ZJ6dMIjbhH6TSNx BCZQ== 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=d+ad6xL2BZKlbbMnIa0tuGc5LdpkOJSQM/RWgHykS6E=; b=NTb0AT0lAyNN+op5ypJremibP2Lw7LHzyi4ml+8hBtIrW+etJ7SKVZUbUOD+DhXTh8 JcRkplJkgMpeVrRa8wdS9Kyt7wLXcU6uxZMrmkrxYVh51yqAZXAQM1HVJIU6fr6abtJH LhGf17UkB8B8tZw5ldVWoD0MXJIxSqhwNde0U/CYMZHMl4T+QtCUc7O7J1E0wmm1gS/m YFD6UwiwDmaRxgMhUOUC2A4CD03OUejUTeD9sr0HpynHwSz+dVvbi1AJos8GcstwhgMj 4I8F7bbmRYE4gvJUgl1e+D+nSgBV5gx7XBfEV4xa9t3kN45u7osa7l2z3pDyo94g40ia sWFA== X-Gm-Message-State: AJIora982DAyUmMKjrRk8wafkEkK51lw4akItuAmB3lrxeHGZYUpz2pp 6h8l0lRYp4ibwLf77zlhFX+cHhplOuDhYQ== X-Google-Smtp-Source: AGRyM1sZDzSSp29zRIurVxHtZZ9x5fxqEB7qndH+6rN2P73zC9+TlL3EUU4dUmEcvmdg+qabmj7VKQ== X-Received: by 2002:a0c:e948:0:b0:468:58c5:699 with SMTP id n8-20020a0ce948000000b0046858c50699mr1935618qvo.63.1655180206199; Mon, 13 Jun 2022 21:16:46 -0700 (PDT) Received: from localhost (22.b2.a86c.ip4.static.sl-reverse.com. [108.168.178.34]) by smtp.gmail.com with ESMTPSA id bj36-20020a05620a192400b006a716fed4d6sm7723452qkb.50.2022.06.13.21.16.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jun 2022 21:16:45 -0700 (PDT) From: Ihor Radchenko To: Ignacio Casso Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] org-copy-subtree in a file with local variables marks buffer as modified [9.5.3 (release_9.5.3-6-gef41f3 @ /home/ignacio/repos/emacs/lisp/org/)] In-Reply-To: References: <875yl7d52o.fsf@localhost> Date: Tue, 14 Jun 2022 12:17:54 +0800 Message-ID: <87mtefq3nx.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::f2a; envelope-from=yantar92@gmail.com; helo=mail-qv1-xf2a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1655180262; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=d+ad6xL2BZKlbbMnIa0tuGc5LdpkOJSQM/RWgHykS6E=; b=IF/vDcvKuEsLPbJolBIBjjTbKqqx4RkPRD6HalyBcpyL0cvAjtt31f7rtaCn0hJTlQj1jb g9N85xWgON2qvs1Sb4LY8LWL0Y1U95Cg+Vm4DswhwIOUkMGYmFNynGZy4Zt+gSRV4YFcX+ VtT/XioY+zdYotnPPSm3tb09Zh+iLzt5B+L67t+onidv4PJluxUNNVXknziQrc38nQ1xQ2 vYpchOGvG/dwbAEeAEflt/BJT27dElbSmdBG2ViQK42P+MjlJqaesww/nhybBasMUG0tQq LHYeEQgtK1bEj6LVKtSXchZgLH5YR4M/5Cclmfs1Us8vFUo8Jr19ZTnzSN4R2A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655180262; a=rsa-sha256; cv=none; b=anEwIryVpgi6CZhGkyuLgspxJmRrKwNObOLYyoR4qnsmR2gp8i0bsqZ+f1m6YK/viMtwiL f4mV9b1zuB7i9lJYq6eYREx2D5ceS9nYn1Picl5p9oFAp2NTS8KPL0EYcnPmPLQV1dfOSS srTOBlDpm/PgqLBAINxXiuGn9EcjAnmAMSZ4tIjMZ0wOc3lntSfcoqfgQ7w573DmKSOp+E +3btl5MF2jJSfRHPUho8s8u2dA4BM3CZWsTOtD9klU2b16/p+n/kN6bqCZWJgzcbsSb/vY Y5Zv1eHdAaHbgtq88p3u3lsGIJy3NfmCHiMt0Cx/B7OwAnvZfCokkEXNOPyszw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gR68lglE; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -1.99 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gR68lglE; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 31F5815A15 X-Spam-Score: -1.99 X-Migadu-Scanner: scn1.migadu.com X-TUID: dWMnzpx68pWQ Ignacio Casso writes: > I've written a patch proposal. It deals with buffer-modified-p and undo > history, but not the other two points you mention. I have tested it and > it works, but I had never dealt before with `buffer-undo-list' so maybe > there are some cases that I have not considered and for which this patch > could be problematic. Let me know what you think: Thanks! > - (delete-and-extract-region (point) (point-max))))))) > + (undo-boundary) > + (setq buffer-undo-list > + (seq-drop-while 'identity buffer-undo-list))))))) This looks fragile and can be disasterous when buffer-undo-list is large. Maybe just use with-silent-modifications or some ideas from there (for example, wrapping modifications inside let-bound (buffer-undo-list t))? We should not inhibit modification hooks though. Otherwise, it will mess up with caching code. Best, Ihor