branch: elpa/popup commit e7420146a7bc6365e4a56af28508aa9687a9906e Merge: 866a091 416049d Author: Jen-Chieh Shen <jcs090...@gmail.com> Commit: GitHub <nore...@github.com>
Merge pull request #124 from auto-complete/dis Fix non displayable character --- popup.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/popup.el b/popup.el index ed7efac..4fee3ac 100644 --- a/popup.el +++ b/popup.el @@ -33,6 +33,7 @@ ;;; Code: (require 'cl-lib) +(require 'mule) (defconst popup-version "0.5.8") @@ -238,6 +239,19 @@ ITEM is not string." (if (stringp item) (get-text-property 0 property item))) +(defun popup-replace-displayable (str &optional rep) + "Replace non-displayable character from STR. + +Optional argument REP is the replacement string of non-displayable character." + (unless rep (setq rep "")) + (let ((result "")) + (mapcar (lambda (ch) + (setq result (concat result + (if (char-displayable-p ch) (string ch) + rep)))) + str) + result)) + (cl-defun popup-make-item (name &key value @@ -1057,6 +1071,8 @@ PROMPT is a prompt string when reading events during event loop." ;; TODO strip text (mainly face) properties (setq string (substring-no-properties string))) + (setq string (popup-replace-displayable string)) + (and (eq margin t) (setq margin 1)) (or margin-left (setq margin-left margin)) (or margin-right (setq margin-right margin))