Re: [PATCH 2/2] emacs: add defcustom notmuch-init-file and load it if exists

Subject: Re: [PATCH 2/2] emacs: add defcustom notmuch-init-file and load it if exists

Date: Sun, 30 Mar 2014 08:25:23 +0100

To: Tomi Ollila, notmuch@notmuchmail.org

Cc: tomi.ollila@iki.fi

From: Mark Walters


This looks good, but I haven't tested as it doesn't fit with my current
setup. (Just to clarify my current setup still works, but it would be a
moderate amount of effort to actually exercise the new code)

One question: is it possible to get emacs to save notmuch customizations
to the notmuch init file rather than to .emacs? I think it isn't but
thought it worth checking in case.

Best wishes

Mark


On Sat, 29 Mar 2014, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> 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
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

Thread: