+2012-09-06 Juri Linkov <juri@jurta.org>
+
+ * replace.el (replace-lax-whitespace): New defcustom.
+ (query-replace, query-replace-regexp, query-replace-regexp-eval)
+ (replace-string, replace-regexp): Mention it in docstrings.
+ (perform-replace, replace-highlight): Let-bind
+ isearch-lax-whitespace and isearch-regexp-lax-whitespace according
+ to the values of replace-lax-whitespace and regexp-flag.
+ Don't let-bind search-whitespace-regexp. (Bug#10885)
+
+ * isearch.el (isearch-query-replace): Let-bind
+ replace-lax-whitespace instead of let-binding
+ replace-search-function and replace-re-search-function.
+ (isearch-lazy-highlight-search): Let-bind isearch-lax-whitespace
+ and isearch-regexp-lax-whitespace to lazy-highlight variables.
+ (isearch-toggle-symbol): Set isearch-regexp to nil
+ in isearch-word mode (like in isearch-toggle-word).
+
2012-09-06 Juri Linkov <juri@jurta.org>
* replace.el (replace-search-function)
(interactive)
(setq isearch-word (unless (eq isearch-word 'isearch-symbol-regexp)
'isearch-symbol-regexp))
+ (if isearch-word (setq isearch-regexp nil))
(setq isearch-success t isearch-adjusted t)
(isearch-update))
;; set `search-upper-case' to nil to not call
;; `isearch-no-upper-case-p' in `perform-replace'
(search-upper-case nil)
- (replace-search-function
- (if (and isearch-lax-whitespace (not regexp-flag))
- #'search-forward-lax-whitespace
- replace-search-function))
- (replace-re-search-function
- (if (and isearch-regexp-lax-whitespace regexp-flag)
- #'re-search-forward-lax-whitespace
- replace-re-search-function))
+ (replace-lax-whitespace
+ (and search-whitespace-regexp
+ (if isearch-regexp
+ isearch-regexp-lax-whitespace
+ isearch-lax-whitespace)))
;; Set `isearch-recursive-edit' to nil to prevent calling
;; `exit-recursive-edit' in `isearch-done' that terminates
;; the execution of this command when it is non-nil.
(let ((case-fold-search isearch-lazy-highlight-case-fold-search)
(isearch-regexp isearch-lazy-highlight-regexp)
(isearch-word isearch-lazy-highlight-word)
+ (isearch-lax-whitespace
+ isearch-lazy-highlight-lax-whitespace)
+ (isearch-regexp-lax-whitespace
+ isearch-lazy-highlight-regexp-lax-whitespace)
+ (isearch-forward isearch-lazy-highlight-forward)
(search-invisible nil) ; don't match invisible text
(retry t)
(success nil)
- (isearch-forward isearch-lazy-highlight-forward)
(bound (if isearch-lazy-highlight-forward
(min (or isearch-lazy-highlight-end-limit (point-max))
(if isearch-lazy-highlight-wrapped
:type 'boolean
:group 'matching)
+(defcustom replace-lax-whitespace nil
+ "Non-nil means `query-replace' matches a sequence of whitespace chars.
+When you enter a space or spaces in the strings or regexps to be replaced,
+it will match any sequence matched by the regexp `search-whitespace-regexp'."
+ :type 'boolean
+ :group 'matching
+ :version "24.3")
+
(defvar query-replace-history nil
"Default history list for query-replace commands.
See `query-replace-from-history-variable' and
matched is all caps, or capitalized, then its replacement is upcased
or capitalized.)
+If `replace-lax-whitespace' is non-nil, a space or spaces in the string
+to be replaced will match a sequence of whitespace chars defined by the
+regexp in `search-whitespace-regexp'.
+
Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace
only matches surrounded by word boundaries.
Fourth and fifth arg START and END specify the region to operate on.
all caps, or capitalized, then its replacement is upcased or
capitalized.)
+If `replace-lax-whitespace' is non-nil, a space or spaces in the regexp
+to be replaced will match a sequence of whitespace chars defined by the
+regexp in `search-whitespace-regexp'.
+
Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace
only matches surrounded by word boundaries.
Fourth and fifth arg START and END specify the region to operate on.
Preserves case in each replacement if `case-replace' and `case-fold-search'
are non-nil and REGEXP has no uppercase letters.
+If `replace-lax-whitespace' is non-nil, a space or spaces in the regexp
+to be replaced will match a sequence of whitespace chars defined by the
+regexp in `search-whitespace-regexp'.
+
Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace
only matches that are surrounded by word boundaries.
Fourth and fifth arg START and END specify the region to operate on."
\(Preserving case means that if the string matched is all caps, or capitalized,
then its replacement is upcased or capitalized.)
+If `replace-lax-whitespace' is non-nil, a space or spaces in the string
+to be replaced will match a sequence of whitespace chars defined by the
+regexp in `search-whitespace-regexp'.
+
In Transient Mark mode, if the mark is active, operate on the contents
of the region. Otherwise, operate from point to the end of the buffer.
Preserve case in each match if `case-replace' and `case-fold-search'
are non-nil and REGEXP has no uppercase letters.
+If `replace-lax-whitespace' is non-nil, a space or spaces in the regexp
+to be replaced will match a sequence of whitespace chars defined by the
+regexp in `search-whitespace-regexp'.
+
In Transient Mark mode, if the mark is active, operate on the contents
of the region. Otherwise, operate from point to the end of the buffer.
replace-search-function)
(let ((isearch-regexp regexp-flag)
(isearch-word delimited-flag)
+ (isearch-lax-whitespace
+ (and replace-lax-whitespace (not regexp-flag)))
+ (isearch-regexp-lax-whitespace
+ (and replace-lax-whitespace regexp-flag))
(isearch-case-fold-search case-fold-search)
(isearch-forward t))
(isearch-search-fun))))
(let ((isearch-string search-string)
(isearch-regexp regexp-flag)
(isearch-word delimited-flag)
- (search-whitespace-regexp nil)
+ (isearch-lax-whitespace
+ (and replace-lax-whitespace (not regexp-flag)))
+ (isearch-regexp-lax-whitespace
+ (and replace-lax-whitespace regexp-flag))
(isearch-case-fold-search case-fold-search)
(isearch-forward t)
(isearch-error nil))