[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: |
Sun, 11 Sep 2022 13:07:13 +0300 |
> Cc: 57693@debbugs.gnu.org
> Date: Sun, 11 Sep 2022 12:43:52 +0300
> From: Eli Zaretskii <eliz@gnu.org>
>
> > From: Ihor Radchenko <yantar92@gmail.com>
> > Cc: 57693@debbugs.gnu.org
> > Date: Sun, 11 Sep 2022 17:31:06 +0800
> >
> > > insert the character
> > > call the new magic
> > > if the new magic says NO-CAN-DO
> > > replace the character with something else
> > >
> > > If the above is acceptable, I think it can be done, although it would
> > > not be very useful in other situations. But if you want to know the
> > > answer before you insert the character, I don't think we know how to
> > > satisfy your requirements with 100% accuracy. At least I cannot see
> > > how it could be done; maybe someone else will.
> >
> > The described approach should be acceptable.
> > What I have in mind is a function like
> >
> > (insert-displayable '("fancy version" "backup"))
> >
> > The function will try to insert "fancy version" first; check if all the
> > characters are displayable, and replace the inserted text with "backup"
> > if not.
>
> OK, I will see what I can do.
Here's what I suggest for GUI frames:
(defun insert-char-safely (ch repl)
"Insert character CH, if it can be displayed; otherwise insert REPL."
(insert ch)
(unless (font-at (1- (point)))
(delete-char -1)
(insert repl)))
Do you need this to work for TTY frames as well? If so, it could be a
problem, since most terminal emulators don't provide a way of
inquiring whether a certain character can be displayed.
char-displayable-p currently just checks on most terminals that the
terminal-coding-system can _encode_ the character, which isn't enough
if the terminal encoding is UTF-8.
- bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, (continued)
bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Ihor Radchenko, 2022/09/10
- bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Eli Zaretskii, 2022/09/10
- bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Ihor Radchenko, 2022/09/10
- bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Eli Zaretskii, 2022/09/10
- bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Ihor Radchenko, 2022/09/10
- bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Eli Zaretskii, 2022/09/10
- bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Ihor Radchenko, 2022/09/11
- bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Eli Zaretskii, 2022/09/11
- bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?,
Eli Zaretskii <=
- bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Ihor Radchenko, 2022/09/12
- bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Eli Zaretskii, 2022/09/12
- bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Ihor Radchenko, 2022/09/12
- bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Eli Zaretskii, 2022/09/13
- bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Ihor Radchenko, 2022/09/13
- bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Eli Zaretskii, 2022/09/13
bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Ihor Radchenko, 2022/09/12
bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?, Robert Pluim, 2022/09/09