[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tip/offtopic] A function to describe the characters of a word at po
From: |
Juan Manuel Macías |
Subject: |
Re: [tip/offtopic] A function to describe the characters of a word at point |
Date: |
Fri, 15 Jul 2022 00:56:41 +0000 |
Hi, Marcin and Samuel, thanks for your comments,
Marcin Borkowski writes:
> You might want to extend it and create a minor mode which would display
> data about the current character in the echo area, Eldoc-style, or in
> a tooltip when you hover the mouse pointer over a character. Depending
> on what exactly you need, these ideas might be more or less useful, of
> course.
I also have written a smaller function to display a quick information of
a single character at point, something much simpler and not as verbose
as describe-char. But it had never occurred to me to do something
eldoc-like with it. In my case, although for those contexts I prefer
quick information (describe-char also has its relaxing moment), I don't
feel such an urgency :-).
In any case, something quick and dirty, just as a proof of concept,
could be this:
(define-minor-mode char-info-at-point-mode
"TODO"
:init-value nil
:lighter ("chinfo")
(if char-info-at-point-mode
(add-hook 'post-command-hook #'char-name-at-point nil t)
(remove-hook 'post-command-hook #'char-name-at-point 'local)))
(defun char-name-at-point ()
(interactive)
(let* ((char-name (get-char-code-property (char-after (point)) 'name))
(code (format "#%x" (char-after (point))))
(dec (get-char-code-property (char-after (point)) 'decomposition))
(info (concat
char-name
" / "
code
" / descomp: "
dec
"\s"
(mapconcat (lambda (cod)
(format "#%x" cod))
dec "\s+\s"))))
(message info)))
Best regards,
Juan Manuel