Finally fix multiline highlighting.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Tue, 20 Dec 2011 23:15:57 +0200
changeset 849 c34dc5f47510
parent 848 8125f4d8b6d4
child 850 38ca922a6d11
Finally fix multiline highlighting.
dict-mode.el
--- a/dict-mode.el	Tue Dec 20 22:11:20 2011 +0200
+++ b/dict-mode.el	Tue Dec 20 23:15:57 2011 +0200
@@ -27,6 +27,24 @@
         ("\\[[^]]+]" . font-lock-type-face)
         ))
 
+(defun dict-c5-font-lock-extend-region ()
+  ""
+  (let (beg end)
+    ;; font-lock-beg font-lock-end
+    (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)))
+      (goto-char font-lock-beg)
+      (forward-line -2)
+      (when (eq (char-after (point)) ?_)
+        (setq font-lock-beg (point)))
+      )))
+
+
 ;;;###autoload
 (define-derived-mode dict-c5-mode fundamental-mode "Dict-c5"
   "Derived mode for editing C5 dictd source file."
@@ -39,6 +57,7 @@
   (use-local-map dict-c5-mode-map)
   (modify-syntax-entry ?' ".")
   (modify-syntax-entry ?\" ".")
+  (add-hook 'font-lock-extend-region-functions 'dict-c5-font-lock-extend-region t)
   )
 
 ;;; dict-mode.el ends here