Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 742C8431FBF for ; Sat, 29 Mar 2014 01:08:13 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PwBkbMjNrNNW for ; Sat, 29 Mar 2014 01:08:11 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by olra.theworths.org (Postfix) with ESMTP id 9DEDA431FBC for ; Sat, 29 Mar 2014 01:08:11 -0700 (PDT) Received: by guru.guru-group.fi (Postfix, from userid 501) id A1B781000F3; Sat, 29 Mar 2014 10:08:05 +0200 (EET) From: Tomi Ollila To: notmuch@notmuchmail.org Subject: [PATCH 2/2] emacs: add defcustom notmuch-init-file and load it if exists Date: Sat, 29 Mar 2014 10:07:59 +0200 Message-Id: <1396080479-19161-2-git-send-email-tomi.ollila@iki.fi> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1396080479-19161-1-git-send-email-tomi.ollila@iki.fi> References: <1396080479-19161-1-git-send-email-tomi.ollila@iki.fi> Cc: tomi.ollila@iki.fi X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Mar 2014 08:08:13 -0000 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