From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Chong Yidong" Newsgroups: gmane.emacs.devel Subject: search-whitespace-regexp Date: Fri, 4 Feb 2005 09:12:33 -0500 (EST) Message-ID: <1982.220.255.95.17.1107526353.squirrel@220.255.95.17> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1107526565 12652 80.91.229.6 (4 Feb 2005 14:16:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 4 Feb 2005 14:16:05 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 04 15:15:58 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Cx4Fa-0005c3-00 for ; Fri, 04 Feb 2005 15:15:58 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Cx4T7-0004TY-Ew for ged-emacs-devel@m.gmane.org; Fri, 04 Feb 2005 09:29:57 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Cx4Qh-0003m7-1C for emacs-devel@gnu.org; Fri, 04 Feb 2005 09:27:27 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Cx4QN-0003dx-6v for emacs-devel@gnu.org; Fri, 04 Feb 2005 09:27:11 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Cx4QM-0003cr-5a for emacs-devel@gnu.org; Fri, 04 Feb 2005 09:27:06 -0500 Original-Received: from [64.21.80.18] (helo=shark.dnsvelocity.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1Cx4CP-0004HC-FG for emacs-devel@gnu.org; Fri, 04 Feb 2005 09:12:41 -0500 Original-Received: from stupidch by shark.dnsvelocity.com with local (Exim 4.43) id 1Cx4CH-0000tM-De for emacs-devel@gnu.org; Fri, 04 Feb 2005 09:12:33 -0500 Original-Received: from 220.255.95.17 ([220.255.95.17]) (SquirrelMail authenticated user cyd@stupidchicken.com); by www.stupidchicken.com with HTTP; Fri, 4 Feb 2005 09:12:33 -0500 (EST) Original-To: emacs-devel@gnu.org User-Agent: SquirrelMail/1.4.3a X-Mailer: SquirrelMail/1.4.3a X-Priority: 3 (Normal) Importance: Normal X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - shark.dnsvelocity.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [32675 33085] / [47 12] X-AntiAbuse: Sender Address Domain - shark.dnsvelocity.com X-Source: /usr/local/cpanel/3rdparty/bin/php X-Source-Args: /usr/local/cpanel/3rdparty/bin/php /usr/local/cpanel/base/3rdparty/squirrelmail/src/compose.php X-Source-Dir: stupidchicken.com:/base/3rdparty/squirrelmail/src X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:32870 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:32870 CVS Emacs has a variable, search-whitespace-regexp, which is a regexp that replaces any space or spaces entered into isearch-forward-regexp. Setting this variable to "[ \t\r\n]+" provides incremental searching across line breaks, which is a commonly requested feature. However, I believe that using search-whitespace-regexp in isearch-forward-regexp is a misfeature. It should instead be used for isearch-forward. When a user calls isearch-forward-regexp, he probably knows the precise expression he wants, and how to craft a regular expression to find it. In certain situations, it might be a nuisance for Emacs to silently tamper with the regular expression he supplies. The search-whitespace-regexp feature is more appropriate for "casual" incremental searching. New users, in particular, do not expect isearch to be foiled by line breaks. However, telling them to set search-whitespace-regexp and use isearch-forward-regexp instead is not a good solution, because commonly-used characters such as "." have a special meaning in regexps. The solution is to apply the search-whitespace-regexp behavior to isearch-forward, rather than isearch-forward-regexp. The following patch accomplishes this *** isearch.el~ Fri Feb 4 19:33:15 2005 --- isearch.el Fri Feb 4 21:59:13 2005 *************** *** 109,120 **** :type 'boolean :group 'isearch) ! (defcustom search-whitespace-regexp "\\s-+" "*If non-nil, regular expression to match a sequence of whitespace chars. ! This applies to regular expression incremental search. ! When you put a space or spaces in the incremental regexp, it stands for ! this, unless it is inside of a regexp construct such as [...] or *, + or ?. ! 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 `]+'." :type 'regexp --- 109,119 ---- :type 'boolean :group 'isearch) ! (defcustom search-whitespace-regexp nil "*If non-nil, regular expression to match a sequence of whitespace chars. ! This applies to incremental search. When you put a space or ! spaces in the incremental search string, it stands for this. ! You might want to use something like \"[ \\t\\r\\n]+\". In the Customization buffer, that is `[' followed by a space, a tab, a carriage return (control-M), a newline, and `]+'." :type 'regexp *************** *** 573,584 **** Do incremental search forward for regular expression. With a prefix argument, do a regular string search instead. Like ordinary incremental search except that your input ! is treated as a regexp. See \\[isearch-forward] for more info. ! ! 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 `[ ]'." (interactive "P\np") (isearch-mode t (null not-regexp) nil (not no-recursive-edit))) --- 572,578 ---- Do incremental search forward for regular expression. With a prefix argument, do a regular string search instead. Like ordinary incremental search except that your input ! is treated as a regexp. See \\[isearch-forward] for more info." (interactive "P\np") (isearch-mode t (null not-regexp) nil (not no-recursive-edit))) *************** *** 2029,2035 **** (isearch-regexp (if isearch-forward 're-search-forward 're-search-backward)) (t ! (if isearch-forward 'search-forward 'search-backward))))) (defun isearch-search () ;; Do the search with the current search string. --- 2023,2043 ---- (isearch-regexp (if isearch-forward 're-search-forward 're-search-backward)) (t ! (if isearch-forward 'isearch-search-forward 'isearch-search-backward))))) ! ! (defun isearch-search-forward (string &optional bound noerror count) ! (re-search-forward ! (if search-whitespace-regexp ! (replace-regexp-in-string " +" search-whitespace-regexp string) ! string) ! bound noerror count)) ! ! (defun isearch-search-backward (string &optional bound noerror count) ! (re-search-backward ! (if search-whitespace-regexp ! (replace-regexp-in-string " +" search-whitespace-regexp string) ! string) ! bound noerror count)) (defun isearch-search () ;; Do the search with the current search string. *************** *** 2041,2047 **** (let ((inhibit-point-motion-hooks search-invisible) (inhibit-quit nil) (case-fold-search isearch-case-fold-search) - (search-spaces-regexp search-whitespace-regexp) (retry t)) (if isearch-regexp (setq isearch-invalid-regexp nil)) (setq isearch-within-brackets nil) --- 2049,2054 ---- *************** *** 2377,2384 **** (defun isearch-lazy-highlight-search () "Search ahead for the next or previous match, for lazy highlighting. Attempt to do the search exactly the way the pending isearch would." ! (let ((case-fold-search isearch-case-fold-search) ! (search-spaces-regexp search-whitespace-regexp)) (funcall (isearch-search-fun) isearch-string (if isearch-forward --- 2384,2390 ---- (defun isearch-lazy-highlight-search () "Search ahead for the next or previous match, for lazy highlighting. Attempt to do the search exactly the way the pending isearch would." ! (let ((case-fold-search isearch-case-fold-search)) (funcall (isearch-search-fun) isearch-string (if isearch-forward