diff options
| author | Lars Ingebrigtsen | 2021-10-29 22:58:21 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-10-29 22:58:21 +0200 |
| commit | 1da9d7402bed91e660a10e1fbadfe281c92d8905 (patch) | |
| tree | c6a99348d4bee8df4d66d8396cafe3223775274c | |
| parent | 932413913a4fc8489ce90a1ebf2ef2adbfa57f86 (diff) | |
| download | emacs-1da9d7402bed91e660a10e1fbadfe281c92d8905.tar.gz emacs-1da9d7402bed91e660a10e1fbadfe281c92d8905.zip | |
Make the adjustment more efficient
| -rw-r--r-- | lisp/play/emoji.el | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/lisp/play/emoji.el b/lisp/play/emoji.el index c0c3dcc53ec..a34bbac62b1 100644 --- a/lisp/play/emoji.el +++ b/lisp/play/emoji.el | |||
| @@ -249,20 +249,35 @@ character) under point is." | |||
| 249 | (setq emoji--all-bases (make-hash-table :test #'equal)) | 249 | (setq emoji--all-bases (make-hash-table :test #'equal)) |
| 250 | (emoji--adjust-displayable (cons "Emoji" emoji--labels)))) | 250 | (emoji--adjust-displayable (cons "Emoji" emoji--labels)))) |
| 251 | 251 | ||
| 252 | (defvar emoji--font nil) | ||
| 253 | |||
| 252 | (defun emoji--adjust-displayable (alist) | 254 | (defun emoji--adjust-displayable (alist) |
| 253 | "Remove glyphs we don't have fonts for." | 255 | "Remove glyphs we don't have fonts for." |
| 256 | (let ((emoji--font nil)) | ||
| 257 | (emoji--adjust-displayable-1 alist))) | ||
| 258 | |||
| 259 | (defun emoji--adjust-displayable-1 (alist) | ||
| 254 | (if (consp (caddr alist)) | 260 | (if (consp (caddr alist)) |
| 255 | (dolist (child (cdr alist)) | 261 | (dolist (child (cdr alist)) |
| 256 | (emoji--adjust-displayable child)) | 262 | (emoji--adjust-displayable-1 child)) |
| 257 | (setcdr alist (seq-filter | 263 | (while (cdr alist) |
| 258 | (lambda (glyph) | 264 | (let ((glyph (cadr alist))) |
| 259 | ;; Store all the emojis for later retrieval by | 265 | ;; Store all the emojis for later retrieval by |
| 260 | ;; the search feature. | 266 | ;; the search feature. |
| 261 | (when-let ((name (emoji--name glyph))) | 267 | (when-let ((name (emoji--name glyph))) |
| 262 | (setf (gethash (downcase name) emoji--all-bases) glyph)) | 268 | (setf (gethash (downcase name) emoji--all-bases) glyph)) |
| 263 | ;; Say whether we should include in graphical displays. | 269 | ;; Remove glyphs we don't have in graphical displays. |
| 264 | (not (symbolp (char-displayable-p (elt glyph 0))))) | 270 | (if (let ((char (elt glyph 0))) |
| 265 | (cdr alist))))) | 271 | (if emoji--font |
| 272 | (elt (wrap emoji--font 0 1 (vector char)) 0) | ||
| 273 | (when-let ((font (car (internal-char-font nil char)))) | ||
| 274 | (setq emoji--font font)))) | ||
| 275 | (setq alist (cdr alist)) | ||
| 276 | ;; Remove the element. | ||
| 277 | (setcdr alist (cddr alist))))))) | ||
| 278 | |||
| 279 | (defun wrap (a b c d) | ||
| 280 | (font-get-glyphs a b c d)) | ||
| 266 | 281 | ||
| 267 | (defun emoji--parse-emoji-test () | 282 | (defun emoji--parse-emoji-test () |
| 268 | (setq emoji--labels nil) | 283 | (setq emoji--labels nil) |