emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug: org-map-entries calls file-exists-p when SCOPE is nil [9.4.4 (relea


From: Rodrigo Morales
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

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 via email to

[Prev in Thread] Current Thread [Next in Thread]