emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* 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/)]
@ 2021-10-02  3:39 Rodrigo Morales
  2021-10-02 14:41 ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Rodrigo Morales @ 2021-10-02  3:39 UTC (permalink / raw)
  To: emacs-orgmode


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: 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/)]
  2021-10-02  3:39 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/)] Rodrigo Morales
@ 2021-10-02 14:41 ` Ihor Radchenko
  2022-10-11  8:25   ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Ihor Radchenko @ 2021-10-02 14:41 UTC (permalink / raw)
  To: Rodrigo Morales; +Cc: emacs-orgmode

Rodrigo Morales <moralesrodrigo1100@gmail.com> writes:

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

Confirmed



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: 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/)]
  2021-10-02 14:41 ` Ihor Radchenko
@ 2022-10-11  8:25   ` Ihor Radchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Ihor Radchenko @ 2022-10-11  8:25 UTC (permalink / raw)
  To: Rodrigo Morales; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@gmail.com> writes:

> Rodrigo Morales <moralesrodrigo1100@gmail.com> writes:
>
>> #+BEGIN_EXAMPLE
>> Non-existent agenda file ~/foo.org.  [R]emove from list or [A]bort?
>> #+END_EXAMPLE
>
> Confirmed

Fixed on main.
Sorry for the delay.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=88c85d620bb0153f0290552b5eb3b333a32f7fb8


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-11  8:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-02  3:39 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/)] Rodrigo Morales
2021-10-02 14:41 ` Ihor Radchenko
2022-10-11  8:25   ` Ihor Radchenko

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).