summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorRobert Pluim <rpluim@gmail.com>2019-11-19 11:33:10 +0100
committerRobert Pluim <rpluim@gmail.com>2019-11-23 18:51:07 +0100
commita27c8929f2ab26dc0d27c8969857d3bc108747f5 (patch)
treebd1e136fd360482749b2f9e9c6a54d514f2a8ef5 /lisp
parentb9e99ab5ac49f8cb03fc1c27eb830a24e9bdf83c (diff)
downloademacs-a27c8929f2ab26dc0d27c8969857d3bc108747f5.tar.gz
Have what-cursor-position optionally show character name
* 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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/simple.el33
1 files changed, 23 insertions, 10 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index c61ccd511c5..2aac557154a 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1389,10 +1389,17 @@ absolute line number."
(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. 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
@@ -1404,6 +1411,12 @@ In addition, with prefix argument, show details about that character
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 @@ in *Help* buffer. See also the command `describe-char'."
(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 @@ in *Help* buffer. See also the command `describe-char'."
(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)))