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

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

bug#57693: 29.0.50; Is there a more reliable version of `char-displayabl


From: Eli Zaretskii
Subject: bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?
Date: Sat, 18 Feb 2023 13:56:24 +0200

> From: Ihor Radchenko <yantar92@posteo.net>
> Cc: Stefan Kangas <stefankangas@gmail.com>, yantar92@gmail.com,
>  57693@debbugs.gnu.org
> Date: Sat, 18 Feb 2023 11:32:56 +0000
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >>     (defun insert-char-safely (ch repl)
> >>       "Insert character CH, if it can be displayed; otherwise insert REPL.
> >>     On TTY frames, always insert REPL."
> >>       (if (not (display-graphic-p))
> >>           (insert repl)
> >>         (insert ch)
> >>         (unless (font-at (1- (point)))
> >>           (delete-char -1)
> >>           (insert repl))))
> >
> > We could, but IME typical uses of fancy characters do not insert them
> > into a buffer, but use them in header-line, overlay strings, and
> > suchlikes.
> 
> `font-at' accepts optional third argument STRING.
> For example, (font-at 0 nil "🧠a")

My comment was because Stefan suggested a function that inserts a
character into a buffer, not because font-at by default reports about
a character at point.

> As an alternative thought, may Emacs display engine accept a text
> property like 'display-alternative to display some fallback
> character/string if some parts of the displayed text cannot be
> displayed?

We already have something like that: see glyphless-char-display and
glyphless-char-display-mode.  The problem is that (a) on GUI displays
the replacement will be displayed in a box; (b) the replacement must
be an ASCII character; and (c) the char-table we use for that is
global, i.e. it affects the entire session.  But if someone wants a
more flexible feature which lifts some of those restrictions, that's
the place to start nonetheless.





reply via email to

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