Permalink
Browse files

* mu4e: dynamic folder updates

  • Loading branch information...
1 parent af5ad98 commit 5779820ba099b0f04cf9450682e08abf711f1d29 @djcb committed Sep 27, 2012
Showing with 66 additions and 90 deletions.
  1. +30 −31 mu4e/mu4e-headers.el
  2. +6 −5 mu4e/mu4e-mark.el
  3. +4 −1 mu4e/mu4e-utils.el
  4. +26 −53 mu4e/mu4e-view.el
View
@@ -390,9 +390,9 @@ after the end of the search results."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defmacro mu4e~headers-defun-mark-func (mark)
+(defmacro mu4e~headers-defun-mark-for (mark)
"Define a function mu4e~headers-mark-MARK."
- (let ((funcname (intern (concat "mu4e~headers-mark-" (symbol-name mark))))
+ (let ((funcname (intern (concat "mu4e-headers-mark-for-" (symbol-name mark))))
(docstring (concat "Mark header at point with " (symbol-name mark) ".")))
`(defun ,funcname () ,docstring
(interactive)
@@ -401,16 +401,16 @@ after the end of the search results."
;; define our mark functions; there must be some way to do this in a loop but
;; since `mu4e~headers-defun-mark-func' is a macro, the argument must be a
;; literal value.
-(mu4e~headers-defun-mark-func refile)
-(mu4e~headers-defun-mark-func deferred)
-(mu4e~headers-defun-mark-func delete)
-(mu4e~headers-defun-mark-func flag)
-(mu4e~headers-defun-mark-func move)
-(mu4e~headers-defun-mark-func read)
-(mu4e~headers-defun-mark-func trash)
-(mu4e~headers-defun-mark-func unflag)
-(mu4e~headers-defun-mark-func unmark)
-(mu4e~headers-defun-mark-func unread)
+(mu4e~headers-defun-mark-for refile)
+(mu4e~headers-defun-mark-for deferred)
+(mu4e~headers-defun-mark-for delete)
+(mu4e~headers-defun-mark-for flag)
+(mu4e~headers-defun-mark-for move)
+(mu4e~headers-defun-mark-for read)
+(mu4e~headers-defun-mark-for trash)
+(mu4e~headers-defun-mark-for unflag)
+(mu4e~headers-defun-mark-for unmark)
+(mu4e~headers-defun-mark-for unread)
;;; headers-mode and mode-map ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -468,25 +468,24 @@ after the end of the search results."
(define-key map "y" 'mu4e-select-other-view)
;; marking/unmarking ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (define-key map (kbd "<backspace>") 'mu4e~headers-mark-trash)
- (define-key map (kbd "d") 'mu4e~headers-mark-trash)
- (define-key map (kbd "<delete>") 'mu4e~headers-mark-delete)
- (define-key map (kbd "<deletechar>") 'mu4e~headers-mark-delete)
- (define-key map (kbd "D") 'mu4e~headers-mark-delete)
- (define-key map (kbd "m") 'mu4e~headers-mark-move)
- (define-key map (kbd "r") 'mu4e~headers-mark-refile)
-
- (define-key map (kbd "o") 'mu4e~headers-mark-unread)
- (define-key map (kbd "s") 'mu4e~headers-mark-read)
-
- (define-key map (kbd "u") 'mu4e~headers-mark-unmark)
- (define-key map (kbd "+") 'mu4e~headers-mark-flag)
- (define-key map (kbd "-") 'mu4e~headers-mark-unflag)
- (define-key map (kbd "&") 'mu4e-headers-mark-custom)
-
-
- (define-key map (kbd "*") 'mu4e~headers-mark-deferred)
- (define-key map (kbd "<kp-multiply>") 'mu4e~headers-mark-deferred)
+ (define-key map (kbd "<backspace>") 'mu4e-headers-mark-for-trash)
+ (define-key map (kbd "d") 'mu4e-headers-mark-for-trash)
+ (define-key map (kbd "<delete>") 'mu4e-headers-mark-for-delete)
+ (define-key map (kbd "<deletechar>") 'mu4e-headers-mark-for-delete)
+ (define-key map (kbd "D") 'mu4e-headers-mark-for-delete)
+ (define-key map (kbd "m") 'mu4e-headers-mark-for-move)
+ (define-key map (kbd "r") 'mu4e-headers-mark-for-refile)
+
+ (define-key map (kbd "o") 'mu4e-headers-mark-for-unread)
+ (define-key map (kbd "s") 'mu4e-headers-mark-for-read)
+
+ (define-key map (kbd "u") 'mu4e-headers-mark-for-unmark)
+ (define-key map (kbd "+") 'mu4e-headers-mark-for-flag)
+ (define-key map (kbd "-") 'mu4e-headers-mark-for-unflag)
+ (define-key map (kbd "&") 'mu4e-headers-mark-for-custom)
+
+ (define-key map (kbd "*") 'mu4e-headers-mark-for-deferred)
+ (define-key map (kbd "<kp-multiply>") 'mu4e-headers-mark-for-deferred)
(define-key map (kbd "#") 'mu4e-mark-resolve-deferred-marks)
(define-key map "U" 'mu4e-mark-unmark-all)
View
@@ -172,10 +172,11 @@ provided, function asks for it."
"Mark the header at point, or, if region is active, mark all
headers in the region. Optionally, provide TARGET (for moves)."
(let ((target ;; ask or check the target if it's a move
- (case mark
- ('refile (mu4e-get-refile-folder (mu4e-message-at-point)))
- ('move (mu4e~mark-get-move-target target))
- ('trash (mu4e-get-trash-folder (mu4e-message-at-point))) )))
+ (or target
+ (case mark
+ (refile (mu4e-get-refile-folder (mu4e-message-at-point)))
+ (move (mu4e~mark-get-move-target target))
+ (trash (mu4e-get-trash-folder (mu4e-message-at-point))) ))))
(if (not (use-region-p))
;; single message
(mu4e-mark-at-point mark target)
@@ -186,7 +187,7 @@ headers in the region. Optionally, provide TARGET (for moves)."
(while (<= (line-beginning-position) e)
(setq target ;; refile/trash targets are determined per-message
(case mark
- (refile (mu4e-get-refile-folder (mu4e-message-at-point)))
+ (refile (mu4e-get-refile-folder (mu4e-message-at-point)))
(trash (mu4e-get-trash-folder (mu4e-message-at-point)))
(t target)))
(mu4e-mark-at-point mark target)
View
@@ -521,7 +521,10 @@ This is used by the completion function in mu4e-compose."
(and mu4e-compose-complete-ignore-address-regexp
(string-match mu4e-compose-complete-ignore-address-regexp mail))
(add-to-list 'lst
- (if name (format "\"%s\" <%s>" name mail) mail))))))
+ (if name (format "\"%s\" <%s>"
+ ;; hack so we don't get ',' in e-mail addresses...
+ (replace-regexp-in-string "," "" name)
+ mail) mail))))))
(setq mu4e~contacts-for-completion lst)
(mu4e-message "Contacts received: %d"
(length mu4e~contacts-for-completion))))
View
@@ -546,7 +546,7 @@ at POINT, or if nil, at (point)."
(define-key map (kbd "D") 'mu4e-view-mark-for-delete)
(define-key map (kbd "m") 'mu4e-view-mark-for-move)
(define-key map (kbd "r") 'mu4e-view-mark-for-refile)
-
+
(define-key map (kbd "&") 'mu4e-view-mark-custom)
(define-key map (kbd "+") 'mu4e-view-mark-flag)
@@ -559,7 +559,7 @@ at POINT, or if nil, at (point)."
;; misc
(define-key map "w" 'longlines-mode)
(define-key map "h" 'mu4e-view-toggle-hide-cited)
-
+
;; next 3 only warn user when attempt in the message view
(define-key map "u" 'mu4e-view-unmark)
(define-key map "U" 'mu4e-view-unmark-all)
@@ -1059,15 +1059,7 @@ attachments) in response to a (mu4e~proc-extract 'temp ... )."
(setq buffer-read-only t))
(t (mu4e-error "Unsupported action %S" what))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;;; marking
-(defun mu4e~view-mark-set (mark)
- "Set mark on the current messages."
- (let ((docid (mu4e-msg-field mu4e~view-msg :docid)))
- (mu4e~view-in-headers-context
- (mu4e-mark-at-point mark))))
-
-(defun mu4e-view-mark-custom ()
+ (defun mu4e-view-mark-custom ()
"Run some custom mark function."
(mu4e~view-in-headers-context
(mu4e-headers-mark-custom)))
@@ -1089,50 +1081,31 @@ user that unmarking only works in the header list."
user that unmarking only works in the header list."
(interactive)
(if (mu4e~split-view-p)
- (mu4e~view-mark-set 'unmark)
+ (mu4e-view-mark-for-unmark)
(mu4e-message "Unmarking needs to be done in the header list view")))
-(defun mu4e-view-mark-for-move ()
- "Mark the current message for moving."
- (interactive)
- (mu4e~view-mark-set 'move)
- (mu4e-view-headers-next))
-
-(defun mu4e-view-mark-for-trash ()
- "Mark the current message for moving to the trash folder."
- (interactive)
- (mu4e~view-mark-set 'trash)
- (mu4e-view-headers-next))
-
-(defun mu4e-view-mark-for-refile ()
- "Mark the current message for refiling."
- (interactive)
- (mu4e~view-mark-set 'refile)
- (mu4e-view-headers-next))
-
-(defun mu4e-view-mark-for-delete ()
- "Mark the current message for deletion."
- (interactive)
- (mu4e~view-mark-set 'delete)
- (mu4e-view-headers-next))
-
-(defun mu4e-view-mark-flag ()
- "Mark the current message for flagging."
- (interactive)
- (mu4e~view-mark-set 'flag)
- (mu4e-view-headers-next))
-
-(defun mu4e-view-mark-unflag ()
- "Mark the current message for unflagging."
- (interactive)
- (mu4e~view-mark-set 'unflag)
- (mu4e-view-headers-next))
-
-(defun mu4e-view-mark-deferred ()
- "Mark the current message for unflagging."
- (interactive)
- (mu4e~view-mark-set 'deferred)
- (mu4e-view-headers-next))
+(defmacro mu4e~view-defun-mark-for (mark)
+ "Define a function mu4e-view-mark-for-MARK."
+ (let ((funcname (intern (concat "mu4e-view-mark-for-" (symbol-name mark))))
+ (docstring (concat "Mark the current message for " (symbol-name mark) ".")))
+ `(defun ,funcname () ,docstring
+ (interactive)
+ (mu4e~view-in-headers-context
+ (mu4e-headers-mark-and-next (quote mark))))))
+
+;; would be cool to do something like the following, but somehow, I can't get
+;; the quoting right...
+;; (dolist (mark '(move trash refile delete flag unflag unmark deferred))
+;; (mu4e~view-defun-mark-for mark))
+
+(mu4e~view-defun-mark-for move)
+(mu4e~view-defun-mark-for trash)
+(mu4e~view-defun-mark-for refile)
+(mu4e~view-defun-mark-for delete)
+(mu4e~view-defun-mark-for flag)
+(mu4e~view-defun-mark-for unflag)
+(mu4e~view-defun-mark-for unmark)
+(mu4e~view-defun-mark-for deferred)
(defun mu4e-view-marked-execute ()
"Execute the marks."

0 comments on commit 5779820

Please sign in to comment.