From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 g301MIGyx2LDfgEAbAwnHQ (envelope-from ) for ; Fri, 08 Jul 2022 06:28:49 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id yLMJL4Gyx2L3NQAAauVa8A (envelope-from ) for ; Fri, 08 Jul 2022 06:28:49 +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 59D8610B02 for ; Fri, 8 Jul 2022 06:28:49 +0200 (CEST) Received: from localhost ([::1]:44424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9fbj-0000jT-Mw for larch@yhetil.org; Fri, 08 Jul 2022 00:28:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9fTq-0005eO-DT for emacs-orgmode@gnu.org; Fri, 08 Jul 2022 00:20:38 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:47096) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9fTo-0000kR-Jk for emacs-orgmode@gnu.org; Fri, 08 Jul 2022 00:20:38 -0400 Received: by mail-pf1-x430.google.com with SMTP id a15so22514352pfv.13 for ; Thu, 07 Jul 2022 21:20:35 -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=YRpXFC8buN8KDspJRM2CQ35Xn2z/5rDsgs7DXBkcE6s=; b=ob1/H0fTD8WRl3dFMsA6OnmXPSOh2j4UlEwkOeSpsBiI7Mm2vOxmYTZmi9HLqh3Vy5 5EroyadUwrxLH+aRouakFrfrXMS3ltumsngLMsWy3idsdfmwhRLv86lPSQU7dIBjcqT/ clqowuXKtjvCsj8/KfNr0ncFRRIBtYl6YBJiLNnw56bWJN7VmImsGlscApzB6FMTcRGC LjS88l9um0iXyZP2VMZQWH21uQF7CGUSVQyuAoQ3eFs9UNRdGDUdVu2BzPnyFWWesesz VRcKdeTI1WmHECRa14vwPitatCR9m3r5HMANwcphT/kdHaESlhJA95Wx9LEg4/A/Ps1k KQPQ== 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=YRpXFC8buN8KDspJRM2CQ35Xn2z/5rDsgs7DXBkcE6s=; b=GB/a3SbXoU6fIS2xn4i14j4Aw13iKUqdWOiX1cnWZO4C9H3gPuInAydbsR3wxCYlPp QF4OFn4lilISRUGo81WG4i3azY3T3ajJNYdXbS06QES/ncW9dP0ljeKr/kkwdBZ7IIMk GB/zGmWP753hHtFC1gC+2SNiFY4uSxFZP/FE6ukQ0mNf1QHkXeFVo3dOS1QgqZhM8uBs ar+KnywWABseskRyCGJPNIN1ZkEgTNsonEYXaNro8OCcSvmcXbsBHl+gTKPxOgRwdCMQ dEtOXnA5bplv2NIZBNS4TNI7wY45kj73FivNfw2yC55olPOWJCB+nVINbcelrx9ombRk Fnrg== X-Gm-Message-State: AJIora9RYHMsWLQqSVkF5asTCLMMEcgb4ecJuOvOp8cdCX8l+nDGIOI2 cttmH0uD92s7Xk/CwmxAMHQ= X-Google-Smtp-Source: AGRyM1v5jdA1vkUDkFrbcdRIfE4oU4IpfBH+snRiLlM7wRCOqYONL+L3ikn7hLMjs1s9XRB6aat9+Q== X-Received: by 2002:aa7:8018:0:b0:528:9759:30f5 with SMTP id j24-20020aa78018000000b00528975930f5mr1543048pfi.33.1657254034471; Thu, 07 Jul 2022 21:20:34 -0700 (PDT) Received: from localhost ([155.94.207.39]) by smtp.gmail.com with ESMTPSA id q1-20020a170902eb8100b0016c08addb4csm3561708plg.127.2022.07.07.21.20.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 21:20:33 -0700 (PDT) From: Ihor Radchenko To: Al Haji-Ali Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] org-agenda-prepare-buffers does not save restrictions In-Reply-To: <87y1x588rs.fsf@thinkpad.mail-host-address-is-not-set> References: <87y1x588rs.fsf@thinkpad.mail-host-address-is-not-set> Date: Fri, 08 Jul 2022 12:21:40 +0800 Message-ID: <87a69k44kr.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=yantar92@gmail.com; helo=mail-pf1-x430.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=1657254529; 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=YRpXFC8buN8KDspJRM2CQ35Xn2z/5rDsgs7DXBkcE6s=; b=bLWRztWckkkT7b7dF0hvoaTUwoQME7UzWh+delyYVHTAc928ZatwNlgQcnIETmWs2nPWst SkVcdihpyUx1C2KRrgd5vWW2ffs070GR4STSTUX7msGqcqZxo9e+38YSBg1ARGUgizJG67 rrBrj0hqTmYsKYboK70iYUtes0w/PQwp0e94b8bJ/zlzrz1AVUHfuNeRyJWYz0pkMGojYX tpyG+gp04TFBJduLE0HbpG9ZK1FTkmFCESt85zQ334fw7LNbFRj3TSZhMgCM9XXt1NIGKu 0TQ2M5LBah+EqGMgxFQ1mZC+NsqyHzYcxCgW+FSQPRagVyHBVvNpA2doxoloaQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1657254529; a=rsa-sha256; cv=none; b=kU+KSkzb5rDicWnip5SjWIzc7uJM0+Ajqra7B2pzyPgR1kjSYsTGVrjnT2DM/Y/0HLhIBO s/YSfTaaSWR11XkLuRCgMzRTIFXPQiEauw8P+lckQmQ0toItyfqzDa25/6azzTu6d6iJmh C+Y0gXQZZ0kmuFhp3FYrafBoNZH/OS20pqM9COtHcv1Y5cJhKtxb5T+5ZuOvKGn+jM9cU9 uG8jEXguv9A69hYHymEjhJDxQPAricS1KNF+rCDKgjyuwzO3nb2ku5sgvT6cmwmiDy4mPe fu20uJyWpJt/he310qgyV8sJIclrTS/TdITOtUfT91F/Ft4OSSMvFNv2snygSw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="ob1/H0fT"; 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.44 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="ob1/H0fT"; 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: 59D8610B02 X-Spam-Score: -3.44 X-Migadu-Scanner: scn1.migadu.com X-TUID: 98ZqDG0/HRYw Al Haji-Ali writes: > I am not sure if this has been reported before, of if the behaviour is intended. But to reproduce this "bug": > - Open an org file from the agenda. > - Restrict to some headline > - Execute the following command: > > (with-temp-buffer > (org-agenda-prepare-buffers (org-agenda-files t))) > > - The restriction is removed. > > Note that executing `(org-agenda-prepare-buffers (org-agenda-files t))` in the buffer (without `with-temp-buffer`) restores the restriction upon completion. > > The reason is that `save-restriction` (and `save-excursion`) are called in `org-agenda-prepare-buffers` > before switching to the buffer of the org file so the restriction is not saved (the point is manually restored but not the restriction). > > This has implications on running `org-map-entries` where all org buffers in the agenda (beside the current one) lose their restrictions. I agree that the current behavior might be unexpected. I also do not see any potential side effects of applying the proposed patch. > Attached is a possible patch to fix this. Thanks for the patch! The patch looks good. Could you please create a proper patch following https://orgmode.org/worg/org-contribute.html#first-patch instructions? You will need to add the proper commit message and add TINYCHANGE line to the message. All the details are described in the link. Best, Ihor