[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: evaluating numbers
From: |
Robert Pluim |
Subject: |
Re: evaluating numbers |
Date: |
Fri, 15 Nov 2019 15:54:46 +0100 |
>>>>> On Thu, 14 Nov 2019 20:39:44 +0200, Eli Zaretskii <address@hidden> said:
Eli> The right way of doing this is "C-u C-x =". And if we think that this
Eli> shows way too much info, I'm OK with modifying "C-x =" to show the
Eli> character name as an optional feature. These are commands that were
Eli> specifically designed to describe text; doing that as part of integer
Eli> evaluation is too general for that.
I like my bikesheds painted in #ff7f00
(what-cursor-position could definitely benefit from some refactoring
of those format strings).
diff --git a/lisp/simple.el b/lisp/simple.el
index e3ac709408..a9d2a152dc 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1389,6 +1389,12 @@ 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
@@ -1404,6 +1410,9 @@ what-cursor-position
in *Help* buffer. See also the command `describe-char'."
(interactive "P")
(let* ((char (following-char))
+ (char-name-fmt (if what-cursor-show-names
+ (format ", ?\\N{%s}" (get-char-code-property 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 +1458,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 +1477,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)"
- char char char
+ (format "(%d, #o%o, #x%x%s, file %s)"
+ char char char char-name-fmt
(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)))
- Re: evaluating numbers, (continued)
- Re: evaluating numbers, Andreas Schwab, 2019/11/14
- Re: evaluating numbers, Eli Zaretskii, 2019/11/14
- Re: evaluating numbers, Paul Eggert, 2019/11/14
- Re: evaluating numbers, Eli Zaretskii, 2019/11/14
- Re: evaluating numbers, Eli Zaretskii, 2019/11/14
- Re: evaluating numbers, Štěpán Němec, 2019/11/15
- Re: evaluating numbers,
Robert Pluim <=
- Re: evaluating numbers, Eli Zaretskii, 2019/11/15
- Re: evaluating numbers, Eli Zaretskii, 2019/11/15
- Re: evaluating numbers, Robert Pluim, 2019/11/15
- Re: evaluating numbers, Robert Pluim, 2019/11/15
- Re: evaluating numbers, Lars Ingebrigtsen, 2019/11/15
- Re: evaluating numbers, Robert Pluim, 2019/11/15
- 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