Hello,
I see that the signature of `denote-link` recently changed (it now
requires a type and a description). To adapt my code, I created a small
function (lifted from recent changes I saw in the code base):
(defun my-denote-link (path)
(let ((type (denote-filetype-heuristics path)))
(denote-link
path
type
(denote--link-get-description path type))))
Is there a better way to do this?
While I’m at it, here is the context where I use it (to create journal
entries):
(defun my-denote-journal-link ()
(interactive)
(let* ((date (org-read-date))
(time (org-time-string-to-time date))
(title (format-time-string "%A %d %B %Y" time))
(initial (denote-sluggify title))
(target (read-file-name "Select note: " (denote-directory) nil nil initial
(lambda (f)
(or (denote-file-has-identifier-p f)
(file-directory-p f))))))
(if (file-exists-p target)
(my-denote-link target)
(let (path)
(save-window-excursion
(denote title '("journal") 'org nil date)
(save-buffer)
(setq path (buffer-file-name)))
(my-denote-link path)))))
Is there a better way to achieve this?
Thanks again for denote, I use it all the time.
Best,
Alan
> From: alan.schmitt@polytechnique.org> Date: Tue, 26 Sep 2023 14:54:39 +0200>> Hello,
Hello Alan,
> I see that the signature of `denote-link` recently changed (it now> requires a type and a description).
Indeed. I changed it yesterday. I think this change makes
'denote-link' more useful, because its behaviour can be better
controlled from Lisp.
> To adapt my code, I created a small function (lifted from recent> changes I saw in the code base):>> (defun my-denote-link (path)> (let ((type (denote-filetype-heuristics path)))> (denote-link> path> type> (denote--link-get-description path type))))>> Is there a better way to do this?
This seems fine.
> While I’m at it, here is the context where I use it (to create journal> entries):>> (defun my-denote-journal-link ()> (interactive)> (let* ((date (org-read-date))> (time (org-time-string-to-time date))> (title (format-time-string "%A %d %B %Y" time))> (initial (denote-sluggify title))> (target (read-file-name "Select note: " (denote-directory) nil nil initial> (lambda (f)> (or (denote-file-has-identifier-p f)> (file-directory-p f))))))> (if (file-exists-p target)> (my-denote-link target)> (let (path)> (save-window-excursion> (denote title '("journal") 'org nil date)> (save-buffer)> (setq path (buffer-file-name)))> (my-denote-link path)))))>> Is there a better way to achieve this?
It looks okay. For the 'read-file-name' also check the latest changes I
made to 'denote-file-prompt': it now takes a FILES-MATCHING-REGEXP
argument. This might help you with custom file filters.
Since we are on the topic of journal entries, take a look at the new
'denote-journal-extras.el' file. Maybe it helps you do what you want
and/or we can add your ideas there.
> Thanks again for denote, I use it all the time.
You are welcome!
All the best,
Prot
--
Protesilaos Stavrou
https://protesilaos.com
Hi Prot,
On 2023-09-26 18:34, Protesilaos Stavrou <info@protesilaos.com> writes:
>> Is there a better way to achieve this?>> It looks okay. For the 'read-file-name' also check the latest changes I> made to 'denote-file-prompt': it now takes a FILES-MATCHING-REGEXP> argument. This might help you with custom file filters.
It works great! There goes some of my custom code.
> Since we are on the topic of journal entries, take a look at the new> 'denote-journal-extras.el' file. Maybe it helps you do what you want> and/or we can add your ideas there.
Very nice! It seems to be doing everything that I need except the "link
or create" part. I’ll try migrating to it.
Thanks again,
Alan
Hello,
I’m sending this again as I see from
https://lists.sr.ht/~protesilaos/denote/%3Cm2cyy5rt68.fsf%40mac-03220211.irisa.fr%3E
that DKIM signature failed. I suspect that it is because my patch was
attached instead of inline (the message is cut short at the patch).
I think I found a place that needs to be adapted to the denote-link
change:
> From: Alan Schmitt <alan.schmitt@polytechnique.org>> Date: Wed, 27 Sep 2023 14:44:54 +0200>> Hello,>> I’m sending this again as I see from> https://lists.sr.ht/~protesilaos/denote/%3Cm2cyy5rt68.fsf%40mac-03220211.irisa.fr%3E> that DKIM signature failed. I suspect that it is because my patch was> attached instead of inline (the message is cut short at the patch).
I think the DKIM signature is a matter that has to do with your email
server. I remember I had to enable something for my email service
provider to get that right.
> I think I found a place that needs to be adapted to the denote-link> change:>>From fcc684ef478869ffd304a553809b96a472c82db2 Mon Sep 17 00:00:00 2001> From: Alan Schmitt <alan.schmitt@polytechnique.org>> Date: Wed, 27 Sep 2023 13:25:53 +0200> Subject: [PATCH] fix denote-link-or-create
Thank you! I installed the patch.
All the best,
Prot
--
Protesilaos Stavrou
https://protesilaos.com