emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/emoji d2377c7: Parse the non-zwj er alternates


From: Lars Ingebrigtsen
Subject: scratch/emoji d2377c7: Parse the non-zwj er alternates
Date: Tue, 26 Oct 2021 14:40:31 -0400 (EDT)

branch: scratch/emoji
commit d2377c708d600bebc278f62d2e3faa14bb720e3e
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Parse the non-zwj er alternates
---
 lisp/play/emoji.el | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/lisp/play/emoji.el b/lisp/play/emoji.el
index afd1733..dc384cf 100644
--- a/lisp/play/emoji.el
+++ b/lisp/play/emoji.el
@@ -38,7 +38,9 @@
   ;; Remove debugging.
   (unless (and nil emoji--labels)
     (emoji--parse-labels)
-    (emoji--parse-variants)
+    (setq emoji--variants (make-hash-table :test #'equal))
+    (emoji--parse-normal-variants)
+    (emoji--parse-zwj-variants)
     (emoji--define-transient))
   (funcall (intern "emoji-command-Emoji")))
 
@@ -79,7 +81,7 @@
     ;; Finally split up the too-long lists.
     (emoji--split-long-lists emoji--labels)))
 
-(defun emoji--parse-variants ()
+(defun emoji--parse-zwj-variants ()
   (with-temp-buffer
     (let ((table (make-hash-table :test #'equal)))
       (insert-file-contents (expand-file-name
@@ -103,12 +105,28 @@
             (setf (gethash base table)
                   (nconc (gethash base table) (list glyph))))))
       ;; Finally create the mapping from the base glyphs to derived ones.
-      (setq emoji--variants (make-hash-table :test #'equal))
       (maphash (lambda (_k v)
                  (setf (gethash (car v) emoji--variants)
                        (cdr v)))
                table))))
 
+(defun emoji--parse-normal-variants ()
+  (with-temp-buffer
+    (let ((case-fold-search t))
+      (insert-file-contents (expand-file-name
+                             "../admin/unidata/emoji-sequences.txt"
+                             data-directory))
+      (unless (re-search-forward "^# RGI_Emoji_Modifier_Sequence" nil t)
+        (error "Can't find RGI_Emoji_Modifier_Sequence"))
+      (forward-line 2)
+      (while (looking-at "\\([[:xdigit:]]+\\) +\\([[:xdigit:]]+\\)")
+        (let ((parent (string (string-to-number (match-string 1) 16)))
+              (modifier (string (string-to-number (match-string 2) 16))))
+          (setf (gethash parent emoji--variants)
+                (append (gethash parent emoji--variants)
+                        (list (concat parent modifier)))))
+        (forward-line 1)))))
+
 (defun emoji--add-characters (chars main sub)
   (let ((subs (if (member sub '( "cat-face" "monkey-face" "skin-tone"
                                  "country-flag" "subdivision-flag"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]