branch: externals/marginalia commit 61674a8eec40e8a9f6c6b79c65f8dbf95bb8ea71 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Do not escape all multibyte characters (Fix #118, #141) --- marginalia.el | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/marginalia.el b/marginalia.el index e71ccc367f..e8af643abb 100644 --- a/marginalia.el +++ b/marginalia.el @@ -599,17 +599,22 @@ keybinding since CAND includes it." ((pred numberp) (propertize (number-to-string val) 'face 'marginalia-number)) (_ (let ((print-escape-newlines t) (print-escape-control-characters t) - (print-escape-multibyte t) + ;;(print-escape-multibyte t) (print-level 10) (print-length marginalia-field-width)) (propertize - (prin1-to-string - (if (stringp val) - ;; Get rid of string properties to save some of the precious space - (substring-no-properties - val 0 - (min (length val) marginalia-field-width)) - val)) + (replace-regexp-in-string + ;; `print-escape-control-characters' does not escape Unicode control characters. + "[\x0-\x1F\x7f-\x9f\x061c\x200e\x200f\x202a-\x202e\x2066-\x2069]" + (lambda (x) (format "\\x%x" (string-to-char x))) + (prin1-to-string + (if (stringp val) + ;; Get rid of string properties to save some of the precious space + (substring-no-properties + val 0 + (min (length val) marginalia-field-width)) + val)) + 'fixedcase 'literal) 'face (cond ((listp val) 'marginalia-list)