~protesilaos/denote

6 2

Programmatic way to remove keywords (make denote--rewrite-keywords public)

Details
Message ID
<m2ttzgn2wu.fsf@m4x.org>
DKIM signature
missing
Download raw message
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
Details
Message ID
<m2v8jvl9rk.fsf@mac-03220211.irisa.fr>
In-Reply-To
<m2ttzgn2wu.fsf@m4x.org> (view parent)
DKIM signature
missing
Download raw message
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
Details
Message ID
<871qmjbdxo.fsf@protesilaos.com>
In-Reply-To
<m2v8jvl9rk.fsf@mac-03220211.irisa.fr> (view parent)
DKIM signature
missing
Download raw message
> 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
Details
Message ID
<m2edqjl4dq.fsf@mac-03220211.irisa.fr>
In-Reply-To
<871qmjbdxo.fsf@protesilaos.com> (view parent)
DKIM signature
missing
Download raw message
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
Details
Message ID
<871qmg20v0.fsf@protesilaos.com>
In-Reply-To
<m2ttzgn2wu.fsf@m4x.org> (view parent)
DKIM signature
missing
Download raw message
> 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
Details
Message ID
<m2h6vcbuqt.fsf@m4x.org>
In-Reply-To
<871qmg20v0.fsf@protesilaos.com> (view parent)
DKIM signature
missing
Download raw message
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
Details
Message ID
<87v8jszooz.fsf@protesilaos.com>
In-Reply-To
<m2h6vcbuqt.fsf@m4x.org> (view parent)
DKIM signature
missing
Download raw message
> 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
Reply to thread Export thread (mbox)