help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Find all the name and alias corresponding to a codepoint in Emacs.


From: Emanuel Berg
Subject: Re: Find all the name and alias corresponding to a codepoint in Emacs.
Date: Sat, 12 Mar 2022 05:00:45 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Hongyi Zhao wrote:

> Say, for back-tick or grave accent ( ` ) symbol, I want to
> let Emacs give me all of its name and alias, but the `M-x
> describe-char ` can only give the following information:
>
>   name: GRAVE ACCENT
>   old-name: SPACING GRAVE

I'd say use `backquote' in Lisp settings (indeed, even an
Elisp function) ... for everything else, use the (new) name.

> So, I want to know if it's possible to find all the name and
> alias corresponding to a codepoint in Emacs.

Uhm, what other aliases would that be? And if any, where are
they stored in Emacs?

BTW, check this out:

;; -*- 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 (old: %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 "%s (at point: %d)" msg-dc position) ))))))

;; (what-char)                  ; "space"
;; (what-char 754)              ; "right parenthesis (old: closing parenthesis)"
;; C-u 754 M-x what-char RET    ; same, but also killed
;; C-u M-x what-char RET* (C-y) ; asterisk is yanked
;; M-x what-char RET            ; line feed (lf) (at point: 1034)


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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]