From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: org-map-entries calls org-agenda-prepare-buffers unnecessarily? Date: Tue, 26 Jun 2018 18:19:00 +0200 Message-ID: <87r2ktr05n.fsf@nicolasgoaziou.fr> References: <878t73jyow.fsf@alphapapa.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXqgN-0000da-QY for emacs-orgmode@gnu.org; Tue, 26 Jun 2018 12:19:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXqgK-0005lP-Kw for emacs-orgmode@gnu.org; Tue, 26 Jun 2018 12:19:07 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:33907) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fXqgK-0005je-EK for emacs-orgmode@gnu.org; Tue, 26 Jun 2018 12:19:04 -0400 In-Reply-To: <878t73jyow.fsf@alphapapa.net> (Adam Porter's message of "Sun, 24 Jun 2018 23:07:59 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Adam Porter Cc: emacs-orgmode@gnu.org Hello, Adam Porter writes: > I've noticed that org-map-entries calls org-agenda-prepare-buffers > whenever its SCOPE argument is nil. According to the docstring, a nil > SCOPE means, "The current buffer, respecting the restriction if any," so > it doesn't seem necessary to call org-agenda-prepare-buffers. Here be dragons! > I noticed this because I have a function in my org-mode-hook that runs > org-map-entries (applying a read-only property to entries with a > read_only tag), and whenever I find-file on a non-existent Org file, I'm > prompted, "Non-existent agenda file %s. [R]emove from list or > [A]bort?", which is caused by org-map-entries being called with a nil > SCOPE, which calls org-agenda-prepare-buffers, which calls > org-check-agenda-file on the not-yet-existent file. So if this behavior > is indeed unnecessary, it would be nice to fix it. For simple cases like yours, I suggest to map over headlines manually, e.g., (goto-char (point-min)) (unless (org-at-heading-p) (outline-next-heading)) (while (not (eobp)) ... do stuff...) > Is this a bug, or am I missing something? Neither. `org-map-entries' is a complex function that arguably does more than it should. Regards, -- Nicolas Goaziou