mu4e: allow mu4e-get-mail-command to be a function
For making it easier to influence the behavior.
This commit is contained in:
@ -559,7 +559,12 @@ BUFNAME is the name of the buffer, and DATA is lisp-data, if any."
|
|||||||
"Set VAR to VAL if VAR is nil."
|
"Set VAR to VAL if VAR is nil."
|
||||||
`(unless ,var (setq ,var ,val)))
|
`(unless ,var (setq ,var ,val)))
|
||||||
|
|
||||||
|
|
||||||
;;; Misc
|
;;; Misc
|
||||||
|
(defun mu4e--fun-val (val)
|
||||||
|
"If var is a function, return (funcall VAL), otherwise return VAL."
|
||||||
|
(if (functionp val) (funcall val) val))
|
||||||
|
|
||||||
(defun mu4e-join-paths (directory &rest components)
|
(defun mu4e-join-paths (directory &rest components)
|
||||||
"Append COMPONENTS to DIRECTORY and return the resulting string.
|
"Append COMPONENTS to DIRECTORY and return the resulting string.
|
||||||
|
|
||||||
|
|||||||
@ -33,15 +33,20 @@
|
|||||||
;;; Customization
|
;;; Customization
|
||||||
|
|
||||||
(defcustom mu4e-get-mail-command "true"
|
(defcustom mu4e-get-mail-command "true"
|
||||||
"Shell command for retrieving new mail.
|
"Shell command for retrieving new mail or a function.
|
||||||
|
|
||||||
Common values are \"offlineimap\", \"fetchmail\" or \"mbsync\", but
|
Common values are \"offlineimap\", \"fetchmail\" or \"mbsync\", but
|
||||||
arbitrary shell-commands can be used.
|
arbitrary shell-commands can be used. If it is a function, it should
|
||||||
|
return a string specifying the same.
|
||||||
|
|
||||||
When set to the literal string \"true\" (the default), the
|
When set to the literal string \"true\" (the default), the
|
||||||
command simply finishes successfully (running the \"true\"
|
command simply finishes successfully (running the \"true\"
|
||||||
command) without retrieving any mail. This can be useful when
|
command) without retrieving any mail. This can be useful when
|
||||||
mail is already retrieved in another way, such as a local MDA."
|
mail is already retrieved in another way, such as a local MDA."
|
||||||
:type 'string
|
:type 'string
|
||||||
|
:type '(choice
|
||||||
|
(string :tag "Shell command")
|
||||||
|
(function :tag "Function that returns a string (shell command)"))
|
||||||
:group 'mu4e
|
:group 'mu4e
|
||||||
:safe 'stringp)
|
:safe 'stringp)
|
||||||
|
|
||||||
@ -105,8 +110,8 @@ running."
|
|||||||
|
|
||||||
(defvar mu4e-update-pre-hook nil
|
(defvar mu4e-update-pre-hook nil
|
||||||
"Hook run just *before* the mail-retrieval / database updating process starts.
|
"Hook run just *before* the mail-retrieval / database updating process starts.
|
||||||
You can use this hook for example to `mu4e-get-mail-command' with
|
You can use this hook for example to update
|
||||||
some specific setting.")
|
`mu4e-get-mail-command' with some specific setting.")
|
||||||
|
|
||||||
(defcustom mu4e-hide-index-messages nil
|
(defcustom mu4e-hide-index-messages nil
|
||||||
"Whether to hide the \"Indexing...\" and contacts messages."
|
"Whether to hide the \"Indexing...\" and contacts messages."
|
||||||
@ -271,9 +276,9 @@ If
|
|||||||
RUN-IN-BACKGROUND is non-nil (or called with prefix-argument),
|
RUN-IN-BACKGROUND is non-nil (or called with prefix-argument),
|
||||||
run in the background; otherwise, pop up a window."
|
run in the background; otherwise, pop up a window."
|
||||||
(let* ((process-connection-type t)
|
(let* ((process-connection-type t)
|
||||||
|
(cmd (mu4e--fun-val mu4e-get-mail-command))
|
||||||
(proc (start-process-shell-command
|
(proc (start-process-shell-command
|
||||||
mu4e--update-name mu4e--update-name
|
mu4e--update-name mu4e--update-name cmd))
|
||||||
mu4e-get-mail-command))
|
|
||||||
(buf (process-buffer proc))
|
(buf (process-buffer proc))
|
||||||
(win (or run-in-background
|
(win (or run-in-background
|
||||||
(mu4e--temp-window buf mu4e--update-buffer-height))))
|
(mu4e--temp-window buf mu4e--update-buffer-height))))
|
||||||
|
|||||||
@ -521,11 +521,12 @@ Emacs/@t{mu4e}. However, you can also do it from within
|
|||||||
@subsection Basics
|
@subsection Basics
|
||||||
|
|
||||||
To set up mail-retrieval from within @t{mu4e}, set the variable
|
To set up mail-retrieval from within @t{mu4e}, set the variable
|
||||||
@code{mu4e-get-mail-command} to the program or shell command you want to
|
@code{mu4e-get-mail-command} to a shell command you want to use for retrieving
|
||||||
use for retrieving mail. You can then get your e-mail using @kbd{M-x
|
mail. It can also be a function which returns such a shell-command.
|
||||||
mu4e-update-mail-and-index}, or @kbd{C-S-u} in all @t{mu4e}-views;
|
|
||||||
alternatively, you can use @kbd{C-c C-u}, which may be more convenient
|
You can then get your e-mail using @kbd{M-x mu4e-update-mail-and-index}, or
|
||||||
if you use emacs in a terminal.
|
@kbd{C-S-u} in all @t{mu4e}-views; alternatively, you can use @kbd{C-c C-u},
|
||||||
|
which may be more convenient if you use emacs in a terminal.
|
||||||
|
|
||||||
You can kill the (foreground) update process with @kbd{q}.
|
You can kill the (foreground) update process with @kbd{q}.
|
||||||
|
|
||||||
@ -608,10 +609,9 @@ A simple setup could look something like:
|
|||||||
mu4e-update-interval 300) ;; update every 5 minutes
|
mu4e-update-interval 300) ;; update every 5 minutes
|
||||||
@end lisp
|
@end lisp
|
||||||
|
|
||||||
A hook @code{mu4e-update-pre-hook} is available which is run right
|
To influence the details, a hook @code{mu4e-update-pre-hook} is available, which
|
||||||
before starting the process. That can be useful, for example, to
|
is called right before starting the process. It is also possible to set
|
||||||
influence, @code{mu4e-get-mail-command} based on the the current
|
@code{mu4e-get-mail-command} to a function which returns a command.
|
||||||
situation (location, time of day, ...).
|
|
||||||
|
|
||||||
It is possible to get notifications when the indexing process does any
|
It is possible to get notifications when the indexing process does any
|
||||||
updates --- for example when receiving new mail. See
|
updates --- for example when receiving new mail. See
|
||||||
|
|||||||
Reference in New Issue
Block a user