emacs-diffs
[Top][All Lists]
Advanced

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

scratch/sqlite db53f01 2/2: Use emoji--recent as the first usage of stic


From: Lars Ingebrigtsen
Subject: scratch/sqlite db53f01 2/2: Use emoji--recent as the first usage of sticky.el
Date: Tue, 7 Dec 2021 01:51:40 -0500 (EST)

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

    Use emoji--recent as the first usage of sticky.el
---
 lisp/international/emoji.el | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/lisp/international/emoji.el b/lisp/international/emoji.el
index 5f8c358..eead00f 100644
--- a/lisp/international/emoji.el
+++ b/lisp/international/emoji.el
@@ -30,6 +30,7 @@
 (require 'cl-lib)
 (require 'cl-extra)
 (require 'transient)
+(require 'sticky)
 
 (defgroup emoji nil
   "Inserting Emojis."
@@ -59,7 +60,7 @@
 (defvar emoji--derived nil)
 (defvar emoji--names (make-hash-table :test #'equal))
 (defvar emoji--done-derived nil)
-(defvar emoji--recent (list "😀" "😖"))
+(define-sticky-variable emoji--recent (list "😀" "😖"))
 (defvar emoji--insert-buffer)
 
 ;;;###autoload
@@ -83,7 +84,7 @@ of a visual interface."
   (unless (fboundp 'emoji--command-Emoji)
     (emoji--define-transient))
   (funcall (emoji--define-transient
-            (cons "Recent" emoji--recent) t)))
+            (cons "Recent" (sticky-value emoji--recent)) t)))
 
 ;;;###autoload
 (defun emoji-search ()
@@ -529,15 +530,17 @@ character) under point is."
   (lambda ()
     (interactive)
     (funcall (emoji--define-transient
-              (cons "Recent" emoji--recent) t end-function))))
+              (cons "Recent" (sticky-value emoji--recent)) t end-function))))
 
 (defun emoji--add-recent (glyph)
   "Add GLYPH to the set of recently used emojis."
-  (setq emoji--recent (delete glyph emoji--recent))
-  (push glyph emoji--recent)
-  ;; Shorten the list.
-  (when-let ((tail (nthcdr 30 emoji--recent)))
-    (setcdr tail nil)))
+  (let ((recent (sticky-value emoji--recent)))
+    (setq recent (delete glyph recent))
+    (push glyph recent)
+    ;; Shorten the list.
+    (when-let ((tail (nthcdr 30 recent)))
+      (setcdr tail nil))
+    (setf (sticky-value emoji--recent) recent)))
 
 (defun emoji--columnize (list columns)
   "Split LIST into COLUMN columns."



reply via email to

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