unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: yantar92@gmail.com
Cc: 57693@debbugs.gnu.org
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	[thread overview]
Message-ID: <837d2a9qcu.fsf@gnu.org> (raw)
In-Reply-To: <838rmq9rfr.fsf@gnu.org> (message from Eli Zaretskii on Sun, 11 Sep 2022 12:43:52 +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.





  reply	other threads:[~2022-09-11 10:07 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-09 13:25 bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'? Ihor Radchenko
2022-09-09 13:38 ` Eli Zaretskii
2022-09-09 22:25   ` Stefan Kangas
2022-09-10  6:01     ` Eli Zaretskii
2022-09-10  6:06       ` Ihor Radchenko
2022-09-10  6:35         ` Eli Zaretskii
2022-09-10  6:44           ` Ihor Radchenko
2022-09-10  4:48   ` Ihor Radchenko
2022-09-10  6:24     ` Eli Zaretskii
2022-09-10  6:37       ` Ihor Radchenko
2022-09-10  7:56         ` Eli Zaretskii
2022-09-10  8:17           ` Ihor Radchenko
2022-09-10  8:42             ` Eli Zaretskii
2022-09-11  9:31               ` Ihor Radchenko
2022-09-11  9:43                 ` Eli Zaretskii
2022-09-11 10:07                   ` Eli Zaretskii [this message]
2022-09-12  5:46                     ` Ihor Radchenko
2022-09-12 11:15                       ` Eli Zaretskii
2022-09-13  1:44                         ` Ihor Radchenko
2022-09-13 11:19                           ` Eli Zaretskii
2022-09-14  1:52                             ` Ihor Radchenko
2022-09-14  2:43                               ` Eli Zaretskii
2023-02-17 19:18                       ` Stefan Kangas
2023-02-17 19:29                         ` Eli Zaretskii
2023-02-17 22:31                           ` Stefan Kangas
2023-02-18  6:56                             ` Eli Zaretskii
2023-02-18  9:00                               ` Stefan Kangas
2023-02-18  9:18                                 ` Eli Zaretskii
2023-02-18 11:32                                   ` Ihor Radchenko
2023-02-18 11:56                                     ` Eli Zaretskii
2023-02-19 11:31                                       ` Ihor Radchenko
2023-02-19 11:55                                         ` Eli Zaretskii
2023-02-19 12:08                                           ` Ihor Radchenko
2023-02-19 12:23                                             ` Eli Zaretskii
2023-02-19 14:19                                               ` Ihor Radchenko
2023-02-19 15:02                                                 ` Eli Zaretskii
2023-02-18 11:35                               ` Ihor Radchenko
2023-02-18 12:00                                 ` Eli Zaretskii
2022-09-12  5:24                   ` Ihor Radchenko
2022-09-09 13:46 ` Robert Pluim
2022-09-09 22:25   ` Stefan Kangas
2022-09-10  4:56     ` Ihor Radchenko
2022-09-10  6:02     ` Eli Zaretskii
2022-09-10  4:53   ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=837d2a9qcu.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=57693@debbugs.gnu.org \
    --cc=yantar92@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).