From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#46240: Sorting order of read-char-by-name Date: Wed, 03 Feb 2021 19:27:54 +0200 Organization: LINKOV.NET Message-ID: <87bld1t6z9.fsf@mail.linkov.net> References: <87v9bb4tm2.fsf@mail.linkov.net> <83wnvr65zg.fsf@gnu.org> <87o8h266x2.fsf@mail.linkov.net> <838s865mxs.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7712"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 46240@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 03 19:01:09 2021 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 1l7MSj-0001uB-AE for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Feb 2021 19:01:09 +0100 Original-Received: from localhost ([::1]:46652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7MSi-0004wD-BE for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Feb 2021 13:01:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7MF4-0005iN-IJ for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 12:47:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55460) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7MF4-0007w3-Bm for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 12:47:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l7MF4-00083u-AW for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2021 12:47:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 03 Feb 2021 17:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46240 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 46240-submit@debbugs.gnu.org id=B46240.161237437830885 (code B ref 46240); Wed, 03 Feb 2021 17:47:02 +0000 Original-Received: (at 46240) by debbugs.gnu.org; 3 Feb 2021 17:46:18 +0000 Original-Received: from localhost ([127.0.0.1]:38763 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7MEM-000824-7w for submit@debbugs.gnu.org; Wed, 03 Feb 2021 12:46:18 -0500 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:50117) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7MEL-00081b-0p for 46240@debbugs.gnu.org; Wed, 03 Feb 2021 12:46:17 -0500 X-Originating-IP: 91.129.108.204 Original-Received: from mail.gandi.net (m91-129-108-204.cust.tele2.ee [91.129.108.204]) (Authenticated sender: juri@linkov.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id EFFACC0004; Wed, 3 Feb 2021 17:46:09 +0000 (UTC) In-Reply-To: <838s865mxs.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 02 Feb 2021 20:44:47 +0200") 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" Xref: news.gmane.io gmane.emacs.bugs:199219 Archived-At: --=-=-= Content-Type: text/plain > So maybe we need this to be an opt-in behavior. Here is an option for this: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=read-char-by-name-sort-function.patch diff --git a/etc/NEWS b/etc/NEWS index 7cdb9d9430..0ff78e58e1 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -850,6 +850,11 @@ iso-transl RET', it supports the same key sequences as 'C-x 8', so e.g. like 'C-x 8 [' inserts a left single quotation mark, 'C-x \ [' does the same. +--- +*** New user option 'read-char-by-name-sort-function'. +It can enable sorting the characters of completion from +'C-x 8 RET TAB' by codepoints instead of character names. + --- *** Improved language transliteration in Malayalam input methods. Added a new Mozhi scheme. The inapplicable ITRANS scheme is now diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 5dc3de4422..6e1e045a4a 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -3083,6 +3083,12 @@ mule--ucs-names-affixation (list name (concat (if char (format "%c" char) " ") "\t") ""))) names)) +(defun mule--ucs-names-sort-by-code (names) + (let* ((codes-and-names + (mapcar (lambda (name) (cons (gethash name ucs-names) name)) names)) + (sorted (sort codes-and-names (lambda (a b) (< (car a) (car b)))))) + (mapcar #'cdr sorted))) + (defun char-from-name (string &optional ignore-case) "Return a character as a number from its Unicode name STRING. If optional IGNORE-CASE is non-nil, ignore case in STRING. @@ -3104,6 +3110,16 @@ char-from-name ignore-case)) code))))))) +(defcustom read-char-by-name-sort-function nil + "Function to sort characters displayed by `read-char-by-name' completion." + :type '(choice + (const :tag "Sort by character names" nil) + (const :tag "Sort by character codepoints" + mule--ucs-names-sort-by-code) + (function :tag "Custom function")) + :group 'mule + :version "28.1") + (defun read-char-by-name (prompt) "Read a character by its Unicode name or hex number string. Display PROMPT and read a string that represents a character by its @@ -3130,8 +3146,9 @@ read-char-by-name prompt (lambda (string pred action) (if (eq action 'metadata) - '(metadata + `(metadata (affixation-function . mule--ucs-names-affixation) + (display-sort-function . ,read-char-by-name-sort-function) (category . unicode-name)) (complete-with-action action (ucs-names) string pred))))) (char --=-=-=--