From: David Pinto <carandraug@gmail.com>
To: David Bremner <david@tethera.net>
Cc: notmuch@notmuchmail.org
Subject: Re: automatically changing FCC when From changes (or fill FCC only when sending)
Date: Mon, 2 Oct 2023 10:28:54 +0000 [thread overview]
Message-ID: <CAPOrs_1Fso=e1dmFaJNFgWnRAcpLDbV4fDb13tk_SJXSOfkh-w@mail.gmail.com> (raw)
In-Reply-To: <874jjm33oo.fsf@tethera.net>
On Fri, 22 Sept 2023 at 10:25, David Bremner <david@tethera.net> wrote:
> David Pinto <carandraug@gmail.com> writes:
> > [...]
> > You mention updating the "From" when the "To" changes with the
> > notmuch-address-post-completion-functions hook. Could there be a hook
> > for when the "From" changes which I could use to change the FCC?
>
> My partial-solution relies on using completion to change To. If you are
> OK with that (i.e. manual editing without completion would not update
> Fcc), then the same scheme could work.
>
> Another option that seems technically feasible, but would involve some
> elisp programming, would be to write a command that re-applies the
> calculation of Fcc from From that already exists, and run that manually
> or perhaps opt-in to running it automatically on send.
Thank you for the hints. I followed your hint and read the code for
notmuch-fcc-header-setup. Then I wrote a function that updates the
FCC header and I hooked it to the address-post-completion:
(defun update-fcc-header (addr)
"Replace FCC header appropriate for given address"
(let ((subdir (cdr (assoc addr notmuch-fcc-dirs 'string-match-p))))
(when subdir
(save-excursion
(message-goto-fcc)
(delete-region (line-beginning-position) (point))
(insert "Fcc: " subdir)))))
(defun update-fcc-header-when-from-address-completion (addr)
"To hook on notmuch-address-post-completion-functions"
(let ((cline (thing-at-point 'line)))
(when (or (string-prefix-p "From:" cline)
(string-prefix-p "Resent-From:" cline))
(update-fcc-header addr))))
(setq notmuch-address-post-completion-functions
'(update-fcc-header-when-from-address-completion))
It's here for anyone interested on the same functionality in the
future.
Do you think this is an interesting feature to be part of notmuch? If
so, I could improve it and add some checks to cover for the different
notmuch-fcc-dirs types of values.
Best wishes
David
prev parent reply other threads:[~2023-10-02 10:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-16 0:18 automatically changing FCC when From changes (or fill FCC only when sending) David Pinto
2023-09-16 16:17 ` David Bremner
2023-09-21 23:19 ` David Pinto
2023-09-22 10:25 ` David Bremner
2023-09-22 10:41 ` David Bremner
2023-10-02 10:28 ` David Pinto [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPOrs_1Fso=e1dmFaJNFgWnRAcpLDbV4fDb13tk_SJXSOfkh-w@mail.gmail.com' \
--to=carandraug@gmail.com \
--cc=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).