diff options
| author | Artur Malabarba | 2015-07-05 16:44:22 +0100 |
|---|---|---|
| committer | Artur Malabarba | 2015-07-05 16:45:58 +0100 |
| commit | 5516728eac58aba87a39427b7a3d1bfb8e2a19d0 (patch) | |
| tree | 8dd0bfce218180836b4a43fa148d82e4649fff75 | |
| parent | 1323c13978b7280ddf034e8f527f48d17487b5a2 (diff) | |
| download | emacs-5516728eac58aba87a39427b7a3d1bfb8e2a19d0.tar.gz emacs-5516728eac58aba87a39427b7a3d1bfb8e2a19d0.zip | |
* lisp/character-fold.el (character-fold-table):
Only fold decompositions if at least one character is non-spacing.
(Bug#20975)
| -rw-r--r-- | 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 fca13bf96c1..bf5ae59f41a 100644 --- a/lisp/character-fold.el +++ b/lisp/character-fold.el | |||
| @@ -52,7 +52,9 @@ some).") | |||
| 52 | ;; Skip trivial cases like ?a decomposing to (?a). | 52 | ;; Skip trivial cases like ?a decomposing to (?a). |
| 53 | (unless (or (and (eq i (car dec)) | 53 | (unless (or (and (eq i (car dec)) |
| 54 | (not (cdr dec)))) | 54 | (not (cdr dec)))) |
| 55 | (let ((d dec) k found multiletter) | 55 | (let ((d dec) |
| 56 | (fold-decomp t) | ||
| 57 | k found) | ||
| 56 | (while (and d (not found)) | 58 | (while (and d (not found)) |
| 57 | (setq k (pop d)) | 59 | (setq k (pop d)) |
| 58 | ;; Is k a number or letter, per unicode standard? | 60 | ;; Is k a number or letter, per unicode standard? |
| @@ -63,20 +65,30 @@ some).") | |||
| 63 | ;; because then we don't want the first letter to match | 65 | ;; because then we don't want the first letter to match |
| 64 | ;; the decomposition. | 66 | ;; the decomposition. |
| 65 | (dolist (k d) | 67 | (dolist (k d) |
| 66 | (when (memq (get-char-code-property k 'general-category) | 68 | (when (and fold-decomp |
| 67 | '(Lu Ll Lt Lm Lo Nd Nl No)) | 69 | (memq (get-char-code-property k 'general-category) |
| 68 | (setq multiletter t))) | 70 | '(Lu Ll Lt Lm Lo Nd Nl No))) |
| 71 | (setq fold-decomp nil))) | ||
| 69 | ;; If there's no number or letter on the | 72 | ;; If there's no number or letter on the |
| 70 | ;; decomposition, take the first character in it. | 73 | ;; decomposition, take the first character in it. |
| 71 | (setq found (car-safe dec))) | 74 | (setq found (car-safe dec))) |
| 75 | ;; Finally, we only fold multi-char decomposition if at | ||
| 76 | ;; least one of the chars is non-spacing (combining). | ||
| 77 | (when fold-decomp | ||
| 78 | (setq fold-decomp nil) | ||
| 79 | (dolist (k dec) | ||
| 80 | (when (and (not fold-decomp) | ||
| 81 | (> (get-char-code-property k 'canonical-combining-class) 0)) | ||
| 82 | (setq fold-decomp t)))) | ||
| 72 | ;; Add i to the list of characters that k can | 83 | ;; Add i to the list of characters that k can |
| 73 | ;; represent. Also possibly add its decomposition, so we can | 84 | ;; represent. Also possibly add its decomposition, so we can |
| 74 | ;; match multi-char representations like (format "a%c" 769) | 85 | ;; match multi-char representations like (format "a%c" 769) |
| 75 | (when (and found (not (eq i k))) | 86 | (when (and found (not (eq i k))) |
| 76 | (let ((chars (cons (char-to-string i) (aref equiv k)))) | 87 | (let ((chars (cons (char-to-string i) (aref equiv k)))) |
| 77 | (aset equiv k | 88 | (aset equiv k |
| 78 | (if multiletter chars | 89 | (if fold-decomp |
| 79 | (cons (apply #'string dec) chars))))))))) | 90 | (cons (apply #'string dec) chars) |
| 91 | chars)))))))) | ||
| 80 | table) | 92 | table) |
| 81 | 93 | ||
| 82 | ;; Add some manual entries. | 94 | ;; Add some manual entries. |