From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jonas Bernoulli Newsgroups: gmane.emacs.bugs Subject: bug#60740: [PATCH 1/2] No longer use transient in isearch-emoji-by-name Date: Thu, 2 Feb 2023 00:09:17 +0100 Message-ID: <20230201230918.550-2-jonas@bernoul.li> References: <83leli3nly.fsf@gnu.org> <20230201230918.550-1-jonas@bernoul.li> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="460"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org To: 60740@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 02 00:10:18 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNMF8-000AZ3-Cl for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Feb 2023 00:10:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNMEw-0003b3-M5; Wed, 01 Feb 2023 18:10:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNMEt-0003a0-EC for bug-gnu-emacs@gnu.org; Wed, 01 Feb 2023 18:10:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNMEt-0007Hg-59 for bug-gnu-emacs@gnu.org; Wed, 01 Feb 2023 18:10:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pNMEs-0005qW-VQ for bug-gnu-emacs@gnu.org; Wed, 01 Feb 2023 18:10:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jonas Bernoulli Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 01 Feb 2023 23:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60740 X-GNU-PR-Package: emacs Original-Received: via spool by 60740-submit@debbugs.gnu.org id=B60740.167529297222401 (code B ref 60740); Wed, 01 Feb 2023 23:10:02 +0000 Original-Received: (at 60740) by debbugs.gnu.org; 1 Feb 2023 23:09:32 +0000 Original-Received: from localhost ([127.0.0.1]:60098 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNMEO-0005pF-BP for submit@debbugs.gnu.org; Wed, 01 Feb 2023 18:09:32 -0500 Original-Received: from mail.hostpark.net ([212.243.197.30]:37398) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNMEN-0005p7-0z for 60740@debbugs.gnu.org; Wed, 01 Feb 2023 18:09:31 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 6BF8C1625C; Thu, 2 Feb 2023 00:09:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bernoul.li; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=sel2011a; t=1675292970; bh=QtVCjcByFpXhbQZ +9Mj6XzyqhnSx86gU2h8+dPOOTf0=; b=zjQ4H5c1jp7ow6+tGC8XUjlt5UCDZ9g +JulYznepuVAtAlHAe1BjqmaAV+GppVjDuCSbDlwoNJmpzJ83k+B1plnRmGjN7t0 +QF+j98p/SteIdFATg65cG28JBRwbfVR7OM/q/G8EqF/crByTRJpC+jgPkhdXv7v a1rNDqaOUn08= X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Original-Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail1.hostpark.net [127.0.0.1]) (amavisd-new, port 10224) with ESMTP id Y3IQdFf8VXwC; Thu, 2 Feb 2023 00:09:30 +0100 (CET) Original-Received: from customer (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id 294EB16255; Thu, 2 Feb 2023 00:09:30 +0100 (CET) X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201230918.550-1-jonas@bernoul.li> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:254612 Archived-At: * 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'. --- lisp/international/emoji.el | 36 ++++++++++++++++++++---------------- lisp/isearch.el | 20 ++++++++------------ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lisp/international/emoji.el b/lisp/international/emoji.el index 2d17cf639b0..f75bd877991 100644 --- a/lisp/international/emoji.el +++ b/lisp/international/emoji.el @@ -245,6 +245,7 @@ emoji-list-help (error "Emoji name is unknown") (message "%s" name))))) +;;;###autoload (defun emoji--init (&optional force inhibit-adjust) (when (or (not emoji--labels) force) @@ -638,7 +639,7 @@ emoji--split-long-lists collect (cons (concat (string prefix) "-group") (seq-take bit 77)))))))) -(defun emoji--choose-emoji () +(defun emoji--read-emoji () ;; Use the list of names. (let* ((table (if (not emoji-alternate-names) @@ -678,21 +679,24 @@ emoji--choose-emoji (complete-with-action action table string pred))) nil t))) (when (cl-plusp (length name)) - (let* ((glyph (if emoji-alternate-names - (cadr (split-string name "\t")) - (gethash name emoji--all-bases))) - (derived (gethash glyph emoji--derived))) - (if (not derived) - ;; Simple glyph with no derivations. - (progn - (emoji--add-recent glyph) - (insert glyph)) - ;; Choose a derived version. - (let ((emoji--done-derived (make-hash-table :test #'equal))) - (setf (gethash glyph emoji--done-derived) t) - (funcall - (emoji--define-transient - (cons "Choose Emoji" (cons glyph derived)))))))))) + (let ((glyph (if emoji-alternate-names + (cadr (split-string name "\t")) + (gethash name emoji--all-bases)))) + (cons glyph (gethash glyph emoji--derived)))))) + +(defun emoji--choose-emoji () + (pcase-let ((`(,glyph ,derived)) (emoji--read-emoji)) + (if (not derived) + ;; Simple glyph with no derivations. + (progn + (emoji--add-recent glyph) + (insert glyph)) + ;; Choose a derived version. + (let ((emoji--done-derived (make-hash-table :test #'equal))) + (setf (gethash glyph emoji--done-derived) t) + (funcall + (emoji--define-transient + (cons "Choose Emoji" (cons glyph derived)))))))) (defvar-keymap emoji-zoom-map "+" #'emoji-zoom-increase diff --git a/lisp/isearch.el b/lisp/isearch.el index 22e27764127..bfa71756146 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -2774,25 +2774,21 @@ isearch-char-by-name (mapconcat 'isearch-text-char-description string "")))))))) -(defvar emoji--derived) (defun isearch-emoji-by-name (&optional count) "Read an Emoji name and add it to the search string COUNT times. COUNT (interactively, the prefix argument) defaults to 1. The command accepts Unicode names like \"smiling face\" or \"heart with arrow\", and completion is available." (interactive "p") + (emoji--init) (with-isearch-suspended - (let ((emoji (with-temp-buffer - ;; Derived emoji not supported yet (bug#60740). - ;; So first load `emoji--labels', then `emoji--init' - ;; will not fill `emoji--derived' that is set - ;; to an empty hash table below. - (ignore-errors (require 'emoji-labels)) - (let ((emoji--derived (make-hash-table :test #'equal))) - (emoji-search)) - (if (and (integerp count) (> count 1)) - (apply 'concat (make-list count (buffer-string))) - (buffer-string))))) + (pcase-let* ((`(,glyph . ,derived) (emoji--read-emoji)) + (emoji (if derived + (completing-read "Select derivation: " + (cons glyph derived) nil t) + glyph))) + (when (and (integerp count) (> count 1)) + (setq emoji (apply 'concat (make-list count emoji)))) (when emoji (setq isearch-new-string (concat isearch-string emoji) isearch-new-message (concat isearch-message -- 2.39.1