From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Felix Dietrich Newsgroups: gmane.emacs.help Subject: Re: Find all the name and alias corresponding to a codepoint in Emacs. Date: Sun, 20 Mar 2022 17:01:28 +0100 Message-ID: <87a6dk4nqf.fsf@sperrhaken.name> References: <83fsnnd6n2.fsf@gnu.org> <83ee37cy43.fsf@gnu.org> <83ee37mmar.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="7160"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 20 17:16:12 2022 Return-path: Envelope-to: geh-help-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 1nVyE0-0001lD-Oa for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 20 Mar 2022 17:16:12 +0100 Original-Received: from localhost ([::1]:40960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVyDz-0005Xh-N8 for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 20 Mar 2022 12:16:11 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:47254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVxzy-00061C-AM for help-gnu-emacs@gnu.org; Sun, 20 Mar 2022 12:01:50 -0400 Original-Received: from mout.kundenserver.de ([217.72.192.73]:39669) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVxzu-0006Hu-8u for help-gnu-emacs@gnu.org; Sun, 20 Mar 2022 12:01:41 -0400 Original-Received: from localhost ([77.183.63.12]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MrPVJ-1nqDn72Ukh-00oViX for ; Sun, 20 Mar 2022 17:01:34 +0100 In-Reply-To: <83ee37mmar.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 12 Mar 2022 13:40:12 +0200") X-Provags-ID: V03:K1:AoKfSE0YorWXWquLP6i9mPmRT4CSkqW+mycBRWYfzhvxga5Jk4u RDi0unWAwn85089xliuY9MS1eVWwwTP/z9iBGXA3gJRiSoe0/4JF7L958h6C13/sJPlAqcX sjCF/62QVZLWRha9E7XehPzh1/BBZpUy/LAeWL73qTqUKq8XuPSUXbSF6rRvNnCcTmnbvvP uvWiVbr38ZdadkdtYolCQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:bXDoDKozewE=:JY13xhz4+pWQMIt7sYxYp9 MtWVNDEVIulj9Xv0avlf2ojMGcIGwZEwcGlIJAywwEudo0R47202NI4u/MKATnNs++Gu4hg0t 9OxPP7IAz9Ts+Q/3qaun37yGgSf66TLQnVruiR4poJpIMls0LU5YW2QXGq4DfwoZs32e0t0Uq vISijugafGyGdbJmCfGxBPAh4sRSviS+y7aLRPcwkBwVxh3FJT+4PR4dSERk6yAbHjmdNoMSr zF4XzT5D/WfoDB4Vtgmrjs/h3ka0CG43SzOyYLWZ3ejSrnmJOilCttmoX6GKODg4DmUlHie1C hSpZqlk6S7NraremCo/AA+nGsM3DMDa0FYNk7K90VJy14P4EXX2M9KeScjDloAc2VOLLWS3QX 01qDgH2JMo93Yse5gya9cWBfWfe0Xhri/jocrK8/BCdTJ/mGr3aW8KUEx0v84z5oDdTZXPPhQ BbxCHBJKgp+kvhyD3JAvM8MQvdUzyD8fQkuu+ApoN4prl/B1yUmyNg60bZ4gpyD+0hRzShfgG uOXdU76C1BnYq2BVPtiNum++/Twzj6/kQ81rbxrgyceH9yMkp+OxEOTAbo+FrCLJV8Uk8ARUl Ev81qlpTD1+r4AdNZo+6Y6n/Ua9wXU3i95tLs/EfKF1QQfiGXlyo+eNBLQ+t4KJbDE5G+vId8 oxd/FuOTG/xTvXlDBzMQtZ9a0UGRFvAEV7QqWy3UBcRvVB9stIi0BLxRc6g8FVi/gcoB61TKV BLygDyLsJCuaeYzu Received-SPF: none client-ip=217.72.192.73; envelope-from=felix.dietrich@sperrhaken.name; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:136696 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: >> From: Hongyi Zhao >> Date: Sat, 12 Mar 2022 19:20:11 +0800 >> Cc: help-gnu-emacs >>=20 >> > > Character code properties: customize what to show >> > > name: GRAVE ACCENT >> > > old-name: SPACING GRAVE >> > > general-category: Sk (Symbol, Modifier) >> > > canonical-combining-class: 0 (Spacing, split, enclosing, reordrant, >> > > and Tibetan subjoined) >> > > bidi-class: ON (Other Neutrals) >> > > decomposition: (96) ('`') >> > > mirrored: N >> > >> > Why is that a problem? >>=20 >> The "grave accent" is also named as "backtick" or "backquote", and I >> hope to see all these names in Emacs. > > We only show the Unicode data, and it has only "SPACING GRAVE" as an > alternative name. A somewhat harebrained idea of mine queries Wikidata for aliases stored there. Use the command =E2=80=98wd-char-aliases-show=E2=80=99 to display a= list of aliases for the character under the cursor. This sketch has no comments or docstrings, nor does it check for errors. The query is slow and might very well not be entirely correct. (I do not have much of an understanding of SPARQL and Wikidata.) Maybe it can still be of use to you =E2=80=93 or of interest as a curiosity. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=character-aliases.el Content-Transfer-Encoding: quoted-printable Content-Description: Emacs Lisp code to search character aliases on Wikidata (defun wd-char-aliases-query (char) (let* ((wikidata-endpoint "https://query.wikidata.org/sparql") (url-request-method "POST") (url-request-extra-headers '(("Accept" . "application/sparql-results+json") ("Content-Type" . "application/x-www-form-urlencoded"))) (sparql-query-template "select distinct (lcase(?label) as ?label) where { ?char wdt:P31/wdt:P279* wd:Q3241972; wdt:P487 \"%s\". { ?char skos:altLabel ?label } union { ?char rdfs:label ?label } filter ( LANG(?label) =3D \"en\" ) filter ( fn:not(fn:matches(?label, \"U\\\\+([a-fA-F]|[0-9])+\")) ) filter ( STRLEN(?label) > 2 ) }" ) (sparql-query (format sparql-query-template (string char))) (url-request-data (concat "query=3D" (url-hexify-string sparql-query)))) (let ((buf (url-retrieve-synchronously wikidata-endpoint))) (with-current-buffer buf (goto-char (point-min)) (re-search-forward "^$") (forward-line) (buffer-substring (point) (point-max)))))) (defun wd-char-aliases (char) (let* ((query-result (wd-char-aliases-query char)) (json (json-read-from-string query-result)) (results (cdr (assq 'results json))) (bindings (cdr (assq 'bindings results)))) (mapcar (lambda (b) (let ((l (assq 'label b))) (cdr (assq 'value l)))) bindings))) (defun wd-char-aliases-show () (interactive) (let* ((aliases (wd-char-aliases (char-after)))) (if (null aliases) (message "No character aliases found") (with-output-to-temp-buffer "*Character Aliases*" (dolist (a aliases) (princ a) (terpri)))))) --=-=-= Content-Type: text/plain -- Felix Dietrich --=-=-=--