all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Joseph Turner <joseph@breatheoutbreathe.in>
Cc: Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Silently remove lockfiles from org-agenda-files
Date: Fri, 19 Jan 2024 13:19:33 +0000	[thread overview]
Message-ID: <87y1clo3yy.fsf@localhost> (raw)
In-Reply-To: <87wms5stho.fsf@breatheoutbreathe.in>

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.

> 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.

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


  reply	other threads:[~2024-01-19 13:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19  6:27 [PATCH] Silently remove lockfiles from org-agenda-files Joseph Turner
2024-01-19 13:19 ` Ihor Radchenko [this message]
2024-01-31 21:51   ` Joseph Turner
2024-02-01 11:47     ` 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y1clo3yy.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=joseph@breatheoutbreathe.in \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.