mirror of https://github.com/djcb/mu.git
mu4e: add command mu4e-server-repl
This for testing the mu4e server.
This commit is contained in:
parent
3d4805de0c
commit
8b16e5a449
|
@ -386,6 +386,29 @@ As per issue #2198."
|
|||
(signal-process proc 'SIGKILL)))) ;; forcefully
|
||||
(process-list)))
|
||||
|
||||
(defun mu4e--server-args()
|
||||
"Return the command line args for the command to start the mu4e-server."
|
||||
;; [--debug] server [--muhome=..]
|
||||
(seq-filter #'identity ;; filter out nil
|
||||
`(,(when mu4e-mu-debug "--debug")
|
||||
"server"
|
||||
,(when mu4e-mu-home (format "--muhome=%s" mu4e-mu-home)))))
|
||||
|
||||
(defun mu4e-server-repl ()
|
||||
"Start a mu4e-server repl.
|
||||
|
||||
This is meant for debugging/testing - the repl is designed for
|
||||
machines, not for humans.
|
||||
|
||||
You cannot run the repl when mu4e is running (or vice-versa)."
|
||||
(interactive)
|
||||
(if (mu4e-running-p)
|
||||
(mu4e-error "Cannot run repl when mu4e is running")
|
||||
(let ((cmd (string-join (cons mu4e-mu-binary (mu4e--server-args)) " ")))
|
||||
(term cmd)
|
||||
(rename-buffer "*mu4e-repl*" 'unique)
|
||||
(message "invoked: '%s'" cmd))))
|
||||
|
||||
(defun mu4e--server-start ()
|
||||
"Start the mu server process."
|
||||
(let ((default-directory temporary-file-directory)) ;;ensure it's local.
|
||||
|
@ -403,16 +426,12 @@ As per issue #2198."
|
|||
(concat
|
||||
"Found mu version %s, but mu4e needs version %s"
|
||||
"; please set `mu4e-mu-binary' "
|
||||
"accordingly") version mu4e-mu-version)))
|
||||
"accordingly")
|
||||
version mu4e-mu-version)))
|
||||
;; kill old/stale servers, if any.
|
||||
(mu4e--kill-stale)
|
||||
(let* ((process-connection-type nil) ;; use a pipe
|
||||
(args
|
||||
;; [--debug] server [--muhome=..]
|
||||
(seq-filter (lambda (arg) arg) ;; filter out nil
|
||||
`(,(when mu4e-mu-debug "--debug")
|
||||
"server"
|
||||
,(when mu4e-mu-home (format "--muhome=%s" mu4e-mu-home))))))
|
||||
(args (mu4e--server-args)))
|
||||
(setq mu4e--server-buf "")
|
||||
(mu4e-log 'misc "* invoking '%s' with parameters %s" mu4e-mu-binary
|
||||
(mapconcat (lambda (arg) (format "'%s'" arg)) args " "))
|
||||
|
|
Loading…
Reference in New Issue