[Top][All Lists]

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

problems with overlays

From: Sebastian Meisel
Subject: problems with overlays
Date: Tue, 24 Apr 2007 11:56:51 +0200
User-agent: Thunderbird (Macintosh/20070221)


I try to write a function to highlight the commas in a sentence. I have still some problems to determine the borders of the sentence. But most of all, I have problems to remove the overlays when I don't need them anymore. I need to distinguish them from other overlays in the buffer. I looked an the TeX-fold mode and it seemed using the category property it a good way to do that. But it doesn't work.

;; hightlight commatas
(defface gspell-highlight-commata-face
'((((class color)) (:foreground "Red" :background "LightGreen" :bold t : underline: t)) (t (:bold t)))
 "Face used for a word accepted by Gspell.")

(defun gspell-highlight-commata-sentence ()
 "Hightlight commatas in the current senctence"
 (let ((hier (point))
   (satz-grenze (concat "\\. \\|" paragraph-start))
   (satz-ende (buffer-end 1))
   (satz-anfang 0))
     (re-search-backward satz-grenze (- hier 100) t 1)
     (let ((satz-anfang (match-end 0)))
   (goto-char hier)
   (if (re-search-forward satz-grenze (+ hier 100) t 1)
       (setq satz-ende (+ (match-beginning 0) 1)))
   (goto-char satz-ende)
   (while (re-search-backward "," satz-anfang t)
     (let ((ov-start (match-beginning 0))
       (ov-end (match-end 0)))
       (let ((ov (make-overlay ov-start ov-end (current-buffer) t nil)))
         (overlay-put ov 'face 'gspell-highlight-commata-face)
         (overlay-put ov 'category 'gspell-comma)

(defun gspell-remove-comma-overlays ()
"Remove all comma-overlays from buffer." (interactive)
 (let ((start (buffer-end -1))
   (end (buffer-end 1)))
   (setq overlays (overlays-in start end))
   (while overlays
     (when (eq (overlay-get (car overlays) 'category) 'gspell-comma)
   (delete-overlay (car overlays))
   (setq overlays (cdr overlays))))))

Thanks for any hint.

Sebastian Meisel

reply via email to

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