No longer use transient in isearch-emoji-by-name
* lisp/isearch.el (isearch-emoji-by-name): Use 'emoji--read-emoji' and if that returns derivations, 'completing-read' to select one of them. This fixes bug#60740. * lisp/international/emoji.el (emoji--init): Autoload. (emoji--read-emoji): New function, which doesn't use transient and returns a list of the glyph and all derivations, if any. (emoji--choose-emoji): Use 'emoji--read-emoji'.
This commit is contained in:
parent
0c125fcc67
commit
58dc03ba7e
2 changed files with 28 additions and 28 deletions
|
@ -245,6 +245,7 @@ the name is not known."
|
||||||
(error "Emoji name is unknown")
|
(error "Emoji name is unknown")
|
||||||
(message "%s" name)))))
|
(message "%s" name)))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
(defun emoji--init (&optional force inhibit-adjust)
|
(defun emoji--init (&optional force inhibit-adjust)
|
||||||
(when (or (not emoji--labels)
|
(when (or (not emoji--labels)
|
||||||
force)
|
force)
|
||||||
|
@ -638,7 +639,7 @@ We prefer the earliest unique letter."
|
||||||
collect (cons (concat (string prefix) "-group")
|
collect (cons (concat (string prefix) "-group")
|
||||||
(seq-take bit 77))))))))
|
(seq-take bit 77))))))))
|
||||||
|
|
||||||
(defun emoji--choose-emoji ()
|
(defun emoji--read-emoji ()
|
||||||
;; Use the list of names.
|
;; Use the list of names.
|
||||||
(let* ((table
|
(let* ((table
|
||||||
(if (not emoji-alternate-names)
|
(if (not emoji-alternate-names)
|
||||||
|
@ -678,21 +679,24 @@ We prefer the earliest unique letter."
|
||||||
(complete-with-action action table string pred)))
|
(complete-with-action action table string pred)))
|
||||||
nil t)))
|
nil t)))
|
||||||
(when (cl-plusp (length name))
|
(when (cl-plusp (length name))
|
||||||
(let* ((glyph (if emoji-alternate-names
|
(let ((glyph (if emoji-alternate-names
|
||||||
(cadr (split-string name "\t"))
|
(cadr (split-string name "\t"))
|
||||||
(gethash name emoji--all-bases)))
|
(gethash name emoji--all-bases))))
|
||||||
(derived (gethash glyph emoji--derived)))
|
(cons glyph (gethash glyph emoji--derived))))))
|
||||||
(if (not derived)
|
|
||||||
;; Simple glyph with no derivations.
|
(defun emoji--choose-emoji ()
|
||||||
(progn
|
(pcase-let ((`(,glyph ,derived)) (emoji--read-emoji))
|
||||||
(emoji--add-recent glyph)
|
(if (not derived)
|
||||||
(insert glyph))
|
;; Simple glyph with no derivations.
|
||||||
;; Choose a derived version.
|
(progn
|
||||||
(let ((emoji--done-derived (make-hash-table :test #'equal)))
|
(emoji--add-recent glyph)
|
||||||
(setf (gethash glyph emoji--done-derived) t)
|
(insert glyph))
|
||||||
(funcall
|
;; Choose a derived version.
|
||||||
(emoji--define-transient
|
(let ((emoji--done-derived (make-hash-table :test #'equal)))
|
||||||
(cons "Choose Emoji" (cons glyph derived))))))))))
|
(setf (gethash glyph emoji--done-derived) t)
|
||||||
|
(funcall
|
||||||
|
(emoji--define-transient
|
||||||
|
(cons "Choose Emoji" (cons glyph derived))))))))
|
||||||
|
|
||||||
(defvar-keymap emoji-zoom-map
|
(defvar-keymap emoji-zoom-map
|
||||||
"+" #'emoji-zoom-increase
|
"+" #'emoji-zoom-increase
|
||||||
|
|
|
@ -2774,25 +2774,21 @@ With argument, add COUNT copies of the character."
|
||||||
(mapconcat 'isearch-text-char-description
|
(mapconcat 'isearch-text-char-description
|
||||||
string ""))))))))
|
string ""))))))))
|
||||||
|
|
||||||
(defvar emoji--derived)
|
|
||||||
(defun isearch-emoji-by-name (&optional count)
|
(defun isearch-emoji-by-name (&optional count)
|
||||||
"Read an Emoji name and add it to the search string COUNT times.
|
"Read an Emoji name and add it to the search string COUNT times.
|
||||||
COUNT (interactively, the prefix argument) defaults to 1.
|
COUNT (interactively, the prefix argument) defaults to 1.
|
||||||
The command accepts Unicode names like \"smiling face\" or
|
The command accepts Unicode names like \"smiling face\" or
|
||||||
\"heart with arrow\", and completion is available."
|
\"heart with arrow\", and completion is available."
|
||||||
(interactive "p")
|
(interactive "p")
|
||||||
|
(emoji--init)
|
||||||
(with-isearch-suspended
|
(with-isearch-suspended
|
||||||
(let ((emoji (with-temp-buffer
|
(pcase-let* ((`(,glyph . ,derived) (emoji--read-emoji))
|
||||||
;; Derived emoji not supported yet (bug#60740).
|
(emoji (if derived
|
||||||
;; So first load `emoji--labels', then `emoji--init'
|
(completing-read "Select derivation: "
|
||||||
;; will not fill `emoji--derived' that is set
|
(cons glyph derived) nil t)
|
||||||
;; to an empty hash table below.
|
glyph)))
|
||||||
(ignore-errors (require 'emoji-labels))
|
(when (and (integerp count) (> count 1))
|
||||||
(let ((emoji--derived (make-hash-table :test #'equal)))
|
(setq emoji (apply 'concat (make-list count emoji))))
|
||||||
(emoji-search))
|
|
||||||
(if (and (integerp count) (> count 1))
|
|
||||||
(apply 'concat (make-list count (buffer-string)))
|
|
||||||
(buffer-string)))))
|
|
||||||
(when emoji
|
(when emoji
|
||||||
(setq isearch-new-string (concat isearch-string emoji)
|
(setq isearch-new-string (concat isearch-string emoji)
|
||||||
isearch-new-message (concat isearch-message
|
isearch-new-message (concat isearch-message
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue