unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/2] emacs: instruct user to autoload notmuch instead of require'ing it
@ 2014-03-29  8:07 Tomi Ollila
  2014-03-29  8:07 ` [PATCH 2/2] emacs: add defcustom notmuch-init-file and load it if exists Tomi Ollila
  2014-03-30 22:32 ` [PATCH 1/2] emacs: instruct user to autoload notmuch instead of require'ing it David Bremner
  0 siblings, 2 replies; 6+ messages in thread
From: Tomi Ollila @ 2014-03-29  8:07 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

When (require 'notmuch) is added to ~/.emacs notmuch is loaded to every
instance of emacs although it may not be used in majority of
those instances.

When (autoload 'notmuch "notmuch" ...) is added to ~/.emacs notmuch
is loaded (only) when user invokes the notmuch function.

User may want to add other entrypoints to notmuch by adding more
autoloads -- the autoload instruction given should offer them clue how
to do so.
---

This borrows models from emacs, gnus & erc (at least).

I've been dogfooding this for 2 months now, by just loading my
"global" notmuch config from ~/.emacs.d/notmuch-config.el instead
of autoloading that file. I'd like to move the contents of my
"site-specific" configuration files here in the future...

 README           | 2 +-
 emacs/notmuch.el | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/README b/README
index 3a003ad..d92fcfd 100644
--- a/README
+++ b/README
@@ -42,7 +42,7 @@ the libnotmuch library.
 Notmuch installs a full-featured email interface for use within
 emacs. To use this, first add the following line to your .emacs file:
 
-	(require 'notmuch)
+	(autoload 'notmuch "notmuch" "Notmuch mail" t)
 
 Then, either run "emacs -f notmuch" or execute the command "M-x
 notmuch" from within a running emacs.
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 7dec273..34a3b3c 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -36,7 +36,7 @@
 ;;
 ;; Then, to actually run it, add:
 ;;
-;;	(require 'notmuch)
+;;	(autoload 'notmuch "notmuch" "Notmuch mail" t)
 ;;
 ;; to your ~/.emacs file, and then run "M-x notmuch" from within emacs,
 ;; or run:
-- 
1.8.0

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

* [PATCH 2/2] emacs: add defcustom notmuch-init-file and load it if exists
  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
  2014-03-30  2:09   ` David Bremner
  2014-03-30  7:25   ` Mark Walters
  2014-03-30 22:32 ` [PATCH 1/2] emacs: instruct user to autoload notmuch instead of require'ing it David Bremner
  1 sibling, 2 replies; 6+ messages in thread
From: Tomi Ollila @ 2014-03-29  8:07 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

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

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

* Re: [PATCH 2/2] emacs: add defcustom notmuch-init-file and load it if exists
  2014-03-29  8:07 ` [PATCH 2/2] emacs: add defcustom notmuch-init-file and load it if exists Tomi Ollila
@ 2014-03-30  2:09   ` David Bremner
  2014-03-30  7:25   ` Mark Walters
  1 sibling, 0 replies; 6+ messages in thread
From: David Bremner @ 2014-03-30  2:09 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila

Tomi Ollila <tomi.ollila@iki.fi> writes:

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

This seems unobjectionable.

d

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

* Re: [PATCH 2/2] emacs: add defcustom notmuch-init-file and load it if exists
  2014-03-29  8:07 ` [PATCH 2/2] emacs: add defcustom notmuch-init-file and load it if exists Tomi Ollila
  2014-03-30  2:09   ` David Bremner
@ 2014-03-30  7:25   ` Mark Walters
  2014-03-30  7:49     ` Tomi Ollila
  1 sibling, 1 reply; 6+ messages in thread
From: Mark Walters @ 2014-03-30  7:25 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila


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

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

* Re: [PATCH 2/2] emacs: add defcustom notmuch-init-file and load it if exists
  2014-03-30  7:25   ` Mark Walters
@ 2014-03-30  7:49     ` Tomi Ollila
  0 siblings, 0 replies; 6+ messages in thread
From: Tomi Ollila @ 2014-03-30  7:49 UTC (permalink / raw)
  To: Mark Walters, notmuch

On Sun, Mar 30 2014, Mark Walters <markwalters1009@gmail.com> wrote:

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

tnx for looking :D

How do you currently do it? all in .emacs or done someting like in
http://notmuchmail.org/emacstips/#index6h2

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

My .emacs is static, cloned from git repository everywhere. Last lines of
my .emacs are:

---8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--
(load-file (concat compiled-directory "/dot-emacs.elc"))

(setq custom-file "~/local/custom.el")
(load custom-file)

; -- if there are lines below this, those has been added
; -- by some program -- and those needs to be moved elsewhere.
---8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--

i.e. (at least) all customizations can be moved to other file.

I currently have a problem w/ customizations as those work well in
terminal with light background. Occasionally I read mail using my
Nokia N9 fingerterm which has black background (many things unreadable
there). I may end up ditching customization settings and do those with
setq's in these configuration files I have (that is what I've done in
all other emacs software)

>
> Best wishes
>
> Mark
>

Tomi

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

* Re: [PATCH 1/2] emacs: instruct user to autoload notmuch instead of require'ing it
  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 ` [PATCH 2/2] emacs: add defcustom notmuch-init-file and load it if exists Tomi Ollila
@ 2014-03-30 22:32 ` David Bremner
  1 sibling, 0 replies; 6+ messages in thread
From: David Bremner @ 2014-03-30 22:32 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila

Tomi Ollila <tomi.ollila@iki.fi> writes:

> When (require 'notmuch) is added to ~/.emacs notmuch is loaded to every
> instance of emacs although it may not be used in majority of
> those instances.

Series pushed. Needs a NEWS patch; in particular for people who already
load notmuch-config.el manually.

A patch for doc/notmuch-emacs.rst would be great as well.

d

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

end of thread, other threads:[~2014-03-30 22:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 2/2] emacs: add defcustom notmuch-init-file and load it if exists Tomi Ollila
2014-03-30  2:09   ` 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

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