From: "Mattias Engdegård" <mattiase@acm.org>
To: Robert Pluim <rpluim@gmail.com>
Cc: Lars Ingebrigtsen <larsi@gnus.org>,
Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>,
24902@debbugs.gnu.org
Subject: bug#24902: 25.1; C-x = for Unicode
Date: Wed, 26 Jan 2022 18:02:46 +0100 [thread overview]
Message-ID: <537072BC-F9DF-4B7B-BA88-02320A731013@acm.org> (raw)
In-Reply-To: <87a6fihaku.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 388 bytes --]
26 jan. 2022 kl. 14.48 skrev Robert Pluim <rpluim@gmail.com>:
> U+006F 'LATIN SMALL LETTER O' point=2938 of 2942 col=52
The single quotes are mostly noise; a comma after the name seems to work just as well and is less intrusive (and shorter). The syntax "U+1234 NAME IN CAPS" is Unicode standard and the user is likely to have encountered it before.
Here is an updated patch.
[-- Attachment #2: 0001-Cleaner-what-cursor-position-format.patch --]
[-- Type: application/octet-stream, Size: 6220 bytes --]
From a4d4eaf9fcb83b98277959083028aa2a20489a1c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Mon, 24 Jan 2022 16:49:08 +0100
Subject: [PATCH] Cleaner `what-cursor-position` format
Add a new `C-x =` output format, under the control of the new
`what-cursor-format` user option, that uses more modern formatting
and omits noise syntax and rarely used information. It always
includes the character name.
* lisp/simple.el (what-cursor-format): New.
(what-cursor-show-names): Explain relation to `what-cursor-format`.
(what-cursor-position--default,
what-cursor-position--traditional): New functions.
(what-cursor-position): Reduce to calling the right back-end function.
* etc/NEWS: Announce.
---
etc/NEWS | 6 ++++
lisp/simple.el | 78 ++++++++++++++++++++++++++++++++++++++------------
2 files changed, 65 insertions(+), 19 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index abef1019ac..68fb9110f1 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -183,6 +183,12 @@ wheel reports. Unlike 'pixel-scroll-mode', this mode scrolls the
display pixel-by-pixel, as opposed to only animating line-by-line
scrolls.
+** New user option 'what-cursor-format'
+It governs the output format of 'what-cursor-position', normally
+bound to 'C-x ='. When 'traditional', the output is identical
+to that of Emacs 28; when 'default', a simpler, briefer format
+that always includes the character name is used.
+
** Terminal Emacs
---
diff --git a/lisp/simple.el b/lisp/simple.el
index 801a3c992c..2cc90426e2 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1564,27 +1564,57 @@ count-lines
(1- (line-number-at-pos))
(line-number-at-pos)))))))
+(defcustom what-cursor-format 'default
+ "What to show in the echo area in `what-cursor-position'.
+The `default' format gives the hex code and name of the character
+after point, the cursor position, buffer size, and column number.
+
+The `traditional' format also displays the code in decimal and octal,
+and only includes the name if `what-cursor-show-name' is non-nil.
+For a non-ASCII multibyte character, it also gives the encoding in the
+buffer's selected coding system if the coding system encodes the
+character safely. If the character is encoded into one byte, that
+code is shown in hex. If the character is encoded into more than one
+byte, just \"...\" is shown."
+ :type '(choice (const :tag "Default" default)
+ (const :tag "Traditional" traditional))
+ :version "29.1"
+ :group 'editing-basics)
+
(defcustom what-cursor-show-names nil
- "Whether to show character names in `what-cursor-position'."
+ "Whether to show character names in `what-cursor-position'.
+It only applies when `what-cursor-format' is `traditional'."
:type 'boolean
:version "27.1"
:group 'editing-basics)
-(defun what-cursor-position (&optional detail)
- "Print info on cursor position (on screen and within buffer).
-Also describe the character after point, and give its character
-code in octal, decimal and hex. If `what-cursor-show-names' is
-non-nil, additionally show the name of the character.
-
-For a non-ASCII multibyte character, also give its encoding in the
-buffer's selected coding system if the coding system encodes the
-character safely. If the character is encoded into one byte, that
-code is shown in hex. If the character is encoded into more than one
-byte, just \"...\" is shown.
-
-In addition, with prefix argument, show details about that character
-in *Help* buffer. See also the command `describe-char'."
- (interactive "P")
+(defun what-cursor-position--default ()
+ "Default echo area output of `what-cursor-position'."
+ (let* ((char (char-after))
+ (char-info
+ (cond
+ ((null char) "")
+ ((<= #x3fff80 char #x3fffff)
+ (format "#x%02X (raw byte) " (logand char #xff)))
+ (t
+ (format "U+%04X %s, "
+ char
+ (or (get-char-code-property char 'name)
+ (get-char-code-property char 'old-name)
+ "(undefined)")))))
+ (beg (point-min))
+ (end (point-max))
+ (narrow (if (and (= beg 1) (= (1- end) (buffer-size)))
+ ""
+ (format " (narrowed to %d-%d)" beg end))))
+ (message "%spoint=%d/%d%s col=%d"
+ char-info
+ (point) (buffer-size)
+ narrow
+ (current-column))))
+
+(defun what-cursor-position--traditional ()
+ "Traditional echo area output of `what-cursor-position'."
(let* ((char (following-char))
(char-name (and what-cursor-show-names
(or (get-char-code-property char 'name)
@@ -1671,9 +1701,6 @@ what-cursor-position
"..."
(encoded-string-description encoded coding)))
(format "(%d, #o%o, #x%x%s)" char char char char-name-fmt)))))
- (if detail
- ;; We show the detailed information about CHAR.
- (describe-char (point)))
(if (or (/= beg 1) (/= end (1+ total)))
(message "Char: %s%s %s point=%d of %d (%d%%) <%d-%d> column=%d%s"
(if (< char 256)
@@ -1688,6 +1715,19 @@ what-cursor-position
(buffer-substring-no-properties (point) (1+ (point))))
(single-key-description char))
bidi-fixer encoding-msg pos total percent col hscroll))))))
+
+(defun what-cursor-position (&optional detail)
+ "Print info on cursor position (on screen and within buffer).
+Also describe the character after point according to `what-cursor-format'.
+
+In addition, with prefix argument, show details about that character
+in *Help* buffer. See also the command `describe-char'."
+ (interactive "P")
+ (when detail
+ (describe-char (point)))
+ (cond
+ ((eq what-cursor-format 'default) (what-cursor-position--default))
+ ((eq what-cursor-format 'traditional) (what-cursor-position--traditional))))
\f
;; Initialize read-expression-map. It is defined at C level.
(defvar read-expression-map
--
2.32.0 (Apple Git-132)
next prev parent reply other threads:[~2022-01-26 17:02 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-08 12:02 bug#24902: 25.1; C-x = for Unicode Ulrich Windl
2016-11-08 12:23 ` Andreas Schwab
2016-11-08 13:49 ` bug#24902: Antw: " Ulrich Windl
2016-11-08 19:53 ` Phil Sainty
2016-11-10 4:56 ` Marcin Borkowski
2016-11-10 7:23 ` Mark Oteiza
2016-11-08 12:25 ` Phil Sainty
2022-01-23 16:20 ` Lars Ingebrigtsen
2022-01-23 16:56 ` Kévin Le Gouguec
2022-01-23 18:44 ` Mattias Engdegård
2022-01-24 9:21 ` Lars Ingebrigtsen
2022-01-24 10:40 ` Mattias Engdegård
2022-01-24 11:00 ` Lars Ingebrigtsen
2022-01-24 11:27 ` Robert Pluim
2022-01-24 14:09 ` Mattias Engdegård
2022-01-24 16:06 ` Mattias Engdegård
2022-01-24 16:28 ` bug#24902: [External] : " Drew Adams
2022-01-24 16:35 ` Lars Ingebrigtsen
2022-01-24 17:29 ` Mattias Engdegård
2022-01-24 17:39 ` Lars Ingebrigtsen
2022-01-25 15:38 ` Mattias Engdegård
2022-01-25 16:41 ` Robert Pluim
2022-01-25 17:15 ` Eli Zaretskii
2022-01-25 18:00 ` Mattias Engdegård
2022-01-25 18:11 ` Eli Zaretskii
[not found] ` <C2E2A281020000A84D5C4BFC@gwsmtp.uni-regensburg.de>
[not found] ` <469D64F5020000015C413831@gwsmtp.uni-regensburg.de>
[not found] ` <D3C7A175020000FA5C413831@gwsmtp.uni-regensburg.de>
[not found] ` <A9CE96C702000053824A10E1@gwsmtp.uni-regensburg.de>
[not found] ` <A7201B24020000235C413831@gwsmtp.uni-regensburg.de>
2022-01-26 7:09 ` bug#24902: Antw: [EXT] " Ulrich Windl
[not found] ` <DD8FDCE7020000A54D5C4BFC@gwsmtp.uni-regensburg.de>
[not found] ` <0106AEA10200006A824A10E1@gwsmtp.uni-regensburg.de>
2022-01-26 14:09 ` Ulrich Windl
2022-01-26 16:53 ` Mattias Engdegård
2022-01-26 17:25 ` Eli Zaretskii
2022-01-27 15:39 ` Lars Ingebrigtsen
2022-01-27 17:11 ` Juri Linkov
2022-01-28 13:09 ` Richard Stallman
2022-01-28 14:37 ` Eli Zaretskii
2022-01-28 17:05 ` bug#24902: [External] : " Drew Adams
2022-01-29 14:34 ` Lars Ingebrigtsen
2022-01-29 14:57 ` Eli Zaretskii
2022-01-30 15:47 ` Lars Ingebrigtsen
2022-01-30 16:46 ` Eli Zaretskii
2022-01-31 9:59 ` Robert Pluim
2022-01-31 15:27 ` Lars Ingebrigtsen
2022-01-31 16:46 ` Eli Zaretskii
2022-01-31 17:00 ` Lars Ingebrigtsen
2022-01-31 18:00 ` Eli Zaretskii
2022-02-01 5:06 ` Richard Stallman
2022-01-31 17:40 ` Mattias Engdegård
2022-01-31 17:45 ` Lars Ingebrigtsen
2022-01-31 18:15 ` Mattias Engdegård
2022-01-31 18:30 ` Lars Ingebrigtsen
2022-01-28 13:45 ` Lars Ingebrigtsen
2022-01-28 14:16 ` Mattias Engdegård
2022-01-28 17:05 ` bug#24902: [External] : " Drew Adams
2022-01-29 14:32 ` Lars Ingebrigtsen
2022-01-29 16:47 ` Mattias Engdegård
2022-01-30 15:50 ` Lars Ingebrigtsen
[not found] ` <13FDBD490200009C5C413831@gwsmtp.uni-regensburg.de>
[not found] ` <6?= =?UTF-8?Q?1F261F5020?= =?UTF-8?Q?000A100047?= =?UTF-8?Q?30B@gwsmtp?= =?UTF-8?Q?.uni-regen?= =?UTF-8?Q?sburg.de>
2022-01-27 9:12 ` bug#24902: Antw: [EXT] Re: bug#24902: 25.1; C‑x " Ulrich Windl
2022-01-27 9:43 ` Robert Pluim
2022-01-27 10:11 ` bug#24902: Antw: [EXT] Re: bug#24902: 25.1; C‑x= " Ulrich Windl
2022-01-27 10:20 ` Robert Pluim
2022-01-27 12:38 ` bug#24902: Antw: [EXT] Re: bug#24902: 25.1; C‑x = " Mattias Engdegård
2022-01-27 13:24 ` Ulrich Windl
2022-01-27 9:59 ` Eli Zaretskii
2022-01-26 13:10 ` bug#24902: 25.1; C-x " Lars Ingebrigtsen
2022-01-26 13:35 ` Eli Zaretskii
2022-01-26 13:46 ` Mattias Engdegård
2022-01-26 14:07 ` Lars Ingebrigtsen
2022-01-26 13:48 ` Robert Pluim
2022-01-26 17:02 ` Mattias Engdegård [this message]
2022-01-24 11:16 ` Robert Pluim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=537072BC-F9DF-4B7B-BA88-02320A731013@acm.org \
--to=mattiase@acm.org \
--cc=24902@debbugs.gnu.org \
--cc=Ulrich.Windl@rz.uni-regensburg.de \
--cc=larsi@gnus.org \
--cc=rpluim@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).