diff options
author | Daniel MartÃn <mardani29@yahoo.es> | 2022-01-12 19:43:15 +0200 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2022-01-12 19:49:50 +0200 |
commit | ecbe80198951093edd98e5c2f41798ac7b0dc5ad (patch) | |
tree | 4fe1c29b37c9b82c54f1f45d139758ab9b3f060e /lisp/isearch.el | |
parent | 0cbc41322ef626b28e9cd90be970b2f2f5e86cd7 (diff) | |
download | emacs-ecbe80198951093edd98e5c2f41798ac7b0dc5ad.tar.gz |
Add isearch-emoji-by-name
* lisp/isearch.el (isearch-emoji-by-name): Add a new command to insert
Emoji characters into incremental search strings. (Bug#52605)
(isearch-mode-map): Bind it to 'C-x 8 e RET'.
(isearch-menu-bar-map): Add it to the menu bar.
* doc/emacs/search.texi (Special Isearch): Update the documentation to
mention the new command.
* etc/NEWS: And advertise it.
Diffstat (limited to 'lisp/isearch.el')
-rw-r--r-- | lisp/isearch.el | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el index 7593a0ec980..5bb11aab839 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -668,6 +668,7 @@ This is like `describe-bindings', but displays only Isearch keys." ;; The key translations defined in the C-x 8 prefix should add ;; characters to the search string. See iso-transl.el. (define-key map "\C-x8\r" 'isearch-char-by-name) + (define-key map "\C-x8e\r" 'isearch-emoji-by-name) map) "Keymap for `isearch-mode'.") @@ -758,6 +759,8 @@ This is like `describe-bindings', but displays only Isearch keys." :help "Search for literal char"] ["Search for char by name" isearch-char-by-name :help "Search for character by name"] + ["Search for Emoji by name" isearch-emoji-by-name + :help "Search for Emoji by name"] "---" ["Toggle input method" isearch-toggle-input-method :help "Toggle input method for search"] @@ -2747,6 +2750,24 @@ With argument, add COUNT copies of the character." (mapconcat 'isearch-text-char-description string "")))))))) +(defun isearch-emoji-by-name (&optional count) + "Read an Emoji name and add it to the search string. +The command accepts CLDR short names like 'smiling face' or +'heart with arrow' and completion is available. With argument, +add COUNT copies of the Emoji." + (interactive "p") + (with-isearch-suspended + (let ((emoji (with-temp-buffer + (emoji-search) + (if (and (integerp count) (> count 1)) + (apply 'concat (make-list count (buffer-string))) + (buffer-string))))) + (when emoji + (setq isearch-new-string (concat isearch-string emoji) + isearch-new-message (concat isearch-message + (mapconcat 'isearch-text-char-description + emoji ""))))))) + (defun isearch-search-and-update () "Do the search and update the display." (when (or isearch-success |