unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Christoph <just.mychris@googlemail.com>
To: notmuch@notmuchmail.org
Subject: Emacs front end mail-user-agent documentation and loading
Date: Thu, 31 Aug 2023 17:41:02 +0200	[thread overview]
Message-ID: <CAK9rt1pFZB4MWLq21HOeBHsop8=6ZjCFRvL_0BH9bTWbXJFShw@mail.gmail.com> (raw)

Hi,

while configuring the notmuch Emacs front end, I was having trouble
getting `notmuch-fcc-dirs' to work as expected.  I figured out that my
issue was, that I was composing mails using `compose-mail' instead of
`notmuch-mua-mail'.  Since notmuch-mua.el provides a mail-user-agent,
configuring message to use the notmuch mail user agent wasn't that
difficult, but it would be nice if that would be stated in emacs-tips
of the notmuch documentation.  Maybe you can add a section to it, so
others don't fall into that trap?  I wasn't using Emacs as a mail
client before, so I didn't have much experience in configuring a
user-agent before.

Since `compose-mail' is defined in simple.el, I didn't find a nice way
to load notmuch lazy using use-package.  I ended up writing a hook
around `compose-mail' to load notmuch on demand like so:

  (use-package notmuch
    :ensure t
    :commands (notmuch
               notmuch-mua-mail
               notmuch-mua-send-and-exit
               notmuch-mua-kill-buffer
               notmuch-mua-send-hook)
    :custom
    (mail-user-agent 'notmuch-user-agent)
    :init
    (defun +notmuch-load-on-compose (&rest _)
      "Load notmuch and remove this advice from `compose-mail'."
      (require 'notmuch)
      (advice-remove 'compose-mail #'+notmuch-load-on-compose))
    (advice-add 'compose-mail :before '+notmuch-load-on-compose))

Do you know if there is a nicer way of loading notmuch lazy, as soon
as `compose-mail' is called?  Sadly, an autoload in the
`notmuch-user-agent' doesn't work.  I don't want to rebind
`compose-mail' to `notmuch-mua-mail' and rely on the key-bind, since
other Emacs functions, like `report-emacs-bug' are calling
`compose-mail' directly and I would like those to work out of the box,
without the need to manually load notmuch beforehand.

Looking forward into playing around with notmuch.

Regards,
Christoph

             reply	other threads:[~2023-08-31 22:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-31 15:41 Christoph [this message]
2023-09-01  0:29 ` Emacs front end mail-user-agent documentation and loading David Bremner
2023-09-02  7:45   ` Christoph

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='CAK9rt1pFZB4MWLq21HOeBHsop8=6ZjCFRvL_0BH9bTWbXJFShw@mail.gmail.com' \
    --to=just.mychris@googlemail.com \
    --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).