Hello,
I use keywords to distinguish between "ongoing", "completed", or
"paused" project, and I would like to write a function to complete a
project by adding the "completed" keyword and removing the "ongoing"
one. While the first part is easy, the 'denote-keywords-remove' function
cannot be used in a non-interactive way.
Looking at the code (reproduced below), I could easily do it if
'denote--rewrite-keywords' was public. Could this modification be considered?
(defun denote-keywords-remove ()
"Prompt for keywords in current note and remove them.
Keywords are retrieved from the file's front matter.
Rename the file without further prompt so that its name reflects
the new front matter, per `denote-rename-file-using-front-matter'."
(declare (interactive-only t))
(interactive)
(if-let* ((file (buffer-file-name))
((denote-file-is-note-p file))
(file-type (denote-filetype-heuristics file)))
(when-let* ((cur-keywords (denote-retrieve-keywords-value file file-type))
((or (listp cur-keywords) (not (string-blank-p cur-keywords))))
(del-keyword (denote--keywords-delete-prompt cur-keywords)))
(denote--rewrite-keywords
file
(seq-difference cur-keywords del-keyword)
file-type)
(denote-rename-file-using-front-matter file t))
(user-error "Buffer not visiting a Denote file")))
Best,
Alan
Hello,
I posted this a day ago, and I have not seen it in my mailbox (although
it seems to have made it to the list:
https://lists.sr.ht/~protesilaos/denote/%3Cm2ttzgn2wu.fsf%40m4x.org%3E).
I’m wondering if this is how sr.ht lists work (senders do not get copy
of their email), or if something is astray.
Alan
On 2023-02-20 09:42, alan.schmitt@polytechnique.org writes:
> Hello,>> I use keywords to distinguish between "ongoing", "completed", or> "paused" project, and I would like to write a function to complete a> project by adding the "completed" keyword and removing the "ongoing"> one. While the first part is easy, the 'denote-keywords-remove' function> cannot be used in a non-interactive way.>> Looking at the code (reproduced below), I could easily do it if> 'denote--rewrite-keywords' was public. Could this modification be considered?>> (defun denote-keywords-remove ()> "Prompt for keywords in current note and remove them.> Keywords are retrieved from the file's front matter.>> Rename the file without further prompt so that its name reflects> the new front matter, per `denote-rename-file-using-front-matter'."> (declare (interactive-only t))> (interactive)> (if-let* ((file (buffer-file-name))> ((denote-file-is-note-p file))> (file-type (denote-filetype-heuristics file)))> (when-let* ((cur-keywords (denote-retrieve-keywords-value file file-type))> ((or (listp cur-keywords) (not (string-blank-p cur-keywords))))> (del-keyword (denote--keywords-delete-prompt cur-keywords)))> (denote--rewrite-keywords> file> (seq-difference cur-keywords del-keyword)> file-type)> (denote-rename-file-using-front-matter file t))> (user-error "Buffer not visiting a Denote file")))>> Best,>> Alan
> From: Alan Schmitt <alan.schmitt@polytechnique.org>> Date: Tue, 21 Feb 2023 09:09:51 +0100>> Hello,
Hello Alan,
> I posted this a day ago, and I have not seen it in my mailbox (although> it seems to have made it to the list:> https://lists.sr.ht/~protesilaos/denote/%3Cm2ttzgn2wu.fsf%40m4x.org%3E).> I’m wondering if this is how sr.ht lists work (senders do not get copy> of their email), or if something is astray.
I have received it but have not yet had the chance to look at its
substance. I will do it later today.
About you not receiving a copy, it seems that this is how the mailing
list works? I don't know but it happens for me as well.
All the best,
Prot
--
Protesilaos Stavrou
https://protesilaos.com
On 2023-02-21 10:49, Protesilaos Stavrou <info@protesilaos.com> writes:
>> I posted this a day ago, and I have not seen it in my mailbox (although>> it seems to have made it to the list:>> https://lists.sr.ht/~protesilaos/denote/%3Cm2ttzgn2wu.fsf%40m4x.org%3E).>> I’m wondering if this is how sr.ht lists work (senders do not get copy>> of their email), or if something is astray.>> I have received it but have not yet had the chance to look at its> substance. I will do it later today.>> About you not receiving a copy, it seems that this is how the mailing> list works? I don't know but it happens for me as well.
Ah, thanks for confirming. And there is no hurry at all.
Best,
Alan
> From: alan.schmitt@polytechnique.org> Date: Mon, 20 Feb 2023 09:42:41 +0100>> Hello,
Hello Alan,
> I use keywords to distinguish between "ongoing", "completed", or> "paused" project, and I would like to write a function to complete a> project by adding the "completed" keyword and removing the "ongoing"> one. While the first part is easy, the 'denote-keywords-remove' function> cannot be used in a non-interactive way.>> Looking at the code (reproduced below), I could easily do it if> 'denote--rewrite-keywords' was public. Could this modification be considered?> [... 25 lines elided]
Yes, I will make it public right now.
All the best,
Prot
--
Protesilaos Stavrou
https://protesilaos.com
On 2023-02-23 11:21, Protesilaos Stavrou <info@protesilaos.com> writes:
>> Looking at the code (reproduced below), I could easily do it if>> 'denote--rewrite-keywords' was public. Could this modification be considered?>> Yes, I will make it public right now.
Thanks a lot!
Best,
Alan
> From: Alan Schmitt <alan.schmitt@polytechnique.org>> Date: Thu, 23 Feb 2023 10:23:38 +0100>> On 2023-02-23 11:21, Protesilaos Stavrou <info@protesilaos.com> writes:>>>> Looking at the code (reproduced below), I could easily do it if>>> 'denote--rewrite-keywords' was public. Could this modification be considered?>>>> Yes, I will make it public right now.>> Thanks a lot!
You are welcome!
--
Protesilaos Stavrou
https://protesilaos.com