emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r106575: Change `wordify' to `word-se


From: Juri Linkov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r106575: Change `wordify' to `word-search-regexp'.
Date: Fri, 02 Dec 2011 12:19:49 +0200
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 106575
fixes bug(s): http://debbugs.gnu.org/10145
committer: Juri Linkov <address@hidden>
branch nick: trunk
timestamp: Fri 2011-12-02 12:19:49 +0200
message:
  Change `wordify' to `word-search-regexp'.
  
  * lisp/isearch.el (isearch-occur): Use `word-search-regexp' for
  `isearch-word'.
  (isearch-search-and-update): Add condition for `isearch-word' and
  call `word-search-regexp'. 
  
  * src/search.c (Fword_search_regexp): New Lisp function created from
  `wordify'.  Change type of arg `lax' from `int' to `Lisp_Object'.
  (Fword_search_backward, Fword_search_forward)
  (Fword_search_backward_lax, Fword_search_forward_lax):
  Use `Fword_search_regexp' instead of `wordify'.  Doc fix.
  (syms_of_search): Define `Sword_search_regexp'.
modified:
  lisp/ChangeLog
  lisp/isearch.el
  src/ChangeLog
  src/search.c
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-12-01 22:34:24 +0000
+++ b/lisp/ChangeLog    2011-12-02 10:19:49 +0000
@@ -1,3 +1,10 @@
+2011-12-02  Juri Linkov  <address@hidden>
+
+       * isearch.el (isearch-occur): Use `word-search-regexp' for
+       `isearch-word'.
+       (isearch-search-and-update): Add condition for `isearch-word' and
+       call `word-search-regexp'.  (Bug#10145)
+
 2011-12-01  Glenn Morris  <address@hidden>
 
        * eshell/em-hist.el (eshell-hist-initialize):

=== modified file 'lisp/isearch.el'
--- a/lisp/isearch.el   2011-11-29 18:39:16 +0000
+++ b/lisp/isearch.el   2011-12-02 10:19:49 +0000
@@ -1438,12 +1438,7 @@
   (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 (word-search-regexp isearch-string))
      (isearch-regexp isearch-string)
      (t (regexp-quote isearch-string)))
     (if current-prefix-arg (prefix-numeric-value current-prefix-arg))))
@@ -1642,8 +1637,10 @@
                   (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-word (word-search-regexp 
isearch-string t))
+                               (isearch-regexp isearch-string)
+                               (t (regexp-quote isearch-string)))))
               (error nil))
             (or isearch-yank-flag
                 (<= (match-end 0)

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2011-12-01 20:19:38 +0000
+++ b/src/ChangeLog     2011-12-02 10:19:49 +0000
@@ -1,3 +1,12 @@
+2011-12-02  Juri Linkov  <address@hidden>
+
+       * search.c (Fword_search_regexp): New Lisp function created from
+       `wordify'.  Change type of arg `lax' from `int' to `Lisp_Object'.
+       (Fword_search_backward, Fword_search_forward)
+       (Fword_search_backward_lax, Fword_search_forward_lax):
+       Use `Fword_search_regexp' instead of `wordify'.  Doc fix.
+       (syms_of_search): Define `Sword_search_regexp'.  (Bug#10145)
+
 2011-12-01  Stefan Monnier  <address@hidden>
 
        * fileio.c (Finsert_file_contents): Move after-change-function call

=== modified file 'src/search.c'
--- a/src/search.c      2011-11-27 18:17:40 +0000
+++ b/src/search.c      2011-12-02 10:19:49 +0000
@@ -83,11 +83,10 @@
    Qnil if no searching has been done yet.  */
 static Lisp_Object last_thing_searched;
 
-/* error condition signaled when regexp compile_pattern fails */
-
+/* Error condition signaled when regexp compile_pattern fails.  */
 static Lisp_Object Qinvalid_regexp;
 
-/* Error condition used for failing searches */
+/* Error condition used for failing searches.  */
 static Lisp_Object Qsearch_failed;
 
 static void set_search_regs (EMACS_INT, EMACS_INT);
@@ -2078,13 +2077,16 @@
   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.  */
+DEFUN ("word-search-regexp", Fword_search_regexp, Sword_search_regexp, 1, 2, 0,
+       doc: /* Return a regexp which matches words, ignoring punctuation.
+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.
 
-static Lisp_Object
-wordify (Lisp_Object string, int lax)
+Used in `word-search-forward', `word-search-backward',
+`word-search-forward-lax', `word-search-backward-lax'.  */)
+  (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 +2127,7 @@
     }
 
   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 +2164,7 @@
       prev_c = c;
     }
 
-  if (!lax || whitespace_at_end)
+  if (NILP (lax) || whitespace_at_end)
     {
       *o++ = '\\';
       *o++ = 'b';
@@ -2217,10 +2219,14 @@
 The match found must not extend before that position.
 Optional third argument, if t, means if fail just return nil (no error).
   If not nil and not t, move to limit of search and return nil.
-Optional fourth argument is repeat count--search for successive occurrences.  
*/)
+Optional fourth argument is repeat count--search for successive occurrences.
+
+Relies on the function `word-search-regexp' to convert a sequence
+of words in STRING to a regexp used to search words without regard
+to punctuation.  */)
   (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 (Fword_search_regexp (string, Qnil), bound, noerror, 
count, -1, 1, 0);
 }
 
 DEFUN ("word-search-forward", Fword_search_forward, Sword_search_forward, 1, 4,
@@ -2231,10 +2237,14 @@
 The match found must not extend after that position.
 Optional third argument, if t, means if fail just return nil (no error).
   If not nil and not t, move to limit of search and return nil.
-Optional fourth argument is repeat count--search for successive occurrences.  
*/)
+Optional fourth argument is repeat count--search for successive occurrences.
+
+Relies on the function `word-search-regexp' to convert a sequence
+of words in STRING to a regexp used to search words without regard
+to punctuation.  */)
   (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 (Fword_search_regexp (string, Qnil), bound, noerror, 
count, 1, 1, 0);
 }
 
 DEFUN ("word-search-backward-lax", Fword_search_backward_lax, 
Sword_search_backward_lax, 1, 4,
@@ -2249,10 +2259,14 @@
 The match found must not extend before that position.
 Optional third argument, if t, means if fail just return nil (no error).
   If not nil and not t, move to limit of search and return nil.
-Optional fourth argument is repeat count--search for successive occurrences.  
*/)
+Optional fourth argument is repeat count--search for successive occurrences.
+
+Relies on the function `word-search-regexp' to convert a sequence
+of words in STRING to a regexp used to search words without regard
+to punctuation.  */)
   (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 (Fword_search_regexp (string, Qt), bound, noerror, 
count, -1, 1, 0);
 }
 
 DEFUN ("word-search-forward-lax", Fword_search_forward_lax, 
Sword_search_forward_lax, 1, 4,
@@ -2267,10 +2281,14 @@
 The match found must not extend after that position.
 Optional third argument, if t, means if fail just return nil (no error).
   If not nil and not t, move to limit of search and return nil.
-Optional fourth argument is repeat count--search for successive occurrences.  
*/)
+Optional fourth argument is repeat count--search for successive occurrences.
+
+Relies on the function `word-search-regexp' to convert a sequence
+of words in STRING to a regexp used to search words without regard
+to punctuation.  */)
   (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 (Fword_search_regexp (string, Qt), bound, noerror, 
count, 1, 1, 0);
 }
 
 DEFUN ("re-search-backward", Fre_search_backward, Sre_search_backward, 1, 4,
@@ -3229,6 +3247,7 @@
   defsubr (&Sposix_string_match);
   defsubr (&Ssearch_forward);
   defsubr (&Ssearch_backward);
+  defsubr (&Sword_search_regexp);
   defsubr (&Sword_search_forward);
   defsubr (&Sword_search_backward);
   defsubr (&Sword_search_forward_lax);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]