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 hdr 'face 'mu4e-header-key-face)
|
||||||
(propertize val 'face 'mu4e-header-val-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)
|
(defun mu4e~draft-references-construct (msg)
|
||||||
"Construct the value of the References: header based on MSG as a
|
"Construct the value of the References: header based on MSG as a
|
||||||
comma-separated string. Normally, this the concatenation of the
|
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 "")))
|
(refs (if (and msgid (not (string= msgid "")))
|
||||||
(append refs (list msgid)) refs))
|
(append refs (list msgid)) refs))
|
||||||
;; no doubles
|
;; no doubles
|
||||||
(refs (delete-duplicates refs :test #'equal)))
|
(refs (delete-duplicates refs :test #'equal))
|
||||||
(mapconcat (lambda (id) (format "<%s>" id)) refs " ")))
|
(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 there's no-one in To, copy the CC-list
|
||||||
(if (zerop (length (mu4e~draft-create-to-lst origmsg)))
|
(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...
|
;; otherwise...
|
||||||
(concat
|
(concat
|
||||||
(mu4e~draft-header "To" (mu4e~draft-recipients-construct :to origmsg))
|
(mu4e~draft-header "To" (mu4e~draft-recipients-construct :to origmsg))
|
||||||
|
|||||||
Reference in New Issue
Block a user