From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id +GGAOZBGpGJW1QAAbAwnHQ (envelope-from ) for ; Sat, 11 Jun 2022 09:38:57 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id cNyYOJBGpGLZAQAAG6o9tA (envelope-from ) for ; Sat, 11 Jun 2022 09:38:56 +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 7558215CB6 for ; Sat, 11 Jun 2022 09:38:56 +0200 (CEST) Received: from localhost ([::1]:42342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzvhv-0005Zl-Il for larch@yhetil.org; Sat, 11 Jun 2022 03:38:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzvfJ-0004dp-31 for emacs-orgmode@gnu.org; Sat, 11 Jun 2022 03:36:16 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:37858) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzvfH-0006oT-J8 for emacs-orgmode@gnu.org; Sat, 11 Jun 2022 03:36:12 -0400 Received: by mail-pl1-x62c.google.com with SMTP id t2so1048008pld.4 for ; Sat, 11 Jun 2022 00:36:10 -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=ta8JvJ/0YetqY9b/Zzi5pK/QYox+dzWvg4t8ePfCEtg=; b=nWToeXFNragtrxgtgD6atceNs5gW2Mj6dJzkiPCno+hlFS4OQf7t6z64qYKL0A6Jpk CRr1BTYooY764MK96lsJn/0NrSV2Ts11HSssaFS/WyaGCl6UiS/zLSuBXbLked8/LZGE vpZGXqJ6ZMFim79RXr97gEJMOY04c2hlMJ04yHWj3P1bXwpNgOhzzKDYqE1i7m+dRHrT 9pcpzSfELu5kzQwSNe+L/wq3DUvGZb866WmxNGqMarkDs2s17HklR1nOIW3JWkCy3f2h JwRGO1Bo0L1th/KTb05epc8qMYGMlyqicpS0IrDorGq7zY9UPCzQl2kqHg7qOnytTyEU r7Dg== 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=ta8JvJ/0YetqY9b/Zzi5pK/QYox+dzWvg4t8ePfCEtg=; b=fN76Ef6MKQpLpDzCOl/aZVNn8476ZxJ/IQf/RwE2IaG6YyMSk6Gdla//Reei7HL0xc 1hOQdWpNdJvR7OIXjyrHlWe1OIm38Y7M0ayHRXLWi6sW9OIuSxG+MkoJxLqmzuo2fc8E BYJQJq9aSgB/olVofH3ikiNb0bHkp7lP2rMBJZuKjGghQRW4ZkACdOFGIb7am3gyHWKD yk25l2PkHHZJps7xojg3HKraTOhyMzgz2CEGh+VpAkXteCPVBwdRNBHfWvjSu2TJvfXL Adc4bVfS8caUvYzK6JwSDF2q6jA1Lo7OIHX8eWsgyAn8iZTwgXX6rO3RpkBIpAny9CAS HkaQ== X-Gm-Message-State: AOAM5322Q3ZA5FovVOeSLskJMFS9IH9a1WJDHg18wNeM15ytsY6yl2gI CKDH2bcKJpx7JV9jPiwV1hNvL8UbaOSdyrmT X-Google-Smtp-Source: ABdhPJxdjC0y0Wmsb0vz2eyPg6g0FS3XTEMhv8NfE5rChqI+IaDO2JFvjO1lxLDUHTHARKB/AHuW9w== X-Received: by 2002:a17:902:b7c1:b0:163:fc78:f844 with SMTP id v1-20020a170902b7c100b00163fc78f844mr47744553plz.108.1654932969807; Sat, 11 Jun 2022 00:36:09 -0700 (PDT) Received: from localhost ([64.32.23.62]) by smtp.gmail.com with ESMTPSA id f19-20020a637553000000b003fc4001fd5fsm932734pgn.10.2022.06.11.00.36.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jun 2022 00:36:08 -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: Date: Sat, 11 Jun 2022 15:36:47 +0800 Message-ID: <875yl7d52o.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=yantar92@gmail.com; helo=mail-pl1-x62c.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=1654933136; 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=ta8JvJ/0YetqY9b/Zzi5pK/QYox+dzWvg4t8ePfCEtg=; b=AEAX7vLIPmpMKyYSPa0ewO/K+fcFdpz7BokNsUI7uWigwhYPWfi8nZCYu1y835+tKGY820 ovbQi8371m9nuia6xaCDD8PQ1EZu6eJT41ohBmGA1bKZuBSPCWBL1PHB0Fy2ZcBJyiRrGf D0icy1iUrQNsRUNpX8sluifffTeX0BhnpqGI6+nGgb/JrHJ1Alwxo+5TWxq1aQiyJgxMmo l1YP+/UEMciOPNTcTXf50OGdD+QCkPzpe38zYuRf5C7zctVPVTT9P6c3pYwtyM6SBie9qz h2IYC+ShwfPuc22ZFPQdKBg9oSjLY3S6dAVjC5TfqzHCio4T6dev23ZTHms6kw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654933136; a=rsa-sha256; cv=none; b=iMdNAMe/QK3fn5dNKMHa2LyuD2lHWTYn3gYjx6pU/O8D74HM8mL0OqMmHp/f7IB/RKTu/N M8BBa/zBkwcsoF64b/0yyCRO0hVwlr0oqwrxuIiissn0BxmaBdT03yl+Kk+PGT8Eey5hVo GTkBebnsDpum0+ed3hozMjdoMv2S+fhMAR1RAZ1d6iJfodiJ6OuxsSOwxc8XxnT6wI8hzZ WUSzzshAT8RvcCQiGRcnIYfwc2QMTZqKakPCi01MYHxBhYbrIVVuAzJEMEGmNwm3FmHMmx QsvQ/OlUnRyvz8JGBzuYLXItbAG8Pb4jJXcajDxg/6b09P35KxQj9u1EY65dkA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nWToeXFN; 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: -3.49 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nWToeXFN; 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: 7558215CB6 X-Spam-Score: -3.49 X-Migadu-Scanner: scn1.migadu.com X-TUID: tEBlbXA9qP/d Ignacio Casso writes: > What would you think about a change like the following in the definition of > `org-preserve-local-variables' to solve the issue? > > + (let ((modified-before-p) (buffer-modified-p)) > ;; current code that deletes local variables > + (unless modified-before-p (set-buffer-modified-p nil)) > ;; current code that executes body > + (let ((modified-after-p (buffer-modified-p))) > ;; current code that restores local variables > + (unless modified-after-p (set-buffer-modified-p nil)))) > > Could the current code or my proposed change have any more unintended > consequences, for example in the undo tree or mark ring? Sometimes when > I undo or jump to the mark, the point moves to the last visible, usually > folded headline of the file, even if I had not edited it recently, and I > have always assumed that it's because it wants to go to the end of the > buffer for some reason I've never been able to come up with or > debug. Could that have something to do with this? buffer-modified-p is not the only parameter affected by juggling around the local variables. There will be undo history, buffer-chars-modified-tick, before/after-change-hooks triggered by `org-preserve-local-variables', etc. However, I do not see any obvious way how your proposed change can negatively affect all the above. Feel free to propose a patch. Best, Ihor