emacs-diffs
[Top][All Lists]
Advanced

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

master ecbe801989 1/2: Add isearch-emoji-by-name


From: Juri Linkov
Subject: master ecbe801989 1/2: Add isearch-emoji-by-name
Date: Wed, 12 Jan 2022 12:50:39 -0500 (EST)

branch: master
commit ecbe80198951093edd98e5c2f41798ac7b0dc5ad
Author: Daniel Martín <mardani29@yahoo.es>
Commit: Juri Linkov <juri@linkov.net>

    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.
---
 doc/emacs/search.texi |  8 ++++++++
 etc/NEWS              |  7 +++++++
 lisp/isearch.el       | 21 +++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi
index c12992c239..e29c2c91af 100644
--- a/doc/emacs/search.texi
+++ b/doc/emacs/search.texi
@@ -443,6 +443,14 @@ a Unicode name or code-point in hex.  This adds the 
specified
 character into the search string, similar to the usual
 @code{insert-char} command (@pxref{Inserting Text}).
 
+@item
+@findex isearch-emoji-by-name
+@kindex C-x 8 e RET @r{(Incremental Search)}
+Type @kbd{C-x 8 e @key{RET}} (@code{isearch-emoji-by-name}), followed
+by the CLDR short name of an Emoji (for example, @samp{smiling face}
+or @samp{heart with arrow}).  This adds the specified Emoji into the
+search string.
+
 @item
 @kindex C-^ @r{(Incremental Search)}
 @findex isearch-toggle-input-method
diff --git a/etc/NEWS b/etc/NEWS
index 9ad8354d11..04b22dbd51 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -392,6 +392,13 @@ the *Completions* buffer.
 +++
 *** New user option 'char-fold-override' disables default character 
equivalences.
 
++++
+*** New command 'isearch-emoji-by-name'.
+It is bound to 'C-x 8 e RET' during an incremental search.  The
+command accepts the CLDR short name of an Emoji (for example, "smiling
+face" or "heart with arrow"), with minibuffer completion, and inserts
+the Emoji character into the search string.
+
 ** New minor mode 'glyphless-display-mode'.
 This allows an easy way to toggle seeing all glyphless characters in
 the current buffer.
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 7593a0ec98..5bb11aab83 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



reply via email to

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