emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rodrigo Morales <moralesrodrigo1100@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Bug: org-map-entries calls file-exists-p when SCOPE is nil [9.4.4 (release_9.4.4 @ /usr/share/emacs/27.2/lisp/org/)]
Date: Fri, 01 Oct 2021 22:39:17 -0500	[thread overview]
Message-ID: <871r54m6xm.fsf@gmail.com> (raw)


Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

     https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.
------------------------------------------------------------------------

* Description of the bug

When =org-map-entries= is executed in a buffer whose associated file
doesn't exist yet and the =SCOPE= argument is =nil=, a prompt for
removing the file from agenda files is shown.

#+BEGIN_EXAMPLE
Non-existent agenda file ~/foo.org.  [R]emove from list or [A]bort?
#+END_EXAMPLE

* Expected results

The prompt for deleting the associated file from agenda files is not shown.

Why would it be required from users that the associated file exists in
disk when they only want to traverse the headlines from the current
buffer?

* Actual results

The prompt for deleting the associated file from agenda files is shown.

* Steps to reproduce this bug

1. Open a Org Mode buffer with no file saved in the hard disk. That
   is, C-x C-f ~/e/unexistent-file.org. Don't save the file. It is
   important that the associated file doesn't exist in your system.

2. Evaluate the following expression in the previous buffer
   =(org-map-entries (lambda () t))=

At this point, you will get the following prompt in the minibuffer.

#+BEGIN_EXAMPLE
Non-existent agenda file ~/unexistent-file.org.  [R]emove from list or [A]bort?
#+END_EXAMPLE

* Backtrace

The backtrace shown below was obtained by instrumenting the function
=org-check-agenda-file= and executing the command shown below in a
buffer whose associated file doesn't exist.

#+BEGIN_SRC elisp
(org-map-entries (lambda () t))
#+END_SRC

#+CAPTION: Backtrace
#+BEGIN_EXAMPLE
org-check-agenda-file("/home/myusername/unexistent-file.org")
org-agenda-prepare-buffers(("/home/beep1560/e/5.org"))
org-map-entries((closure (t) nil t))
eval((org-map-entries #'(lambda nil t)) t)
eval-expression((org-map-entries (lambda nil t)) nil nil 127)
funcall-interactively(eval-expression (org-map-entries (lambda nil t)) nil nil 127)
call-interactively(eval-expression nil nil)
command-execute(eval-expression)
#+END_EXAMPLE

Just for the record, the implementation of =org-check-agenda-file= is
shown below. As we can see below, =file-exists-p= is executed in the file.

#+BEGIN_SRC elisp
(defun org-check-agenda-file (file)
  "Make sure FILE exists.  If not, ask user what to do."
  (unless (file-exists-p file)
    (message "Non-existent agenda file %s.  [R]emove from list or [A]bort?"
	     (abbreviate-file-name file))
    (let ((r (downcase (read-char-exclusive))))
      (cond
       ((equal r ?r)
	(org-remove-file file)
	(throw 'nextfile t))
       (t (user-error "Abort"))))))
#+END_SRC

* Additional information

Adam Porter (alphapapa) reported this 2 years ago ([[https://list.orgmode.org/878t73jyow.fsf@alphapapa.net/T/][link]] to the
thread), but, this hasn't been fixed as for the latest release
(i.e. v9.5)

* System information

#+BEGIN_SRC elisp
(org-version)
#+END_SRC

#+RESULTS:
#+begin_example
9.4.4
#+end_example

#+BEGIN_SRC elisp
(version)
#+END_SRC

#+RESULTS:
#+begin_example
GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.17.4)
 of 2021-03-26
#+end_example


             reply	other threads:[~2021-10-02  3:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-02  3:39 Rodrigo Morales [this message]
2021-10-02 14:41 ` Bug: org-map-entries calls file-exists-p when SCOPE is nil [9.4.4 (release_9.4.4 @ /usr/share/emacs/27.2/lisp/org/)] Ihor Radchenko
2022-10-11  8:25   ` 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=871r54m6xm.fsf@gmail.com \
    --to=moralesrodrigo1100@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).