unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: rpluim@gmail.com,  emacs-devel@gnu.org
Subject: Re: emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation
Date: Mon, 25 Jul 2022 22:49:11 +0300	[thread overview]
Message-ID: <867d41dlc8.fsf@mail.linkov.net> (raw)
In-Reply-To: <86tu75doeq.fsf@mail.linkov.net> (Juri Linkov's message of "Mon,  25 Jul 2022 21:42:53 +0300")

[-- Attachment #1: Type: text/plain, Size: 542 bytes --]

>>> > 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: describe-char-fold-equivalences.patch --]
[-- Type: text/x-diff, Size: 2202 bytes --]

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 @@
 
 \f
 (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))
 
+\f
+(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

  reply	other threads:[~2022-07-25 19:49 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <165875050243.3275.8867100069985547389@vcs2.savannah.gnu.org>
     [not found] ` <20220725120142.D1283C0F203@vcs2.savannah.gnu.org>
2022-07-25 13:01   ` emacs-28 a866674b2a: Fix inaccuracies in "lax search" documentation Robert Pluim
2022-07-25 13:43     ` Eli Zaretskii
2022-07-25 14:48       ` Robert Pluim
2022-07-25 16:02         ` Eli Zaretskii
2022-07-26 12:52       ` Robert Pluim
2022-07-26 13:16         ` Eli Zaretskii
2022-07-26 14:23           ` Robert Pluim
2022-07-26 16:06             ` Eli Zaretskii
2022-07-26 16:54               ` Robert Pluim
2022-07-26 17:15                 ` Eli Zaretskii
2022-07-27  7:54                   ` Robert Pluim
2022-07-27 11:32                     ` Eli Zaretskii
2022-07-25 17:52     ` Juri Linkov
2022-07-25 18:15       ` Eli Zaretskii
2022-07-25 18:42         ` Juri Linkov
2022-07-25 19:49           ` Juri Linkov [this message]
2022-07-26  7:59             ` Robert Pluim
2022-07-26 12:16               ` Eli Zaretskii
2022-07-27  7:46                 ` Juri Linkov
2022-07-27  8:13                   ` Robert Pluim
2022-07-27 11:32                     ` Eli Zaretskii
2022-07-27 18:54                     ` Juri Linkov
2022-07-27 19:23                       ` Eli Zaretskii
2022-07-27 19:55                         ` Juri Linkov
2022-07-28  5:40                           ` Eli Zaretskii
2022-07-28  6:07                             ` Eli Zaretskii
2022-07-28  7:13                               ` Juri Linkov
2022-07-28  7:56                                 ` Eli Zaretskii
2022-07-28  7:10                             ` Juri Linkov
2022-07-28  7:55                               ` Eli Zaretskii
2022-07-28 19:40                                 ` Juri Linkov
2022-08-30  7:29               ` Juri Linkov
2022-08-31  8:49                 ` Robert Pluim
2022-08-31 16:09                   ` Juri Linkov
2022-08-31 16:36                     ` Robert Pluim
2022-08-31 16:40                       ` Eli Zaretskii
2022-08-31 16:56                         ` Robert Pluim
2022-08-31 17:13                           ` Juri Linkov
2022-08-31 17:22                             ` Eli Zaretskii
2022-08-31 17:26                               ` Robert Pluim
2022-08-31 17:29                               ` [External] : " Drew Adams
2022-08-31 18:04                               ` Juri Linkov
2022-08-31 20:14                     ` Stefan Monnier
2022-09-01  7:22                       ` Juri Linkov
2022-09-01  8:14                         ` Robert Pluim
2022-09-01 11:34                           ` Eli Zaretskii
2022-09-01 12:23                             ` Robert Pluim
2022-09-01 13:00                               ` Stefan Monnier
2022-09-01 13:07                                 ` Robert Pluim
2022-09-01 15:28                                   ` Robert Pluim
2022-09-01 15:30                                     ` Eli Zaretskii
2022-09-01 15:58                                       ` Robert Pluim

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=867d41dlc8.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=rpluim@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).