[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 648fdbb 2/6: Don't bind search-spaces-regexp around
From: |
Noam Postavsky |
Subject: |
[Emacs-diffs] master 648fdbb 2/6: Don't bind search-spaces-regexp around possible autoload (Bug#35802) |
Date: |
Tue, 25 Jun 2019 22:06:54 -0400 (EDT) |
branch: master
commit 648fdbbcec159e6bfdb7cd06d32c59e8a17a055e
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
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.
---
lisp/char-fold.el | 1 -
lisp/info.el | 4 +++-
lisp/isearch.el | 44 ++++++++++++++++++++++++++------------------
src/search.c | 4 +++-
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 d2fa710..7223ecf 100644
--- a/lisp/char-fold.el
+++ b/lisp/char-fold.el
@@ -28,7 +28,6 @@
(defun char-fold-make-table ()
(let* ((equiv (make-char-table 'char-fold-table))
(equiv-multi (make-char-table 'char-fold-table))
- (search-spaces-regexp nil) ; workaround for bug#35802
(table (unicode-property-table-internal 'decomposition)))
(set-char-table-extra-slot equiv 0 equiv-multi)
diff --git a/lisp/info.el b/lisp/info.el
index f65c6c3..8e8c337 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."
This applies to Info search for regular expressions.
You might want to use something like \"[ \\t\\r\\n]+\" instead.
In the Customization buffer, that is `[' followed by a space,
-a tab, a carriage return (control-M), a newline, and `]+'."
+a tab, a carriage return (control-M), a newline, and `]+'. Don't
+add any capturing groups into this value; that can change the
+numbering of existing capture groups in unexpected ways."
:type 'regexp
:group 'info)
diff --git a/lisp/isearch.el b/lisp/isearch.el
index bb29c29..f150a3b 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -129,8 +129,10 @@ regexp incremental search. If the value is nil, or
then each space you type matches literally, against one space.
You might want to use something like \"[ \\t\\r\\n]+\" instead.
-In the Customization buffer, that is `[' followed by a space,
-a tab, a carriage return (control-M), a newline, and `]+'."
+In the Customization buffer, that is `[' followed by a space, a
+tab, a carriage return (control-M), a newline, and `]+'. Don't
+add any capturing groups into this value; that can change the
+numbering of existing capture groups in unexpected ways."
:type '(choice (const :tag "Match Spaces Literally" nil)
regexp)
:version "24.3")
@@ -3263,25 +3265,31 @@ Can be changed via `isearch-search-fun-function' for
special needs."
(defun isearch-search-fun-default ()
"Return default functions to use for the search."
(lambda (string &optional bound noerror count)
- ;; Use lax versions to not fail at the end of the word while
- ;; the user adds and removes characters in the search string
- ;; (or when using nonincremental word isearch)
- (let ((search-spaces-regexp (when (cond
- (isearch-regexp
isearch-regexp-lax-whitespace)
- (t isearch-lax-whitespace))
+ (let (;; Evaluate this before binding `search-spaces-regexp' which
+ ;; can break all sorts of regexp searches. In particular,
+ ;; calling `isearch-regexp-function' can trigger autoloading
+ ;; (Bug#35802).
+ (regexp
+ (cond (isearch-regexp-function
+ (let ((lax (and (not bound)
+ (isearch--lax-regexp-function-p))))
+ (when lax
+ (setq isearch-adjusted t))
+ (if (functionp isearch-regexp-function)
+ (funcall isearch-regexp-function string lax)
+ (word-search-regexp string lax))))
+ (isearch-regexp string)
+ (t (regexp-quote string))))
+ ;; Use lax versions to not fail at the end of the word while
+ ;; the user adds and removes characters in the search string
+ ;; (or when using nonincremental word isearch)
+ (search-spaces-regexp (when (if isearch-regexp
+ isearch-regexp-lax-whitespace
+ isearch-lax-whitespace)
search-whitespace-regexp)))
(funcall
(if isearch-forward #'re-search-forward #'re-search-backward)
- (cond (isearch-regexp-function
- (let ((lax (and (not bound) (isearch--lax-regexp-function-p))))
- (when lax
- (setq isearch-adjusted t))
- (if (functionp isearch-regexp-function)
- (funcall isearch-regexp-function string lax)
- (word-search-regexp string lax))))
- (isearch-regexp string)
- (t (regexp-quote string)))
- bound noerror count))))
+ regexp bound noerror count))))
(defun isearch-search-string (string bound noerror)
"Search for the first occurrence of STRING or its translation.
diff --git a/src/search.c b/src/search.c
index 8a0f707..fa57495 100644
--- a/src/search.c
+++ b/src/search.c
@@ -3390,7 +3390,9 @@ syms_of_search (void)
Some commands use this for user-specified regexps.
Spaces that occur inside character classes or repetition operators
or other such regexp constructs are not replaced with this.
-A value of nil (which is the normal value) means treat spaces literally. */);
+A value of nil (which is the normal value) means treat spaces
+literally. Note that a value with capturing groups can change the
+numbering of existing capture groups in unexpected ways. */);
Vsearch_spaces_regexp = Qnil;
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 8a74140..3fde312 100644
--- a/test/lisp/char-fold-tests.el
+++ b/test/lisp/char-fold-tests.el
@@ -124,13 +124,5 @@
;; Ensure it took less than a second.
(should (< (- (time-to-seconds) time) 1))))))
-(ert-deftest char-fold--test-bug-35802 ()
- (let* ((char-code-property-alist ; initial value
- (cons '(decomposition . "uni-decomposition.el")
- char-code-property-alist))
- (search-spaces-regexp "\\(\\s-\\|\n\\)+")
- (char-fold-table (char-fold-make-table)))
- (char-fold--test-match-exactly "ä" "ä")))
-
(provide 'char-fold-tests)
;;; char-fold-tests.el ends here
- [Emacs-diffs] master updated (29babad -> 9552ee4), Noam Postavsky, 2019/06/25
- [Emacs-diffs] master 66aa770 4/6: Merge from emacs-26, Noam Postavsky, 2019/06/25
- [Emacs-diffs] master c7a59d8 5/6: ; Merge from emacs-26, Noam Postavsky, 2019/06/25
- [Emacs-diffs] master 648fdbb 2/6: Don't bind search-spaces-regexp around possible autoload (Bug#35802),
Noam Postavsky <=
- [Emacs-diffs] master ab9e58b 3/6: ; Merge from emacs-26, Noam Postavsky, 2019/06/25
- [Emacs-diffs] master b59ffd2 1/6: Support (rx (and (regexp EXPR) (literal EXPR))) (Bug#36237), Noam Postavsky, 2019/06/25
- [Emacs-diffs] master 9552ee4 6/6: Merge from emacs-26, Noam Postavsky, 2019/06/25