[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#10885: Replace expressions: enhance functionality when searching in
From: |
Juri Linkov |
Subject: |
bug#10885: Replace expressions: enhance functionality when searching in filled paragraphs |
Date: |
Tue, 28 Feb 2012 12:42:16 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (x86_64-pc-linux-gnu) |
>> Would it make sense for replace-regexp/query-replace-regexp (and
>> other commands that read regexps from the user) to respect
>> search-whitespace-regexp, just like isearch?
>
> Good question.
>
> Quote from the docstring of `isearch-forward-regexp':
>
> In regexp incremental searches, a space or spaces normally matches
> any whitespace (the variable `search-whitespace-regexp' controls
> precisely what that means). If you want to search for a literal space
> and nothing else, enter C-q SPC.
>
> Does anyone know why `query-replace-regexp' doesn't behave that way too?
>
> I think it should, i.e., `query-replace-regexp' should find the same
> matches that `isearch-forward-regexp' would find with the same search
> regexp.
Full agreement. This patch for 24.2 brings query-replace closer to isearch:
=== modified file 'lisp/replace.el'
--- lisp/replace.el 2012-02-24 22:46:57 +0000
+++ lisp/replace.el 2012-02-28 10:38:58 +0000
@@ -1752,6 +1752,7 @@ (defun perform-replace (from-string repl
(if (and case-fold-search search-upper-case)
(isearch-no-upper-case-p from-string regexp-flag)
case-fold-search))
+ (search-spaces-regexp (if regexp-flag search-whitespace-regexp))
(nocasify (not (and case-replace case-fold-search)))
(literal (or (not regexp-flag) (eq regexp-flag 'literal)))
(search-function
@@ -2117,9 +2115,8 @@ (defun replace-highlight (match-beg matc
(if query-replace-lazy-highlight
(let ((isearch-string string)
(isearch-regexp regexp)
- (search-whitespace-regexp nil)
(isearch-case-fold-search case-fold)
(isearch-forward t)
(isearch-error nil))
bug#10885: Replace expressions: enhance functionality when searching in filled paragraphs, linuxfever, 2012/02/26
bug#10885: Replace expressions: enhance functionality when searching in filled paragraphs, Dani Moncayo, 2012/02/26