emacs-diffs
[Top][All Lists]
Advanced

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

scratch/emoji 306e084: Generate a emoji labels file


From: Lars Ingebrigtsen
Subject: scratch/emoji 306e084: Generate a emoji labels file
Date: Thu, 28 Oct 2021 06:26:51 -0400 (EDT)

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

    Generate a emoji labels file
---
 .gitignore                |  1 +
 admin/unidata/Makefile.in |  7 +++++--
 lisp/play/emoji.el        | 37 +++++++++++++++++++++++++++++++++++--
 3 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index c7a6ec5..ea1662c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -215,6 +215,7 @@ lisp/international/charprop.el
 lisp/international/charscript.el
 lisp/international/cp51932.el
 lisp/international/emoji-zwj.el
+lisp/international/emoji-labels.el
 lisp/international/eucjp-ms.el
 lisp/international/uni-*.el
 lisp/language/pinyin.el
diff --git a/admin/unidata/Makefile.in b/admin/unidata/Makefile.in
index a953044..c8cf022 100644
--- a/admin/unidata/Makefile.in
+++ b/admin/unidata/Makefile.in
@@ -41,7 +41,7 @@ unifiles = $(addprefix ${unidir}/,$(sort $(shell sed -n 's/^[ 
\t][ \t]*${lparen}
 .PHONY: all
 
 all: ${top_srcdir}/src/macuvs.h ${unifiles} ${unidir}/charscript.el \
-  ${unidir}/charprop.el ${unidir}/emoji-zwj.el
+  ${unidir}/charprop.el ${unidir}/emoji-zwj.el ${unidir}/emoji-labels.el
 
 ## Specify .elc as an order-only prereq so as to not needlessly rebuild
 ## target just because the .elc is missing.
@@ -72,9 +72,11 @@ ${unifiles}: ${srcdir}/unidata-gen.el \
   ${srcdir}/BidiBrackets.txt | \
   ${srcdir}/unidata-gen.elc unidata.txt
        $(AM_V_at)[ ! -f $@ ] || chmod +w $@
-       $(AM_V_GEN)${emacs} -L ${srcdir} -l unidata-gen \
+       ${emacs} -L ${srcdir} -l unidata-gen \
          -f unidata-gen-file $@ ${srcdir}
 
+${unidir}/emoji-labels.el: ${unidir}/../play/emoji.el ${srcdir}/emoji-test.txt
+       ${emacs} -l emoji -f emoji--generate-file $@
 
 .PHONY: charscript.el
 charscript.el: ${unidir}/charscript.el
@@ -113,6 +115,7 @@ gen-clean:
        rm -f ${unidir}/charscript.el*
        rm -f ${unidir}/emoji-zwj.el*
        rm -f ${unifiles} ${unidir}/charprop.el
+       rm -f ${unidir}/emoji-labels.el*
 ## ref: https://lists.gnu.org/r/emacs-devel/2013-11/msg01029.html
 
 maintainer-clean: gen-clean distclean
diff --git a/lisp/play/emoji.el b/lisp/play/emoji.el
index 7ff4173..5799d04 100644
--- a/lisp/play/emoji.el
+++ b/lisp/play/emoji.el
@@ -184,8 +184,11 @@ when the command was issued."
   ;; Remove debugging.
   (when (or (not emoji--labels)
             force)
-    (setq emoji--derived (make-hash-table :test #'equal))
-    (emoji--parse-emoji-test)
+    (unless force
+      (ignore-errors (require 'emoji-labels)))
+    (unless emoji--labels
+      (setq emoji--derived (make-hash-table :test #'equal))
+      (emoji--parse-emoji-test))
     (emoji--define-transient)))
 
 (defun emoji--parse-emoji-test ()
@@ -250,6 +253,36 @@ when the command was issued."
                        (cdr v)))
                derivations))))
 
+(defun emoji--generate-file (&optional file)
+  "Generate an .el file with emoji mapping data and write it to FILE."
+  ;; Running from Makefile.
+  (unless file
+    (setq file (pop command-line-args-left)))
+  (emoji--init t)
+  (with-temp-buffer
+    (insert ";; Generated file -- do not edit.   -*- lexical-binding:t -*-
+;; Copyright © 1991-2021 Unicode, Inc.
+;; Generated from Unicode data files by unidata-gen.el.
+;; The sources for this file are found in the admin/unidata/ directory in
+;; the Emacs sources.  The Unicode data files are used under the
+;; Unicode Terms of Use, as contained in the file copyright.html in that
+;; same directory.\n\n")
+    (dolist (var '(emoji--labels emoji--derived emoji--names))
+      (insert (format "(defconst %s '" var))
+      (pp (symbol-value var) (current-buffer))
+      (insert (format "\n) ;; End %s\n\n" var)))
+    (insert ";; Local Variables:
+;; coding: utf-8
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; End:
+
+(provide 'emoji-labels)
+
+;;; uni-comment.el ends here\n")
+    (write-region (point-min) (point-max) file)))
+
 (defun emoji--base-name (name derivations)
   (let* ((base (replace-regexp-in-string ":.*" "" name))
          (non-binary (replace-regexp-in-string "\\`\\(man\\|woman\\) " ""



reply via email to

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