From: Jonas Bernoulli Date: Sun, 3 Sep 2023 15:50:16 +0000 (+0200) Subject: Make emoji commands compatible with repeat and repeat-complex-command X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=502e7c9a9b34c74b1b99f9e2f13a75f03dabba18;p=emacs.git Make emoji commands compatible with repeat and repeat-complex-command * lisp/international/emoji.el (emoji-search): Read user input inside 'interactive'. * (emoji-insert-glyph): Determine glyph inside 'interactive', using 'emoji--recent' when not invoked from one of its transient prefixes but using 'recent' or 'recent-complex-command'. --- diff --git a/lisp/international/emoji.el b/lisp/international/emoji.el index 856c405b545..bdc79dd200d 100644 --- a/lisp/international/emoji.el +++ b/lisp/international/emoji.el @@ -97,7 +97,7 @@ representing names. For instance: (multisession-value emoji--recent))) ;;;###autoload (autoload 'emoji-search "emoji" nil t) -(transient-define-prefix emoji-search () +(transient-define-prefix emoji-search (glyph derived) "Choose and insert an emoji glyph by typing its Unicode name. This command prompts for an emoji name, with completion, and inserts it. It recognizes the Unicode Standard names of emoji, @@ -106,15 +106,17 @@ and also consults the `emoji-alternate-names' alist." [:class transient-columns :setup-children emoji--setup-suffixes :description emoji--group-description] - (interactive "*") - (emoji--init) - (pcase-let ((`(,glyph . ,derived) (emoji--read-emoji))) - (if derived - (emoji--setup-prefix 'emoji-search "Choose Emoji" - (list glyph) - (cons glyph derived)) - (emoji--add-recent glyph) - (insert glyph)))) + (interactive + (progn (barf-if-buffer-read-only) + (emoji--init) + (let ((cons (emoji--read-emoji))) + (list (car cons) (cdr cons))))) + (if derived + (emoji--setup-prefix 'emoji-search "Choose Emoji" + (list glyph) + (cons glyph derived)) + (emoji--add-recent glyph) + (insert glyph))) (defclass emoji--narrow (transient-suffix) ((title :initarg :title) @@ -142,12 +144,15 @@ and also consults the `emoji-alternate-names' alist." (defun emoji--group-description () (car (oref transient--prefix scope))) -(transient-define-suffix emoji-insert-glyph () +(transient-define-suffix emoji-insert-glyph (glyph) "Insert the emoji you selected." - (interactive nil not-a-mode) - (let ((glyph (oref (transient-suffix-object) description))) - (emoji--add-recent glyph) - (insert glyph))) + (interactive + (list (if (string-prefix-p "emoji-" (symbol-name transient-current-prefix)) + (oref (transient-suffix-object) description) + (car (multisession-value emoji--recent)))) + not-a-mode) + (emoji--add-recent glyph) + (insert glyph)) ;;;###autoload (defun emoji-list ()