diff options
| author | Noam Postavsky | 2019-06-21 07:09:44 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2019-06-25 22:00:03 -0400 |
| commit | 648fdbbcec159e6bfdb7cd06d32c59e8a17a055e (patch) | |
| tree | 49296e3df33421b1b086eb4e5d2912a20fcb2093 | |
| parent | b59ffd2290ff744ca4e7cc2748ba6b66fb2f99f1 (diff) | |
| download | emacs-648fdbbcec159e6bfdb7cd06d32c59e8a17a055e.tar.gz emacs-648fdbbcec159e6bfdb7cd06d32c59e8a17a055e.zip | |
Don't bind search-spaces-regexp around possible autoload (Bug#35802)
* lisp/isearch.el (isearch-search-fun-default): Move possible autoload
trigger outside let-binding of search-spaces-regexp.
* lisp/char-fold.el (char-fold-make-table): Remove no longer needed
workaround.
* lisp/info.el (Info-search-whitespace-regexp):
* lisp/isearch.el (search-whitespace-regexp):
* src/search.c (syms_of_search) <search-spaces-regexp>: Add warning
about adding capturing groups to the value.
* test/lisp/char-fold-tests.el: Remove, binding search-spaces-regexp
to a different should be considered a bug.
| -rw-r--r-- | lisp/char-fold.el | 1 | ||||
| -rw-r--r-- | lisp/info.el | 4 | ||||
| -rw-r--r-- | lisp/isearch.el | 44 | ||||
| -rw-r--r-- | src/search.c | 4 | ||||
| -rw-r--r-- | test/lisp/char-fold-tests.el | 8 |
5 files changed, 32 insertions, 29 deletions
diff --git a/lisp/char-fold.el b/lisp/char-fold.el index d2fa7108bbd..7223ecf738c 100644 --- a/lisp/char-fold.el +++ b/lisp/char-fold.el | |||
| @@ -28,7 +28,6 @@ | |||
| 28 | (defun char-fold-make-table () | 28 | (defun char-fold-make-table () |
| 29 | (let* ((equiv (make-char-table 'char-fold-table)) | 29 | (let* ((equiv (make-char-table 'char-fold-table)) |
| 30 | (equiv-multi (make-char-table 'char-fold-table)) | 30 | (equiv-multi (make-char-table 'char-fold-table)) |
| 31 | (search-spaces-regexp nil) ; workaround for bug#35802 | ||
| 32 | (table (unicode-property-table-internal 'decomposition))) | 31 | (table (unicode-property-table-internal 'decomposition))) |
| 33 | (set-char-table-extra-slot equiv 0 equiv-multi) | 32 | (set-char-table-extra-slot equiv 0 equiv-multi) |
| 34 | 33 | ||
diff --git a/lisp/info.el b/lisp/info.el index f65c6c36272..8e8c3371f42 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -349,7 +349,9 @@ This only has an effect if `Info-hide-note-references' is non-nil." | |||
| 349 | This applies to Info search for regular expressions. | 349 | This applies to Info search for regular expressions. |
| 350 | You might want to use something like \"[ \\t\\r\\n]+\" instead. | 350 | You might want to use something like \"[ \\t\\r\\n]+\" instead. |
| 351 | In the Customization buffer, that is `[' followed by a space, | 351 | In the Customization buffer, that is `[' followed by a space, |
| 352 | a tab, a carriage return (control-M), a newline, and `]+'." | 352 | a tab, a carriage return (control-M), a newline, and `]+'. Don't |
| 353 | add any capturing groups into this value; that can change the | ||
| 354 | numbering of existing capture groups in unexpected ways." | ||
| 353 | :type 'regexp | 355 | :type 'regexp |
| 354 | :group 'info) | 356 | :group 'info) |
| 355 | 357 | ||
diff --git a/lisp/isearch.el b/lisp/isearch.el index bb29c2914be..f150a3bba4b 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el | |||
| @@ -129,8 +129,10 @@ regexp incremental search. If the value is nil, or | |||
| 129 | then each space you type matches literally, against one space. | 129 | then each space you type matches literally, against one space. |
| 130 | 130 | ||
| 131 | You might want to use something like \"[ \\t\\r\\n]+\" instead. | 131 | You might want to use something like \"[ \\t\\r\\n]+\" instead. |
| 132 | In the Customization buffer, that is `[' followed by a space, | 132 | In the Customization buffer, that is `[' followed by a space, a |
| 133 | a tab, a carriage return (control-M), a newline, and `]+'." | 133 | tab, a carriage return (control-M), a newline, and `]+'. Don't |
| 134 | add any capturing groups into this value; that can change the | ||
| 135 | numbering of existing capture groups in unexpected ways." | ||
| 134 | :type '(choice (const :tag "Match Spaces Literally" nil) | 136 | :type '(choice (const :tag "Match Spaces Literally" nil) |
| 135 | regexp) | 137 | regexp) |
| 136 | :version "24.3") | 138 | :version "24.3") |
| @@ -3263,25 +3265,31 @@ Can be changed via `isearch-search-fun-function' for special needs." | |||
| 3263 | (defun isearch-search-fun-default () | 3265 | (defun isearch-search-fun-default () |
| 3264 | "Return default functions to use for the search." | 3266 | "Return default functions to use for the search." |
| 3265 | (lambda (string &optional bound noerror count) | 3267 | (lambda (string &optional bound noerror count) |
| 3266 | ;; Use lax versions to not fail at the end of the word while | 3268 | (let (;; Evaluate this before binding `search-spaces-regexp' which |
| 3267 | ;; the user adds and removes characters in the search string | 3269 | ;; can break all sorts of regexp searches. In particular, |
| 3268 | ;; (or when using nonincremental word isearch) | 3270 | ;; calling `isearch-regexp-function' can trigger autoloading |
| 3269 | (let ((search-spaces-regexp (when (cond | 3271 | ;; (Bug#35802). |
| 3270 | (isearch-regexp isearch-regexp-lax-whitespace) | 3272 | (regexp |
| 3271 | (t isearch-lax-whitespace)) | 3273 | (cond (isearch-regexp-function |
| 3274 | (let ((lax (and (not bound) | ||
| 3275 | (isearch--lax-regexp-function-p)))) | ||
| 3276 | (when lax | ||
| 3277 | (setq isearch-adjusted t)) | ||
| 3278 | (if (functionp isearch-regexp-function) | ||
| 3279 | (funcall isearch-regexp-function string lax) | ||
| 3280 | (word-search-regexp string lax)))) | ||
| 3281 | (isearch-regexp string) | ||
| 3282 | (t (regexp-quote string)))) | ||
| 3283 | ;; Use lax versions to not fail at the end of the word while | ||
| 3284 | ;; the user adds and removes characters in the search string | ||
| 3285 | ;; (or when using nonincremental word isearch) | ||
| 3286 | (search-spaces-regexp (when (if isearch-regexp | ||
| 3287 | isearch-regexp-lax-whitespace | ||
| 3288 | isearch-lax-whitespace) | ||
| 3272 | search-whitespace-regexp))) | 3289 | search-whitespace-regexp))) |
| 3273 | (funcall | 3290 | (funcall |
| 3274 | (if isearch-forward #'re-search-forward #'re-search-backward) | 3291 | (if isearch-forward #'re-search-forward #'re-search-backward) |
| 3275 | (cond (isearch-regexp-function | 3292 | regexp bound noerror count)))) |
| 3276 | (let ((lax (and (not bound) (isearch--lax-regexp-function-p)))) | ||
| 3277 | (when lax | ||
| 3278 | (setq isearch-adjusted t)) | ||
| 3279 | (if (functionp isearch-regexp-function) | ||
| 3280 | (funcall isearch-regexp-function string lax) | ||
| 3281 | (word-search-regexp string lax)))) | ||
| 3282 | (isearch-regexp string) | ||
| 3283 | (t (regexp-quote string))) | ||
| 3284 | bound noerror count)))) | ||
| 3285 | 3293 | ||
| 3286 | (defun isearch-search-string (string bound noerror) | 3294 | (defun isearch-search-string (string bound noerror) |
| 3287 | "Search for the first occurrence of STRING or its translation. | 3295 | "Search for the first occurrence of STRING or its translation. |
diff --git a/src/search.c b/src/search.c index 8a0f707b723..fa574959fb4 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -3390,7 +3390,9 @@ syms_of_search (void) | |||
| 3390 | Some commands use this for user-specified regexps. | 3390 | Some commands use this for user-specified regexps. |
| 3391 | Spaces that occur inside character classes or repetition operators | 3391 | Spaces that occur inside character classes or repetition operators |
| 3392 | or other such regexp constructs are not replaced with this. | 3392 | or other such regexp constructs are not replaced with this. |
| 3393 | A value of nil (which is the normal value) means treat spaces literally. */); | 3393 | A value of nil (which is the normal value) means treat spaces |
| 3394 | literally. Note that a value with capturing groups can change the | ||
| 3395 | numbering of existing capture groups in unexpected ways. */); | ||
| 3394 | Vsearch_spaces_regexp = Qnil; | 3396 | Vsearch_spaces_regexp = Qnil; |
| 3395 | 3397 | ||
| 3396 | DEFSYM (Qinhibit_changing_match_data, "inhibit-changing-match-data"); | 3398 | DEFSYM (Qinhibit_changing_match_data, "inhibit-changing-match-data"); |
diff --git a/test/lisp/char-fold-tests.el b/test/lisp/char-fold-tests.el index 8a7414084b0..3fde312a133 100644 --- a/test/lisp/char-fold-tests.el +++ b/test/lisp/char-fold-tests.el | |||
| @@ -124,13 +124,5 @@ | |||
| 124 | ;; Ensure it took less than a second. | 124 | ;; Ensure it took less than a second. |
| 125 | (should (< (- (time-to-seconds) time) 1)))))) | 125 | (should (< (- (time-to-seconds) time) 1)))))) |
| 126 | 126 | ||
| 127 | (ert-deftest char-fold--test-bug-35802 () | ||
| 128 | (let* ((char-code-property-alist ; initial value | ||
| 129 | (cons '(decomposition . "uni-decomposition.el") | ||
| 130 | char-code-property-alist)) | ||
| 131 | (search-spaces-regexp "\\(\\s-\\|\n\\)+") | ||
| 132 | (char-fold-table (char-fold-make-table))) | ||
| 133 | (char-fold--test-match-exactly "ä" "ä"))) | ||
| 134 | |||
| 135 | (provide 'char-fold-tests) | 127 | (provide 'char-fold-tests) |
| 136 | ;;; char-fold-tests.el ends here | 128 | ;;; char-fold-tests.el ends here |