aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJuri Linkov2013-06-14 00:49:10 +0300
committerJuri Linkov2013-06-14 00:49:10 +0300
commita22289f7ab658767b2f586aa1f1f794b1470df95 (patch)
treef475873ede54bd64998be620e5fe6ba462a0b518 /lisp
parentcb89acab6cdfa418d1d14ad3200712e1dd406673 (diff)
downloademacs-a22289f7ab658767b2f586aa1f1f794b1470df95.tar.gz
emacs-a22289f7ab658767b2f586aa1f1f794b1470df95.zip
* lisp/isearch.el (word-search-regexp): Match whitespace if the search
string begins or ends in whitespace. The LAX arg is applied to both ends of the search string. Use `regexp-quote' and explicit \< and \> instead of \b. Use \` and \' instead of ^ and $. (isearch-symbol-regexp): Sync with `word-search-regexp' where word boundaries are replaced with symbol boundaries, and characters between symbols match non-word non-symbol syntax. Fixes: debbugs:14602
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/isearch.el41
2 files changed, 41 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f21f6e4b068..5327ce12e7b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,15 @@
12013-06-13 Juri Linkov <juri@jurta.org> 12013-06-13 Juri Linkov <juri@jurta.org>
2 2
3 * isearch.el (word-search-regexp): Match whitespace if the search
4 string begins or ends in whitespace. The LAX arg is applied to
5 both ends of the search string. Use `regexp-quote' and explicit
6 \< and \> instead of \b. Use \` and \' instead of ^ and $.
7 (isearch-symbol-regexp): Sync with `word-search-regexp' where word
8 boundaries are replaced with symbol boundaries, and characters
9 between symbols match non-word non-symbol syntax. (Bug#14602)
10
112013-06-13 Juri Linkov <juri@jurta.org>
12
3 * isearch.el (isearch-del-char): Don't exceed the length of 13 * isearch.el (isearch-del-char): Don't exceed the length of
4 `isearch-string' by the prefix arg. (Bug#14563) 14 `isearch-string' by the prefix arg. (Bug#14563)
5 15
diff --git a/lisp/isearch.el b/lisp/isearch.el
index ddb5ba9331c..37070ba6f51 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1540,17 +1540,22 @@ nil and a non-nil value of the option `search-invisible'
1540 "Return a regexp which matches words, ignoring punctuation. 1540 "Return a regexp which matches words, ignoring punctuation.
1541Given STRING, a string of words separated by word delimiters, 1541Given STRING, a string of words separated by word delimiters,
1542compute a regexp that matches those exact words separated by 1542compute a regexp that matches those exact words separated by
1543arbitrary punctuation. If LAX is non-nil, the end of the string 1543arbitrary punctuation. If the string begins or ends in whitespace,
1544need not match a word boundary unless it ends in whitespace. 1544the beginning or the end of the string matches arbitrary whitespace.
1545Otherwise if LAX is non-nil, the beginning or the end of the string
1546need not match a word boundary.
1545 1547
1546Used in `word-search-forward', `word-search-backward', 1548Used in `word-search-forward', `word-search-backward',
1547`word-search-forward-lax', `word-search-backward-lax'." 1549`word-search-forward-lax', `word-search-backward-lax'."
1548 (if (string-match-p "^\\W*$" string) 1550 (cond
1549 "" 1551 ((equal string "") "")
1550 (concat 1552 ((string-match-p "\\`\\W+\\'" string) "\\W+")
1551 "\\b" 1553 (t (concat
1552 (mapconcat 'identity (split-string string "\\W+" t) "\\W+") 1554 (if (string-match-p "\\`\\W" string) "\\W+"
1553 (if (or (not lax) (string-match-p "\\W$" string)) "\\b")))) 1555 (unless lax "\\<"))
1556 (mapconcat 'regexp-quote (split-string string "\\W+" t) "\\W+")
1557 (if (string-match-p "\\W\\'" string) "\\W+"
1558 (unless lax "\\>"))))))
1554 1559
1555(defun word-search-backward (string &optional bound noerror count) 1560(defun word-search-backward (string &optional bound noerror count)
1556 "Search backward from point for STRING, ignoring differences in punctuation. 1561 "Search backward from point for STRING, ignoring differences in punctuation.
@@ -1625,8 +1630,24 @@ to punctuation."
1625(defun isearch-symbol-regexp (string &optional lax) 1630(defun isearch-symbol-regexp (string &optional lax)
1626 "Return a regexp which matches STRING as a symbol. 1631 "Return a regexp which matches STRING as a symbol.
1627Creates a regexp where STRING is surrounded by symbol delimiters \\_< and \\_>. 1632Creates a regexp where STRING is surrounded by symbol delimiters \\_< and \\_>.
1628If LAX is non-nil, the end of the string need not match a symbol boundary." 1633If there are more than one symbol, then compute a regexp that matches
1629 (concat "\\_<" (regexp-quote string) (unless lax "\\_>"))) 1634those exact symbols separated by non-symbol characters. If the string
1635begins or ends in whitespace, the beginning or the end of the string
1636matches arbitrary non-symbol whitespace. Otherwise if LAX is non-nil,
1637the beginning or the end of the string need not match a symbol boundary."
1638 (let ((not-word-symbol-re
1639 ;; This regexp matches all syntaxes except word and symbol syntax.
1640 ;; FIXME: Replace it with something shorter if possible (bug#14602).
1641 "\\(?:\\s-\\|\\s.\\|\\s(\\|\\s)\\|\\s\"\\|\\s\\\\|\\s/\\|\\s$\\|\\s'\\|\\s<\\|\\s>\\|\\s@\\|\\s!\\|\\s|\\)+"))
1642 (cond
1643 ((equal string "") "")
1644 ((string-match-p (format "\\`%s\\'" not-word-symbol-re) string) not-word-symbol-re)
1645 (t (concat
1646 (if (string-match-p (format "\\`%s" not-word-symbol-re) string) not-word-symbol-re
1647 (unless lax "\\_<"))
1648 (mapconcat 'regexp-quote (split-string string not-word-symbol-re t) not-word-symbol-re)
1649 (if (string-match-p (format "%s\\'" not-word-symbol-re) string) not-word-symbol-re
1650 (unless lax "\\_>")))))))
1630 1651
1631(put 'isearch-symbol-regexp 'isearch-message-prefix "symbol ") 1652(put 'isearch-symbol-regexp 'isearch-message-prefix "symbol ")
1632 1653