From: inwit Date: Fri, 11 Mar 2022 16:52:18 +0000 (+0100) Subject: Added tip on context dependent part selection in emacs X-Git-Url: https://git.notmuchmail.org/git?p=notmuch-wiki;a=commitdiff_plain;h=7237f490c36759c664b8c448b8f740d14464d998 Added tip on context dependent part selection in emacs --- diff --git a/emacstips.mdwn b/emacstips.mdwn index 952a62c..5864177 100644 --- a/emacstips.mdwn +++ b/emacstips.mdwn @@ -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.