When I create an .org file (C-x C-f, find-file), the following appears in the mini-buffer: "Non-existent agenda file. [R]emove from list or [A]bort?". The question is not asked when creating a .txt file, for example. Any suggestions on how to troubleshoot and fix the problem?

I found a very old org message thread that discussed a similar problem. I checked the value of before-save-hook and it contains values set by org-roam and vulpea packages. If I follow the old thread, one or both are invoking org-check-agenda-file and "...if the current buffer has not been written out yet, this pops the question". If all that is true and still relevant after 10+ years of updates, is there a way to resolve the problem?

UPDATE: The value of before-save-hook is:

before-save-hook is a variable defined in ‘files.el’.
Its value is (org-roam-link-replace-all t)
Original value was nil
Local in buffer error_when_creating_org_file.org; global value is 

I re-started emacs after removing vulpea, the behavior persisted. I re-started emacs after removing vulpea and org-roam, the behavior persisted! I checked value of before-save-hook, and it is nil. But find-file still queries with non-existent agenda file and asks to remove/abort. So it appears that the issue is not due to either package nor due to values of before-save-hook.

  • What are the values in before-save-hook?
    – NickD
    Jan 21, 2022 at 19:55
  • ... and perhaps more importantly, why are they in before-save-hook?
    – NickD
    Jan 21, 2022 at 20:42
  • BTW, I changed the title: it is not an error, not by Emacs or Org mode in any case.
    – NickD
    Jan 21, 2022 at 20:45
  • @NickD... re:edits, thanks. I updated post with value of before-save-hook. The packages (org-roam and vulpea) designate those values. Not part of myinit.el. My guess: org-roam updates its database when a file is saved, and vulpea updates file-level tag when a file is saved.
    – midas0441
    Jan 22, 2022 at 6:58
  • 1
    Rereading the question, I missed a possibly important point: does the question appear when you open the file, or when you try to save it? If it happens when you open the file, then before-save-hook is the wrong hook to check: maybe check find-file-hook? And maybe org-mode-hook as well?
    – NickD
    Jan 22, 2022 at 14:29

2 Answers 2


Following @NickD suggestion (thanks!), the offending function has been found (based on initial testing). It made sense to examine org-mode-hook because the behavior was specific to creating *.org files. There were several functions in that hook. The most suspicious one (I'll call it problematic-func) contained a call to org-map-entries. In my original post, I referenced an old message thread, which traced the unwanted behavior to calling org-map-entries. I removed problematic-func from org-mode-hook, and the behavior no longer occurs. I plan to use (when (file-exists-p (buffer-file-name (current-buffer))) problematic-func) to resolve the problem (this is how the original poster on the old thread resolved their problem while maintaining the functionality of problematic-func.

  • Glad you got it sorted!
    – NickD
    Jan 23, 2022 at 15:17

I use "org-map-entries" to fold all properties drawers, I met the same error when I use org-roam-dailies-goto-today to create a org file.

Now I use org-element-map to replace org-map-entries, it works without any problem

(defun wu/list-and-fold-property-drawers ()
  "List all property drawers in the current buffer and fold them."
  (org-element-map (org-element-parse-buffer) 'property-drawer
    (lambda (property-drawer)
      ;; (message "Property drawer found at position %s" (org-element-property :begin property-drawer))
        (goto-char (org-element-property :begin property-drawer))
        (org-hide-drawer-toggle t)))))

(add-hook 'org-mode-hook #'wu/list-and-fold-property-drawers)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.