Re: Editing the raw mail file?

Subject: Re: Editing the raw mail file?

Date: Wed, 10 Jul 2024 10:45:45 +0200

To: David Bremner, notmuch@notmuchmail.org

Cc:

From: Morten Kjeldgaard


David Bremner <david@tethera.net> wrote:

> you can use "c F" to copy the file name of the current message into the
> the kill ring, then just yank wherever useful (e.g. to visit the file in
> emacs).
>
> After editing you will need to reindex that file. One way would be
> to use "c i" to copy the message id into the kill ring, then yank it
> into a shell command like
>
>      notmuch reindex id:<whatever>
>
> If that seems to do what you want, then the steps can be automated
> within emacs.

It works! But as you suggested I made two functions to make it easier, I
enclose them below in case others could benefit. One function opens the
mbox file in an edit buffer, the other runs the reindexing, both need to
be run in the context of the message.

I would love to have just one function that carries out both tasks,
opening the file in a temporary buffer, and after you finish with C-c
C-c, it automatically does the reindexing for you. Unfortunately it's
above my current Elisp skills to write this.

Thanks for your help!
Cheers,
Morten

-------8<----- snip -------
(defun mok/notmuch-edit-raw-mail ()
  "Within the context of a mail message, open the raw mbox file in a buffer."
  (interactive)
  (let ((mbox-file-name (notmuch-show-get-filename)))
    (message "edit %s" mbox-file-name)
    (find-file mbox-file-name)))

(defun mok/notmuch-reindex-id ()
  "Within the context of a mail message, reindex the message to update header information"
  (interactive)
  (let ((id (notmuch-show-get-message-id)))
    (message "reindex %s" id)
    (notmuch--call-process notmuch-command nil t nil "reindex" id)))
-------8<----- snip -------
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: