emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 5516728: * lisp/character-fold.el (character-fold-t


From: Artur Malabarba
Subject: [Emacs-diffs] master 5516728: * lisp/character-fold.el (character-fold-table):
Date: Sun, 05 Jul 2015 15:46:37 +0000

branch: master
commit 5516728eac58aba87a39427b7a3d1bfb8e2a19d0
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>

    * lisp/character-fold.el (character-fold-table):
    
    Only fold decompositions if at least one character is non-spacing.
    (Bug#20975)
---
 lisp/character-fold.el |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/lisp/character-fold.el b/lisp/character-fold.el
index fca13bf..bf5ae59 100644
--- a/lisp/character-fold.el
+++ b/lisp/character-fold.el
@@ -52,7 +52,9 @@ some).")
            ;; Skip trivial cases like ?a decomposing to (?a).
            (unless (or (and (eq i (car dec))
                             (not  (cdr dec))))
-             (let ((d dec) k found multiletter)
+             (let ((d dec)
+                   (fold-decomp t)
+                   k found)
                (while (and d (not found))
                  (setq k (pop d))
                  ;; Is k a number or letter, per unicode standard?
@@ -63,20 +65,30 @@ some).")
                    ;; because then we don't want the first letter to match
                    ;; the decomposition.
                    (dolist (k d)
-                     (when (memq (get-char-code-property k 'general-category)
-                                 '(Lu Ll Lt Lm Lo Nd Nl No))
-                       (setq multiletter t)))
+                     (when (and fold-decomp
+                                (memq (get-char-code-property k 
'general-category)
+                                      '(Lu Ll Lt Lm Lo Nd Nl No)))
+                       (setq fold-decomp nil)))
                  ;; If there's no number or letter on the
                  ;; decomposition, take the first character in it.
                  (setq found (car-safe dec)))
+               ;; Finally, we only fold multi-char decomposition if at
+               ;; least one of the chars is non-spacing (combining).
+               (when fold-decomp
+                 (setq fold-decomp nil)
+                 (dolist (k dec)
+                   (when (and (not fold-decomp)
+                              (> (get-char-code-property k 
'canonical-combining-class) 0))
+                     (setq fold-decomp t))))
                ;; Add i to the list of characters that k can
                ;; represent. Also possibly add its decomposition, so we can
                ;; match multi-char representations like (format "a%c" 769)
                (when (and found (not (eq i k)))
                  (let ((chars (cons (char-to-string i) (aref equiv k))))
                    (aset equiv k
-                         (if multiletter chars
-                           (cons (apply #'string dec) chars)))))))))
+                         (if fold-decomp
+                             (cons (apply #'string dec) chars)
+                           chars))))))))
        table)
 
       ;; Add some manual entries.



reply via email to

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