From: Lars Ingebrigtsen Date: Tue, 2 Nov 2021 01:52:29 +0000 (+0100) Subject: Add a better test for emojis X-Git-Tag: emacs-29.0.90~3671^2~294 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ee3e4d0ca20ee75ba0f25ebc226a2959df66c7fb;p=emacs.git Add a better test for emojis * lisp/outline.el (outline--valid-char-p) (outline--valid-emoji-p): New predicates. (outline--make-button, outline-minor-mode-buttons): Use them. --- diff --git a/lisp/outline.el b/lisp/outline.el index 9058293e277..8dffca756fc 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -281,8 +281,8 @@ buttons should look." :version "29.1") (defcustom outline-minor-mode-buttons - '(("▶️". "🔽") - ("▶" . "▼")) + '(("▶️" "🔽" outline--valid-emoji-p) + ("▶" "▼" outline--valid-char-p)) "List of close/open pairs to use if using buttons." :type 'sexp :version "29.1") @@ -951,14 +951,20 @@ If non-nil, EVENT should be a mouse event." (outline-flag-subtree t)) (defun outline--make-button (type) - (cl-loop for (close . open) in outline-minor-mode-buttons - when (and (char-displayable-p (aref close 0)) - (char-displayable-p (aref open 0))) + (cl-loop for (close open test) in outline-minor-mode-buttons + when (and (funcall test close) (funcall test open)) return (concat (if (eq type 'close) close open) " " (buffer-substring (point) (1+ (point)))))) +(defun outline--valid-emoji-p (string) + (when-let ((font (car (internal-char-font nil ?😀)))) + (font-has-char-p font (aref string 0)))) + +(defun outline--valid-char-p (string) + (char-displayable-p (aref string 0))) + (defun outline--make-button-overlay (type) (let ((o (seq-find (lambda (o) (overlay-get o 'outline-button))