reddit / emacs

Set org mode default tags in .dir-locals.el?

the_plonkmaster · 2022-10-21 03:14
Hi folks, This is probably quite a simple question and more to do with Emacs Lisp syntax than anything else. I'm trying to set Org's `org-tag-alist` variable so that a directory containing all my projects can easily have the type of project categorised according to some default tags. Unfortunately, the `.dir-locals.el` file uses different syntax (dot notation?) to what I'm already barely used to with regular Emacs Lisp, so I'm struggling to make it work. In particular, I'm trying to get some group tags in that variable, but I'm utterly clueless because I just haven't had the time to learn Emacs Lisp yet. Could anyone supply a minimum working example of a `.dir-locals.el` snippet that adds group tags to Org mode? Many, many thanks in advance!
kastauyra · 2022-10-21 04:13
This is not answering your question directly so feel free to ignore, but one way to make all org files in a dir to share setup, including tags, is: * create a file, say `setup.org`: ```org #+TAGS: project(p) #+TAGS: { @agenda(a) ... } ... ``` * Add one line to the rest of files in the dir: ```org #+SETUPFILE: setup.org ``` and you are set.
the_plonkmaster · 2022-10-21 04:43
Thank you for that. It may be a good fix if my preferred approach doesn't end up working. Cheers!
h-m-b-tu · 2022-10-21 06:37
There is an info page called "Per-Directory Local Variables" which clearly states the syntax including an example. Issue `info-apropos` and search for "dir-locals".
the_plonkmaster · 2022-10-21 07:18
I have taken a look at that page but it's not quite clear to an Elisp beginner like me. I'm pretty experienced with programming but Lisp's syntax is completely alien; couple that with the fact that I've not actually learned the lang and I'm struggling a little to turn the `setq` examples for setting that Org variable into the dot notation.
[deleted] · 2022-10-21 08:08
Who gave you the idea you needed to learn Emacs Lisp to set user options? M-x add-dir-local-variable RET
0lMon · 2022-10-21 08:39
Hej Hej, Here is a minimal example for `.dir-locals.el` with the example from here: https://orgmode.org/manual/Setting-Tags.html ((org-mode . ((org-tag-alist . ((:startgroup . nil) ("@work" . ?w) ("@home" . ?h) ("@tennisclub" . ?t) (:endgroup . nil) ("laptop" . ?l) ("pc" . ?p)))))) There is probably a little bit of reading ahead of you to understand it by heart. But Maybe this plus the Docs will be enough! Happy Coding! Cheers!
organic-bookworm · 2022-10-21 16:28
Use `M-x customize-option org-tag-alist RET` beforehand -- and you won't need no Lisp. For now...
[deleted] · 2022-10-21 22:31
Oh wow, here I assumed that OP wanted to override the option for a specific directory, but rereading the post I think you're right, it's just setting an option.
organic-bookworm · 2022-10-22 06:38
Nah, it's fine. > Unfortunately, the .dir-locals.el file uses different syntax [...] so I'm struggling to make it work. You've addressed this issue. I just extended your answer a bit.