[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/emoji cdd0c0e: Add a new emoji-list command to see the name
From: |
Lars Ingebrigtsen |
Subject: |
scratch/emoji cdd0c0e: Add a new emoji-list command to see the name |
Date: |
Tue, 26 Oct 2021 20:10:38 -0400 (EDT) |
branch: scratch/emoji
commit cdd0c0eaf4d4524b861559b60abf12f92320439c
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Add a new emoji-list command to see the name
---
lisp/play/emoji.el | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/lisp/play/emoji.el b/lisp/play/emoji.el
index 1246ba2..8d73c6e 100644
--- a/lisp/play/emoji.el
+++ b/lisp/play/emoji.el
@@ -64,6 +64,8 @@ when the command was issued."
(let ((buf (current-buffer)))
(emoji--init)
(switch-to-buffer (get-buffer-create "*Emoji*"))
+ ;; Don't regenerate the buffer if it already exists -- this will
+ ;; leave point where it was the last time it was used.
(when (zerop (buffer-size))
(let ((inhibit-read-only t))
(emoji-list-mode)
@@ -92,16 +94,19 @@ when the command was issued."
(propertize
char
'emoji-glyph char
- 'help-echo
- (or (gethash char emoji--names)
- (get-char-code-property (aref char 0) 'name))))
+ 'help-echo (emoji--name char)))
(when (zerop (mod i width))
(insert "\n")))
(insert "\n\n"))))
+(defun emoji--name (char)
+ (or (gethash char emoji--names)
+ (get-char-code-property (aref char 0) 'name)))
+
(defvar-keymap emoji-list-mode-map
["RET"] #'emoji-list-select
["<mouse-2>"] #'emoji-list-select
+ "h" #'emoji-list-help
[follow-link] 'mouse-face)
(define-derived-mode emoji-list-mode special-mode "Emoji"
@@ -134,6 +139,17 @@ when the command was issued."
(emoji--define-transient (cons "Choose Emoji" (cons glyph derived))
nil end-func)))))))
+(defun emoji-list-help ()
+ "Say what the emoji under point is."
+ (interactive nil emoji-list-mode)
+ (let ((glyph (get-text-property (point) 'emoji-glyph)))
+ (unless glyph
+ (error "No emoji under point"))
+ (let ((name (emoji--name glyph)))
+ (if (not name)
+ (error "Unknown name")
+ (message "%s" name)))))
+
(defun emoji--init ()
;; Remove debugging.
(setq transient-use-variable-pitch t)
@@ -423,17 +439,20 @@ We prefer the earliest unique letter."
(seq-take bit 77))))))))
(defun emoji--choose-emoji ()
+ ;; Find all names.
(let ((names (make-hash-table :test #'equal)))
(dolist (section (emoji--flatten (cons "Emoji" emoji--labels)))
(dolist (char section)
- (when-let ((name (or (gethash char emoji--names)
- (get-char-code-property (aref char 0) 'name))))
+ (when-let ((name (emoji--name char)))
(setf (gethash (downcase name) names) char))))
+ ;; Use the list of names.
(let* ((name (completing-read "Emoji: " names nil t))
(glyph (gethash name names))
(derived (gethash glyph emoji--derived)))
(if (not derived)
+ ;; Simple glyph with no derivations.
(insert glyph)
+ ;; Choose a derived version.
(let ((emoji--done-derived (make-hash-table :test #'equal)))
(setf (gethash glyph emoji--done-derived) t)
(funcall
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- scratch/emoji cdd0c0e: Add a new emoji-list command to see the name,
Lars Ingebrigtsen <=