[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/emoji 8a1d48b 1/2: Rename the emoji description function and mak
From: |
Lars Ingebrigtsen |
Subject: |
scratch/emoji 8a1d48b 1/2: Rename the emoji description function and make it a command, too |
Date: |
Fri, 29 Oct 2021 07:53:18 -0400 (EDT) |
branch: scratch/emoji
commit 8a1d48b4e96d47cec4c2c6a7087a34e019d45927
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Rename the emoji description function and make it a command, too
---
lisp/descr-text.el | 2 +-
lisp/international/mule-cmds.el | 1 +
lisp/play/emoji.el | 29 ++++++++++++++++++++++++++---
3 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/lisp/descr-text.el b/lisp/descr-text.el
index f84a3dd..2a239f8 100644
--- a/lisp/descr-text.el
+++ b/lisp/descr-text.el
@@ -687,7 +687,7 @@ The character information includes:
,@(when-let ((composition-name
(and composition-string
(eq (aref char-script-table char) 'emoji)
- (emoji-composition-name composition-string))))
+ (emoji-describe composition-string))))
(list (list "composition name" composition-name)))
,@(let ((face
(if (not (or disp-vector composition))
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 59535e8..7142ac8 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -3263,6 +3263,7 @@ as names, not numbers."
"e" #'emoji-insert
"i" #'emoji-insert
"s" #'emoji-search
+ "d" #'emoji-describe
"r" #'emoji-recent
"l" #'emoji-list))
diff --git a/lisp/play/emoji.el b/lisp/play/emoji.el
index aa2930b..4e80c4e 100644
--- a/lisp/play/emoji.el
+++ b/lisp/play/emoji.el
@@ -111,11 +111,26 @@ when the command was issued."
(goto-char (point-min))))))
;;;###autoload
-(defun emoji-composition-name (glyph)
+(defun emoji-describe (glyph &optional interactive)
"Say what the name of the composed grapheme cluster GLYPH is.
-If it's not known, this function returns nil."
+If it's not known, this function returns nil.
+
+Interactively, it will message what the name of the emoji (or
+character) under point is."
+ (interactive (list (if (eobp)
+ (error "No glyph under point")
+ (let ((comp (find-composition (point) nil nil t)))
+ (if comp
+ (buffer-substring (car comp) (cadr comp))
+ (buffer-substring (point) (1+ (point))))))
+ t))
(require 'emoji-labels)
- (emoji--name glyph))
+ (if (not interactive)
+ (gethash glyph emoji--names)
+ (let ((name (emoji--name glyph)))
+ (if (not name)
+ (message "No known name for `%s'" glyph)
+ (message "The name of `%s' is \"%s\"" glyph name)))))
(defun emoji--list-generate (name alist)
(let ((width (/ (window-width) 5))
@@ -327,6 +342,14 @@ If it's not known, this function returns nil."
(unless file
(setq file (pop command-line-args-left)))
(emoji--init t t)
+ ;; Weed out the elements that are empty.
+ (let ((glyphs nil))
+ (maphash (lambda (k v)
+ (unless v
+ (push k glyphs)))
+ emoji--derived)
+ (dolist (glyph glyphs)
+ (remhash glyph emoji--derived)))
(with-temp-buffer
(insert ";; Generated file -- do not edit. -*- lexical-binding:t -*-
;; Copyright © 1991-2021 Unicode, Inc.