aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorArtur Malabarba2015-11-28 15:31:43 +0000
committerArtur Malabarba2015-11-28 16:21:54 +0000
commit19141a9be607cf88641c8b90cf494cf5913de49f (patch)
tree052fab897ef5b38f0b1d1999389a4c7de88e0afe /lisp
parent5c5997002b0b0aded744d5828158243fd546b3ec (diff)
downloademacs-19141a9be607cf88641c8b90cf494cf5913de49f.tar.gz
emacs-19141a9be607cf88641c8b90cf494cf5913de49f.zip
* lisp/character-fold.el: Also play nice with case-folding
(character-fold-to-regexp): Take `case-fold-search' into account.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/character-fold.el30
1 files changed, 22 insertions, 8 deletions
diff --git a/lisp/character-fold.el b/lisp/character-fold.el
index 0086345cccb..49d75bd24ee 100644
--- a/lisp/character-fold.el
+++ b/lisp/character-fold.el
@@ -152,11 +152,13 @@ regexp) and other characters are `regexp-quote'd.
152 152
153FROM is for internal use. It specifies an index in the STRING 153FROM is for internal use. It specifies an index in the STRING
154from which to start." 154from which to start."
155 (let ((spaces 0) 155 (let* ((spaces 0)
156 (multi-char-table (char-table-extra-slot character-fold-table 0)) 156 (multi-char-table (char-table-extra-slot character-fold-table 0))
157 (i (or from 0)) 157 (lower-case-table (current-case-table))
158 (end (length string)) 158 (upper-case-table (char-table-extra-slot lower-case-table 0))
159 (out nil)) 159 (i (or from 0))
160 (end (length string))
161 (out nil))
160 ;; When the user types a space, we want to match the table entry 162 ;; When the user types a space, we want to match the table entry
161 ;; for ?\s, which is generally a regexp like "[ ...]". However, 163 ;; for ?\s, which is generally a regexp like "[ ...]". However,
162 ;; the `search-spaces-regexp' variable doesn't "see" spaces inside 164 ;; the `search-spaces-regexp' variable doesn't "see" spaces inside
@@ -173,9 +175,21 @@ from which to start."
173 (setq spaces 0)) 175 (setq spaces 0))
174 (let ((regexp (or (aref character-fold-table c) 176 (let ((regexp (or (aref character-fold-table c)
175 (regexp-quote (string c)))) 177 (regexp-quote (string c))))
176 ;; Long string. The regexp would probably be too long. 178 (alist nil))
177 (alist (unless (> end 60) 179 ;; Long string. The regexp would probably be too long.
178 (aref multi-char-table c)))) 180 (unless (> end 50)
181 (setq alist (aref multi-char-table c))
182 (when case-fold-search
183 (let ((other-c (aref lower-case-table c)))
184 (when (or (not other-c)
185 (eq other-c c))
186 (setq other-c (aref upper-case-table c)))
187 (when other-c
188 (setq alist (append alist (aref multi-char-table other-c)))
189 (setq regexp (concat "\\(?:" regexp "\\|"
190 (or (aref character-fold-table other-c)
191 (regexp-quote (string other-c)))
192 "\\)"))))))
179 (push (let ((alist-out '("\\)"))) 193 (push (let ((alist-out '("\\)")))
180 (pcase-dolist (`(,suffix . ,out-regexp) alist) 194 (pcase-dolist (`(,suffix . ,out-regexp) alist)
181 (let ((len-suf (length suffix))) 195 (let ((len-suf (length suffix)))