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 +FTIHAL+x2JqBgEAbAwnHQ (envelope-from ) for ; Fri, 08 Jul 2022 11:50:58 +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 QBaSHAL+x2IJjgAAauVa8A (envelope-from ) for ; Fri, 08 Jul 2022 11:50: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 D631D28BDD for ; Fri, 8 Jul 2022 11:50:57 +0200 (CEST) Received: from localhost ([::1]:59006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9kdS-0006Hs-Fo for larch@yhetil.org; Fri, 08 Jul 2022 05:50:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9kcm-0006HX-Gz for emacs-orgmode@gnu.org; Fri, 08 Jul 2022 05:50:13 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:36772) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9kck-00015X-Aw for emacs-orgmode@gnu.org; Fri, 08 Jul 2022 05:50:12 -0400 Received: by mail-wr1-x431.google.com with SMTP id o4so29799891wrh.3 for ; Fri, 08 Jul 2022 02:50:07 -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=YKRHuzVZsdX8NWjc5uQL+eVJP7UN0rGBlYfnjqS/FaE=; b=ndG/Zg3po6RE+R1kz2X+DLiDNR04axDnXJ1yQyTpzSyFVJaSnV+MTynoNJwYgzezoE 9sCVhLqItf1ypoi9sFuojFeWghTuq++vhkBut7WTW0ZJZ7L31OuY4luMhNGuc+HtElKK L3JASoL2WBnUQ/fmg+gGG3i9yLLYGsFJzmb+gnRpUudEQNCg88BQ8i9R6XnNGcwBxw/d EI3cOjZVJIZmLSFEgWn1v+lV/s8Damm+E9IRCoU5kMifRWefZuhfdqgoLcYITrP7xzSl LvbO8TH65FOwE+0B772gwEWyzPg4PBnFED76j4PKyqhmzO3pF6X1GerJvTm9Fli0vEnD 5Iow== 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=YKRHuzVZsdX8NWjc5uQL+eVJP7UN0rGBlYfnjqS/FaE=; b=YuMfxaM7byHwSLYg4SoiRHwXKF78idmYYkb/XVRaTVeyRA19/YE9KVzrKGydTAHVk+ Fx+UwhfK95SHC5eAf93Ytz2pSUoXAv2y6HQnqg5nZVKv0+lGvAO4n3MENVvtfXElQBJd XTOXbSbLPRLN2as7FCH+MJZdpmF7GGlwletCH7b07491vj+Q/7Pw2mqyD/SP7xAvc2be Lqz+zUBWostNWDPLmU73HbhJxheEJ5O7UX/QIWNkJ38ByqChbemjza77cXolzlYVt0IT NVA4WLPerl+EEvRb9A8sost6zchIMmh3/xoftXAGAMMjXkWufiUvEYwdcLQYULux40bt Sr5A== X-Gm-Message-State: AJIora9qYIulq7b5jGrEuFll1dh0l6bAhoDYWnJ2B8lj6ZOcZ3xcjYnC tvQnznY+PofgsQ3Y4wgywIA= X-Google-Smtp-Source: AGRyM1tAy8cnrlK/f4XRWr7uHWlwDcSmdC0ga0oRamIt/UufQX++69gs7iJr7eIaJORjq8pWhJkqMg== X-Received: by 2002:a5d:6241:0:b0:21d:8786:b131 with SMTP id m1-20020a5d6241000000b0021d8786b131mr2394726wrv.386.1657273805616; Fri, 08 Jul 2022 02:50:05 -0700 (PDT) Received: from localhost ([137.195.26.27]) by smtp.gmail.com with ESMTPSA id s1-20020a5d4ec1000000b0021004d7d75asm14567453wrv.84.2022.07.08.02.50.04 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 02:50:04 -0700 (PDT) From: Al Haji-Ali To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] org-agenda-prepare-buffers does not save restrictions In-Reply-To: <87a69k44kr.fsf@localhost> References: <87y1x588rs.fsf@thinkpad.mail-host-address-is-not-set> <87a69k44kr.fsf@localhost> Date: Fri, 08 Jul 2022 10:45:11 +0100 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=abdo.haji.ali@gmail.com; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_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=1657273858; 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=YKRHuzVZsdX8NWjc5uQL+eVJP7UN0rGBlYfnjqS/FaE=; b=c0i1Y6SNoqk9tJ7AE9PgtflHmgg3kJJc9/lCA8YrHefov/2gyL/ukUcnK0HRkH83yx+s/0 LY9xATHmHIYrwErvStO6S1C0JkIpitZAUONvb5Jle75LbyodudM9O73VZF0cXu5mLrlm8V lSExL3zUSmC++RAMm6/KlEMT+FvmDltSI2gzAIvwTpRTPKs61WCazB5WQ32ELnoLgT+D/u TkVfzXHMgA+taVGTxl2mt7+jhjnJNnqs5qyevVl0JWN83mB1H5P9yqnWaX/fXEBAPe1bny jSwsEE59fVHLo4FgYKI2To06ua2m/eeAmXHEmD2+yOMy2vJzr6iaGUH+RTe4IA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1657273858; a=rsa-sha256; cv=none; b=KRhsICzEhCtyKyHUUGEqmdz7FQDZ7FaHcD7YRTiCXhvQlqqR8H/yXlV1zYfjowCe/UvzAd ++NQxMcB3ldBuDolFzwJVqFfpe2cMDPjQjCv53enXNZ3ItdWzjrHchi4lxzq60Kc+2tgbz YkWpRKwo/7xd2iUZHbIgKPpXNX0gmZeKemh/L76X3K5i5/S4Y2jkRkrfiRiypER4L8eii0 e17sc78Z2wfdRRlGX1AuzSJGEeWwrRVVYqMq9BG8quq9K68a1N2NW0JDqaBUBdqskfCs0F pmKmgdYMD4UQxwM7XfTTIpq8hFBUA3B3ugBJ2G7tQvJ8YSv+lN/BTzyhAQR3Yg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="ndG/Zg3p"; 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: -7.44 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="ndG/Zg3p"; 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: D631D28BDD X-Spam-Score: -7.44 X-Migadu-Scanner: scn0.migadu.com X-TUID: /cZKEJkthpos --=-=-= Content-Type: text/plain On 08/07/2022, Ihor Radchenko wrote: > Could you please create a proper patch See attached. I made a further change to use `with-current-buffer` instead of `set-buffer+save-excursion`. Best regards, -- Al --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=save-restrictions-agenda-buf.patch >From 398fee0c235c53399cd8cc481f9e732f64ae88cb Mon Sep 17 00:00:00 2001 From: Al Haji-Ali Date: Fri, 8 Jul 2022 10:24:08 +0100 Subject: [PATCH] lisp/org.el: Save restrictions in all agenda file buffers. * lisp/org.el (org-agenda-prepare-buffers): Call `save-restriction'/`save-excursion' for every buffer in the agenda instead of just once for the current buffer. Use `with-current-buffer' instead of `set-buffer'/`save-excursion'. TINYCHANGE --- lisp/org.el | 80 ++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 661efeb9c..ef3e4b950 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -15031,49 +15031,47 @@ When a buffer is unmodified, it is just killed. When modified, it is saved "Create buffers for all agenda files, protect archived trees and comments." (interactive) (let ((inhibit-read-only t) - (org-inhibit-startup org-agenda-inhibit-startup) - pos) + (org-inhibit-startup org-agenda-inhibit-startup)) (setq org-tag-alist-for-agenda nil org-tag-groups-alist-for-agenda nil) - (save-excursion - (save-restriction - (dolist (file files) - (catch 'nextfile - (if (bufferp file) - (set-buffer file) - (org-check-agenda-file file) - (set-buffer (org-get-agenda-file-buffer file))) - (widen) - (org-set-regexps-and-options 'tags-only) - (setq pos (point)) - (or (memq 'category org-agenda-ignore-properties) - (org-refresh-category-properties)) - (or (memq 'stats org-agenda-ignore-properties) - (org-refresh-stats-properties)) - (or (memq 'effort org-agenda-ignore-properties) - (unless org-element-use-cache - (org-refresh-effort-properties))) - (or (memq 'appt org-agenda-ignore-properties) - (org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime)) - (setq org-todo-keywords-for-agenda - (append org-todo-keywords-for-agenda org-todo-keywords-1)) - (setq org-done-keywords-for-agenda - (append org-done-keywords-for-agenda org-done-keywords)) - (setq org-todo-keyword-alist-for-agenda - (append org-todo-keyword-alist-for-agenda org-todo-key-alist)) - (setq org-tag-alist-for-agenda - (org--tag-add-to-alist - org-tag-alist-for-agenda - org-current-tag-alist)) - ;; Merge current file's tag groups into global - ;; `org-tag-groups-alist-for-agenda'. - (when org-group-tags - (dolist (alist org-tag-groups-alist) - (let ((old (assoc (car alist) org-tag-groups-alist-for-agenda))) - (if old - (setcdr old (org-uniquify (append (cdr old) (cdr alist)))) - (push alist org-tag-groups-alist-for-agenda))))) - (goto-char pos))))) + (dolist (file files) + (catch 'nextfile + (with-current-buffer + (if (bufferp file) + file + (org-check-agenda-file file) + (org-get-agenda-file-buffer file)) + (save-excursion + (save-restriction + (widen) + (org-set-regexps-and-options 'tags-only) + (or (memq 'category org-agenda-ignore-properties) + (org-refresh-category-properties)) + (or (memq 'stats org-agenda-ignore-properties) + (org-refresh-stats-properties)) + (or (memq 'effort org-agenda-ignore-properties) + (unless org-element-use-cache + (org-refresh-effort-properties))) + (or (memq 'appt org-agenda-ignore-properties) + (org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime)) + (setq org-todo-keywords-for-agenda + (append org-todo-keywords-for-agenda org-todo-keywords-1)) + (setq org-done-keywords-for-agenda + (append org-done-keywords-for-agenda org-done-keywords)) + (setq org-todo-keyword-alist-for-agenda + (append org-todo-keyword-alist-for-agenda org-todo-key-alist)) + (setq org-tag-alist-for-agenda + (org--tag-add-to-alist + org-tag-alist-for-agenda + org-current-tag-alist)) + ;; Merge current file's tag groups into global + ;; `org-tag-groups-alist-for-agenda'. + (when org-group-tags + (dolist (alist org-tag-groups-alist) + (let ((old (assoc (car alist) org-tag-groups-alist-for-agenda))) + (if old + (setcdr old (org-uniquify (append (cdr old) (cdr alist)))) + (push alist org-tag-groups-alist-for-agenda)))))))))) (setq org-todo-keywords-for-agenda (org-uniquify org-todo-keywords-for-agenda)) (setq org-todo-keyword-alist-for-agenda -- 2.24.4 --=-=-=--