]> git.cworth.org Git - notmuch-wiki/commitdiff
Added tip on context dependent part selection in emacs
authorinwit <inwit@sindominio.net>
Fri, 11 Mar 2022 16:52:18 +0000 (17:52 +0100)
committerinwit <inwit@sindominio.net>
Fri, 11 Mar 2022 16:52:18 +0000 (17:52 +0100)
emacstips.mdwn

index 952a62c21d28202d8f39298f74e3e9b0c5ea3ec4..58641771798bd3f61bb34bd8b6bf7613f4f8fb77 100644 (file)
@@ -939,3 +939,31 @@ discussion](https://notmuchmail.org/pipermail/notmuch/2018/026414.html).
 The `notmuch-extract-thread-patches` and
 `notmuch-extract-message-patches` commands from the `elpa-mailscripts`
 package in Debian (and its derivatives) can do this for you.
+
+## Allow content preference based on message context
+
+The preference for which sub-part of a multipart/alternative part is shown is
+globally set. For example, if you prefer showing the html version over the text
+based, you can set:
+
+    (setq notmuch-multipart/alternative-discouraged '("text/plain" "text/html"))
+
+However, sometimes you might want to adapt your preference depending on the
+context. You can override the default settings on a per-message basis by
+providing a function that has access to the message and which returns the
+discouraged type list. For example:
+
+    (defun my/determine-discouraged (msg)
+      (let* ((headers (plist-get msg :headers))
+             (from (or (plist-get headers :From) "")))
+        (cond
+         ((string-match "whatever@mail.address.com" from)
+          '("text/plain"))
+         (t
+          '("text/html" "multipart/related")))))
+
+    (setq notmuch-multipart/alternative-discouraged
+          'my/determine-discouraged)
+
+This would discourage text/html and multipart/related generally, but discourage
+text/plain should the message be sent from whatever@mail.address.com.