diff options
| author | Lars Ingebrigtsen | 2021-11-02 02:52:29 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-11-02 02:52:29 +0100 |
| commit | ee3e4d0ca20ee75ba0f25ebc226a2959df66c7fb (patch) | |
| tree | e2483575787bed6a8e377d055882f0e753430a06 | |
| parent | d530f3f9fff5ab928211b40e420faac3f5324566 (diff) | |
| download | emacs-ee3e4d0ca20ee75ba0f25ebc226a2959df66c7fb.tar.gz emacs-ee3e4d0ca20ee75ba0f25ebc226a2959df66c7fb.zip | |
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.
| -rw-r--r-- | lisp/outline.el | 16 |
1 files changed, 11 insertions, 5 deletions
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." | |||
| 281 | :version "29.1") | 281 | :version "29.1") |
| 282 | 282 | ||
| 283 | (defcustom outline-minor-mode-buttons | 283 | (defcustom outline-minor-mode-buttons |
| 284 | '(("▶️". "🔽") | 284 | '(("▶️" "🔽" outline--valid-emoji-p) |
| 285 | ("▶" . "▼")) | 285 | ("▶" "▼" outline--valid-char-p)) |
| 286 | "List of close/open pairs to use if using buttons." | 286 | "List of close/open pairs to use if using buttons." |
| 287 | :type 'sexp | 287 | :type 'sexp |
| 288 | :version "29.1") | 288 | :version "29.1") |
| @@ -951,14 +951,20 @@ If non-nil, EVENT should be a mouse event." | |||
| 951 | (outline-flag-subtree t)) | 951 | (outline-flag-subtree t)) |
| 952 | 952 | ||
| 953 | (defun outline--make-button (type) | 953 | (defun outline--make-button (type) |
| 954 | (cl-loop for (close . open) in outline-minor-mode-buttons | 954 | (cl-loop for (close open test) in outline-minor-mode-buttons |
| 955 | when (and (char-displayable-p (aref close 0)) | 955 | when (and (funcall test close) (funcall test open)) |
| 956 | (char-displayable-p (aref open 0))) | ||
| 957 | return (concat (if (eq type 'close) | 956 | return (concat (if (eq type 'close) |
| 958 | close | 957 | close |
| 959 | open) | 958 | open) |
| 960 | " " (buffer-substring (point) (1+ (point)))))) | 959 | " " (buffer-substring (point) (1+ (point)))))) |
| 961 | 960 | ||
| 961 | (defun outline--valid-emoji-p (string) | ||
| 962 | (when-let ((font (car (internal-char-font nil ?😀)))) | ||
| 963 | (font-has-char-p font (aref string 0)))) | ||
| 964 | |||
| 965 | (defun outline--valid-char-p (string) | ||
| 966 | (char-displayable-p (aref string 0))) | ||
| 967 | |||
| 962 | (defun outline--make-button-overlay (type) | 968 | (defun outline--make-button-overlay (type) |
| 963 | (let ((o (seq-find (lambda (o) | 969 | (let ((o (seq-find (lambda (o) |
| 964 | (overlay-get o 'outline-button)) | 970 | (overlay-get o 'outline-button)) |