unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Andrea Greselin <greselin.andrea@gmail.com>
Cc: 52394@debbugs.gnu.org
Subject: bug#52394: 27.2; Isearch with char folding enabled doesn’t match equivalent strings
Date: Sun, 12 Dec 2021 19:19:14 +0200	[thread overview]
Message-ID: <86pmq1q5it.fsf@mail.linkov.net> (raw)
In-Reply-To: <CAJ_oJbY7TU=suyUdKDdDdV=kNF-xS-CDkks2XU088Edi3TBzvQ@mail.gmail.com> (Andrea Greselin's message of "Sun, 12 Dec 2021 10:31:27 +0100")

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

> Even better, yes. In addition to simplifying changing the default,
> something like that would make it easy to create different levels of
> folding and switch between them (by writing commands that add or
> remove certain characters from the list).

Thanks for the suggestion,  This is implemented by the following patch:


[-- Attachment #2: char-fold-override.patch --]
[-- Type: text/x-diff, Size: 3108 bytes --]

diff --git a/lisp/char-fold.el b/lisp/char-fold.el
index e3ab7d5b64..12c9d2d4b1 100644
--- a/lisp/char-fold.el
+++ b/lisp/char-fold.el
@@ -26,6 +26,7 @@
 
 (eval-and-compile
   (put 'char-fold-table 'char-table-extra-slots 1)
+  (defconst char-fold--default-override nil)
   (defconst char-fold--default-include
     '((?\" """ "“" "”" "”" "„" "⹂" "〞" "‟" "‟" "❞" "❝" "❠" "“" "„" "〝" "〟" "🙷" "🙶" "🙸" "«" "»")
       (?' "❟" "❛" "❜" "‘" "’" "‚" "‛" "‚" "󠀢" "❮" "❯" "‹" "›")
@@ -40,7 +41,8 @@
       ))
   (defconst char-fold--default-symmetric nil)
   (defvar char-fold--previous
-    (list char-fold--default-include
+    (list char-fold--default-override
+          char-fold--default-include
           char-fold--default-exclude
           char-fold--default-symmetric)))
 
@@ -67,6 +69,8 @@
       ;; - A single char of the decomp might be allowed to match the
       ;;   character.
       ;; Some examples in the comments below.
+      (unless (or (bound-and-true-p char-fold-override)
+                  char-fold--default-override)
         (map-char-table
          (lambda (char decomp)
            (when (consp decomp)
@@ -135,7 +139,7 @@
                        (aset equiv (car simpler-decomp)
                              (cons (apply #'string decomp)
                                    (aref equiv (car simpler-decomp)))))))))))
-       table)
+         table))
 
       ;; Add some entries to default decomposition
       (dolist (it (or (bound-and-true-p char-fold-include)
@@ -232,7 +236,9 @@ char-fold-table
 \f
 (defun char-fold-update-table ()
   "Update char-fold-table only when one of the options changes its value."
-  (let ((new (list (or (bound-and-true-p char-fold-include)
+  (let ((new (list (or (bound-and-true-p char-fold-override)
+                       char-fold--default-override)
+                   (or (bound-and-true-p char-fold-include)
                        char-fold--default-include)
                    (or (bound-and-true-p char-fold-exclude)
                        char-fold--default-exclude)
@@ -242,6 +248,22 @@ char-fold-update-table
       (setq char-fold-table (char-fold--make-table)
             char-fold--previous new))))
 
+(defcustom char-fold-override char-fold--default-override
+  "Non-nil means to override all default folding characters.
+When nil, the equivalence table is populated with the default set
+of equivalent chars, and you can remove unneeded characters using
+`char-fold-exclude', and add own characters using `char-fold-include'.
+But when this variable is customized to non-nil, you start with
+an empty table where you can add only own characters
+using `char-fold-include'."
+  :type 'boolean
+  :initialize #'custom-initialize-default
+  :set (lambda (sym val)
+         (custom-set-default sym val)
+         (char-fold-update-table))
+  :group 'isearch
+  :version "29.1")
+
 (defcustom char-fold-include char-fold--default-include
   "Additional character foldings to include.
 Each entry is a list of a character and the strings that fold into it."

  reply	other threads:[~2021-12-12 17:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09 20:41 bug#52394: 27.2; Isearch with char folding enabled doesn’t match equivalent strings Andrea Greselin
2021-12-10  2:00 ` Michael Heerdegen
2021-12-10  7:51 ` Juri Linkov
2021-12-10 11:00   ` Andrea Greselin
2021-12-11 19:46     ` Juri Linkov
2021-12-11 20:13       ` Andrea Greselin
2021-12-11 20:34         ` Juri Linkov
2021-12-11 21:14           ` Andrea Greselin
2021-12-12  8:37             ` Juri Linkov
2021-12-12  9:31               ` Andrea Greselin
2021-12-12 17:19                 ` Juri Linkov [this message]
2021-12-12 17:53                   ` Eli Zaretskii
2021-12-12 18:06                     ` Juri Linkov
2021-12-12 18:25                       ` Eli Zaretskii
2021-12-12 18:30                         ` Juri Linkov
2021-12-12 18:43                           ` Eli Zaretskii
2021-12-12 18:54                             ` Juri Linkov
2021-12-12 18:59                               ` Eli Zaretskii
2021-12-12 19:12                                 ` Juri Linkov

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=86pmq1q5it.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=52394@debbugs.gnu.org \
    --cc=greselin.andrea@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).