* [Bug?] Non-existent agenda file %s.
@ 2024-03-25 20:15 Akash Pal
2024-03-28 19:21 ` Ihor Radchenko
0 siblings, 1 reply; 2+ messages in thread
From: Akash Pal @ 2024-03-25 20:15 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 2468 bytes --]
I came across this flow of execution while trying to export a ghost
org-file to pdf, meaning that the file is 'created' through #'find-file but
not saved. While export the following backtrace is noted:
```
Debugger entered--entering a function:
* org-check-agenda-file("/home/akash/Desktop/test.org")
org-agenda-prepare-buffers(("/home/akash/Desktop/test.org"))
org-map-entries((lambda nil (org-set-tags (delete "attached"
(org-get-tags)))) "attached")
custom/org-export-remove-attached-tag(latex)
org-export-as(latex nil nil nil (:output-file "org-exports/test/test.tex"))
org-export-to-file(latex "org-exports/test/test.tex" nil nil nil nil
nil org-latex-compile)
org-latex-export-to-pdf(nil nil nil nil)
org-export-dispatch(nil)
funcall-interactively(org-export-dispatch nil)
command-execute(org-export-dispatch)
```
I have provisions to call #'org-map-entries before export this triggers
#'org-agenda-prepare-buffers which finally calls #'org-check-agenda-files
This asks the user what to do with a non existent file
Non-existent agenda file %s. [R]emove from list or [A]bort?
*Problem*
I think this should not be called unless the file is part of
'org-agenda-files
I have resorted to advicing the function as follows:
```
;; Advice-Patch
;; if #'org-map-entries is called then #'org-check-agenda-file is
executed through #'org-agenda-prepare-buffers
;; issue: neither functions is relevant to non-agenda files, causes
bug asking user for extra input
;; Non-existent agenda file %s. [R]emove from list or [A]bort?
;; see : https://github.com/bzg/org-mode/blob/ec5d76bce1434a54a9a529dbe250b09dc3c132c0/lisp/org.el#L15340
;; Possible solution: Do not call #'org-agenda-prepare-buffers for
non-agenda files => ~exist 'org-agenda-files
(defun my-org-agenda-prepare-buffers-advice (orig-func &rest args)
"Advice function to modify `org-agenda-prepare-buffers'.
It filters the FILES argument to ensure only agenda files are processed."
(let ((files (if (listp (car args)) (car args) nil)))
(when files
(setq files (seq-filter #'(lambda (file) (member file
org-agenda-files)) files)))
(apply orig-func (list files))))
(advice-add 'org-agenda-prepare-buffers :around
#'my-org-agenda-prepare-buffers-advice)
```
I don't know if this is a bug or something peculiar to my use case. Leaving
the solution for others to see and possibly advice further.
First posted on reddit r/emacs.
https://www.reddit.com/r/emacs/comments/1bnhz24/bug_nonexistent_agenda_file_s/
[-- Attachment #2: Type: text/html, Size: 3320 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Bug?] Non-existent agenda file %s.
2024-03-25 20:15 [Bug?] Non-existent agenda file %s Akash Pal
@ 2024-03-28 19:21 ` Ihor Radchenko
0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2024-03-28 19:21 UTC (permalink / raw)
To: Akash Pal; +Cc: emacs-orgmode
Akash Pal <akashpaul21@gmail.com> writes:
> I came across this flow of execution while trying to export a ghost
> org-file to pdf, meaning that the file is 'created' through #'find-file but
> not saved. While export the following backtrace is noted:
>
> ```
> Debugger entered--entering a function:
> * org-check-agenda-file("/home/akash/Desktop/test.org")
> org-agenda-prepare-buffers(("/home/akash/Desktop/test.org"))
> org-map-entries((lambda nil (org-set-tags (delete "attached"
> ...
> I have provisions to call #'org-map-entries before export this triggers
> #'org-agenda-prepare-buffers which finally calls #'org-check-agenda-files
>
> This asks the user what to do with a non existent file
>
> Non-existent agenda file %s. [R]emove from list or [A]bort?
>
> *Problem*
>
> I think this should not be called unless the file is part of
> 'org-agenda-files
This has been fixed already, on main branch.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=6223f20a6
Canceled.
--
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] 2+ messages in thread
end of thread, other threads:[~2024-03-28 19:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-25 20:15 [Bug?] Non-existent agenda file %s Akash Pal
2024-03-28 19:21 ` 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).