* mm + mm-cmd-server: implement 'ping' -> startup version check

This commit is contained in:
djcb
2011-12-13 07:44:45 +02:00
parent 5f1eebcad5
commit 37c884aa2e
4 changed files with 56 additions and 43 deletions

View File

@ -34,14 +34,16 @@
(require 'mm-send)
(require 'mm-proc)
(require 'mm-version) ;; auto-generated
;; mm-version.el is autogenerated, and defines mm/mu-version
(require 'mm-version)
;; Customization
(defgroup mm nil
"Mm." :group 'local)
"mm - the mu mail client"
:group 'local)
(defcustom mm/mu-home nil
"Location of the mu homedir, or nil for the default."
@ -309,8 +311,6 @@ headers)."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; internal variables / constants
(defconst mm/mm-buffer-name "*mm*"
"*internal* Name of the mm main buffer.")
(defconst mm/header-names
'( (:attachments . "Attach")
@ -330,25 +330,22 @@ view). Most fields should be self-explanatory. A special one is
`:from-or-to', which is equal to `:from' unless `:from' matches ,
in which case it will be equal to `:to'.)")
;; General helper functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; TODO: make this recursive
(defun mm/get-sub-maildirs (maildir)
"Get all readable sub-maildirs under MAILDIR."
(let ((maildirs (remove-if
(lambda (dentry)
(let ((path (concat maildir "/" dentry)))
(or
(string= dentry ".")
(string= dentry "..")
(not (file-directory-p path))
(not (file-readable-p path))
(file-exists-p (concat path "/.noindex")))))
(directory-files maildir))))
(map 'list (lambda (dir) (concat "/" dir)) maildirs)))
;; mm startup function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun mm ()
"Start mm. We do this by sending a 'ping' to the mu server
process, and start the main view if the 'pong' we receive from the
server has the expected values."
(interactive)
(if (buffer-live-p mm/main-buffer-name)
(switch-to-buffer mm/main-buffer-name)
(setq mm/proc-pong-func
(lambda (version doccount)
(unless (string= version mm/mu-version)
(error "mu server has version %s, but we need %s"
version mm/mu-version))
(mm/main-view)))
(mm/proc-ping)))
(defun mm/ask-maildir (prompt)
"Ask the user for a shortcut (using PROMPT) as defined in