Now that I have the power of large language models, in the palm of my hand …
You just had to be there, to really appreciate this 😂
Image, courtesy user straiven on makeagif
I decided to see, if it could help me solve one of my real pain points with Org Mode.
I had asked for help over on the fediverse, after months of trial and error, on just how to fix this.
The issue being, I needed a way to tell my Org Agenda, to ignore files with a certain pattern.
I have a folder (called syncbox
) full of files, that Org Mode looks at to generate the agenda for me.
Now these files are also synced via Syncthing over to my phone, where another program called Beorg looks at them too and shows them as entries in my calendar, so that I don’t miss the really important things I need to do.
Functionally, all is well with this setup, except for one teensy thing.
Every once in a while, when certain files are in use on both, my desktop and my phone, Syncthing will create conflicting copies of said files in use.
This happens most often, with my tasks.org
file.
Once it conflicts, my syncbox
gets full with files like,tasks.sync-conflict-20240408-041556-2TQWENY.org
andtasks.sync-conflict-20240516-101335-2TQWENY.org
andtasks.sync-conflict-20240520-053451-2TQWENY.org
What happens then, is that Org Agenda happily reads those files too, and I end up with lots of duplicated tasks.1
As usual, tackling it by writing lisp, was an idea fraught with terror for me. I tried quite a bit and failed.
My next plan of attack was that Org Agenda had a regex2, that it would process. My regex is better than my lisp, but even that was to no avail.
Emacs regex does not support lookaheads / lookbehinds and I did not want to have some complicated pattern, that even I would not recognise, a few months down the line.
In the meanwhile, Ihor told me to stop faffing about and just write a function3
So I asked Claude to go do the work for me and I ended up with …
(defun mjb/set-org-agenda-files-from-syncbox-directory ()
"Set `org-agenda-files' to all Org files in the 'syncbox' directory, excluding files with '.sync-conflict' in the name."
(let ((syncbox-dir (expand-file-name "syncbox" my-org-directory)))
(when (file-directory-p syncbox-dir)
(setq org-agenda-files
(mapcar
(lambda (file) (expand-file-name file syncbox-dir))
(seq-filter
(lambda (file) (not (string-match-p "\\.sync-conflict" file)))
(directory-files syncbox-dir t "\.org$")))))))
(mjb/set-org-agenda-files-from-syncbox-directory)
which I dutifully dumped into my init
file.
And that did the trick!
What did strike me, is that now that I am using this approach, my chicken and egg struggle is finally at an end. I don’t have to struggle to learn lisp to hack emacs which needs me to learn lisp.
I realise it takes only a short time of dedicated effort. But right now, it is time I don’t have, and don’t know when I’ll get.
So the new fangled LLM AIs can help me sort my Emacs pain points and I can learn Lisp at leisure.
And I’ll use, friend on the fediverse, Vincent Dardel’s excellent course to do just that.
Feedback on this post? Mail me at feedback at this domain
P.S. Subscribe to my mailing list!
Forward these posts and letters to your friends and get them to subscribe!
P.P.S. Feed my insatiable reading habit.
It drove me nuts in the beginning, when I did not know what was happening. I was like, I /just/ finished this task. And it’s popping up again?! Is my computer haunted? ↩︎
defined in
org-agenda-file-regexp
with a default value of"\\`[^.].*\\.org\\'"
↩︎He did not quite put it that way. He was much kinder, obviously :) ↩︎