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

Tomi Ollila tomi.ollila at iki.fi
Sat Sep 16 02:18:27 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.
---

This is sent as RFC, as I did not (yet) have time to generate/find some
data to test it... anyway to me this looks good (on digital paper ;)

A couple of days ago I spent a little time to find how cl-flet & cl-letf
works -- cl-flet cannot be used as replacement for flet, since former
works in lexical scope... and accorging to this page

http://endlessparentheses.com/understanding-letf-and-how-it-replaces-flet.html

the (cl-letf (((symbol-function 'enriched-decode-display-prop) ...
should do the trick...

(ok, now I grepped notmuch code (again). It seens we're already using
letf & cl-letf and there is no reference to flet ;/ (I thought there were
when I grepped last time) -- well good learning experience...)

Tomi

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

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 99390277..9ebd50ed 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -773,14 +773,11 @@ (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
+  (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