From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: Whitespace search and regex.c Date: Mon, 29 Nov 2004 01:12:20 -0500 Message-ID: References: <87y8gq9da4.fsf-monnier+emacs@gnu.org> <87wtw8tggj.fsf-monnier+emacs@gnu.org> Reply-To: rms@gnu.org NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1101709010 5993 80.91.229.6 (29 Nov 2004 06:16:50 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 29 Nov 2004 06:16:50 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 29 07:16:45 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CYeq4-0007gV-00 for ; Mon, 29 Nov 2004 07:16:44 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CYezR-0005tJ-RD for ged-emacs-devel@m.gmane.org; Mon, 29 Nov 2004 01:26:25 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CYexw-0004xM-5E for emacs-devel@gnu.org; Mon, 29 Nov 2004 01:24:52 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CYexu-0004wi-UP for emacs-devel@gnu.org; Mon, 29 Nov 2004 01:24:51 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CYexu-0004wA-Lo for emacs-devel@gnu.org; Mon, 29 Nov 2004 01:24:50 -0500 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CYeoE-0000Ey-V8 for emacs-devel@gnu.org; Mon, 29 Nov 2004 01:14:51 -0500 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.34) id 1CYelo-0002Px-9f; Mon, 29 Nov 2004 01:12:20 -0500 Original-To: Stefan Monnier In-reply-to: <87wtw8tggj.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Fri, 26 Nov 2004 17:12:25 -0500) 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:30476 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:30476 With your idea, I can solve the remaining problem in isearch.el. This change seems unproblematical. *** isearch.el 12 Oct 2004 04:45:09 -0400 1.242 --- isearch.el 28 Nov 2004 21:26:36 -0500 *************** *** 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. ! 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 :group 'isearch) --- 109,122 ---- :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 :group 'isearch) *************** *** 260,267 **** (define-key map "\r" 'isearch-exit) (define-key map "\C-j" 'isearch-printing-char) (define-key map "\t" 'isearch-printing-char) - (define-key map " " 'isearch-whitespace-chars) - (define-key map [?\S-\ ] 'isearch-whitespace-chars) (define-key map "\C-w" 'isearch-yank-word-or-char) (define-key map "\M-\C-w" 'isearch-del-char) --- 262,267 ---- *************** *** 485,491 **** 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))) --- 485,496 ---- 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))) *************** *** 1676,1686 **** ;; Assume character codes 0200 - 0377 stand for characters in some ;; single-byte character set, and convert them to Emacs ;; characters. ! (and enable-multibyte-characters ! (>= char ?\200) ! (<= char ?\377) ! (setq char (unibyte-char-to-multibyte char))) ! (isearch-process-search-char char))) (defun isearch-return-char () "Convert return into newline for incremental search. --- 1681,1699 ---- ;; Assume character codes 0200 - 0377 stand for characters in some ;; single-byte character set, and convert them to Emacs ;; characters. ! (if (and isearch-regexp (= char ?\ )) ! (if (condition-case err ! (progn ! (string-match isearch-string "") ! nil) ! (error (equal (cadr err) "Unmatched [ or [^"))) ! (isearch-process-search-char char) ! (isearch-process-search-string "[ ]" " ")) ! (and enable-multibyte-characters ! (>= char ?\200) ! (<= char ?\377) ! (setq char (unibyte-char-to-multibyte char))) ! (isearch-process-search-char char)))) (defun isearch-return-char () "Convert return into newline for incremental search. *************** *** 1704,1725 **** (isearch-process-search-multibyte-characters char) (isearch-process-search-char char))))) - (defun isearch-whitespace-chars () - "Match all whitespace chars, if in regexp mode. - If you want to search for just a space, type \\\\[isearch-quote-char] SPC." - (interactive) - (if isearch-regexp - (if (and search-whitespace-regexp (not isearch-within-brackets) - (not isearch-invalid-regexp)) - (isearch-process-search-string search-whitespace-regexp " ") - (isearch-printing-char)) - (progn - ;; This way of doing word search doesn't correctly extend current search. - ;; (setq isearch-word t) - ;; (setq isearch-adjusted t) - ;; (goto-char isearch-barrier) - (isearch-printing-char)))) - (defun isearch-process-search-char (char) ;; Append the char to the search string, update the message and re-search. (isearch-process-search-string --- 1717,1722 ---- *************** *** 1960,1965 **** --- 1957,1963 ---- (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) *************** *** 2373,2379 **** (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 --- 2371,2378 ---- (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