* unified the action / attachment handling

- mu4e-utils.el: s/mu4e-offer-action/mu4e-choose-action/, and return a
    function now, rather than executing it directly
  - mu4e-view.el: implement the attachment handling function in terms of
    mu4e-choose-action, and each other. also fix some small issues.
This commit is contained in:
djcb
2012-04-20 17:53:41 +03:00
parent e0db2dcfb2
commit fbf9c70cbb
2 changed files with 73 additions and 68 deletions

View File

@ -392,18 +392,18 @@ there is no message at point."
"Get FIELD (a symbol, see `mu4e-header-names') for the message at
point in eiter the headers buffer or the view buffer."
(plist-get (mu4e-message-at-point t) field))
(defun mu4e-choose-action (prompt actions)
"Ask user with PROMPT to choose some action from ACTIONS. ACTIONS
is a list of actions like `mu4e-view-attachments-actions',
`mu4e-view-actions', `mu4e-header-actions'. Then, call the function
is a list of actions like `mu4e-view-attachments-actions',
`mu4e-view-actions', `mu4e-header-actions'. Returns the
action (function) to invoke, or nil. "
(if (null actions)
(message "No actions of this type defined")
(let ((kar (mu4e-read-option prompt actions)))
(dolist (action actions)
(let ((shortcut (cadr action)) (func (nth 2 action)))
(when (eq kar shortcut)
(message "No actions of this type defined")
(let* ((kar (mu4e-read-option prompt actions))
(action ;; find the action for this kar
(find-if (lambda (ac) (eq kar (cadr ac))) actions)))
(when action
(nth 2 action))))) ;; return func
(defun mu4e-capture-message ()