From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation Date: Mon, 25 Jul 2022 22:49:11 +0300 Organization: LINKOV.NET Message-ID: <867d41dlc8.fsf@mail.linkov.net> References: <165875050243.3275.8867100069985547389@vcs2.savannah.gnu.org> <20220725120142.D1283C0F203@vcs2.savannah.gnu.org> <87r1298hxp.fsf@gmail.com> <864jz513nb.fsf@mail.linkov.net> <83h735dpno.fsf@gnu.org> <86tu75doeq.fsf@mail.linkov.net> 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="9649"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: rpluim@gmail.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jul 25 21:53:40 2022 Return-path: Envelope-to: ged-emacs-devel@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 1oG496-0002MC-5G for ged-emacs-devel@m.gmane-mx.org; Mon, 25 Jul 2022 21:53:40 +0200 Original-Received: from localhost ([::1]:42428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oG493-0008Dj-Vc for ged-emacs-devel@m.gmane-mx.org; Mon, 25 Jul 2022 15:53:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oG474-0006vT-16 for emacs-devel@gnu.org; Mon, 25 Jul 2022 15:51:35 -0400 Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]:58801) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oG471-0002w2-I6; Mon, 25 Jul 2022 15:51:33 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id B0FC460009; Mon, 25 Jul 2022 19:51:27 +0000 (UTC) In-Reply-To: <86tu75doeq.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 25 Jul 2022 21:42:53 +0300") Received-SPF: pass client-ip=217.70.183.195; envelope-from=juri@linkov.net; helo=relay3-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:292651 Archived-At: --=-=-= Content-Type: text/plain >>> > Should we make `char-fold-to-regexp' into a command and refer to it >>> > from here? Or add something like `char-fold-show-equivalences'? >>> >>> A better name would be `describe-char-fold'. >> >> For a command, I'd say describe-character-foldings. But >> char-fold-show-equivalences is IMO a better name. > > All similar commands have names starting with the `describe-' prefix like > `describe-char', `describe-character-set'. So maybe then > `describe-char-fold-equivalences'. Ok, then let's use describe-char-fold-equivalences: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=describe-char-fold-equivalences.patch diff --git a/lisp/char-fold.el b/lisp/char-fold.el index 05ae52cae0..71a1fb1910 100644 --- a/lisp/char-fold.el +++ b/lisp/char-fold.el @@ -48,6 +48,7 @@ (eval-and-compile + (defvar char-fold--no-regexp nil) (defun char-fold--make-table () (let* ((equiv (make-char-table 'char-fold-table)) (equiv-multi (make-char-table 'char-fold-table)) @@ -201,11 +202,14 @@ symmetric))) ;; Convert the lists of characters we compiled into regexps. - (map-char-table - (lambda (char decomp-list) - (let ((re (regexp-opt (cons (char-to-string char) decomp-list)))) - (aset equiv char re))) - equiv) + (unless char-fold--no-regexp + ;; Non-nil `char-fold--no-regexp' unoptimized for regexp + ;; is used by `describe-char-fold-equivalences'. + (map-char-table + (lambda (char decomp-list) + (let ((re (regexp-opt (cons (char-to-string char) decomp-list)))) + (aset equiv char re))) + equiv)) equiv))) (defconst char-fold-table @@ -421,6 +425,28 @@ char-fold-search-backward (interactive "sSearch: ") (re-search-backward (char-fold-to-regexp string) bound noerror count)) + +(defun describe-char-fold-equivalences () + "Describe character equivalences of `char-fold-to-regexp'." + (interactive) + (require 'help-fns) + (let ((help-buffer-under-preparation t)) + (help-setup-xref (list #'describe-char-fold-equivalences) + (called-interactively-p 'interactive)) + (let ((equivalences nil)) + (map-char-table + (lambda (char list) + (setq equivalences (cons (cons char list) equivalences))) + (let ((char-fold--no-regexp t)) + (char-fold--make-table))) + (with-help-window (help-buffer) + (with-current-buffer standard-output + (insert "A list char-fold equivalences for `char-fold-to-regexp'.\n\n") + (dolist (equiv (nreverse equivalences)) + (insert (format "%c: %s\n" (car equiv) + (mapconcat #'identity (cdr equiv) + " "))))))))) + (provide 'char-fold) ;;; char-fold.el ends here --=-=-=--