From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#10885: Replace expressions: enhance functionality when searching in filled paragraphs Date: Fri, 07 Sep 2012 12:28:59 +0300 Organization: JURTA Message-ID: <87a9x25gh0.fsf@mail.jurta.org> References: <33392837.post@talk.nabble.com> <1oipiuxspa.fsf@fencepost.gnu.org> <87d38z1bp3.fsf@mail.jurta.org> <87linm79pc.fsf@mail.jurta.org> <8762ebbehj.fsf@mail.jurta.org> <87oblo21xe.fsf@mail.jurta.org> <87boho1wyz.fsf@mail.jurta.org> <87ligozwx1.fsf@mail.jurta.org> <87y5knpm4r.fsf@mail.jurta.org> <871uif3xjh.fsf@mail.jurta.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1347010928 8872 80.91.229.3 (7 Sep 2012 09:42:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Sep 2012 09:42:08 +0000 (UTC) Cc: 10885@debbugs.gnu.org To: Dani Moncayo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 07 11:42:08 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T9v4Z-0006RS-Mo for geb-bug-gnu-emacs@m.gmane.org; Fri, 07 Sep 2012 11:41:59 +0200 Original-Received: from localhost ([::1]:39116 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9v4T-0000zf-8r for geb-bug-gnu-emacs@m.gmane.org; Fri, 07 Sep 2012 05:41:53 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9v4N-0000sq-B3 for bug-gnu-emacs@gnu.org; Fri, 07 Sep 2012 05:41:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T9v4M-0005Oq-2c for bug-gnu-emacs@gnu.org; Fri, 07 Sep 2012 05:41:47 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35919) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9v4L-0005Ol-Vq for bug-gnu-emacs@gnu.org; Fri, 07 Sep 2012 05:41:46 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1T9v4c-0003aR-Fk for bug-gnu-emacs@gnu.org; Fri, 07 Sep 2012 05:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 07 Sep 2012 09:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10885 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10885-submit@debbugs.gnu.org id=B10885.134701088513738 (code B ref 10885); Fri, 07 Sep 2012 09:42:02 +0000 Original-Received: (at 10885) by debbugs.gnu.org; 7 Sep 2012 09:41:25 +0000 Original-Received: from localhost ([127.0.0.1]:45463 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9v40-0003ZV-LN for submit@debbugs.gnu.org; Fri, 07 Sep 2012 05:41:25 -0400 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:58450 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9v3x-0003ZI-IJ for 10885@debbugs.gnu.org; Fri, 07 Sep 2012 05:41:23 -0400 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id F3C87451CC5E; Fri, 7 Sep 2012 02:41:02 -0700 (PDT) In-Reply-To: (Dani Moncayo's message of "Fri, 7 Sep 2012 10:33:19 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:63891 Archived-At: > I think replace-regexp-lax-whitespace is needed while the Isearch > counterpart (isearch-regexp-lax-whitespace) exists, if you want to > support the option I was asking for, whereby the lax-whitespace > settings in query-replace[-regexp] are "connected" (or "redirected") > to the Isearch counterparts. > > And IMO this option is important, for a consistent user-experience. The reason why replace-regexp-lax-whitespace is important to have is not just for consistency but because replace-lax-whitespace should not affect regexp replacements. But currently its value applies to regexp replacements because it depends on calls from isearch that has a separate variable for regexp that starts a lax-whitespace regexp replacement to replace the same regexp matches as in isearch. So actually a lax-whitespace regexp replacement feature exists in replace.el implicitly. A clean way to fix this problem is to add a new option replace-regexp-lax-whitespace: === modified file 'lisp/replace.el' --- lisp/replace.el 2012-09-06 09:12:16 +0000 +++ lisp/replace.el 2012-09-07 09:27:35 +0000 @@ -35,7 +35,15 @@ (defcustom case-replace t (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, +When you enter a space or spaces in the strings to be replaced, +it will match any sequence matched by the regexp `search-whitespace-regexp'." + :type 'boolean + :group 'matching + :version "24.3") + +(defcustom replace-regexp-lax-whitespace nil + "Non-nil means `query-replace-regexp' matches a sequence of whitespace chars. +When you enter a space or spaces in the regexps to be replaced, it will match any sequence matched by the regexp `search-whitespace-regexp'." :type 'boolean :group 'matching @@ -282,7 +290,7 @@ (defun query-replace-regexp (regexp to-s 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 +If `replace-regexp-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'. @@ -362,7 +370,7 @@ (defun query-replace-regexp-eval (regexp 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 +If `replace-regexp-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'. @@ -499,7 +507,7 @@ (defun replace-regexp (regexp to-string 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 +If `replace-regexp-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'. @@ -1790,9 +1798,9 @@ (defun perform-replace (from-string repl (let ((isearch-regexp regexp-flag) (isearch-word delimited-flag) (isearch-lax-whitespace - (and replace-lax-whitespace (not regexp-flag))) + replace-lax-whitespace) (isearch-regexp-lax-whitespace - (and replace-lax-whitespace regexp-flag)) + replace-regexp-lax-whitespace) (isearch-case-fold-search case-fold-search) (isearch-forward t)) (isearch-search-fun)))) @@ -2151,9 +2159,9 @@ (defun replace-highlight (match-beg matc (isearch-regexp regexp-flag) (isearch-word delimited-flag) (isearch-lax-whitespace - (and replace-lax-whitespace (not regexp-flag))) + replace-lax-whitespace) (isearch-regexp-lax-whitespace - (and replace-lax-whitespace regexp-flag)) + replace-regexp-lax-whitespace) (isearch-case-fold-search case-fold-search) (isearch-forward t) (isearch-error nil)) === modified file 'lisp/isearch.el' --- lisp/isearch.el 2012-09-06 09:12:16 +0000 +++ lisp/isearch.el 2012-09-07 09:27:42 +0000 @@ -1613,10 +1613,9 @@ (defun isearch-query-replace (&optional ;; `isearch-no-upper-case-p' in `perform-replace' (search-upper-case nil) (replace-lax-whitespace - (and search-whitespace-regexp - (if isearch-regexp - isearch-regexp-lax-whitespace - isearch-lax-whitespace))) + isearch-lax-whitespace) + (replace-regexp-lax-whitespace + isearch-regexp-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.