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

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

[PATCH] isearch-pass-comments


From: Andreas Roehler
Subject: [PATCH] isearch-pass-comments
Date: Tue, 22 Dec 2009 16:35:28 +0100
User-agent: Thunderbird 2.0.0.19 (X11/20081227)

Hi,

occasionally it's been asked for a way not to stop inside
comments while isearch.

Herewith a patch against isearch.el.  Introduced a
customizable variable `isearch-pass-comments', which
toggles the behaviour.

Tested with GNU Emacs 23.1.50.1 (i686-pc-linux-gnu, GTK+ Version 2.12.0)

XEmacs-users: a resp. patch has been sent to address@hidden

Enjoy!

Andreas

--
https://code.launchpad.net/s-x-emacs-werkstatt/
http://bazaar.launchpad.net/~a-roehler/python-mode/python-mode.el/


--- MY-PATH/emacs/lisp/isearch.el       2009-10-01 04:17:41.000000000 +0200
+++ MY-PATH/progarbeit/emacs/veraendert/isearch.el      2009-12-22 
16:26:53.000000000 +0100
@@ -75,6 +75,11 @@
   :type 'boolean
   :group 'isearch)
 
+(defcustom isearch-pass-comments t
+  "Non-nil means isearch will not stop inside a comment. "
+  :type 'boolean
+  :group 'isearch)
+
 (defcustom search-slow-window-lines 1
   "Number of lines in slow search display windows.
 These are the short windows used during incremental search on slow terminals.
@@ -2250,6 +2255,12 @@
       (goto-char pos1)
       pos1)))
 
+(setq inside-comment-function
+      (if (functionp 'in-comment-p-lor)
+          '(in-comment-p-lor)
+        '(let ((state (parse-partial-sexp (point-min) (point)))) 
+           (or (nth 4 state) (nth 7 state)(nth 8 state)))))
+
 (defun isearch-search ()
   ;; Do the search with the current search string.
   (if isearch-message-function
@@ -2268,8 +2279,13 @@
            (retry t))
        (setq isearch-error nil)
        (while retry
-         (setq isearch-success
-               (isearch-search-string isearch-string nil t))
+          (if isearch-pass-comments
+              (lexical-let ((erg (isearch-search-string isearch-string nil t)))
+                (while
+                    (and erg (eval inside-comment-function))
+                  (setq erg (isearch-search-string isearch-string nil t)))
+                (setq isearch-success erg))
+            (setq isearch-success (isearch-search-string isearch-string nil 
t)))
          ;; Clear RETRY unless the search predicate says
          ;; to skip this search hit.
          (if (or (not isearch-success)

reply via email to

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