denote
denote copied to clipboard
Denote multi-keyword and org tags/agenda
I have just started to use denote
and org-agenda
. When a multi-keyword my_name
is added to a denote
filetags it is converted to my-name
, but in the filename is is my_name
. Having my-name
in the filetags
causes org-agenda
to not show the tags in the agenda view, since the only valid special characters is _
or @
.
Not sure what my options are to make it work in both denote
and org-agenda
.
Also thank you everything you do!
Hello @djgoku! I am afraid there is no good solution here. The problem with my_name
is that Denote interprets it as _my
and _name
because it appears in the file name like this:
DATE--TITLE__my_name.org
Put differently, by reading the file name we cannot know if those are two separate keywords or a single keyword.
About the use of hyphens, I found this in org.el
:
(defconst org-tag-re "[[:alnum:]_@#%]+"
"Regexp matching a single tag.")
The constraint is that we exclude @
, #
, %
from file names. Changing org-tag-re
will probably break things...
Perhaps we can allow for camelcase like myName
? Otherwise you will have to use single words for the agenda to work.
If there is something else we can do to accommodate this use-case, I am happy to learn about it.
Hello @protesilaos! Giving M-x denote
file title
and another_keyword,file_keyword
creates this file
20230109T231457--file-title__another-keyword_file-keyword.org
If I replace dashes in filetags
to underscores like #+filetags: :another_keyword:file_keyword:
then run M-x denote-rename-file-using-front-matter
it renames the file to: 20230109T231457--file-title__another_keyword_file_keyword.org
. Which shows up correctly in org-agenda
edit So maybe using underscores for both filetags
and keywords in the filename would work?
So maybe using underscores for both
filetags
and keywords in the filename would work?
What happened in that renaming operation is that the two keywords another_keyword
and file_keyword
were converted into four keywords: another
, keyword
, file
, keyword
. This means that in the keywords' prompt you will get those as completion candidates, even though that was not your intention.
This can work, though it depends on your workflow and the specific words you will use. Though in that case, you can skip the renaming part and just use the individual words as keywords.
Ahh good to know.
My denote/org config is:
(setq org-agenda-files '("~/dev/org" "~/dev/notes"))
(use-package
denote
:straight t
:config
(setq denote-directory "~/dev/notes"))
My workflow is M-x denote
and then type in file title and add keywords. I can look into seeing if I can modify the function that modifies keywords that get inserted into #+filetags
and builds the filename string to see if I can get it to work for my workflow.
I'll give an example of what I want and the output I would want so it works in org-agenda
.
M-x denote
File title: notes of things I have learned while writing code
File keyword: emacs_lisp,software_development,data_structures
Wanted Filename created 20230111T162437--notes-of-things-i-have-learned-while-writing-code__data_structures_elisp_software_development.org
Wanted File contents:
#+title: notes of things I have learned while writing code
#+date: [2023-01-11 Wed 16:24]
#+filetags: :data_structures:elisp:software_development:
#+identifier: 20230111T162437
If there is a way to configure the keyword separator for the file name I could configure it to be ___
three underscores or maybe a single dash?
If three underscores:
20230111T162437--notes-of-things-i-have-learned-while-writing-code__data_structures___elisp___software_development.org
If a single dash:
20230111T162437--notes-of-things-i-have-learned-while-writing-code__data_structures-elisp-software_development.org
.
Thanks for the detailed explanation! The use of the triple underscores will not solve our problem. With the current approach, we can search for, say, _data
to list all relevant notes. If the underscore is a word separator, we will still get false positives like _structures
.
I think the only way to accommodate the Org agenda while also using multi-word keywords is to employ camelCasing or similar techniques. Denote would still need to be modified to not alter the capitalisation of those words.
Here I should note why the casing of keywords is changed. I did it to streamline the experience. We do not need to worry about typos or possible variations of the same concept like XTerm
, xterm
, Xterm
.
With the current approach, we can search for, say,
_data
to list all relevant notes. If the underscore is a word separator, we will still get false positives like_structures
.
Do you mind elaborating on your workflow of how you search for relevant notes?
I think the only way to accommodate the Org agenda while also using multi-word keywords is to employ camelCasing or similar techniques. Denote would still need to be modified to not alter the capitalisation of those words.
Edit: I do understand there is at least two things in play here. There is a need for consistent file naming and from that builds the front matter. Not only would file naming need to be changed or configurable but the way that keywords are saved in front matter would need to change to make valid org-mode
tags.
If the keyword separator in filenames could be configured to a -
(single dash) that should work, no? If there is something more to read within the code to try and understand why or why this won't work, I would be happy to read.
In recent versions of Denote we no longer support multi-word keywords. The user option denote-file-name-slug-functions
can be used to apply some specific transformation (e.g. to upcase
) the given input. I am thus closing this. Thank you!