all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: emacs-devel@gnu.org
Subject: Re: search-default-mode char-fold-to-regexp and Greek Extended block characters, Re: search-default-mode char-fold-to-regexp and Greek Extended block characters
Date: Fri, 26 Jul 2019 13:09:27 +0200	[thread overview]
Message-ID: <m2o91hjbmg.fsf@gmail.com> (raw)
In-Reply-To: <87v9vp23g0.fsf@mail.linkov.net> (Juri Linkov's message of "Fri,  26 Jul 2019 00:35:51 +0300")

>>>>> On Fri, 26 Jul 2019 00:35:51 +0300, Juri Linkov <juri@linkov.net> said:

    Juri> If there are many such cases, then better to handle them automatically indeed
    Juri> (if this doesn't cause slowdown too much) instead of adding them one by one
    Juri> to the default values.  Does this handle ß as well?

There are 74, and I donʼt want to maintain such a list by hand :-).

ß is not a complex character, so is never looked at here. But if we
hoist the checking out of the loop over complex characters, we can
make that work as well (this supersedes my previous patch).

I have no idea of the performance impact of all this.

diff --git i/lisp/char-fold.el w/lisp/char-fold.el
index f379229e6c..bee485c8ed 100644
--- i/lisp/char-fold.el
+++ w/lisp/char-fold.el
@@ -49,6 +49,36 @@
                             (funcall func (car char) v table)))
                         table))
 
+      (map-char-table
+       (lambda (char category)
+         ;; If the uppercase version of a character is not a single
+         ;; character, we add a mapping from the first character of
+         ;; the uppercase version to the lowercase character. This
+         ;; handles eg ß => SS and ῗ => Ϊ́
+
+         (when (eq category 'Ll)
+           (let ((start char)
+                 (end char))
+             (when (consp char)
+               (setq start (car char)
+                     end (cdr char)))
+             (while (<= start end)
+               (let* ((str (char-to-string start))
+                      (upper (upcase str))
+                      (roundtrip (downcase upper)))
+                 (when (> (length roundtrip) 1)
+                   ;; Complex characters map to the decomposed version
+                   ;; + diacriticals, simple characters map to the
+                   ;; base char.  Also add the reverse mapping for
+                   ;; simple characters.
+                   (if (cdr (get-char-code-property start 'decomposition))
+                       (setq str roundtrip)
+                     (aset equiv start
+                           (cons roundtrip (aref equiv start))))
+                   (aset equiv (aref roundtrip 0)
+                         (cons str (aref equiv (aref roundtrip 0))))))
+               (setq start (+ 1 start))))))
+             (unicode-property-table-internal 'general-category))
       ;; Compile a list of all complex characters that each simple
       ;; character should match.
       ;; In summary this loop does 3 things:
diff --git i/test/lisp/char-fold-tests.el w/test/lisp/char-fold-tests.el
index e519435ef0..cf155d3cb5 100644
--- i/test/lisp/char-fold-tests.el
+++ w/test/lisp/char-fold-tests.el
@@ -154,9 +154,9 @@ char-fold--test-without-customization
             ("ι"
              "ί" ;; 1 level decomposition
              "ί" ;; 2 level decomposition
-             ;; FIXME:
-             ;; "ΐ" ;; 3 level decomposition
+             "ΐ" ;; 3 level decomposition
              )
+            ("ß" "ss")
             )))
     (dolist (strings matches)
       (apply 'char-fold--test-match-exactly strings))))
@@ -165,7 +165,6 @@ char-fold--test-with-customization
   :tags '(:expensive-test)
   (let* ((char-fold-include
           '(
-            (?ß "ss") ;; de
             (?o "ø")  ;; da no nb nn
             (?l "ł")  ;; pl
             ))
@@ -184,8 +183,7 @@ char-fold--test-with-customization
           '(
             ("e" "ℯ" "ḗ" "ë" "ë")
             ("е" "ё" "ё")
-            ("ι" "ί" "ί"
-             ;; FIXME: "ΐ"
+            ("ι" "ί" "ί" "ΐ"
              )
             ("ß" "ss")
             ("o" "ø")



  reply	other threads:[~2019-07-26 11:09 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-19 14:18 search-default-mode char-fold-to-regexp and Greek Extended block characters Robert Pluim
2019-07-19 14:37 ` Eli Zaretskii
2019-07-19 16:03   ` Robert Pluim
2019-07-19 18:13     ` Eli Zaretskii
2019-07-21 11:03       ` Robert Pluim
2019-07-22 18:39         ` Robert Pluim
2019-07-23 14:57           ` Eli Zaretskii
2019-07-23 17:43             ` Robert Pluim
2019-07-23 20:29               ` Juri Linkov
2019-07-24  7:56                 ` Robert Pluim
2019-07-24  7:59                   ` Robert Pluim
2019-07-24  9:04                 ` Robert Pluim
2019-07-24 23:12                   ` Juri Linkov
2019-07-25  0:18                     ` Basil L. Contovounesios
2019-07-25 18:40                       ` Juri Linkov
2019-07-25 20:44                         ` search-default-mode char-fold-to-regexp and Greek Extended block characters, " Robert Pluim
2019-07-25 21:35                           ` Juri Linkov
2019-07-26 11:09                             ` Robert Pluim [this message]
2019-07-26 18:38                               ` Juri Linkov
2019-07-29  8:32                                 ` Robert Pluim
2019-07-29 18:09                                   ` Juri Linkov
2019-07-30  8:09                                     ` Robert Pluim
2019-07-30 10:15                                       ` Eli Zaretskii
2019-07-25  2:36                     ` Eli Zaretskii
2019-07-25  8:59                       ` Robert Pluim
2019-07-25 12:53                         ` Eli Zaretskii
2019-07-25  8:46                     ` Robert Pluim
2019-07-25 18:46                       ` Juri Linkov
2019-07-26  6:04                         ` Eli Zaretskii
2019-07-26 18:40                           ` Juri Linkov
2019-07-26 19:13                             ` Eli Zaretskii
2019-07-19 18:53 ` 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2o91hjbmg.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=juri@linkov.net \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.