From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.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 2A/PJYqVqGJXhgAAbAwnHQ (envelope-from ) for ; Tue, 14 Jun 2022 16:04:58 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id MH7WJYqVqGLh+AAA9RJhRA (envelope-from ) for ; Tue, 14 Jun 2022 16:04:58 +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 3CDE410C18 for ; Tue, 14 Jun 2022 16:04:58 +0200 (CEST) Received: from localhost ([::1]:50720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o17A9-0000Uo-ET for larch@yhetil.org; Tue, 14 Jun 2022 10:04:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o179T-0000RK-Rk for emacs-orgmode@gnu.org; Tue, 14 Jun 2022 10:04:16 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]:40770) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o179R-0002fm-6b for emacs-orgmode@gnu.org; Tue, 14 Jun 2022 10:04:14 -0400 Received: by mail-pf1-x432.google.com with SMTP id z17so8643858pff.7 for ; Tue, 14 Jun 2022 07:04:12 -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=w1ffu9ckkXFAwEXuFSxntby/1DnbASyKUbewRH9TE84=; b=lsFfWJszE2Ypy+prnpnGmP/iNO96+r4M/8vqF3wU3a+JF9XDx0zApoRHsGcWjLIpVe Ya9yeP0fUkFk6rH4MGwmBcFDAOTKTWu44wC5tgOzF8biiM2rczn4FxuEbJmVuPlezsaX T4gbwewbzhh0MSFBPY4fCU0NtNdfQWwAoinGQMfC+UL3+9GlRbKNC8HvHuKHtEWL9u+o dmGCOYIA2R1DZCTRPd4YEm5RYZAFELjBUnZMcGVocq9yHN14oiDIYrOxyssY+YIO2Tp1 rsFrzPs0ToYDOehpU7WWXEkHrNY20EVnlu413CT9Xr9T1+9hdnYXTIFlFP9BM5j78pTz pzPw== 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=w1ffu9ckkXFAwEXuFSxntby/1DnbASyKUbewRH9TE84=; b=VV5IuvWWeNyydQArdTs0xyZytBVF7u70T0XT/1UjfxI9erWtC6GlnjgJ9IUx+XFLqP C7377Y43qK890zOIe9MTWi2VWHTlMBU/i1MECHFn+5RdYLGQaeOrVY3jnwGxMcnoaQwr zmtOxy2lmcFlR5SSZCx0MIDgvNiR4nlxnUpC6t4ulzdqmDtA85EqFMMWPnqRRbyDTfI6 Aa9n6Pvq65oFtDQGoF4HK5vgYImXtAqf9MVGZOnfSy21SZ61N3reZs1Wo5+JMp95Uwa+ 8Gg7ghB33BEJuKkND8N2eAc24uowioBq7Or2RIPPy1bKheMe/8quBHPo6jv/FNR35IYa vtBA== X-Gm-Message-State: AOAM533gcmxeFymMKjrIlfOaSUms2+I0HUW3TMjB0HbHRl7+K1ZeFFtq nkFfykGY+VI8KwjwZpKyXH0= X-Google-Smtp-Source: ABdhPJx/xRQmXBzARSZbsvP499HmzZmSZy0y7EUODRZF4kNj5dpfL7l/6yF2dTDfWBrTwxbiGSmRew== X-Received: by 2002:a63:2a0d:0:b0:3ab:392c:f45c with SMTP id q13-20020a632a0d000000b003ab392cf45cmr4726261pgq.575.1655215451869; Tue, 14 Jun 2022 07:04:11 -0700 (PDT) Received: from localhost ([155.94.207.39]) by smtp.gmail.com with ESMTPSA id m9-20020a62a209000000b005184af1d72fsm5737499pff.15.2022.06.14.07.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 07:04:11 -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> <87mtefq3nx.fsf@localhost> Date: Tue, 14 Jun 2022 22:05:21 +0800 Message-ID: <87a6afwdb2.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=yantar92@gmail.com; helo=mail-pf1-x432.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=1655215498; 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=w1ffu9ckkXFAwEXuFSxntby/1DnbASyKUbewRH9TE84=; b=uLMwQWiG2icyCm59Jj8HUs7G/HZWNsgWb3LnKoLedjIUltVms2QZWFjlodl40iUAyIg7Io 2IuPc95ZWseEr0f7jJFCghIr7Y3qfPI7YMNeHnxsGStTJACqvIEI1Zrn4b1J/l6L8WElnX AvVeLgqf573pUsbPydKdNdsltAefxx093fFEC1K9LoZsLPTGrFrTuY2V30wJQXg/eSTLk9 R98iGaUzxKbcs0xX8PRE09cN5Y7Riq0l/7RG408RbrJsSLe88rfjlVTXs2B4sAWqWg3XHd 2XWs0tM/LnFpyvjt97f0NzxDFyKtOVMRErr/wSartECGSnUdMD0Hx8YeUUDk/A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655215498; a=rsa-sha256; cv=none; b=ASkzHkccYg6RSjmtQQ+ModlLQE/aujESIGmid/C9sXJ1Da2EDBOPU/rboUciffP37AR/Jg IELjKB75Y/dPRqTyOVN1gq4MMCd3r9+kTTpKJzG5EoiZ2gBaqKUIgnMY9xWYWEaTrTrZyw BpFlIhxsLPRKQXwWiwzFMgtgqJeF9/I0gnofsAxrF4o95kV5jUl/wvv2o+ve6ImtX+rUOv imArlhwTCzX8QejjZ2VLWdcdJICdRzQZpnqpF9hFtghNHZ8+28PdsUi4VsL/A4ZtHyR2V4 7xLfVIa1KsMIRNcfrrC4YC2ipPaFmOly2eqlifUu5OhHgAkQ9xRmvP6Q8TBhFQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lsFfWJsz; 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: -5.49 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lsFfWJsz; 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: 3CDE410C18 X-Spam-Score: -5.49 X-Migadu-Scanner: scn0.migadu.com X-TUID: hIbLKttEwgKy Ignacio Casso writes: >>> + (setq buffer-undo-list >>> + (seq-drop-while 'identity buffer-undo-list))))))) >> >> This looks fragile and can be disasterous when buffer-undo-list is >> large. > > I agree that it is very fragile, but could you explain why is it also > problematic with a large `buffer-undo-list'? I guess you mean > efficiency-wise, but it would only iterate through the few items added > since the call to (undo-boundary). Is there something else I'm not seeing? Simply because I saw iteration over a potentially large list. Looking closer, you are indeed right and performance should not be a problem in this particular scenario. >> 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. > > Done. I attach the new patch: LGTM! Applied onto main via aa789b89d. Best, Ihor