mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-09 05:01:02 -08:00
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.
This commit is contained in:
parent
d530f3f9ff
commit
ee3e4d0ca2
1 changed files with 11 additions and 5 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue