From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#71411: 30.0.50; Show Unicode names when describing translations Date: Fri, 07 Jun 2024 14:16:38 +0200 Message-ID: <874ja5hrrt.fsf@gmail.com> References: <878qzhhwkl.fsf@gmail.com> <86frtpf1se.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24489"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71411@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 07 14:19:14 2024 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 1sFYYs-0006CZ-Ns for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 Jun 2024 14:19:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFYYT-0007pt-Ca; Fri, 07 Jun 2024 08:18:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFYYR-0007pV-Nl for bug-gnu-emacs@gnu.org; Fri, 07 Jun 2024 08:18:47 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sFYYR-0005Op-Fh for bug-gnu-emacs@gnu.org; Fri, 07 Jun 2024 08:18:47 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sFYYg-0003GT-4F for bug-gnu-emacs@gnu.org; Fri, 07 Jun 2024 08:19:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 07 Jun 2024 12:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71411 X-GNU-PR-Package: emacs Original-Received: via spool by 71411-submit@debbugs.gnu.org id=B71411.171776268612401 (code B ref 71411); Fri, 07 Jun 2024 12:19:02 +0000 Original-Received: (at 71411) by debbugs.gnu.org; 7 Jun 2024 12:18:06 +0000 Original-Received: from localhost ([127.0.0.1]:52125 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFYXk-0003Dt-P5 for submit@debbugs.gnu.org; Fri, 07 Jun 2024 08:18:06 -0400 Original-Received: from mail-lf1-f54.google.com ([209.85.167.54]:61947) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFYXi-0003DD-1f for 71411@debbugs.gnu.org; Fri, 07 Jun 2024 08:18:03 -0400 Original-Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-52bc335e49aso120491e87.3 for <71411@debbugs.gnu.org>; Fri, 07 Jun 2024 05:17:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717762600; x=1718367400; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=/B41zgEkNm4Uqi+3b7H1Gs+bAfJ+sOxFMXOSfldkxP0=; b=JCr7A/cUxR9LpdMXzcL6T9Dc96u8H5AYMPRlmY5d+8MeHeYO4t4OfiT50QAi7xFhUk iggK5ceyFW0u2NPmqvqxWLCpvJP3XVFQCDpig+rneD9aOh4e3zosMrusRieVqizthTy1 EuE0i5SddIaebaHRzemKqlDFme8LwBmH95k/rzIFZgu8n0gPkjWJzj9zm5/9DKHMP4Nz R6H7dAj5ONi8HhRhC354oa1rJlbJ1BAHTUyupuDZ5/tkOP9B1RE0UF4f17wA2mKnxNiZ p/L/Vc39rS+mZbFgh2ArhmxHbdYyG22ijhxya61c1ZSqNXZEuB+F2UcGSNj6SvJnHkBY MxVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717762600; x=1718367400; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/B41zgEkNm4Uqi+3b7H1Gs+bAfJ+sOxFMXOSfldkxP0=; b=EWfI93jCskC7y8P69cxjoZX4MLTtEPmIpMcVbd0VatK/w4MmqmXPfEX7i7p3B8aMcL XKcmkDu91fPfP3S3/aY9NwlM3/bI43Vw46eDj6OKajG+KQNSZrn4g+mHb2y9fzGS/n0Q kqmfNoMtEug9sfdxD8g0lqubGxF4gCMVO16MRMGCOiH6oosmDAOsttswXCzoU+QWkIM7 bZHyrUFrGRzDgfZEU541L80gr6Zu4nHjrZfL7vM3g5Zfumi0SHBz4FHe5zAT14e9RtHk SyBRhCdeOxQcQqwu2sBUepQEMn55ny83OCftN3uWfzI7jQ/bZ0MOtMpnNvv7Q+ojqzOR GRzA== X-Gm-Message-State: AOJu0YwlKVApcCbVP9ZXvRa3VvOecGqM5Hkx/mG12p4SLmB69Gmjsmqz z9hOkL/z9UlTIKUZFUZk4X0J85fAJ46VNGdxeUdrkNixEW6RYwAfyVSjPg== X-Google-Smtp-Source: AGHT+IEyzRvh3C1Cq4O7PklZnE44sVprnBLhioW8IA7H0x4MPQJ5LzTLf/5XxvwxJySB+ubwg6b9uQ== X-Received: by 2002:ac2:482c:0:b0:529:b634:bed1 with SMTP id 2adb3069b0e04-52bb9fd8c72mr1312714e87.58.1717762600056; Fri, 07 Jun 2024 05:16:40 -0700 (PDT) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4215c2a6c9fsm51732125e9.28.2024.06.07.05.16.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 05:16:39 -0700 (PDT) In-Reply-To: <86frtpf1se.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 07 Jun 2024 14:08:33 +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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:286764 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >>>>> On Fri, 07 Jun 2024 14:08:33 +0300, Eli Zaretskii said: Eli> Does this mean that if I type "C-h k a" I will be told that a is L= ATIN Eli> SMALL LETTER A? That'd be an annoyance, I think. That=CA=BCs not a translated binding, so no. Let me attach the patches. Robert --=20 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-char-to-name-convenience-function.patch >From 847d582f89110f8c2f0e88c1533ced0606970fba Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Fri, 7 Jun 2024 12:05:34 +0200 Subject: [PATCH 1/3] Add 'char-to-name' convenience function To: emacs-devel@gnu.org * lisp/international/mule-cmds.el (char-to-name): New function. This is the inverse of 'char-from-name'. * doc/lispref/nonascii.texi (Character Codes): Document it. * etc/NEWS: Announce it. --- doc/lispref/nonascii.texi | 5 +++++ etc/NEWS | 4 ++++ lisp/international/mule-cmds.el | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/doc/lispref/nonascii.texi b/doc/lispref/nonascii.texi index b33082e2b24..195b818c0bd 100644 --- a/doc/lispref/nonascii.texi +++ b/doc/lispref/nonascii.texi @@ -435,6 +435,11 @@ Character Codes @end example @end defun +@defun char-to-name char +This function returns the Unicode name of @var{char}. Returns +@code{nil} if @var{char} is not a character or has no Unicode name. +@end defun + @defun get-byte &optional pos string This function returns the byte at character position @var{pos} in the current buffer. If the current buffer is unibyte, this is literally diff --git a/etc/NEWS b/etc/NEWS index 5fb1625a76c..c63e231f44f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2186,6 +2186,10 @@ it returns a short "unique" string that identifies the function. In either case, the string is propertized so clicking on it gives further details. +** New function 'char-to-name'. +This is a convenience function to return the Unicode name of a char (if +it has one). + ** New function 'cl-type-of'. This function is like 'type-of' except that it sometimes returns a more precise type. For example, for nil and t it returns 'null' diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index e80c42f523a..7d784ef3b1b 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -3183,6 +3183,13 @@ mule--ucs-names-group (script (and char (aref char-script-table char)))) (if script (symbol-name script) "ungrouped")))) +(defun char-to-name (char) + "Return the Unicode name for CHAR, if it has one, else nil. +Return nil if CHAR is not a character." + (and (characterp char) + (or (get-char-code-property char 'name) + (get-char-code-property char 'old-name)))) + (defun char-from-name (string &optional ignore-case) "Return a character as a number from its Unicode name STRING. If optional IGNORE-CASE is non-nil, ignore case in STRING. -- 2.39.2 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Use-char-to-name.patch >From 5ff4c3ac95d8dfcc172ad36f0ebd9c12443c9046 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Fri, 7 Jun 2024 12:07:50 +0200 Subject: [PATCH 2/3] Use 'char-to-name' To: emacs-devel@gnu.org * lisp/international/emoji.el (emoji--name): Lookup name using 'char-to-name'. * lisp/international/textsec.el (textsec-domain-suspicious-p): And here. * lisp/simple.el (what-cursor-position): And here. --- lisp/international/emoji.el | 2 +- lisp/international/textsec.el | 2 +- lisp/simple.el | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lisp/international/emoji.el b/lisp/international/emoji.el index 4f3aab5a6be..cbf7c547f4c 100644 --- a/lisp/international/emoji.el +++ b/lisp/international/emoji.el @@ -245,7 +245,7 @@ emoji--fontify-glyph (defun emoji--name (glyph) (or (gethash glyph emoji--names) - (get-char-code-property (aref glyph 0) 'name))) + (char-to-name (aref glyph 0)))) (defvar-keymap emoji-list-mode-map "RET" #'emoji-list-select diff --git a/lisp/international/textsec.el b/lisp/international/textsec.el index 4740dd81345..224363732fe 100644 --- a/lisp/international/textsec.el +++ b/lisp/international/textsec.el @@ -296,7 +296,7 @@ textsec-domain-suspicious-p "" (concat ": " (string char))) char - (get-char-code-property char 'name))))) + (char-to-name char))))) domain) ;; Does IDNA allow it? (unless (puny-highly-restrictive-domain-p domain) diff --git a/lisp/simple.el b/lisp/simple.el index 68209eadc41..8d7e379b584 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1827,8 +1827,7 @@ what-cursor-position (interactive "P") (let* ((char (following-char)) (char-name (and what-cursor-show-names - (or (get-char-code-property char 'name) - (get-char-code-property char 'old-name)))) + (char-to-name char))) (char-name-fmt (if char-name (format ", %s" char-name) "")) -- 2.39.2 --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0003-Show-character-names-when-describing-translations.patch Content-Transfer-Encoding: quoted-printable >From a2adb11e15a60ad30741c6cd8c47f03b5b1a902e Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Fri, 7 Jun 2024 12:21:11 +0200 Subject: [PATCH 3/3] Show character names when describing translations To: emacs-devel@gnu.org This implements Bug#71411. * lisp/help.el (help-key-description): Use 'char-to-name' to show the Unicode name of translated keys. (help--describe-command): And here. * etc/NEWS: Announce the change. --- etc/NEWS | 14 ++++++++++++++ lisp/help.el | 9 +++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index c63e231f44f..66bc4d741ff 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -182,6 +182,20 @@ This user option controls outline visibility in the ou= tput buffer of *** 'C-h m' ('describe-mode') uses outlining by default. Set 'describe-mode-outline' to nil to get back the old behavior. =20 +*** 'C-h k' ('describe-key') shows Unicode name. +For translated keys only, this will now show the Unicode name of the +translation, e.g. 'C-h k C-x 8 E' will now show + + =E2=82=AC 'EURO SIGN' (translated from C-x 8 E) + +*** 'C-h b' ('describe-bindings') shows Unicode names. +For translated keys only, Unicode names will now be shown, i.e. + + A-! =C2=A1 INVERTED EXCLAMATION MARK + A-$ =C2=A4 CURRENCY SIGN + +and so on. + ** Outline mode =20 *** New commands to show/hide outlines by regexp. diff --git a/lisp/help.el b/lisp/help.el index 2feb178ff6c..878dd404256 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -883,7 +883,9 @@ help-key-description (let ((otherstring (help--key-description-fontified untranslated))) (if (equal string otherstring) string - (format "%s (translated from %s)" string otherstring)))))) + (if-let ((char-name (char-to-name (aref string 0)))) + (format "%s '%s' (translated from %s)" string char-name othe= rstring) + (format "%s (translated from %s)" string otherstring))))))) =20 (defun help--binding-undefined-p (defn) (or (null defn) (integerp defn) (equal defn #'undefined))) @@ -1664,7 +1666,10 @@ help--shadow-lookup (defun help--describe-command (definition &optional translation) (cond ((or (stringp definition) (vectorp definition)) (if translation - (insert (key-description definition nil) "\n") + (insert (concat (key-description definition nil) + (when-let ((char-name (char-to-name (aref def= inition 0)))) + (format "\t%s" char-name)) + "\n")) ;; These should be rare nowadays, replaced by `kmacro's. (insert "Keyboard Macro\n"))) ((keymapp definition) --=20 2.39.2 --=-=-=--