[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Silently remove lockfiles from org-agenda-files
From: |
Joseph Turner |
Subject: |
Re: [PATCH] Silently remove lockfiles from org-agenda-files |
Date: |
Wed, 31 Jan 2024 13:51:18 -0800 |
Hi Ihor,
Ihor Radchenko <yantar92@posteo.net> writes:
> Joseph Turner <joseph@breatheoutbreathe.in> writes:
>
>> 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.
>
> You may consider reporting the hang to Emacs or EXWM bug tracker.
>> My configuration contains the equivalent of
>>
>> (setopt org-agenda-files
>> (directory-files-recursively "~/.local/share/org/todo" ".org$"))
>
> I'd recommend using a different approach - use org-agenda-file-regexp
> instead of ".org$"; or use #'file-directory-p as predicate - Org mode
> then select Org files inside all the listed directories by itself.
Good to know about org-agenda-file-regexp.
>> The attached patch silently removes lockfiles from org-agenda-files.
>
>> - "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))
>
> I feel slightly reluctant about this patch:
>
> 1. You are only working around the actual problem with agenda file being
> deleted from disk while Emacs is loading. So, the patch is not
> solving a real Org mode problem - Org mode prompting about
> non-existing file is not wrong; your bug has nothing to do with Org
> mode itself.
>
> 2. In theory, there might be users with actual Org files starting from
> ".#" for whatever reason. The probability is not high, but if users
> choose to set org-agenda-files directly, file-by-file, that's a
> choice we should better respect in order to not create a blocker.
Yes, I think you're right. Thanks for your caution :)
Joseph