emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Al Haji-Ali <abdo.haji.ali@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [BUG] org-agenda-prepare-buffers does not save restrictions
Date: Fri, 08 Jul 2022 12:21:40 +0800	[thread overview]
Message-ID: <87a69k44kr.fsf@localhost> (raw)
In-Reply-To: <87y1x588rs.fsf@thinkpad.mail-host-address-is-not-set>

Al Haji-Ali <abdo.haji.ali@gmail.com> 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


  reply	other threads:[~2022-07-08  4:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07 11:25 [BUG] org-agenda-prepare-buffers does not save restrictions Al Haji-Ali
2022-07-08  4:21 ` Ihor Radchenko [this message]
2022-07-08  9:45   ` Al Haji-Ali
2022-07-09  3:57     ` Ihor Radchenko
2022-07-10  8:58       ` Al Haji-Ali
2022-07-10 10:06         ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a69k44kr.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=abdo.haji.ali@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).