* mu4e-utils.el: warn when no actions are defined + some cosmetics

This commit is contained in:
djcb
2012-04-20 08:46:05 +03:00
parent bff93c9962
commit e0db2dcfb2

View File

@ -124,7 +124,7 @@ paths."
(string-match "\\.\\{1,2\\}$" de))) (string-match "\\.\\{1,2\\}$" de)))
(directory-files (concat path mdir)))) (directory-files (concat path mdir))))
;; 2. get the list of dirs with a /cur leaf dir ;; 2. get the list of dirs with a /cur leaf dir
(maildirs)) (maildirs))
(dolist (dir subdirs) (dolist (dir subdirs)
(if (string= dir "cur") (if (string= dir "cur")
;; be pedantic, and insist on there being a new/tmp as well ;; be pedantic, and insist on there being a new/tmp as well
@ -146,7 +146,7 @@ top-level Maildir here."
(file-directory-p (concat path "/tmp")) (file-directory-p (concat path "/tmp"))
(file-directory-p (concat path "/new"))) (file-directory-p (concat path "/new")))
'("/")) '("/"))
(mu4e--get-maildirs-1 path))) (mu4e--get-maildirs-1 path)))
(defun mu4e-ask-maildir (prompt) (defun mu4e-ask-maildir (prompt)
@ -343,7 +343,7 @@ processing takes part in the background, unless buf is non-nil."
(let* ((status (process-status proc)) (let* ((status (process-status proc))
(code (process-exit-status proc)) (code (process-exit-status proc))
;; sadly, fetchmail returns '1' when there is no mail; this is not really ;; sadly, fetchmail returns '1' when there is no mail; this is not really
;; an error of course, but it's hard to distinguish from a genuine error ;; an error of course, but it's hard to distinguish from a genuine error
(maybe-error (or (not (eq status 'exit)) (/= code 0)))) (maybe-error (or (not (eq status 'exit)) (/= code 0))))
(message nil) (message nil)
;; there may be an error, give the user up to 5 seconds to check ;; there may be an error, give the user up to 5 seconds to check
@ -351,8 +351,8 @@ processing takes part in the background, unless buf is non-nil."
(sit-for 5)) (sit-for 5))
(mu4e-proc-index mu4e-maildir) (mu4e-proc-index mu4e-maildir)
(let ((buf (process-buffer proc))) (let ((buf (process-buffer proc)))
(when (buffer-live-p buf) (when (buffer-live-p buf)
(kill-buffer buf)))))))) (kill-buffer buf))))))))
(defun mu4e-display-manual () (defun mu4e-display-manual ()
@ -397,17 +397,19 @@ point in eiter the headers buffer or the view buffer."
"Ask user with PROMPT to choose some action from ACTIONS. ACTIONS "Ask user with PROMPT to choose some action from ACTIONS. ACTIONS
is a list of actions like `mu4e-view-attachments-actions', is a list of actions like `mu4e-view-attachments-actions',
`mu4e-view-actions', `mu4e-header-actions'. Then, call the function `mu4e-view-actions', `mu4e-header-actions'. Then, call the function
for this action, with the currrent message plist as the argument." for this action, with the currrent message plist as the argument."
(let ((kar (mu4e-read-option prompt actions))) (if (null actions)
(dolist (action actions) (message "No actions of this type defined")
(let ((shortcut (cadr action)) (func (nth 2 action))) (let ((kar (mu4e-read-option prompt actions)))
(when (eq kar shortcut) (dolist (action actions)
(let ((shortcut (cadr action)) (func (nth 2 action)))
(when (eq kar shortcut)
(funcall func msg))))))) (funcall func msg)))))))
(defun mu4e-capture-message () (defun mu4e-capture-message ()
"Capture the path of the message at point." "Capture the path of the message at point."
(interactive) (interactive)
(setq mu4e-captured-message (mu4e-message-at-point t)) (setq mu4e-captured-message (mu4e-message-at-point t))
(message "Message has been captured")) (message "Message has been captured"))
(defun mu4e-kill-buffer-and-window (buf) (defun mu4e-kill-buffer-and-window (buf)
@ -489,7 +491,7 @@ process."
(defun mu4e-proc-is-running () (defun mu4e-proc-is-running ()
"Whether the mu process is running." "Whether the mu process is running."
(buffer-live-p mu4e-mu-proc)) (buffer-live-p mu4e-mu-proc))
(defun* mu4e (&key (hide-ui nil)) (defun* mu4e (&key (hide-ui nil))
"Start mu4e . We do this by sending a 'ping' to the mu server "Start mu4e . We do this by sending a 'ping' to the mu server
@ -502,7 +504,7 @@ non-nil, don't show the UI."
(unless hide-ui (unless hide-ui
(mu4e-main-view)) (mu4e-main-view))
(progn (progn
;; otherwise, check whether all is okay; ;; otherwise, check whether all is okay;
(mu4e-check-requirements) (mu4e-check-requirements)
;; explicit version checks are a bit questionable, ;; explicit version checks are a bit questionable,
;; better to check for specific features ;; better to check for specific features
@ -560,13 +562,13 @@ either 'to-server, 'from-server or 'misc. This function is meant for debugging."
(misc 'font-lock-variable-name-face) (misc 'font-lock-variable-name-face)
(otherwise (error "Unsupported log type")))) (otherwise (error "Unsupported log type"))))
(msg (propertize (apply 'format frm args) 'face msg-face))) (msg (propertize (apply 'format frm args) 'face msg-face)))
(goto-char (point-max)) (goto-char (point-max))
(insert tstamp (insert tstamp
(case type (case type
(from-server " <- ") (from-server " <- ")
(to-server " -> " ) (to-server " -> " )
(otherwise " ")) (otherwise " "))
msg "\n") msg "\n")
;; if `mu4e-log-max-lines is specified and exceeded, clearest the oldest ;; if `mu4e-log-max-lines is specified and exceeded, clearest the oldest
;; lines ;; lines
@ -576,7 +578,7 @@ either 'to-server, 'from-server or 'misc. This function is meant for debugging."
(goto-char (point-max)) (goto-char (point-max))
(forward-line (- mu4e-log-max-lines lines)) (forward-line (- mu4e-log-max-lines lines))
(beginning-of-line) (beginning-of-line)
(delete-region (point-min) (point))))))))) (delete-region (point-min) (point)))))))))
(defun mu4e-toggle-logging () (defun mu4e-toggle-logging ()
"Toggle between enabling/disabling debug-mode (in debug-mode, "Toggle between enabling/disabling debug-mode (in debug-mode,