From 6378288287d988f8cee83a6bd6d451dccaa870fa Mon Sep 17 00:00:00 2001 From: djcb Date: Mon, 7 May 2012 21:59:06 +0300 Subject: [PATCH] * add compatibilty wrapper for emacs24's read-char-choice --- emacs/mu4e-proc.el | 107 ++++++++++++++++++++++---------------------- emacs/mu4e-utils.el | 14 +++--- 2 files changed, 60 insertions(+), 61 deletions(-) diff --git a/emacs/mu4e-proc.el b/emacs/mu4e-proc.el index 421b52a1..85cb4962 100644 --- a/emacs/mu4e-proc.el +++ b/emacs/mu4e-proc.el @@ -182,72 +182,73 @@ The server output is as follows: (mu4e-log 'misc "* Received %d byte(s)" (length str)) (setq mu4e~proc-buf (concat mu4e~proc-buf str)) ;; update our buffer (let ((sexp (mu4e~proc-eat-sexp-from-buf))) - (while sexp - (mu4e-log 'from-server "%S" sexp) - (cond - ;; a header plist can be recognized by the existence of a :date field - ((plist-get sexp :date) - (funcall mu4e-header-func sexp)) + (with-local-quit + (while sexp + (mu4e-log 'from-server "%S" sexp) + (cond + ;; a header plist can be recognized by the existence of a :date field + ((plist-get sexp :date) + (funcall mu4e-header-func sexp)) - ;; the found sexp, we receive after getting all the headers - ((plist-get sexp :found) - (funcall mu4e-found-func (plist-get sexp :found))) + ;; the found sexp, we receive after getting all the headers + ((plist-get sexp :found) + (funcall mu4e-found-func (plist-get sexp :found))) - ;; viewing a specific message - ((plist-get sexp :view) - (funcall mu4e-view-func (plist-get sexp :view))) + ;; viewing a specific message + ((plist-get sexp :view) + (funcall mu4e-view-func (plist-get sexp :view))) - ;; receive an erase message - ((plist-get sexp :erase) - (funcall mu4e-erase-func)) + ;; receive an erase message + ((plist-get sexp :erase) + (funcall mu4e-erase-func)) - ;; receive a :sent message - ((plist-get sexp :sent) - (funcall mu4e-sent-func - (plist-get sexp :docid) - (plist-get sexp :path))) + ;; receive a :sent message + ((plist-get sexp :sent) + (funcall mu4e-sent-func + (plist-get sexp :docid) + (plist-get sexp :path))) - ;; receive a pong message - ((plist-get sexp :pong) - (funcall mu4e-pong-func - (plist-get sexp :version) (plist-get sexp :doccount))) + ;; receive a pong message + ((plist-get sexp :pong) + (funcall mu4e-pong-func + (plist-get sexp :version) (plist-get sexp :doccount))) - ;; something got moved/flags changed - ((plist-get sexp :update) - (funcall mu4e-update-func - (plist-get sexp :update) (plist-get sexp :move))) + ;; something got moved/flags changed + ((plist-get sexp :update) + (funcall mu4e-update-func + (plist-get sexp :update) (plist-get sexp :move))) - ;; a message got removed - ((plist-get sexp :remove) - (funcall mu4e-remove-func (plist-get sexp :remove))) + ;; a message got removed + ((plist-get sexp :remove) + (funcall mu4e-remove-func (plist-get sexp :remove))) - ;; start composing a new message - ((plist-get sexp :compose) - (funcall mu4e-compose-func - (plist-get sexp :compose) - (plist-get sexp :original) - (plist-get sexp :include))) + ;; start composing a new message + ((plist-get sexp :compose) + (funcall mu4e-compose-func + (plist-get sexp :compose) + (plist-get sexp :original) + (plist-get sexp :include))) - ;; do something with a temporary file - ((plist-get sexp :temp) - (funcall mu4e-temp-func - (plist-get sexp :temp) ;; name of the temp file - (plist-get sexp :what) ;; what to do with it (pipe|emacs|open-with...) - (plist-get sexp :param)));; parameter for the action + ;; do something with a temporary file + ((plist-get sexp :temp) + (funcall mu4e-temp-func + (plist-get sexp :temp) ;; name of the temp file + (plist-get sexp :what) ;; what to do with it (pipe|emacs|open-with...) + (plist-get sexp :param)));; parameter for the action - ;; get some info - ((plist-get sexp :info) - (funcall mu4e-info-func sexp)) + ;; get some info + ((plist-get sexp :info) + (funcall mu4e-info-func sexp)) - ;; receive an error - ((plist-get sexp :error) - (funcall mu4e-error-func - (plist-get sexp :error) - (plist-get sexp :message))) + ;; receive an error + ((plist-get sexp :error) + (funcall mu4e-error-func + (plist-get sexp :error) + (plist-get sexp :message))) - (t (mu4e-message "Unexpected data from server [%S]" sexp))) + (t (mu4e-message "Unexpected data from server [%S]" sexp))) - (setq sexp (mu4e~proc-eat-sexp-from-buf))))) + (setq sexp (mu4e~proc-eat-sexp-from-buf)))))) ;; error codes are defined in src/mu-util.h diff --git a/emacs/mu4e-utils.el b/emacs/mu4e-utils.el index 2f7d9f86..90479e98 100644 --- a/emacs/mu4e-utils.el +++ b/emacs/mu4e-utils.el @@ -91,14 +91,12 @@ dir already existed, or has been created, nil otherwise." (defun mu4e~read-char-choice (prompt choices) "Compatiblity wrapper for `read-char-choice', which is emacs-24 only." - (if (fboundp 'read-char-choice) - (read-char-choice prompt choices) - (let ((choice) (ok)) - (while (not ok) - (message nil);; this seems needed... - (setq choice (read-char prompt)) - (setq ok (member choice choices))) - choice))) + (let ((choice) (ok) (inhibit-quit nil)) + (while (not ok) + (message nil);; this seems needed... + (setq choice (read-char-exclusive prompt)) + (setq ok (member choice choices))) + choice)) (defun mu4e-read-option (prompt options) "Ask user for an option from a list on the input area. PROMPT