Commit a27c8929 authored by Robert Pluim's avatar Robert Pluim

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.
parent b9e99ab5
......@@ -696,6 +696,15 @@ position as a percentage of the total. After @samp{column=} is the
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, as defined by the Unicode Character
Database, is shown as well. The part in parentheses would then 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
......
......@@ -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.
......
......@@ -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)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment