GNU bug report logs - #11381
23.3; isearch-search-and-update issue?

Previous Next

Package: emacs;

Reported by: Andy Grover <andy <at> groveronline.com>

Date: Sun, 29 Apr 2012 23:00:02 UTC

Severity: wishlist

Found in version 23.3

Done: Chong Yidong <cyd <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #38 received at 11381 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 11381 <at> debbugs.gnu.org
Subject: Re: bug#11381: 23.3; isearch-search-and-update issue?
Date: Sun, 27 May 2012 12:35:20 +0300
>> +		   (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 "")




This bug report was last modified 12 years and 205 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.