unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* what-char
@ 2022-02-05  8:13 Emanuel Berg via Users list for the GNU Emacs text editor
  2022-02-05  8:37 ` what-char Emanuel Berg via Users list for the GNU Emacs text editor
  2022-02-05 17:24 ` [External] : what-char Drew Adams
  0 siblings, 2 replies; 4+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-02-05  8:13 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: emacs-devel

New interesting code from uXu!

Have the echo area display the name and old-name (if
available) of the char at point.

Watch out for the argument pos! From Lisp, it means
position. Interactively, it means don't just echo, also kill
the data. But even from Lisp it can be omitted, and point
is used ...

If used interactively, the point number is also echoed, but
not returned or killed.

Tricky? Have no fear - "I" is here.

;; -*- lexical-binding: t -*-
;;
;; this file:
;;   https://dataswamp.org/~incal/emacs-init/char.el

(defun what-char (&optional pos)
  (interactive "P")
  (let*((position (or (and (numberp pos) pos)
                      (point) ))
        (kill pos)
        (char (char-after position)) )
    (when char
      (let*((name     (get-char-code-property char 'name))
            (old-name (get-char-code-property char 'old-name))
            (msg (if (and name old-name)
                     (format "%s (%s)" name old-name)
                   (or name old-name) ))
            (msg-dc (when (stringp msg) (downcase msg))) )
        (when msg-dc
          (prog1 msg-dc
            (when kill (kill-new msg-dc))
            (message "%d: %s" position msg-dc) ))))))

;; (what-char)                     ; "space"
;; (what-char (point-min))         ; "semicolon"
;; (what-char 692)                 ; "left parenthesis (opening parenthesis)"
;; C-u M-x what-char RET* then C-y ; asterisk is inserted
;; M-x what-char RET               ; 1016: line feed (lf)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-06  4:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-05  8:13 what-char Emanuel Berg via Users list for the GNU Emacs text editor
2022-02-05  8:37 ` what-char Emanuel Berg via Users list for the GNU Emacs text editor
2022-02-05 17:24 ` [External] : what-char Drew Adams
2022-02-06  4:16   ` Richard Stallman

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).