GNU bug report logs -
#46240
Sorting order of read-char-by-name
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Mon, 1 Feb 2021 17:25:02 UTC
Severity: normal
Tags: fixed, patch
Fixed in version 28.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Tags: patch
After typing e.g. 'C-x 8 RET GREEK TAB' completions are sorted in an
non-alphabetical order:
Ͳ GREEK CAPITAL LETTER ARCHAIC SAMPI
Β GREEK CAPITAL LETTER BETA
Χ GREEK CAPITAL LETTER CHI
Ϯ GREEK CAPITAL LETTER DEI
Δ GREEK CAPITAL LETTER DELTA
where the 22nd letter of the Greek alphabet CHI is between BETA and DELTA.
This is because currently completions are sorted by English names.
The following patch sorts them by their Unicode order that mostly follows
the alphabetical order, and at least makes more sense to be consistent
with Unicode tables where characters are grouped more logically.
Then the above example is sorted alphabetically:
Α GREEK CAPITAL LETTER ALPHA
Β GREEK CAPITAL LETTER BETA
Γ GREEK CAPITAL LETTER GAMMA
Δ GREEK CAPITAL LETTER DELTA
Ε GREEK CAPITAL LETTER EPSILON
More examples with better sorting is 'C-x 8 RET SUBSCRIPT TAB'
where instead of sorting by names of numbers:
₈ SUBSCRIPT DIGIT EIGHT
₅ SUBSCRIPT DIGIT FIVE
₄ SUBSCRIPT DIGIT FOUR
₉ SUBSCRIPT DIGIT NINE
₁ SUBSCRIPT DIGIT ONE
₇ SUBSCRIPT DIGIT SEVEN
₆ SUBSCRIPT DIGIT SIX
will be sorted by numerical order:
₀ SUBSCRIPT DIGIT ZERO
₁ SUBSCRIPT DIGIT ONE
₂ SUBSCRIPT DIGIT TWO
₃ SUBSCRIPT DIGIT THREE
₄ SUBSCRIPT DIGIT FOUR
₅ SUBSCRIPT DIGIT FIVE
etc.
[mule--ucs-names-sort-by-char.patch (text/x-diff, inline)]
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 5dc3de4422..0593d72279 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-char (names)
+ (let* ((chars-and-names
+ (mapcar (lambda (name) (cons (gethash name ucs-names) name)) names))
+ (sorted (sort chars-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.
@@ -3132,6 +3138,7 @@ read-char-by-name
(if (eq action 'metadata)
'(metadata
(affixation-function . mule--ucs-names-affixation)
+ (display-sort-function . mule--ucs-names-sort-by-char)
(category . unicode-name))
(complete-with-action action (ucs-names) string pred)))))
(char
This bug report was last modified 4 years and 104 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.