This trivial helper function actually made things slightly
*less* readable by adding an unnecessary indirection.
---
 emacs/notmuch-lib.el  |  8 ++------
 emacs/notmuch-show.el | 16 ++++++++--------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 61107e38..2c8de328 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -534,14 +534,10 @@ (defun notmuch-plist-delete (plist property)
       (setq pred (cddr pred)))
     (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)
   "Return t if t1 and t2 are matching content types, taking wildcards into 
account."
-  (let ((st1 (notmuch-split-content-type t1))
-       (st2 (notmuch-split-content-type t2)))
+  (let ((st1 (split-string t1 "/"))
+       (st2 (split-string t2 "/")))
     (if (or (string= (cadr st1) "*")
            (string= (cadr st2) "*"))
        ;; Comparison of content types should be case insensitive.
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 14250d34..09cdeaaa 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -573,12 +573,13 @@ (defun notmuch-show--register-cids (msg part)
       ;; alternative (even if we can't render it).
       (push (list content-id msg part) notmuch-show--cids)))
   ;; Recurse on sub-parts
-  (let ((ctype (notmuch-split-content-type
-               (downcase (plist-get part :content-type)))))
-    (cond ((equal (car ctype) "multipart")
+  (pcase-let ((`(,content ,type)
+              (split-string (downcase (plist-get part :content-type)) "/")))
+    (cond ((equal content "multipart")
           (mapc (apply-partially #'notmuch-show--register-cids msg)
                 (plist-get part :content)))
-         ((equal ctype '("message" "rfc822"))
+         ((and (equal content "message")
+               (equal type "rfc822"))
           (notmuch-show--register-cids
            msg
            (car (plist-get (car (plist-get part :content)) :body)))))))
@@ -851,10 +852,9 @@ (defun notmuch-show-handlers-for (content-type)
              (push func result)))
          ;; Reverse order of prefrence.
          (list (intern (concat "notmuch-show-insert-part-*/*"))
-               (intern (concat
-                        "notmuch-show-insert-part-"
-                        (car (notmuch-split-content-type content-type))
-                        "/*"))
+               (intern (concat "notmuch-show-insert-part-"
+                               (car (split-string content-type "/"))
+                               "/*"))
                (intern (concat "notmuch-show-insert-part-" content-type))))
     result))
 
-- 
2.29.1
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org

Reply via email to