emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Akash Pal <akashpaul21@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [Bug?] Non-existent agenda file %s.
Date: Tue, 26 Mar 2024 01:45:05 +0530	[thread overview]
Message-ID: <CA+6WspKWKD1t_xU6X+PyBXx4F3Smw+j0OuNg3yLoYtDUxnMj+w@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2024-03-28 13:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 20:15 Akash Pal [this message]
2024-03-28 19:21 ` [Bug?] Non-existent agenda file %s 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=CA+6WspKWKD1t_xU6X+PyBXx4F3Smw+j0OuNg3yLoYtDUxnMj+w@mail.gmail.com \
    --to=akashpaul21@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).