Fix infinite invocation of 'dict-c5-font-lock-extend-region' by guarding condition.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Wed, 21 Dec 2011 21:49:03 +0200
changeset 852 571e98c6d3c2
parent 851 1c6bb299d28b
child 853 626114dd8100
Fix infinite invocation of 'dict-c5-font-lock-extend-region' by guarding condition.
dict-mode.el
--- a/dict-mode.el	Tue Dec 20 23:28:29 2011 +0200
+++ b/dict-mode.el	Wed Dec 21 21:49:03 2011 +0200
@@ -29,23 +29,25 @@
 
 (defun dict-c5-font-lock-extend-region ()
   "Look for '_____' expression and extend `font-lock-beg' and `font-lock-end'."
-  (let ((changed nil))
+  ;; (message "%d, %d:%d" (point) font-lock-beg font-lock-end)
+  ;; (message "lines: %d" (count-lines font-lock-beg font-lock-end))
+  (cond
+   ((and
+     (< (count-lines font-lock-beg font-lock-end) 5)
+     (< font-lock-end (point-max))
+     (< (point-min) font-lock-beg))
+    (message "XXX")
     (save-excursion
-      ;; (message "%d, %d:%d" point font-lock-beg font-lock-end)
-      (goto-char font-lock-beg)
-      (beginning-of-line)
-      (when (eq (char-after (point)) ?_)
-        (forward-line 3)
-        (setq font-lock-end (point))
-        (setq changed t))
       (goto-char font-lock-beg)
       (forward-line -2)
-      (when (eq (char-after (point)) ?_)
-        (setq font-lock-beg (point))
-        (setq changed t))
+      (setq font-lock-beg (point))
+      (goto-char font-lock-end)
+      (forward-line 3)
+      (setq font-lock-end (point))
       )
-    changed
-    ))
+    t)
+   (t nil)
+   ))
 
 ;;;###autoload
 (define-derived-mode dict-c5-mode fundamental-mode "Dict-c5"