[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 1866e66 6/6: * lisp/international/mule-cmds.el: Use group-functio
From: |
Juri Linkov |
Subject: |
master 1866e66 6/6: * lisp/international/mule-cmds.el: Use group-function in read-char-by-name. |
Date: |
Thu, 20 May 2021 13:52:28 -0400 (EDT) |
branch: master
commit 1866e66a73083fa5466b040d2cc44ca73da891e9
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
* lisp/international/mule-cmds.el: Use group-function in read-char-by-name.
(mule--ucs-names-group): Simplify for using by group-function.
(read-char-by-name-group): Remove defcustom
obsoleted by completions-group.
(read-char-by-name): Mention completions-group and
completions-group-sort in docstring. Use group-function when
completions-group is non-nil.
https://lists.gnu.org/archive/html/emacs-devel/2021-05/msg00791.html
---
etc/NEWS | 15 ++++++-----
lisp/international/mule-cmds.el | 56 ++++++++++-------------------------------
2 files changed, 22 insertions(+), 49 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 32d7c4f..0bdb79e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1090,12 +1090,11 @@ so e.g. like 'C-x 8 [' inserts a left single quotation
mark,
'C-x \ [' does the same.
---
-*** New user options 'read-char-by-name-sort' and 'read-char-by-name-group'.
-'read-char-by-name-sort' defines the sorting order of characters for
-completion of 'C-x 8 RET TAB' and can be customized to sort them
-by codepoints instead of character names by default. The 't' value of
-'read-char-by-name-group' groups the characters for completion of
-'C-x 8 RET TAB' by Unicode blocks.
+*** New user option 'read-char-by-name-sort'.
+It defines the sorting order of characters for completion of 'C-x 8 RET TAB'
+and can be customized to sort them by codepoints instead of character names.
+Additionally, you can group characters by Unicode blocks after customizing
+'completions-group' and 'completions-group-sort'.
---
*** Improved language transliteration in Malayalam input methods.
@@ -2768,6 +2767,10 @@ each element is a list with three elements: a completion,
a prefix string, and a suffix string.
+++
+** New completion function 'group-function' for grouping candidates.
+It takes two arguments: a completion candidate and a 'transform' flag.
+
++++
** 'read-char-from-minibuffer' and 'y-or-n-p' support 'help-form'.
If you bind 'help-form' to a non-nil value while calling these functions,
then pressing 'C-h' ('help-char') causes the function to evaluate 'help-form'
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 7f8d98b..432ca29 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -3104,35 +3104,11 @@ on encoding."
(list name (concat (if char (list char) " ") "\t") "")))
names))
-(defun mule--ucs-names-group (names)
- (let* ((codes-and-names
- (mapcar (lambda (name) (cons (gethash name ucs-names) name)) names))
- (grouped
- (seq-group-by
- (lambda (code-name)
- (let ((script (aref char-script-table (car code-name))))
- (if script (symbol-name script) "ungrouped")))
- codes-and-names))
- names-with-header header)
- (dolist (group (sort grouped (lambda (a b) (string< (car a) (car b)))))
- (setq header t)
- (dolist (code-name (cdr group))
- (push (list
- (cdr code-name)
- (concat
- (if header
- (progn
- (setq header nil)
- (concat "\n" (propertize
- (format "* %s\n" (car group))
- 'face 'header-line)))
- "")
- ;; prefix
- (if (car code-name) (format "%c" (car code-name)) " ") "\t")
- ;; suffix
- "")
- names-with-header)))
- (nreverse names-with-header)))
+(defun mule--ucs-names-group (name transform)
+ (if transform
+ name
+ (let ((script (aref char-script-table (gethash name ucs-names))))
+ (if script (symbol-name script) "ungrouped"))))
(defun char-from-name (string &optional ignore-case)
"Return a character as a number from its Unicode name STRING.
@@ -3164,14 +3140,6 @@ Defines the sorting order either by character names or
their codepoints."
:group 'mule
:version "28.1")
-(defcustom read-char-by-name-group nil
- "How to group characters for `read-char-by-name' completion.
-When t, split characters to sections of Unicode blocks
-sorted alphabetically."
- :type 'boolean
- :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
@@ -3185,8 +3153,9 @@ preceded by an asterisk `*' and use completion, it will
show all
the characters whose names include that substring, not necessarily
at the beginning of the name.
-The options `read-char-by-name-sort' and `read-char-by-name-group'
-define the sorting order of completion characters and how to group them.
+The options `read-char-by-name-sort', `completions-group', and
+`completions-group-sort' define the sorting order of completion characters,
+whether to group them, and how to sort groups.
Accept a name like \"CIRCULATION FUNCTION\", a hexadecimal
number like \"2A10\", or a number in hash notation (e.g.,
@@ -3204,11 +3173,12 @@ as names, not numbers."
`(metadata
(display-sort-function
. ,(when (eq read-char-by-name-sort 'code)
- #'mule--ucs-names-sort-by-code))
+ #'mule--ucs-names-sort-by-code))
(affixation-function
- . ,(if read-char-by-name-group
- #'mule--ucs-names-group
- #'mule--ucs-names-affixation))
+ . ,#'mule--ucs-names-affixation)
+ (group-function
+ . ,(when completions-group
+ #'mule--ucs-names-group))
(category . unicode-name))
(complete-with-action action (ucs-names) string pred)))))
(char
- master updated (72ec24d -> 1866e66), Juri Linkov, 2021/05/20
- master 443d9ef 1/6: (completing-read): Add `group-function` to the completion metadata, Juri Linkov, 2021/05/20
- master de168b7 2/6: (completion--insert-strings): Split function; Full group title support, Juri Linkov, 2021/05/20
- master cacfd03 3/6: (minibuffer-completion-help): Do not check `completions-group` centrally, Juri Linkov, 2021/05/20
- master 836d69b 4/6: (completion--insert-vertical): Separate groups completely, Juri Linkov, 2021/05/20
- master cb8b994 5/6: (minibuffer-completion-help): Add group sorting, Juri Linkov, 2021/05/20
- master 1866e66 6/6: * lisp/international/mule-cmds.el: Use group-function in read-char-by-name.,
Juri Linkov <=