From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs 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 Message-ID: <837d2a9qcu.fsf@gnu.org> References: <87v8pw1xyo.fsf@localhost> <83a678d5w6.fsf@gnu.org> <878rmr25tk.fsf@localhost> <83czc3bvbg.fsf@gnu.org> <87y1urybt6.fsf@localhost> <837d2bbr2s.fsf@gnu.org> <87edwjy77h.fsf@localhost> <831qsjboy0.fsf@gnu.org> <87v8puw945.fsf@localhost> <838rmq9rfr.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40039"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 57693@debbugs.gnu.org To: yantar92@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 11 12:08:16 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oXJss-000AFR-Se for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 11 Sep 2022 12:08:14 +0200 Original-Received: from localhost ([::1]:33976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oXJsr-0004vK-NO for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 11 Sep 2022 06:08:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXJsg-0004vC-96 for bug-gnu-emacs@gnu.org; Sun, 11 Sep 2022 06:08:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oXJsg-00070d-0B for bug-gnu-emacs@gnu.org; Sun, 11 Sep 2022 06:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oXJsf-0007Jw-Ln for bug-gnu-emacs@gnu.org; Sun, 11 Sep 2022 06:08:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 11 Sep 2022 10:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57693 X-GNU-PR-Package: emacs Original-Received: via spool by 57693-submit@debbugs.gnu.org id=B57693.166289086028111 (code B ref 57693); Sun, 11 Sep 2022 10:08:01 +0000 Original-Received: (at 57693) by debbugs.gnu.org; 11 Sep 2022 10:07:40 +0000 Original-Received: from localhost ([127.0.0.1]:40759 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oXJsJ-0007JL-K7 for submit@debbugs.gnu.org; Sun, 11 Sep 2022 06:07:39 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:33326) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oXJsH-0007J9-Uz for 57693@debbugs.gnu.org; Sun, 11 Sep 2022 06:07:38 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:46838) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXJsB-0006tS-Cd; Sun, 11 Sep 2022 06:07:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=AN6Wv1soFvqcRT2PvRBpBNdl7m9bm6NbHZr3Q/m/b4o=; b=dcqyMnU5SWWG 1ZvPJ4DBGW87r/Ut6Uiljdrazm1ugOSIjSoXUl4mLN1JbKa7chPLTxXfndLFD6t45d6Y6Lnn+fcvS EkaHcct6Bz0n1Unn6pShoB2rBVr/ybZvwI0hi4b4ydTRhGhw47dHL/z/amO+Npd1dwZcoYDFN3ofL w/k1XIMBsa6ihon+zSDDeTiW9zeQzwe6S7dbUezN+QtZUQiCpbqmSFGQdmjglRz1yvEhBCiCZUPZg y9Hfs/T9xDwQBPhmuirhnHA7XPnqfKgZlQy8ZYpJuFazrHlAFi+Kz6qIFEWHd2MyZUJCttA1HwMZz ReBsvAYrl2QNxUJoQdH09w==; Original-Received: from [87.69.77.57] (port=1898 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXJsA-0004No-SW; Sun, 11 Sep 2022 06:07:31 -0400 In-Reply-To: <838rmq9rfr.fsf@gnu.org> (message from Eli Zaretskii on Sun, 11 Sep 2022 12:43:52 +0300) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:242135 Archived-At: > Cc: 57693@debbugs.gnu.org > Date: Sun, 11 Sep 2022 12:43:52 +0300 > From: Eli Zaretskii > > > From: Ihor Radchenko > > 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.