Open utterances-bot opened 1 year ago
Hello, I am referencing your functions here for some custom capture functions that serve a similar purpose. I noticed that in your vulpea-capture-meeting-target
function you have the following section:
(format org-complex-heading-regexp-format
(regexp-quote headline))
Emacs tells me that org-complex-heading-regexp-format
is a buffer-local variable when set, so it appears to me that you are using format
to set a variable. The documentation for format
doesn't mention this use-case, it only talks about formatting a string with a format control string and objects. However, your usage doesn't seem to align with this kind of usage, so I am surprised at how this works! Can you clarify what is going on here?
Hey @danielclucas,
No, I am not setting the value of org-complex-heading-regexp-format
using format
. The latter function does not modify arguments, the first argument is the format string. org-complex-heading-regexp-format
is just a variable that contains 'template' of a regexp that matches a full headline (including todo state, priority, tags, etc.) by given name (in this case, headline
variable). Check it's value while visiting org mode buffer.
For example, if I want to get a regexp to match a headline named 'Hello World', I would do it like this:
> (format org-complex-heading-regexp-format (regexp-quote "Hello World"))
"^\\(\\*+\\)\\(?: +\\(CANCELLED\\|DONE\\|HOLD\\|MEETING\\|TODO\\|WAITING\\)\\)?\\(?: +\\(\\[#.\\]\\)\\)?\\(?: +\\(?:\\[[0-9%/]+\\] *\\)*\\(Hello World\\)\\(?: *\\[[0-9%/]+\\]\\)*\\)\\(?:[ ]+\\(:[[:alnum:]_@#%:]+:\\)\\)?[ ]*$"
The reason for it to be a buffer local, because some of the regexp parts (for example, todo states) can be configured on the buffer level. When writing libraries for org, one should avoid making assumptions about these things, and luckily org mode provides enough variables and helpers to use.
So format
returns a regexp as a string. Then I use it to find specific header where I want to place the the captured item - a heading named 'Meetings'. I use the re-search-forward
to search for this heading using regexp returned by format
.
(if (re-search-forward
(format org-complex-heading-regexp-format
(regexp-quote headline))
nil t)
(beginning-of-line)
(goto-char (point-max))
(unless (bolp) (insert "\n"))
(insert "* " headline "\n")
(beginning-of-line 0))
Basically, if it was found, then return the beginning of line. Otherwise, create a new first-level heading. That's it.
Hope that helps.
Disregard, this is was an issue related to Doom Emacs and not having flyspell setup correctly. See https://github.com/doomemacs/doomemacs/issues/6741
I have imported most (all?) of your configuration snippets into my emacs config and it seems to mostly work, however, I am trying to create some capture templates (specifically for org-roam-dailies), and I think something about this config is causing issues.
I have the following config snippet for defining the templates:
(setq org-element-use-cache nil)
(setq org-roam-title-sources '(title alias))
(setq org-roam-capture-templates
'(("d" "default" plain
"%?"
:target (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
"#+title: ${title}\n")
:unnarrowed t)
("p" "Project" plain (file "~/Sync/org-roam/Templates/ProjectTemplate.template")
:target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
:unnarrowed t)))
(setq org-roam-dailies-directory "daily/")
(setq org-roam-dailies-capture-templates
'(("r" "daily default" plain (file "~/Sync/org-roam/Templates/DailyTemplate.template")
:target (file+head "%<%Y-%m-%d>.org"
"#+title: %<%Y-%m-%d>\n")
:unnarrowed t)))
However, whenever I try to use the templates, I end up with #+title:
properties that look like:
#+title: #+title: 2023-05-02
As far as I can tell, this seems to be caused by vulpea-create
inserting the :ID:
and #+title:
properties at the top newly create org-roam files (which I understand is not the default?
Is my understanding of your configuration correct?
Boris Buliga - Task management with org-roam Vol. 7: Capture
How to setup capture flow with org-roam
https://d12frosted.io/posts/2021-05-21-task-management-with-roam-vol7.html