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#10145: 24.0.91; Word Isearch backward Date: Tue, 29 Nov 2011 02:33:06 +0200 Organization: JURTA Message-ID: <87k46jyd79.fsf@mail.jurta.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1322527459 30665 80.91.229.12 (29 Nov 2011 00:44:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 29 Nov 2011 00:44:19 +0000 (UTC) Cc: 10145@debbugs.gnu.org To: Dani Moncayo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 29 01:44:13 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RVBnw-0002Fy-Sf for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Nov 2011 01:44:13 +0100 Original-Received: from localhost ([::1]:51414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RVBnw-0002sH-9o for geb-bug-gnu-emacs@m.gmane.org; Mon, 28 Nov 2011 19:44:12 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:60131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RVBns-0002qN-U1 for bug-gnu-emacs@gnu.org; Mon, 28 Nov 2011 19:44:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RVBnq-0005VI-Gk for bug-gnu-emacs@gnu.org; Mon, 28 Nov 2011 19:44:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42435) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RVBnq-0005Uw-F6 for bug-gnu-emacs@gnu.org; Mon, 28 Nov 2011 19:44:06 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RVBpi-00046F-Ee for bug-gnu-emacs@gnu.org; Mon, 28 Nov 2011 19:46:02 -0500 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: Tue, 29 Nov 2011 00:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10145 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10145-submit@debbugs.gnu.org id=B10145.132252753315713 (code B ref 10145); Tue, 29 Nov 2011 00:46:02 +0000 Original-Received: (at 10145) by debbugs.gnu.org; 29 Nov 2011 00:45:33 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RVBpE-00045N-Iz for submit@debbugs.gnu.org; Mon, 28 Nov 2011 19:45:33 -0500 Original-Received: from smarty.dreamhost.com ([208.113.175.8]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RVBpA-00045C-Qv for 10145@debbugs.gnu.org; Mon, 28 Nov 2011 19:45:30 -0500 Original-Received: from ps18281.dreamhostps.com (ps18281.dreamhost.com [69.163.218.105]) by smarty.dreamhost.com (Postfix) with ESMTP id 2F2226E809E; Mon, 28 Nov 2011 16:43:31 -0800 (PST) Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id F07A3451C66B; Mon, 28 Nov 2011 16:43:19 -0800 (PST) In-Reply-To: (Dani Moncayo's message of "Sat, 26 Nov 2011 21:26:58 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 28 Nov 2011 19:46:02 -0500 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:54391 Archived-At: > from "emacs -Q", type: `a a RET b b RET M-s w C-r a a SPC b b'. > > At this point, the Isearch (word-type, backward) should succeed, but I > see a failing one. Thanks, this is a bug. The comment in `isearch-search-and-update' says: ;; In reverse search, adding stuff at ;; the end may cause zero or many more chars to be ;; matched, in the string following point. ;; Allow all those possibilities without moving point as ;; long as the match does not extend past search origin. and it calls `looking-at' to implement this. But it doesn't take into account word search. The following patch fixes this bug by using `wordify' now exposed to Lisp: === modified file 'lisp/isearch.el' --- lisp/isearch.el 2011-11-28 06:59:03 +0000 +++ lisp/isearch.el 2011-11-29 00:30:33 +0000 @@ -1648,8 +1643,10 @@ (defun isearch-search-and-update () (if (and (eq case-fold-search t) search-upper-case) (setq case-fold-search (isearch-no-upper-case-p isearch-string isearch-regexp))) - (looking-at (if isearch-regexp isearch-string - (regexp-quote isearch-string)))) + (looking-at (cond + (isearch-regexp isearch-string) + (isearch-word (wordify isearch-string t)) + (t (regexp-quote isearch-string))))) (error nil)) (or isearch-yank-flag (<= (match-end 0) === modified file 'src/search.c' --- src/search.c 2011-11-27 18:17:40 +0000 +++ src/search.c 2011-11-29 00:29:22 +0000 @@ -2078,13 +2078,12 @@ (at your option) any later version. XSETBUFFER (last_thing_searched, current_buffer); } -/* Given STRING, a string of words separated by word delimiters, - compute a regexp that matches those exact words separated by - arbitrary punctuation. If LAX is nonzero, the end of the string - need not match a word boundary unless it ends in whitespace. */ - -static Lisp_Object -wordify (Lisp_Object string, int lax) +DEFUN ("wordify", Fwordify, Swordify, 1, 2, 0, + doc: /* Given STRING, a string of words separated by word delimiters, +compute a regexp that matches those exact words separated by +arbitrary punctuation. If LAX is non-nil, the end of the string +need not match a word boundary unless it ends in whitespace. */) + (Lisp_Object string, Lisp_Object lax) { register unsigned char *o; register EMACS_INT i, i_byte, len, punct_count = 0, word_count = 0; @@ -2125,7 +2124,7 @@ (at your option) any later version. } adjust = - punct_count + 5 * (word_count - 1) - + ((lax && !whitespace_at_end) ? 2 : 4); + + ((!NILP (lax) && !whitespace_at_end) ? 2 : 4); if (STRING_MULTIBYTE (string)) val = make_uninit_multibyte_string (len + adjust, SBYTES (string) @@ -2162,7 +2161,7 @@ (at your option) any later version. prev_c = c; } - if (!lax || whitespace_at_end) + if (NILP (lax) || whitespace_at_end) { *o++ = '\\'; *o++ = 'b'; @@ -2220,7 +2219,7 @@ (at your option) any later version. Optional fourth argument is repeat count--search for successive occurrences. */) (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { - return search_command (wordify (string, 0), bound, noerror, count, -1, 1, 0); + return search_command (Fwordify (string, Qnil), bound, noerror, count, -1, 1, 0); } DEFUN ("word-search-forward", Fword_search_forward, Sword_search_forward, 1, 4, @@ -2234,7 +2233,7 @@ (at your option) any later version. Optional fourth argument is repeat count--search for successive occurrences. */) (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { - return search_command (wordify (string, 0), bound, noerror, count, 1, 1, 0); + return search_command (Fwordify (string, Qnil), bound, noerror, count, 1, 1, 0); } DEFUN ("word-search-backward-lax", Fword_search_backward_lax, Sword_search_backward_lax, 1, 4, @@ -2252,7 +2251,7 @@ (at your option) any later version. Optional fourth argument is repeat count--search for successive occurrences. */) (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { - return search_command (wordify (string, 1), bound, noerror, count, -1, 1, 0); + return search_command (Fwordify (string, Qt), bound, noerror, count, -1, 1, 0); } DEFUN ("word-search-forward-lax", Fword_search_forward_lax, Sword_search_forward_lax, 1, 4, @@ -2270,7 +2269,7 @@ (at your option) any later version. Optional fourth argument is repeat count--search for successive occurrences. */) (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { - return search_command (wordify (string, 1), bound, noerror, count, 1, 1, 0); + return search_command (Fwordify (string, Qt), bound, noerror, count, 1, 1, 0); } DEFUN ("re-search-backward", Fre_search_backward, Sre_search_backward, 1, 4, @@ -3229,6 +3228,7 @@ (at your option) any later version. defsubr (&Sposix_string_match); defsubr (&Ssearch_forward); defsubr (&Ssearch_backward); + defsubr (&Swordify); defsubr (&Sword_search_forward); defsubr (&Sword_search_backward); defsubr (&Sword_search_forward_lax); Actually there are more places that require the Lisp call to `wordify' like in `isearch-occur': === modified file 'lisp/isearch.el' --- lisp/isearch.el 2011-11-28 06:59:03 +0000 +++ lisp/isearch.el 2011-11-29 00:30:33 +0000 @@ -1447,12 +1447,7 @@ (defun isearch-occur (regexp &optional n (interactive (list (cond - (isearch-word (concat "\\b" (replace-regexp-in-string - "\\W+" "\\W+" - (replace-regexp-in-string - "^\\W+\\|\\W+$" "" isearch-string) - nil t) - "\\b")) + (isearch-word (wordify isearch-string)) (isearch-regexp isearch-string) (t (regexp-quote isearch-string))) (if current-prefix-arg (prefix-numeric-value current-prefix-arg))))