emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#35689: closed (Customizable char-fold)


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#35689: closed (Customizable char-fold)
Date: Tue, 23 Jul 2019 20:31:02 +0000

Your message dated Tue, 23 Jul 2019 23:28:09 +0300
with message-id <address@hidden>
and subject line Re: bug#35689: Customizable char-fold
has caused the debbugs.gnu.org bug report #35689,
regarding Customizable char-fold
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden.)


-- 
35689: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=35689
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: Customizable char-fold Date: Sun, 12 May 2019 00:22:53 +0300 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)
Tags: patch

This patch adds long-awaited customization to char-fold.el:

diff --git a/lisp/char-fold.el b/lisp/char-fold.el
index e61bc3edc6..24882008a4 100644
--- a/lisp/char-fold.el
+++ b/lisp/char-fold.el
@@ -24,6 +24,30 @@
 
 (eval-and-compile (put 'char-fold-table 'char-table-extra-slots 1))
 
+(defcustom char-fold-include-base nil
+  "Include mappings from composite character to base letter."
+  :type 'boolean
+  :group 'matching
+  :version "27.1")
+
+(defcustom char-fold-include-alist
+  '((?\" """ "“" "”" "”" "„" "⹂" "〞" "‟" "‟" "❞" "❝" "❠" "“" "„" "〝" "〟" "🙷" 
"🙶" "🙸" "«" "»")
+    (?' "❟" "❛" "❜" "‘" "’" "‚" "‛" "‚" "󠀢" "❮" "❯" "‹" "›")
+    (?` "❛" "‘" "‛" "󠀢" "❮" "‹"))
+  "Additional character mappings to include."
+  :type '(alist :key-type (character :tag "From")
+                :value-type (repeat (string :tag "To")))
+  :group 'lisp
+  :version "27.1")
+
+(defcustom char-fold-exclude-alist nil
+  "Character mappings to exclude from default setting."
+  :type '(alist :key-type (character :tag "From")
+                :value-type (character :tag "To"))
+  :group 'lisp
+  :version "27.1")
+
+
 (defconst char-fold-table
   (eval-when-compile
     (let ((equiv (make-char-table 'char-fold-table))
@@ -76,7 +106,11 @@ char-fold-table
                                       (aref equiv-multi (car decomp))))
                         (aset equiv (car decomp)
                               (cons (char-to-string char)
-                                    (aref equiv (car decomp))))))))
+                                    (aref equiv (car decomp))))
+                        (when char-fold-include-base
+                          (aset equiv char
+                                (cons (char-to-string (car decomp))
+                                      (aref equiv (car decomp)))))))))
                (funcall make-decomp-match-char decomp char)
                ;; Do it again, without the non-spacing characters.
                ;; This allows 'a' to match 'ä'.
@@ -98,13 +132,18 @@ char-fold-table
        table)
 
       ;; Add some manual entries.
-      (dolist (it '((?\" """ "“" "”" "”" "„" "⹂" "〞" "‟" "‟" "❞" "❝" "❠" "“" 
"„" "〝" "〟" "🙷" "🙶" "🙸" "«" "»")
-                    (?' "❟" "❛" "❜" "‘" "’" "‚" "‛" "‚" "󠀢" "❮" "❯" "‹" "›")
-                    (?` "❛" "‘" "‛" "󠀢" "❮" "‹")))
+      (dolist (it char-fold-include-alist)
         (let ((idx (car it))
               (chars (cdr it)))
           (aset equiv idx (append chars (aref equiv idx)))))
 
+      ;; Remove some entries.
+      (dolist (it char-fold-exclude-alist)
+        (let ((idx (car it))
+              (char (cdr it)))
+          (when (aref equiv idx)
+            (aset equiv idx (remove (char-to-string char) (aref equiv idx))))))
+
       ;; Convert the lists of characters we compiled into regexps.
       (map-char-table
        (lambda (char dec-list)

--- End Message ---
--- Begin Message --- Subject: Re: bug#35689: Customizable char-fold Date: Tue, 23 Jul 2019 23:28:09 +0300 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)
Thanks to everyone who helped!  Pushed to master as 376f5df3cc.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]