My configuration contains the equivalent of (setopt org-agenda-files (directory-files-recursively "~/.local/share/org/todo" ".org$"))
My Emacs setup broke today due to the presence of a lockfile inside "~/.local/share/org/todo". I use EXWM, and I show org-agenda on startup: (add-hook 'after-init-hook (lambda () (org-agenda nil "t"))) (setq initial-buffer-choice (lambda () (get-buffer "*Org Agenda*"))) org-agenda-files contained a non-existent file, so org-check-agenda-file attempted to prompt me. For some reason (maybe EXWM didn't fully load), Emacs simply hung without prompting, leaving me with a black screen. The attached patch silently removes lockfiles from org-agenda-files. Thanks! Joseph P.S. I'm not sure how the lockfile ended up there. Maybe I killed Emacs with SIGKILL while one of my agenda files was open and modified in a buffer, and so the lockfile was not deleted?
>From e69e69a03c215704d83f8388370f0db2bc93891d Mon Sep 17 00:00:00 2001 From: Joseph Turner <jos...@breatheoutbreathe.in> Date: Thu, 18 Jan 2024 22:24:10 -0800 Subject: [PATCH] * lisp/org.el (org-check-agenda-file): Silently exclude lockfiles --- lisp/org.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 8929a7217..f48a8ff46 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -15563,8 +15563,12 @@ (defun org-file-menu-entry (file) (vector file (list 'find-file file) t)) (defun org-check-agenda-file (file) - "Make sure FILE exists. If not, ask user what to do." + "Make sure FILE exists. If not, ask user what to do. +Automatically exclude lockfiles." (unless (file-exists-p file) + (when (string-match-p (rx bos ".#") file) ; Exclude lockfiles + (org-remove-file file) + (throw 'nextfile t)) (message "Non-existent agenda file %s. [R]emove from list or [A]bort?" (abbreviate-file-name file)) (let ((r (downcase (read-char-exclusive)))) -- 2.41.0