diff options
| author | Juri Linkov | 2012-05-17 03:03:49 +0300 |
|---|---|---|
| committer | Juri Linkov | 2012-05-17 03:03:49 +0300 |
| commit | a0a79cde7c978cf457c4a817b9a67bb4557f8a5c (patch) | |
| tree | b7097e44bfdde8e6596d5579c736a6eb4d3181c0 /lisp | |
| parent | 5ec546086a3f0ea5ad6ba2501dc4d84188e8b880 (diff) | |
| download | emacs-a0a79cde7c978cf457c4a817b9a67bb4557f8a5c.tar.gz emacs-a0a79cde7c978cf457c4a817b9a67bb4557f8a5c.zip | |
Move word search functions from search.c to isearch.el (bug#10145, bug#11381).
* lisp/isearch.el (word-search-regexp, word-search-backward)
(word-search-forward, word-search-backward-lax)
(word-search-forward-lax): Move functions from search.c.
* src/search.c (Fword_search_regexp, Fword_search_backward)
(Fword_search_forward, Fword_search_backward_lax)
(Fword_search_forward_lax): Move functions to isearch.el.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/isearch.el | 88 |
2 files changed, 95 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 60b238e79d1..b1d9323e481 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2012-05-17 Juri Linkov <juri@jurta.org> | ||
| 2 | |||
| 3 | * isearch.el (word-search-regexp, word-search-backward) | ||
| 4 | (word-search-forward, word-search-backward-lax) | ||
| 5 | (word-search-forward-lax): Move functions from search.c | ||
| 6 | (bug#10145, bug#11381). | ||
| 7 | |||
| 1 | 2012-05-16 Agustín Martín Domingo <agustin.martin@hispalinux.es> | 8 | 2012-05-16 Agustín Martín Domingo <agustin.martin@hispalinux.es> |
| 2 | 9 | ||
| 3 | * flyspell.el (flyspell-check-pre-word-p, flyspell-check-word-p) | 10 | * flyspell.el (flyspell-check-pre-word-p, flyspell-check-word-p) |
diff --git a/lisp/isearch.el b/lisp/isearch.el index 9d69443b6a4..7f68fb4ad32 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el | |||
| @@ -1381,6 +1381,94 @@ Use `isearch-exit' to quit without signaling." | |||
| 1381 | (sit-for 1) | 1381 | (sit-for 1) |
| 1382 | (isearch-update)) | 1382 | (isearch-update)) |
| 1383 | 1383 | ||
| 1384 | |||
| 1385 | ;; Word search | ||
| 1386 | |||
| 1387 | (defun word-search-regexp (string &optional lax) | ||
| 1388 | "Return a regexp which matches words, ignoring punctuation. | ||
| 1389 | Given STRING, a string of words separated by word delimiters, | ||
| 1390 | compute a regexp that matches those exact words separated by | ||
| 1391 | arbitrary punctuation. If LAX is non-nil, the end of the string | ||
| 1392 | need not match a word boundary unless it ends in whitespace. | ||
| 1393 | |||
| 1394 | Used in `word-search-forward', `word-search-backward', | ||
| 1395 | `word-search-forward-lax', `word-search-backward-lax'." | ||
| 1396 | (if (string-match-p "^\\W*$" string) | ||
| 1397 | "" | ||
| 1398 | (concat | ||
| 1399 | "\\b" | ||
| 1400 | (mapconcat 'identity (split-string string "\\W+" t) "\\W+") | ||
| 1401 | (if (or (not lax) (string-match-p "\\W$" string)) "\\b")))) | ||
| 1402 | |||
| 1403 | (defun word-search-backward (string &optional bound noerror count) | ||
| 1404 | "Search backward from point for STRING, ignoring differences in punctuation. | ||
| 1405 | Set point to the beginning of the occurrence found, and return point. | ||
| 1406 | An optional second argument bounds the search; it is a buffer position. | ||
| 1407 | The match found must not extend before that position. | ||
| 1408 | Optional third argument, if t, means if fail just return nil (no error). | ||
| 1409 | If not nil and not t, move to limit of search and return nil. | ||
| 1410 | Optional fourth argument is repeat count--search for successive occurrences. | ||
| 1411 | |||
| 1412 | Relies on the function `word-search-regexp' to convert a sequence | ||
| 1413 | of words in STRING to a regexp used to search words without regard | ||
| 1414 | to punctuation." | ||
| 1415 | (interactive "sWord search backward: ") | ||
| 1416 | (re-search-backward (word-search-regexp string nil) bound noerror count)) | ||
| 1417 | |||
| 1418 | (defun word-search-forward (string &optional bound noerror count) | ||
| 1419 | "Search forward from point for STRING, ignoring differences in punctuation. | ||
| 1420 | Set point to the end of the occurrence found, and return point. | ||
| 1421 | An optional second argument bounds the search; it is a buffer position. | ||
| 1422 | The match found must not extend after that position. | ||
| 1423 | Optional third argument, if t, means if fail just return nil (no error). | ||
| 1424 | If not nil and not t, move to limit of search and return nil. | ||
| 1425 | Optional fourth argument is repeat count--search for successive occurrences. | ||
| 1426 | |||
| 1427 | Relies on the function `word-search-regexp' to convert a sequence | ||
| 1428 | of words in STRING to a regexp used to search words without regard | ||
| 1429 | to punctuation." | ||
| 1430 | (interactive "sWord search: ") | ||
| 1431 | (re-search-forward (word-search-regexp string nil) bound noerror count)) | ||
| 1432 | |||
| 1433 | (defun word-search-backward-lax (string &optional bound noerror count) | ||
| 1434 | "Search backward from point for STRING, ignoring differences in punctuation. | ||
| 1435 | Set point to the beginning of the occurrence found, and return point. | ||
| 1436 | |||
| 1437 | Unlike `word-search-backward', the end of STRING need not match a word | ||
| 1438 | boundary, unless STRING ends in whitespace. | ||
| 1439 | |||
| 1440 | An optional second argument bounds the search; it is a buffer position. | ||
| 1441 | The match found must not extend before that position. | ||
| 1442 | Optional third argument, if t, means if fail just return nil (no error). | ||
| 1443 | If not nil and not t, move to limit of search and return nil. | ||
| 1444 | Optional fourth argument is repeat count--search for successive occurrences. | ||
| 1445 | |||
| 1446 | Relies on the function `word-search-regexp' to convert a sequence | ||
| 1447 | of words in STRING to a regexp used to search words without regard | ||
| 1448 | to punctuation." | ||
| 1449 | (interactive "sWord search backward: ") | ||
| 1450 | (re-search-backward (word-search-regexp string t) bound noerror count)) | ||
| 1451 | |||
| 1452 | (defun word-search-forward-lax (string &optional bound noerror count) | ||
| 1453 | "Search forward from point for STRING, ignoring differences in punctuation. | ||
| 1454 | Set point to the end of the occurrence found, and return point. | ||
| 1455 | |||
| 1456 | Unlike `word-search-forward', the end of STRING need not match a word | ||
| 1457 | boundary, unless STRING ends in whitespace. | ||
| 1458 | |||
| 1459 | An optional second argument bounds the search; it is a buffer position. | ||
| 1460 | The match found must not extend after that position. | ||
| 1461 | Optional third argument, if t, means if fail just return nil (no error). | ||
| 1462 | If not nil and not t, move to limit of search and return nil. | ||
| 1463 | Optional fourth argument is repeat count--search for successive occurrences. | ||
| 1464 | |||
| 1465 | Relies on the function `word-search-regexp' to convert a sequence | ||
| 1466 | of words in STRING to a regexp used to search words without regard | ||
| 1467 | to punctuation." | ||
| 1468 | (interactive "sWord search: ") | ||
| 1469 | (re-search-forward (word-search-regexp string t) bound noerror count)) | ||
| 1470 | |||
| 1471 | |||
| 1384 | (defun isearch-query-replace (&optional delimited regexp-flag) | 1472 | (defun isearch-query-replace (&optional delimited regexp-flag) |
| 1385 | "Start `query-replace' with string to replace from last search string. | 1473 | "Start `query-replace' with string to replace from last search string. |
| 1386 | The arg DELIMITED (prefix arg if interactive), if non-nil, means replace | 1474 | The arg DELIMITED (prefix arg if interactive), if non-nil, means replace |