From 6814250a0c95e0849c191e7f5fe8e2a8bee31440 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 2 Aug 2016 22:49:19 +0800 Subject: spacemacs: update mu/mu4e to git20160802 --- _spacemacs.d/local/mu4e/mu4e-draft.el | 61 +++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 20 deletions(-) (limited to '_spacemacs.d/local/mu4e/mu4e-draft.el') diff --git a/_spacemacs.d/local/mu4e/mu4e-draft.el b/_spacemacs.d/local/mu4e/mu4e-draft.el index c41e38d..d7df6e0 100644 --- a/_spacemacs.d/local/mu4e/mu4e-draft.el +++ b/_spacemacs.d/local/mu4e/mu4e-draft.el @@ -99,7 +99,6 @@ its settings apply." (funcall mu4e-compose-cite-function)) (pop-mark) (goto-char (point-min)) - (mu4e~fontify-cited) (buffer-string)))) (defun mu4e~draft-header (hdr val) @@ -109,7 +108,17 @@ If VAL is nil, return nil." ;; later. (when val (format "%s: %s\n" (propertize hdr 'face 'mu4e-header-key-face) - (propertize val 'face 'mu4e-header-val-face)))) + (propertize val 'face 'mu4e-header-value-face)))) + +(defconst mu4e~max-reference-num 21 + "Maximum number of References:, as suggested by +`message-shorten-references'.") + +(defun mu4e~shorten-1 (list cut surplus) + "Cut SURPLUS elements out of LIST, beginning with CUTth +one. Code borrowed from `message-shorten-1'." + (setcdr (nthcdr (- cut 2) list) + (nthcdr (+ (- cut 2) surplus 1) list))) (defun mu4e~draft-references-construct (msg) "Construct the value of the References: header based on MSG as a @@ -125,10 +134,16 @@ References. If both are empty, return nil." (refs (if (and msgid (not (string= msgid ""))) (append refs (list msgid)) refs)) ;; no doubles - (refs (delete-duplicates refs :test #'equal))) + (refs (delete-duplicates refs :test #'equal)) + (refnum (length refs)) + (cut 2)) + ;; remove some refs when there are too many + (when (> refnum mu4e~max-reference-num) + (let ((surplus (- refnum mu4e~max-reference-num))) + (mu4e~shorten-1 refs cut surplus))) (mapconcat (lambda (id) (format "<%s>" id)) refs " "))) - + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; determine the recipient fields for new messages @@ -311,7 +326,7 @@ You can append flags." (format-time-string "%s" (current-time)) (random 65535) (random 65535) (random 65535) (random 65535) hostname (or flagstr "")))) - + (defun mu4e~draft-common-construct () "Construct the common headers for each message." (concat @@ -346,11 +361,12 @@ fields will be the same as in the original." (mu4e~draft-header "To" (mu4e~draft-recipients-list-to-string (mu4e-message-field origmsg :to))) (mu4e~draft-header "Cc" (mu4e~draft-recipients-list-to-string - (mu4e-message-field origmsg :cc)))) - + (mu4e-message-field origmsg :cc)))) + ;; if there's no-one in To, copy the CC-list (if (zerop (length (mu4e~draft-create-to-lst origmsg))) - (mu4e~draft-header "To" (mu4e~draft-recipients-construct :cc origmsg reply-all)) + (mu4e~draft-header "To" (mu4e~draft-recipients-construct + :cc origmsg reply-all)) ;; otherwise... (concat (mu4e~draft-header "To" (mu4e~draft-recipients-construct :to origmsg)) @@ -415,9 +431,10 @@ fields will be the same as in the original." (defun mu4e-draft-open (compose-type &optional msg) - "Open a draft file for a new message (when COMPOSE-TYPE is `reply', `forward' or `new'), -open an existing draft (when COMPOSE-TYPE is `edit'), or re-send -an existing message (when COMPOSE-TYPE is `resend'). + "Open a draft file for a new message (when COMPOSE-TYPE is `reply', + `forward' or `new'), open an existing draft (when COMPOSE-TYPE +is `edit'), or re-send an existing message (when COMPOSE-TYPE is +`resend'). The name of the draft folder is constructed from the concatenation of `mu4e-maildir' and `mu4e-drafts-folder' (the @@ -428,10 +445,11 @@ will be created from either `mu4e~draft-reply-construct', or (unless mu4e-maildir (mu4e-error "mu4e-maildir not set")) (let ((draft-dir nil)) (case compose-type - + (edit - ;; case-1: re-editing a draft messages. in this case, we do know the full - ;; path, but we cannot really know 'drafts folder'... we make a guess + ;; case-1: re-editing a draft messages. in this case, we do know the + ;; full path, but we cannot really know 'drafts folder'... we make a + ;; guess (setq draft-dir (mu4e~guess-maildir (mu4e-message-field msg :path))) (mu4e~draft-open-file (mu4e-message-field msg :path))) @@ -442,9 +460,9 @@ will be created from either `mu4e~draft-reply-construct', or (let ((draft-path (mu4e~draft-determine-path draft-dir))) (copy-file (mu4e-message-field msg :path) draft-path) (mu4e~draft-open-file draft-path))) - + ((reply forward new) - ;; case-3: creating a new message; in this case, we can determing + ;; case-3: creating a new message; in this case, we can determine ;; mu4e-get-drafts-folder (setq draft-dir (mu4e-get-drafts-folder msg)) (let ((draft-path (mu4e~draft-determine-path draft-dir)) @@ -454,7 +472,7 @@ will be created from either `mu4e~draft-reply-construct', or (forward (mu4e~draft-forward-construct msg)) (new (mu4e~draft-newmsg-construct))))) (mu4e~draft-open-file draft-path) - (insert initial-contents) + (insert initial-contents) (newline) ;; include the message signature (if it's set) (if (and mu4e-compose-signature-auto-include mu4e-compose-signature) @@ -463,12 +481,15 @@ will be created from either `mu4e~draft-reply-construct', or (message-insert-signature) (mu4e~fontify-signature)))))) (t (mu4e-error "unsupported compose-type %S" compose-type))) - ;; evaluate mu4e~drafts-drafts-folder once, here, and use that value - ;; throughout. + ;; if we didn't find a draft folder yet, try some default + (unless draft-dir + (setq draft-dir (mu4e-get-drafts-folder msg))) + ;; evaluate mu4e~drafts-drafts-folder once, here, and use that value + ;; throughout. (set (make-local-variable 'mu4e~draft-drafts-folder) draft-dir) (put 'mu4e~draft-drafts-folder 'permanent-local t) (unless mu4e~draft-drafts-folder (mu4e-error "failed to determine drafts folder")))) - + (provide 'mu4e-draft) -- cgit v1.2.2