unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* ispell highlighting
@ 2005-01-12  1:59 Juri Linkov
  2005-01-13  3:13 ` Richard Stallman
  2005-01-18 10:47 ` Juri Linkov
  0 siblings, 2 replies; 3+ messages in thread
From: Juri Linkov @ 2005-01-12  1:59 UTC (permalink / raw)
  Cc: k.stevens, ispell-el-bugs

Ispell is one of the few packages for which it would be natural to
take advantage of isearch lazy highlighting.  Actually, ispell.el
already uses isearch highlighting to highlight spelling errors,
but only for XEmacs in `ispell-highlight-spelling-error-xemacs'.
(BTW, with the recent removal of arguments of `isearch-dehighlight'
in Emacs CVS the byte compiler now started to complain in
this function about missing arguments of `isearch-dehighlight'.
Is it possible to enclose this line in a conditional construct
for its compilation only in XEmacs?)

I don't know what is the best way to get this change installed.
Would maintainers of ispell.el prefer to update it on the Web page
or is it right to simply install it in Emacs CVS?

Anyway, the code below takes care of compatibility with other Emacs
versions and will use lazy highlighting only in the presence of
recently renamed lazy-highlight variables which guarantees that
the code will correctly work (together with another patch I have just
submitted and which I hope will be installed as well).

Index: lisp/textmodes/ispell.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/textmodes/ispell.el,v
retrieving revision 1.151
diff -u -r1.151 ispell.el
--- lisp/textmodes/ispell.el	22 Dec 2004 00:22:58 -0000	1.151
+++ lisp/textmodes/ispell.el	12 Jan 2005 01:01:30 -0000
@@ -237,7 +237,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 "21.4")
+
+(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'.
@@ -2142,8 +2152,17 @@
   (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 (buffer-substring-no-properties start end))
+		(isearch-regexp nil)
+		(isearch-case-fold-search nil))
+	    (isearch-lazy-highlight-new-loop))
+	(isearch-lazy-highlight-cleanup lazy-highlight-cleanup)
+	(setq isearch-lazy-highlight-last-string nil))))
 
 
 (defun ispell-highlight-spelling-error (start end &optional highlight refresh)

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ispell highlighting
  2005-01-12  1:59 ispell highlighting Juri Linkov
@ 2005-01-13  3:13 ` Richard Stallman
  2005-01-18 10:47 ` Juri Linkov
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Stallman @ 2005-01-13  3:13 UTC (permalink / raw)
  Cc: k.stevens, ispell-el-bugs, emacs-devel

It is always proper to install changes directly into the Emacs CVS
repository.  We will not include files that we cannot maintain.  When
a file lists a specific maintainer, it is a good thing to email it to
the maintainer also; but let's not turn file maintainers into
bottlenecks.

When a file lists a specific maintainer, it is also ok to mail the
change to the maintainer and ask him to DTRT.  But if you do that, do
check in a few weeks to see that it has been acted on.  Some file
maintainers have become inactive, and we don't know.

In this case, please install it directly.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ispell highlighting
  2005-01-12  1:59 ispell highlighting Juri Linkov
  2005-01-13  3:13 ` Richard Stallman
@ 2005-01-18 10:47 ` Juri Linkov
  1 sibling, 0 replies; 3+ messages in thread
From: Juri Linkov @ 2005-01-18 10:47 UTC (permalink / raw)
  Cc: k.stevens, ispell-el-bugs

Below is an improved patch for ispell.el.  I changed isearch-regexp
for highlighting from `nil' to `t', added `regexp-quote' and "\\b"
around the string.  This may not highlight all words correctly
according to CASECHARS rules, but at least it will highlight
exactly the same words that will be replaced by query-replace
invoked from ispell.el after typing R.  (And when query-replace is
activated from ispell.el, it rehighlights the same words with its own
highlighting).

Index: lisp/textmodes/ispell.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/textmodes/ispell.el,v
retrieving revision 1.152
diff -u -r1.152 ispell.el
--- lisp/textmodes/ispell.el	13 Jan 2005 04:33:05 -0000	1.152
+++ lisp/textmodes/ispell.el	18 Jan 2005 09:51:25 -0000
@@ -237,7 +237,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 "21.4")
+
+(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'.
@@ -2181,8 +2191,21 @@
   (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))
+	(isearch-lazy-highlight-cleanup lazy-highlight-cleanup)
+	(setq isearch-lazy-highlight-last-string nil))))
 
 
 (defun ispell-highlight-spelling-error (start end &optional highlight refresh)

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-01-18 10:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-12  1:59 ispell highlighting Juri Linkov
2005-01-13  3:13 ` Richard Stallman
2005-01-18 10:47 ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).