unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Emacs front end mail-user-agent documentation and loading
@ 2023-08-31 15:41 Christoph
  2023-09-01  0:29 ` David Bremner
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph @ 2023-08-31 15:41 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-02  7:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-31 15:41 Emacs front end mail-user-agent documentation and loading Christoph
2023-09-01  0:29 ` David Bremner
2023-09-02  7:45   ` Christoph

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).