[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: evaluating numbers
From: |
Robert Pluim |
Subject: |
Re: evaluating numbers |
Date: |
Wed, 20 Nov 2019 14:00:16 +0100 |
>>>>> On Mon, 18 Nov 2019 19:05:37 +0200, Eli Zaretskii <address@hidden> said:
>> From: Robert Pluim <address@hidden>
>> Cc: address@hidden, address@hidden,
>> address@hidden, address@hidden, address@hidden
>> Date: Mon, 18 Nov 2019 17:54:18 +0100
>>
>> Char: i (105, #o151, #x69, (LATIN SMALL LETTER I)) point=55242 of 379127
(15%) column=43
>>
>> That seems ... suboptimal to me (at least, I donʼt like it).
Eli> Fine, then let's go with just the name.
Latest version attached, which produces output like so:
Char: i (105, #o151, #x69, LATIN SMALL LETTER I) point=1482 of 1715 (86%)
<860-1716> column=13
Iʼll push this weekend if everyone's ok with it.
Robert
>From 8f8a3888439d959cff60a0cdea2070b1d3ebc15d Mon Sep 17 00:00:00 2001
From: Robert Pluim <address@hidden>
Date: Tue, 19 Nov 2019 11:33:10 +0100
Subject: [PATCH] Have what-cursor-position optionally show character name
To: address@hidden
* lisp/simple.el (what-cursor-show-names): New defcustom, default nil.
(what-cursor-position): Show character names if what-cursor-show-names
is non-nil.
* doc/emacs/basic.texi (Position Info): Add what-cursor-show-names
description.
* etc/NEWS: Announce what-cursor-show-names.
---
doc/emacs/basic.texi | 10 ++++++++++
etc/NEWS | 5 +++++
lisp/simple.el | 31 ++++++++++++++++++++++---------
3 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/doc/emacs/basic.texi b/doc/emacs/basic.texi
index d0bd46c35f..79a546f9e7 100644
--- a/doc/emacs/basic.texi
+++ b/doc/emacs/basic.texi
@@ -696,6 +696,16 @@ Position Info
horizontal position of point, in columns counting from the left edge
of the window.
+@vindex what-cursor-show-names
+ If the user option @code{what-cursor-show-names} is non-@code{nil},
+the name of the character is shown as well, so the part in parentheses
+would become:
+
+@smallexample
+(99, #o143, #x63, LATIN SMALL LETTER C)
+@end smallexample
+
+
If the buffer has been narrowed, making some of the text at the
beginning and the end temporarily inaccessible, @kbd{C-x =} displays
additional text describing the currently accessible range. For
diff --git a/etc/NEWS b/etc/NEWS
index 4887b8e681..fdfe2d8692 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -231,6 +231,11 @@ To get the old, less-secure behavior, you can set the
*** When run by root, emacsclient no longer connects to non-root sockets.
(Instead you can use Tramp methods to run root commands in a non-root Emacs.)
++++
+** New user option 'what-cursor-show-names'.
+When non-nil, what-cursor-position will show the name of the character
+in addition to the decimal/hex/octal representation. Default nil.
+
+++
** New function 'network-lookup-address-info'.
This does IPv4 and/or IPv6 address lookups on hostnames.
diff --git a/lisp/simple.el b/lisp/simple.el
index c61ccd511c..a63f2552df 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1389,10 +1389,17 @@ line-number-at-pos
(forward-line 0)
(1+ (count-lines start (point)))))))
+(defcustom what-cursor-show-names nil
+ "Whether to show character names in `what-cursor-position'."
+ :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.
+Also describe the character after point, and give its character
+code in octal, decimal and hex, plus its name if
+`what-cursor-show-names' is non-nil.
For a non-ASCII multibyte character, also give its encoding in the
buffer's selected coding system if the coding system encodes the
@@ -1404,6 +1411,12 @@ what-cursor-position
in *Help* buffer. See also the command `describe-char'."
(interactive "P")
(let* ((char (following-char))
+ (char-name (and what-cursor-show-names
+ (or (get-char-code-property char 'name)
+ (get-char-code-property char 'old-name))))
+ (char-name-fmt (if char-name
+ (format ", %s" char-name)
+ ""))
(bidi-fixer
;; If the character is one of LRE, LRO, RLE, RLO, it will
;; start a directional embedding, which could completely
@@ -1449,7 +1462,7 @@ what-cursor-position
(setq coding (default-value 'buffer-file-coding-system)))
(if (eq (char-charset char) 'eight-bit)
(setq encoding-msg
- (format "(%d, #o%o, #x%x, raw-byte)" char char char))
+ (format "(%d, #o%o, #x%x%s, raw-byte)" char char char
char-name-fmt))
;; Check if the character is displayed with some `display'
;; text property. In that case, set under-display to the
;; buffer substring covered by that property.
@@ -1468,17 +1481,17 @@ what-cursor-position
(setq encoding-msg
(if display-prop
(if (not (stringp display-prop))
- (format "(%d, #o%o, #x%x, part of display \"%s\")"
- char char char under-display)
- (format "(%d, #o%o, #x%x, part of display \"%s\"->\"%s\")"
- char char char under-display display-prop))
+ (format "(%d, #o%o, #x%x%s, part of display \"%s\")"
+ char char char char-name-fmt under-display)
+ (format "(%d, #o%o, #x%x%s, part of display
\"%s\"->\"%s\")"
+ char char char char-name-fmt under-display
display-prop))
(if encoded
- (format "(%d, #o%o, #x%x, file %s)"
+ (format "(%d, #o%o, #x%x%s, file %s)"
char char char
(if (> (length encoded) 1)
"..."
(encoded-string-description encoded coding)))
- (format "(%d, #o%o, #x%x)" char char char)))))
+ (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)))
--
2.23.0
- Re: evaluating numbers, (continued)
- Re: evaluating numbers, Eli Zaretskii, 2019/11/15
- Re: evaluating numbers, Richard Stallman, 2019/11/16
- Re: evaluating numbers, Robert Pluim, 2019/11/17
- Re: evaluating numbers, Eli Zaretskii, 2019/11/18
- Re: evaluating numbers, Robert Pluim, 2019/11/18
- Re: evaluating numbers, Eli Zaretskii, 2019/11/18
- Re: evaluating numbers,
Robert Pluim <=
- Re: evaluating numbers, Eli Zaretskii, 2019/11/20
- Re: evaluating numbers, Robert Pluim, 2019/11/20
- Re: evaluating numbers, Eli Zaretskii, 2019/11/20
- Re: evaluating numbers, Richard Stallman, 2019/11/19
- Re: evaluating numbers, Robert Pluim, 2019/11/19
- Re: evaluating numbers, Robert Pluim, 2019/11/15
- Re: evaluating numbers, Eli Zaretskii, 2019/11/15
- Re: evaluating numbers, Robert Pluim, 2019/11/15
- Re: evaluating numbers, Eli Zaretskii, 2019/11/15
- Re: evaluating numbers, Juri Linkov, 2019/11/16