[PATCH v2] emacs: cl-letf enriched-decode-display-prop for text/encriched display

Tomi Ollila tomi.ollila at iki.fi
Tue Sep 19 22:25:44 PDT 2017


Dynamically bind enriched-decode-display-prop when inserting
text/enriched part. This complements commit 9b0582383833 for
emacs versions before 24.4 which do not have advice-add functionality.

Note the (require 'enriched). Without that if 'enriched were not
already provided, the part processing via mm-display-part would
eventually load that, providing enriched-decode-display-prop
overriding our temporary definition (for the first time
text/enriched part is handled).
---

I felt mentioning this (require 'enriched) important enough to be
stored in the blockchain of notmuch commit history -- knowing such
a subtle behaviour may prevent related bugs somewhere, sometime...

I've now tested this on Emacs 25.2.1 I also tried on Emacs 23.1.1
but there my environment gave:

$ EMACS=/usr/bin/emacs ./devel/try-emacs-mua -Q
+ exec /usr/bin/emacs --debug-init --load ./devel/try-emacs-mua -Q
Fatal error (6)zsh: abort      EMACS=/usr/bin/emacs ./devel/try-emacs-mua -Q

(not immediately, but when trying to see search output...)

anyway, now I've checked:

$ less emacs-25.2/lisp/textmodes/enriched.el
$ less emacs-24.3/lisp/textmodes/enriched.el
$ less emacs-23.1/lisp/textmodes/enriched.el

and the implementation is same enough to know that this works
similarly on all of these emacs versions...

For 0.26 it is time to explicitly drop support for emacs 23
and deprecate emacs versions before 24.4...

 emacs/notmuch-show.el | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 993902770095..1514eca57f43 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -773,14 +773,12 @@ (defun notmuch-show-insert-part-text/calendar (msg part content-type nth depth b
 (defun notmuch-show-insert-part-text/x-vcalendar (msg part content-type nth depth button)
   (notmuch-show-insert-part-text/calendar msg part content-type nth depth button))
 
-;; https://bugs.gnu.org/28350
-(defun notmuch-show--enriched-decode-display-prop (start end &optional param)
-  (list start end))
-
 (defun notmuch-show-insert-part-text/enriched (msg part content-type nth depth button)
-  (advice-add 'enriched-decode-display-prop :override
-	      #'notmuch-show--enriched-decode-display-prop)
-  nil)
+  ;; https://bugs.gnu.org/28350
+  (require 'enriched)
+  (cl-letf (((symbol-function 'enriched-decode-display-prop)
+	     (lambda (start end &optional param) (list start end))))
+    (notmuch-show-insert-part-*/* msg part content-type nth depth button)))
 
 (defun notmuch-show-get-mime-type-of-application/octet-stream (part)
   ;; If we can deduce a MIME type from the filename of the attachment,
-- 
2.13.3



More information about the notmuch mailing list