unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Edmondson <dme@dme.org>
To: Sean Whitton <spwhitton@spwhitton.name>, notmuch@notmuchmail.org
Subject: Re: Lazily loading notmuch into Emacs
Date: Tue, 02 Jun 2020 12:41:02 +0100	[thread overview]
Message-ID: <m2eeqxbsq9.fsf@dme.org> (raw)
In-Reply-To: <87367ed6y7.fsf@iris.silentflame.com>

On Monday, 2020-06-01 at 10:36:16 -07, Sean Whitton wrote:

> Hello,
>
> I don't want to put (require 'notmuch) into my Emacs init because that
> will slow down initial Emacs startup a fair bit, especially since my
> (file which is equivalent to) notmuch-config.el does quite a bit of
> processing to populate notmuch-saved-searches.
>
> So I have this:
>
>     ;; Ensure notmuch does its `message-mode' configuration and that my
>     ;; notmuch-config.el gets loaded before certain commands happen.  An
>     ;; alternative to advising `compose-mail' and friends here would be
>     ;; to remap its keys to `notmuch-mua-new-mail', but it is nice to
>     ;; have things work correctly if some lisp code somewhere calls
>     ;; `compose-mail' or friends
>     (defun spw/load-notmuch (&rest ignore)
>       (require 'notmuch))
>     (dolist (cmd '(compose-mail
>                    compose-mail-other-window
>                    compose-mail-other-frame
>                    notmuch-jump-search
>                    notmuch-hello))
>       (advice-add cmd :before #'spw/load-notmuch))
>
>     (global-set-key "\C-cs" #'notmuch-search)
>     (global-set-key "\C-cm" #'notmuch-jump-search)
>     (global-set-key "\C-cM" #'notmuch-hello)
>
> This is not a very idiomatic way to make use of an ELPA package,
> however.  Does anyone have a better approach that does not involve
> advice-add?  I'm using the elpa-notmuch package on Debian.

I'd hoped that:

(require 'notmuch-mua)
(setq mail-user-agent 'notmuch-user-agent)

would be sufficient to get things wired up, but it doesn't seem to be.

If we fix that, would it seem more appropriate? If we get it right then
it shouldn't load any other notmuch code (including notmuch-config.el)
until you actually use one of the functions.

(None of this will configure your chosen bindings of course, you'll
still have to do that yourself.)

dme.
-- 
Everybody's got something to hide, 'cept me and my monkey.

  reply	other threads:[~2020-06-02 11:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-01 17:36 Lazily loading notmuch into Emacs Sean Whitton
2020-06-02 11:41 ` David Edmondson [this message]
2020-06-02 21:50   ` Sean Whitton

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=m2eeqxbsq9.fsf@dme.org \
    --to=dme@dme.org \
    --cc=notmuch@notmuchmail.org \
    --cc=spwhitton@spwhitton.name \
    /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).