changeset 60714:438b974e257c

(ispell-lazy-highlight): New defcustom. (ispell-highlight-face): Set default face to `isearch' when lazy highlighting is enabled. (ispell-highlight-spelling-error-overlay): Set `ispell-overlay' priority to 1. Add lazy highlighting. (ispell-highlight-spelling-error-xemacs): Remove obsolete arg from `isearch-dehighlight'.
author Juri Linkov <juri@jurta.org>
date Fri, 18 Mar 2005 10:00:03 +0000
parents 77391bae98f1
children 7ccba703d1ac
files lisp/textmodes/ispell.el
diffstat 1 files changed, 28 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/ispell.el	Fri Mar 18 09:59:45 2005 +0000
+++ b/lisp/textmodes/ispell.el	Fri Mar 18 10:00:03 2005 +0000
@@ -238,7 +238,17 @@
   :type '(choice (const block) (const :tag "off" nil) (const :tag "on" t))
   :group 'ispell)
 
-(defcustom ispell-highlight-face 'highlight
+(defcustom ispell-lazy-highlight (boundp 'lazy-highlight-cleanup)
+  "*Controls the lazy-highlighting of spelling errors.
+When non-nil, all text in the buffer matching the current spelling
+error is highlighted lazily using isearch lazy highlighting (see
+`lazy-highlight-initial-delay' and `lazy-highlight-interval')."
+  :type 'boolean
+  :group 'lazy-highlight
+  :group 'ispell
+  :version "22.1")
+
+(defcustom ispell-highlight-face (if ispell-lazy-highlight 'isearch 'highlight)
   "*The face used for Ispell highlighting.  For Emacses with overlays.
 Possible values are `highlight', `modeline', `secondary-selection',
 `region', and `underline'.
@@ -2160,7 +2170,7 @@
 otherwise it is displayed normally."
   (if highlight
       (isearch-highlight start end)
-    (isearch-dehighlight t))
+    (isearch-dehighlight))
   ;;(sit-for 0)
   )
 
@@ -2174,8 +2184,23 @@
   (if highlight
       (progn
 	(setq ispell-overlay (make-overlay start end))
+	(overlay-put ispell-overlay 'priority 1) ;higher than lazy overlays
 	(overlay-put ispell-overlay 'face ispell-highlight-face))
-    (delete-overlay ispell-overlay)))
+    (delete-overlay ispell-overlay))
+  (if (and ispell-lazy-highlight (boundp 'lazy-highlight-cleanup))
+      (if highlight
+	  (let ((isearch-string
+		 (concat
+		  "\\b"
+		  (regexp-quote (buffer-substring-no-properties start end))
+		  "\\b"))
+		(isearch-regexp t)
+		(isearch-case-fold-search nil))
+	    (isearch-lazy-highlight-new-loop
+	     (if (boundp 'reg-start) reg-start)
+	     (if (boundp 'reg-end)   reg-end)))
+	(lazy-highlight-cleanup lazy-highlight-cleanup)
+	(setq isearch-lazy-highlight-last-string nil))))
 
 
 (defun ispell-highlight-spelling-error (start end &optional highlight refresh)