Hello Jack,
[ CC Denote mailing list. ]
I just noticed your blog post about what you are doing with org-agenda
and denote: <https://baty.net/2022/keeping-my-org-agenda-updated>.
In the Denote manual, I maintain a list of such publications for the
benefit of users. Can I include yours on this list?
* * *
The tweak that may benefit your workflow is to use some regular
expression notation to further narrow the file you need for the agenda.
Some examples, in case you need them:
1. Match files that start with "2022", have arbitrary text after that,
and include "_project":
"^2022.*_project"
2. Match files that include "_project", some arbitrary text after it
(e.g. more keywords), and ends in ".org":
"_project.*\\.org\\'"
3. Combine the above two:
"^2022.*_project.*\\.org\\'"
4. This is like the first example, but specifies a month in addition to
the year:
"^202212.*_project"
5. Same as above, but captures months 10, 11, 12:
"^20221[0-2].*_project"
If you have more specific pattern-matching requirements, we can cover
them. This sort of information can also go in the manual, if there is a
need for it (I already mention some examples, but we can always write
more).
You can check all those by visiting the denote-directory with Dired and
then invoking 'M-x re-builder'. In the resulting buffer, you can add
the regular expression to see what it matches.
All the best,
Protesilaos (or simply "Prot")
--
Protesilaos Stavrou
https://protesilaos.com
On 7 Dec 2022, at 10:16, Protesilaos Stavrou wrote:
> Hello Jack,>
Hello Prot,
>> I just noticed your blog post about what you are doing with org-agenda> and denote: <https://baty.net/2022/keeping-my-org-agenda-updated> .>> In the Denote manual, I maintain a list of such publications for the> benefit of users. Can I include yours on this list?
You should absolutely feel free to include it.
> * * *>> The tweak that may benefit your workflow is to use some regular> expression notation to further narrow the file you need for the agenda.> Some examples, in case you need them:>> 1. Match files that start with "2022", have arbitrary text after that,> and include "_project":>> "^2022.*_project">> 2. Match files that include "_project", some arbitrary text after it> (e.g. more keywords), and ends in ".org":>> "_project.*\\.org\\'">> 3. Combine the above two:>> "^2022.*_project.*\\.org\\'">> 4. This is like the first example, but specifies a month in addition to> the year:>> "^202212.*_project">> 5. Same as above, but captures months 10, 11, 12:>> "^20221[0-2].*_project">> If you have more specific pattern-matching requirements, we can cover> them. This sort of information can also go in the manual, if there is a> need for it (I already mention some examples, but we can always write> more).>> You can check all those by visiting the denote-directory with Dired and> then invoking 'M-x re-builder'. In the resulting buffer, you can add> the regular expression to see what it matches.
These may come in handy, thanks! For now, the simple tag match works well enough, but I can imagine wanting to narrow the search further some day, probably to include more than one tag, e.g. "project" and "inprogress" or similar.
The other part that I'm missing is an after-save-hook of some kind to update the agenda files automatically. For the moment, I restart/reload Emacs often enough that it hasn't been an issue.
Thanks for Denote.
Jack
> From: Jack Baty <jack@baty.net>> Date: Wed, 7 Dec 2022 10:42:24 -0500>> On 7 Dec 2022, at 10:16, Protesilaos Stavrou wrote:>>> Hello Jack,>>>> Hello Prot,
Hi Jack,
>>>> I just noticed your blog post about what you are doing with org-agenda>> and denote: <https://baty.net/2022/keeping-my-org-agenda-updated> .>>>> In the Denote manual, I maintain a list of such publications for the>> benefit of users. Can I include yours on this list?>> You should absolutely feel free to include it.
Thank you! I will do it after this email.
> [... 35 lines elided]>> You can check all those by visiting the denote-directory with Dired and>> then invoking 'M-x re-builder'. In the resulting buffer, you can add>> the regular expression to see what it matches.>> These may come in handy, thanks! For now, the simple tag match works> well enough, but I can imagine wanting to narrow the search further> some day, probably to include more than one tag, e.g. "project" and> "inprogress" or similar.
Very well!
> The other part that I'm missing is an after-save-hook of some kind to> update the agenda files automatically. For the moment, I> restart/reload Emacs often enough that it hasn't been an issue.
If I understand your need correctly, the following will do the trick:
(defvar my-denote-to-agenda-regexp "_project"
"Denote file names that are added to the agenda.
See `my-add-denote-to-agenda'.")
(defun my-denote-add-to-agenda ()
"Add current file to the `org-agenda-files', if needed.
The file's name must match the `my-denote-to-agenda-regexp'.
Add this to the `after-save-hook' or call it interactively."
(interactive)
(when-let* ((file (buffer-file-name))
((denote-file-is-note-p file))
((string-match-p my-denote-to-agenda-regexp (buffer-file-name))))
(add-to-list 'org-agenda-files file)))
;; Example to add the file automatically. Uncomment it:
;; (add-hook 'after-save-hook #'my-denote-add-to-agenda)
(defun my-denote-remove-from-agenda ()
"Remove current file from the `org-agenda-files'.
See `my-denote-add-to-agenda' for how to add files to the Org
agenda."
(interactive)
(when-let* ((file (buffer-file-name))
((string-match-p my-denote-to-agenda-regexp (buffer-file-name))))
(setq org-agenda-files (delete file org-agenda-files))))
Please try the above and let me know what you think about it.
Another trick is to shorten the file name that appears on the agenda.
You can add the #+CATEGORY: keyword and give it whatever word you want
(or even an emoji). For example, here is the file I am testing this
with:
#+title: This is a test
#+date: [2022-12-09 Fri 03:40]
#+filetags: :project:
#+identifier: 20221209T034025
#+CATEGORY: 🦄
* TODO Say hello to Jack and the Denote mailing list
SCHEDULED: <2022-12-09 Fri 04:00>
> Thanks for Denote.
You are welcome!
All the best,
Prot
--
Protesilaos Stavrou
https://protesilaos.com
Protesilaos Stavrou <info@protesilaos.com> writes:
>> From: Jack Baty <jack@baty.net>>> Date: Wed, 7 Dec 2022 10:42:24 -0500>>>> On 7 Dec 2022, at 10:16, Protesilaos Stavrou wrote:>>>>> Hello Jack,>>>>>>> Hello Prot,>> Hi Jack,>>>>>>> I just noticed your blog post about what you are doing with >>> org-agenda>>> and denote: >>> <https://baty.net/2022/keeping-my-org-agenda-updated> .>>>>>> In the Denote manual, I maintain a list of such publications >>> for the>>> benefit of users. Can I include yours on this list?>>>> You should absolutely feel free to include it.>> Thank you! I will do it after this email.>>> [... 35 lines elided]>>>> You can check all those by visiting the denote-directory with >>> Dired and>>> then invoking 'M-x re-builder'. In the resulting buffer, you >>> can add>>> the regular expression to see what it matches.>>>> These may come in handy, thanks! For now, the simple tag match >> works>> well enough, but I can imagine wanting to narrow the search >> further>> some day, probably to include more than one tag, e.g. "project" >> and>> "inprogress" or similar.>> Very well!>>> The other part that I'm missing is an after-save-hook of some >> kind to>> update the agenda files automatically. For the moment, I>> restart/reload Emacs often enough that it hasn't been an issue.>> If I understand your need correctly, the following will do the > trick:>> (defvar my-denote-to-agenda-regexp "_project"> "Denote file names that are added to the agenda.> See `my-add-denote-to-agenda'.")>> (defun my-denote-add-to-agenda ()> "Add current file to the `org-agenda-files', if needed.> The file's name must match the `my-denote-to-agenda-regexp'.>> Add this to the `after-save-hook' or call it interactively."> (interactive)> (when-let* ((file (buffer-file-name))> ((denote-file-is-note-p file))> ((string-match-p my-denote-to-agenda-regexp > (buffer-file-name))))> (add-to-list 'org-agenda-files file)))>> ;; Example to add the file automatically. Uncomment it:>> ;; (add-hook 'after-save-hook #'my-denote-add-to-agenda)>> (defun my-denote-remove-from-agenda ()> "Remove current file from the `org-agenda-files'.> See `my-denote-add-to-agenda' for how to add files to the > Org> agenda."> (interactive)> (when-let* ((file (buffer-file-name))> ((string-match-p my-denote-to-agenda-regexp > (buffer-file-name))))> (setq org-agenda-files (delete file org-agenda-files))))>> Please try the above and let me know what you think about it.
This is terrific, thank you! If you don't mind, I'll also add it
to my post.
>> Another trick is to shorten the file name that appears on the > agenda.> You can add the #+CATEGORY: keyword and give it whatever word > you want> (or even an emoji). For example, here is the file I am testing > this> with:>> #+title: This is a test> #+date: [2022-12-09 Fri 03:40]>> #+filetags: :project:> #+identifier: 20221209T034025>> #+CATEGORY: 🦄>> * TODO Say hello to Jack and the Denote mailing list> SCHEDULED: <2022-12-09 Fri 04:00>>
Good suggestion. I make good use of #+CATEGORY: in my Denote
files, as filenames can become rather unwieldy.
Best,
Jack
> From: Jack Baty <jack@baty.net>> Date: Fri, 9 Dec 2022 04:38:24 -0500> [... 86 lines elided]>> Please try the above and let me know what you think about it.>> This is terrific, thank you! If you don't mind, I'll also add it > to my post.
You are welcome! Yes, you are free to do whatever you want. They are
yours.
>>>> Another trick is to shorten the file name that appears on the agenda.>> You can add the #+CATEGORY: keyword and give it whatever word you>> want (or even an emoji). For example, here is the file I am testing>> this with:>>>> #+title: This is a test>> #+date: [2022-12-09 Fri 03:40]>>>> #+filetags: :project:>> #+identifier: 20221209T034025>>>> #+CATEGORY: 🦄>>>> * TODO Say hello to Jack and the Denote mailing list>> SCHEDULED: <2022-12-09 Fri 04:00>>>>> Good suggestion. I make good use of #+CATEGORY: in my Denote > files, as filenames can become rather unwieldy.
Exactly! Need to keep the agenda buffer neat and tidy.
--
Protesilaos Stavrou
https://protesilaos.com