From ebdff209ab8762367ce0db66ad0fa386642e61ad Mon Sep 17 00:00:00 2001 From: George Kettleborough Date: Sun, 21 Apr 2013 14:14:08 +0100 Subject: Add highlighting for multiple line comments --- lisp/ldg-fonts.el | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'lisp/ldg-fonts.el') diff --git a/lisp/ldg-fonts.el b/lisp/ldg-fonts.el index 8ba84c84..fc0b7813 100644 --- a/lisp/ldg-fonts.el +++ b/lisp/ldg-fonts.el @@ -115,6 +115,7 @@ ;; ledger-font-other-face) (,ledger-comment-regex 0 'ledger-font-comment-face) + (,ledger-multiline-comment-regex 0 'ledger-font-comment-face) (,ledger-payee-pending-regex 2 'ledger-font-payee-pending-face) ; Works (,ledger-payee-cleared-regex 2 @@ -130,7 +131,34 @@ (,ledger-other-entries-regex 1 'ledger-font-other-face)) "Expressions to highlight in Ledger mode.") - + +(defun ledger-extend-region-multiline-comment () + "Adjusts the variables font-lock-beg and font-lock-end if they + fall within a multiline comment. Returns non-nil if an + adjustment is made." + (let (beg end) + ;; fix beg + (save-excursion + (goto-char font-lock-beg) + (end-of-line) + (when (re-search-backward ledger-multiline-comment-start-regex nil t) + (setq beg (point)) + (re-search-forward ledger-multiline-comment-regex nil t) + (if (and (>= (point) font-lock-beg) + (/= beg font-lock-beg)) + (setq font-lock-beg beg) + (setq beg nil)))) + ;; fix end + (save-excursion + (goto-char font-lock-end) + (end-of-line) + (when (re-search-backward ledger-multiline-comment-start-regex nil t) + (re-search-forward ledger-multiline-comment-regex nil t) + (setq end (point)) + (if (> end font-lock-end) + (setq font-lock-end end) + (setq end nil)))) + (or beg end))) (provide 'ldg-fonts) -- cgit v1.2.3