emacs-diffs
[Top][All Lists]
Advanced

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

scratch/emoji 66f4d26 2/2: Don't recurse on the first derived char


From: Lars Ingebrigtsen
Subject: scratch/emoji 66f4d26 2/2: Don't recurse on the first derived char
Date: Tue, 26 Oct 2021 19:13:06 -0400 (EDT)

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

    Don't recurse on the first derived char
---
 lisp/play/emoji.el | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/lisp/play/emoji.el b/lisp/play/emoji.el
index 766a086..c559755 100644
--- a/lisp/play/emoji.el
+++ b/lisp/play/emoji.el
@@ -127,9 +127,11 @@ when the command was issued."
           (progn
             (funcall end-func)
             (insert glyph))
-        (funcall
-         (emoji--define-transient (cons "Choose Emoji" (cons glyph derived))
-                                  nil end-func))))))
+        (let ((emoji--done-derived (make-hash-table :test #'equal)))
+          (setf (gethash glyph emoji--done-derived) t)
+          (funcall
+           (emoji--define-transient (cons "Choose Emoji" (cons glyph derived))
+                                    nil end-func)))))))
 
 (defun emoji--init ()
   ;; Remove debugging.
@@ -290,12 +292,16 @@ when the command was issued."
                                   (concat char (string #xfe0f))
                                 char))))))
 
+(defvar emoji--done-derived nil)
+
 (defun emoji--define-transient (&optional alist inhibit-derived
                                           end-function)
   (unless alist
     (setq alist (cons "Emoji" emoji--labels)))
   (let* ((mname (pop alist))
          (name (intern (format "emoji--command-%s" mname)))
+         (emoji--done-derived (or emoji--done-derived
+                                  (make-hash-table :test #'equal)))
          (has-subs (consp (cadr alist)))
          (layout
           (if has-subs
@@ -319,14 +325,20 @@ when the command was issued."
                                 char
                                 (let ((derived
                                        (and (not inhibit-derived)
+                                            (not (gethash char
+                                                          emoji--done-derived))
                                             (gethash char emoji--derived))))
                                   (if derived
                                       ;; We have a derived glyph, so add
                                       ;; another level.
-                                      (emoji--define-transient
-                                       (cons (concat mname " " char)
-                                             (cons char derived))
-                                       t end-function)
+                                      (progn
+                                        (setf (gethash char
+                                                       emoji--done-derived)
+                                              t)
+                                        (emoji--define-transient
+                                         (cons (concat mname " " char)
+                                               (cons char derived))
+                                         t end-function))
                                     ;; Insert the emoji.
                                     (lambda ()
                                       (interactive)
@@ -423,9 +435,11 @@ We prefer the earliest unique letter."
            (derived (gethash glyph emoji--derived)))
       (if (not derived)
           (insert glyph)
-        (funcall
-         (emoji--define-transient
-          (cons "Choose Emoji" (cons glyph derived))))))))
+        (let ((emoji--done-derived (make-hash-table :test #'equal)))
+          (setf (gethash glyph emoji--done-derived) t)
+          (funcall
+           (emoji--define-transient
+            (cons "Choose Emoji" (cons glyph derived)))))))))
 
 (provide 'emoji)
 



reply via email to

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