mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
emacs: inline notmuch-split-content-type
This trivial helper function actually made things slightly *less* readable by adding an unnecessary indirection.
This commit is contained in:
parent
4f57e01843
commit
dff7f06711
2 changed files with 10 additions and 14 deletions
|
@ -534,14 +534,10 @@ This replaces spaces, percents, and double quotes in STR with
|
||||||
(setq pred (cddr pred)))
|
(setq pred (cddr pred)))
|
||||||
(cdr xplist)))
|
(cdr xplist)))
|
||||||
|
|
||||||
(defun notmuch-split-content-type (content-type)
|
|
||||||
"Split content/type into 'content' and 'type'."
|
|
||||||
(split-string content-type "/"))
|
|
||||||
|
|
||||||
(defun notmuch-match-content-type (t1 t2)
|
(defun notmuch-match-content-type (t1 t2)
|
||||||
"Return t if t1 and t2 are matching content types, taking wildcards into account."
|
"Return t if t1 and t2 are matching content types, taking wildcards into account."
|
||||||
(let ((st1 (notmuch-split-content-type t1))
|
(let ((st1 (split-string t1 "/"))
|
||||||
(st2 (notmuch-split-content-type t2)))
|
(st2 (split-string t2 "/")))
|
||||||
(if (or (string= (cadr st1) "*")
|
(if (or (string= (cadr st1) "*")
|
||||||
(string= (cadr st2) "*"))
|
(string= (cadr st2) "*"))
|
||||||
;; Comparison of content types should be case insensitive.
|
;; Comparison of content types should be case insensitive.
|
||||||
|
|
|
@ -573,12 +573,13 @@ message at DEPTH in the current thread."
|
||||||
;; alternative (even if we can't render it).
|
;; alternative (even if we can't render it).
|
||||||
(push (list content-id msg part) notmuch-show--cids)))
|
(push (list content-id msg part) notmuch-show--cids)))
|
||||||
;; Recurse on sub-parts
|
;; Recurse on sub-parts
|
||||||
(let ((ctype (notmuch-split-content-type
|
(pcase-let ((`(,content ,type)
|
||||||
(downcase (plist-get part :content-type)))))
|
(split-string (downcase (plist-get part :content-type)) "/")))
|
||||||
(cond ((equal (car ctype) "multipart")
|
(cond ((equal content "multipart")
|
||||||
(mapc (apply-partially #'notmuch-show--register-cids msg)
|
(mapc (apply-partially #'notmuch-show--register-cids msg)
|
||||||
(plist-get part :content)))
|
(plist-get part :content)))
|
||||||
((equal ctype '("message" "rfc822"))
|
((and (equal content "message")
|
||||||
|
(equal type "rfc822"))
|
||||||
(notmuch-show--register-cids
|
(notmuch-show--register-cids
|
||||||
msg
|
msg
|
||||||
(car (plist-get (car (plist-get part :content)) :body)))))))
|
(car (plist-get (car (plist-get part :content)) :body)))))))
|
||||||
|
@ -851,10 +852,9 @@ will return nil if the CID is unknown or cannot be retrieved."
|
||||||
(push func result)))
|
(push func result)))
|
||||||
;; Reverse order of prefrence.
|
;; Reverse order of prefrence.
|
||||||
(list (intern (concat "notmuch-show-insert-part-*/*"))
|
(list (intern (concat "notmuch-show-insert-part-*/*"))
|
||||||
(intern (concat
|
(intern (concat "notmuch-show-insert-part-"
|
||||||
"notmuch-show-insert-part-"
|
(car (split-string content-type "/"))
|
||||||
(car (notmuch-split-content-type content-type))
|
"/*"))
|
||||||
"/*"))
|
|
||||||
(intern (concat "notmuch-show-insert-part-" content-type))))
|
(intern (concat "notmuch-show-insert-part-" content-type))))
|
||||||
result))
|
result))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue