unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: notmuch@notmuchmail.org
Cc: tomi.ollila@iki.fi
Subject: [PATCH 2/2] emacs: add defcustom notmuch-init-file and load it if exists
Date: Sat, 29 Mar 2014 10:07:59 +0200	[thread overview]
Message-ID: <1396080479-19161-2-git-send-email-tomi.ollila@iki.fi> (raw)
In-Reply-To: <1396080479-19161-1-git-send-email-tomi.ollila@iki.fi>

So that users can easily organize their notmuch-specific configurations
to separate file and they don't have to have notmuch configurations in
*every* emacs installation they launch, especially if those need to
'(require notmuch) to make the configurations possible.
---
 emacs/notmuch.el | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 34a3b3c..64295ac 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -85,6 +85,18 @@ (defcustom notmuch-search-result-format
   :type '(alist :key-type (string) :value-type (string))
   :group 'notmuch-search)
 
+;; The name of this variable `notmuch-init-file' is consistent with the
+;; convention used in e.g. emacs and gnus. The value, `notmuch-config[.el[c]]'
+;; is consistent with notmuch cli configuration file `~/.notmuch-config'.
+(defcustom notmuch-init-file (locate-user-emacs-file "notmuch-config")
+  "Your Notmuch Emacs-Lisp configuration file name.
+If a file with one of the suffixes defined by `get-load-suffixes' exists,
+it will be read instead.
+This file is read once when notmuch is loaded; the notmuch hooks added
+there will be called at other points of notmuch execution."
+  :type 'file
+  :group 'notmuch)
+
 (defvar notmuch-query-history nil
   "Variable to store minibuffer history for notmuch queries")
 
@@ -1017,3 +1029,9 @@ (defun notmuch-cycle-notmuch-buffers ()
 (setq mail-user-agent 'notmuch-user-agent)
 
 (provide 'notmuch)
+
+;; After provide to avoid loops if notmuch was require'd via notmuch-init-file.
+(if init-file-user ; don't load init file if the -q option was used.
+    (let ((init-file (locate-file notmuch-init-file '("/")
+				  (get-load-suffixes))))
+      (if init-file (load init-file nil t t))))
-- 
1.8.0

  reply	other threads:[~2014-03-29  8:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-29  8:07 [PATCH 1/2] emacs: instruct user to autoload notmuch instead of require'ing it Tomi Ollila
2014-03-29  8:07 ` Tomi Ollila [this message]
2014-03-30  2:09   ` [PATCH 2/2] emacs: add defcustom notmuch-init-file and load it if exists David Bremner
2014-03-30  7:25   ` Mark Walters
2014-03-30  7:49     ` Tomi Ollila
2014-03-30 22:32 ` [PATCH 1/2] emacs: instruct user to autoload notmuch instead of require'ing it David Bremner

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=1396080479-19161-2-git-send-email-tomi.ollila@iki.fi \
    --to=tomi.ollila@iki.fi \
    --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).