diff options
| author | Artur Malabarba | 2015-10-25 01:43:23 +0100 |
|---|---|---|
| committer | Artur Malabarba | 2015-10-25 01:11:59 +0000 |
| commit | f5f18f95d459a4031eda4b7f43a151e12a386338 (patch) | |
| tree | 5bc6c14154a2786733750c7f4bfd7d4a38434d47 | |
| parent | c5f9ccfce272e06be568182c2c088f628add4eaf (diff) | |
| download | emacs-f5f18f95d459a4031eda4b7f43a151e12a386338.tar.gz emacs-f5f18f95d459a4031eda4b7f43a151e12a386338.zip | |
* lisp/character-fold.el: Many improvements
(character-fold-search-forward, character-fold-search-backward):
New command
(character-fold-to-regexp): Remove lax-whitespace hack.
(character-fold-search): Remove variable. Only isearch and
query-replace use char-folding, and they both have their own
variables to configure that.
| -rw-r--r-- | lisp/character-fold.el | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/lisp/character-fold.el b/lisp/character-fold.el index 988a5065c0d..6b242f45f4e 100644 --- a/lisp/character-fold.el +++ b/lisp/character-fold.el | |||
| @@ -23,14 +23,6 @@ | |||
| 23 | ;;; Code: | 23 | ;;; Code: |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | ;;;###autoload | ||
| 27 | (defvar character-fold-search nil | ||
| 28 | "Non-nil if searches should fold similar characters. | ||
| 29 | This means some characters will match entire groups of characters. | ||
| 30 | For instance, \" will match all variants of double quotes, and | ||
| 31 | the letter a will match all of its accented versions (and then | ||
| 32 | some).") | ||
| 33 | |||
| 34 | (defconst character-fold-table | 26 | (defconst character-fold-table |
| 35 | (eval-when-compile | 27 | (eval-when-compile |
| 36 | (let* ((equiv (make-char-table 'character-fold-table)) | 28 | (let* ((equiv (make-char-table 'character-fold-table)) |
| @@ -110,21 +102,32 @@ some).") | |||
| 110 | "Used for folding characters of the same group during search.") | 102 | "Used for folding characters of the same group during search.") |
| 111 | 103 | ||
| 112 | ;;;###autoload | 104 | ;;;###autoload |
| 113 | (defun character-fold-to-regexp (string &optional lax) | 105 | (defun character-fold-to-regexp (string &optional _lax) |
| 114 | "Return a regexp matching anything that character-folds into STRING. | 106 | "Return a regexp matching anything that character-folds into STRING. |
| 115 | If `character-fold-search' is nil, `regexp-quote' string. | 107 | Any character in STRING that has an entry in |
| 116 | Otherwise, any character in STRING that has an entry in | ||
| 117 | `character-fold-table' is replaced with that entry (which is a | 108 | `character-fold-table' is replaced with that entry (which is a |
| 118 | regexp) and other characters are `regexp-quote'd. | 109 | regexp) and other characters are `regexp-quote'd." |
| 119 | If LAX is non-nil, any single whitespace character is allowed to | 110 | (apply #'concat |
| 120 | match any number of times." | 111 | (mapcar (lambda (c) (or (aref character-fold-table c) |
| 121 | (if character-fold-search | 112 | (regexp-quote (string c)))) |
| 122 | (apply #'concat | 113 | string))) |
| 123 | (mapcar (lambda (c) (if (and lax (memq c '(?\s ?\t ?\r ?\n))) | 114 | |
| 124 | "[ \t\n\r\xa0\x2002\x2d\x200a\x202f\x205f\x3000]+" | 115 | |
| 125 | (or (aref character-fold-table c) | 116 | ;;; Commands provided for completeness. |
| 126 | (regexp-quote (string c))))) | 117 | (defun character-fold-search-forward (string &optional bound noerror count) |
| 127 | string)) | 118 | "Search forward for a character-folded version of STRING. |
| 128 | (regexp-quote string))) | 119 | STRING is converted to a regexp with `character-fold-to-regexp', |
| 120 | which is searched for with `re-search-forward'. | ||
| 121 | BOUND NOERROR COUNT are passed to `re-search-forward'." | ||
| 122 | (interactive "sSearch: ") | ||
| 123 | (re-search-forward (character-fold-to-regexp string) bound noerror count)) | ||
| 124 | |||
| 125 | (defun character-fold-search-backward (string &optional bound noerror count) | ||
| 126 | "Search backward for a character-folded version of STRING. | ||
| 127 | STRING is converted to a regexp with `character-fold-to-regexp', | ||
| 128 | which is searched for with `re-search-backward'. | ||
| 129 | BOUND NOERROR COUNT are passed to `re-search-backward'." | ||
| 130 | (interactive "sSearch: ") | ||
| 131 | (re-search-backward (character-fold-to-regexp string) bound noerror count)) | ||
| 129 | 132 | ||
| 130 | ;;; character-fold.el ends here | 133 | ;;; character-fold.el ends here |