From bfb2dd0e9d95882fe4907ff5f2ab3c857b415368 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 2 Sep 2021 13:43:00 +0300 Subject: [PATCH] Improve a recent change in 'mule-cmds.el' * lisp/international/mule-cmds.el (select-safe-coding-system--format-list): Display codepoints in hex and as characters. Display the ellipsis in a better place. Enlarge the limit to 5 codepoints, as the display is now easier to grasp. (select-safe-coding-system-interactively): Don't use 'select-safe-coding-system--format-list' for "rejected" coding-systems, as those don't come with characters and positions. --- lisp/international/mule-cmds.el | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index a883c231cbd..abccc4f72c0 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -663,19 +663,23 @@ overrides that argument.") codings)) (defun select-safe-coding-system--format-list (list) - (let ((spec " %-20s %6s %10s %s\n")) - (insert (format spec "Coding System" "Pos" "Code Point" "")) + (let ((spec1 " %-20s %6s %-10s %s\n") + (spec2 " %-20s %6s #x%-8X %c\n") + (nmax 5)) + (insert (format spec1 "Coding System" "Pos" "Codepoint" "Char")) (cl-loop for (coding . pairs) in list do (cl-loop for pair in pairs - ;; If there's a lot, only do the first three. - for i from 1 upto 3 + ;; If there's a lot, only do the first five. + for i from 1 upto nmax do (insert - (format spec + (format spec2 (if (= i 1) coding "") - (car pair) (cdr pair) - (if (and (= i 3) (> (length pairs) 3)) - "..." - "")))))) + (car pair) + (cdr pair) + (cdr pair)))) + (if (> (length pairs) nmax) + (insert (format spec1 "" "..." "" ""))))) + (insert "\n")) (defun select-safe-coding-system-interactively (from to codings unsafe @@ -736,14 +740,18 @@ DEFAULT is the coding system to use by default in the query." (concat " \"" (if (> (length from) 10) (concat (substring from 0 10) "...\"") (concat from "\""))) - (format-message " text\nin the buffer `%s'" bufname)) + (format-message + " the following\nproblematic characters in the buffer `%s'" + bufname)) ":\n") (select-safe-coding-system--format-list unsafe) (when rejected (insert "These safely encode the text in the buffer, but are not recommended for encoding text in this context, e.g., for sending an email message.\n ") - (select-safe-coding-system--format-list rejected)) + (dolist (x rejected) + (princ " ") (princ x)) + (insert "\n")) (when unsafe (insert (if rejected "The other coding systems" "However, each of them") -- 2.39.2