bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#11381: 23.3; isearch-search-and-update issue?


From: Juri Linkov
Subject: bug#11381: 23.3; isearch-search-and-update issue?
Date: Sun, 27 May 2012 12:35:20 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (x86_64-pc-linux-gnu)

>> +               (if (eq isearch-word 'symbol-search-regexp)
>> +                   "symbol "
>
> Comparing two functions for equality is a bad idea.

Comparing two functions can be avoided by using properties
on function symbols like in the patch below.

The same solution of using symbol properties could be used also
for isearch filters to replace

             (and (eq isearch-filter-predicate 'isearch-filter-visible)
                  search-invisible))

with

             (and (symbolp isearch-filter-predicate)
                  (get isearch-filter-predicate 'visible)
                  search-invisible))
and
(put 'isearch-filter-visible 'visible t)

=== modified file 'lisp/isearch.el'
--- lisp/isearch.el     2012-05-17 00:03:49 +0000
+++ lisp/isearch.el     2012-05-27 09:34:07 +0000
@@ -1468,6 +1500,20 @@ (defun word-search-forward-lax (string &
   (interactive "sWord search: ")
   (re-search-forward (word-search-regexp string t) bound noerror count))
 
+;; Symbol search
+
+(defun symbol-search-regexp (string &optional lax)
+  "Return a regexp which matches STRING as a symbol.
+Creates a regexp where STRING is surrounded by symbol delimiters \\_< and \\_>.
+If LAX is non-nil, the end of the string need not match a symbol
+boundary unless it ends in whitespace."
+  (concat
+   "\\_<"
+   (regexp-quote string)
+   (if (or (not lax) (string-match-p "\\W$" string)) "\\_>")))
+
+(put 'symbol-search-regexp 'isearch-message-prefix "symbol ")
+
 
 (defun isearch-query-replace (&optional delimited regexp-flag)
   "Start `query-replace' with string to replace from last search string.
@@ -2329,7 +2428,11 @@ (defun isearch-message-prefix (&optional
                              (< (point) isearch-opoint)))
                       "over")
                   (if isearch-wrapped "wrapped ")
-                  (if isearch-word "word " "")
+                  (if isearch-word
+                      (or (and (symbolp isearch-word)
+                               (get isearch-word 'isearch-message-prefix))
+                          "word ")
+                    "")
                   (if isearch-regexp "regexp " "")
                   (if multi-isearch-next-buffer-current-function "multi " "")
                   (or isearch-message-prefix-add "")





reply via email to

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