mu4e: limit # of references to 21
Following the example of `message-shorten-references', only allow up to 21 references, since some mail servers limit them. Fixes #859.
This commit is contained in:
@ -111,6 +111,16 @@ If VAL is nil, return nil."
|
||||
(propertize hdr 'face 'mu4e-header-key-face)
|
||||
(propertize val 'face 'mu4e-header-val-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
|
||||
comma-separated string. Normally, this the concatenation of the
|
||||
@ -125,8 +135,14 @@ 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)))
|
||||
(mapconcat (lambda (id) (format "<%s>" id)) refs " ")))
|
||||
(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 " "))))
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@ -350,7 +366,8 @@ fields will be the same as in the original."
|
||||
|
||||
;; 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))
|
||||
|
||||
Reference in New Issue
Block a user