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: Stefan Kangas
Subject: bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?
Date: Sat, 18 Feb 2023 01:00:38 -0800

Eli Zaretskii <eliz@gnu.org> writes:

> That's for GUI displays only.  And it's for strings, not characters.
> To test a single character, you don't need a separate function, IMO,
> you just need to use the test that is the core of that code.
[...]
> If you need to care for TTY frames, that problem has no known solution
> that works for all terminal emulators.  So using fancy characters in
> general-purpose Emacs features is a problem that cannot be solved
> programmatically, or at least we don't currently know how to do that.

Thanks, those are useful clarifications.  But could we not just fall
back to the replacement on TTY frames instead?  Something like:

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





reply via email to

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