unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Cc: emacs-devel@gnu.org
Subject: what-char
Date: Sat, 05 Feb 2022 09:13:39 +0100	[thread overview]
Message-ID: <871r0h91e4.fsf@zoho.eu> (raw)

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




             reply	other threads:[~2022-02-05  8:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-05  8:13 Emanuel Berg via Users list for the GNU Emacs text editor [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871r0h91e4.fsf@zoho.eu \
    --to=help-gnu-emacs@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=moasenwood@zoho.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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