diff options
author | Craig Earls <enderw88@gmail.com> | 2013-04-22 06:39:47 -0700 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2013-04-22 06:39:47 -0700 |
commit | f688b314d72f6cc3121ab39ce225e5e6d07c547a (patch) | |
tree | dfe937fe497c20f8528f8ec6154b06696984c887 /lisp/ldg-fonts.el | |
parent | 26fd5b26d863e2aa729b818b2fab33cffbcc306e (diff) | |
parent | ebdff209ab8762367ce0db66ad0fa386642e61ad (diff) | |
download | fork-ledger-f688b314d72f6cc3121ab39ce225e5e6d07c547a.tar.gz fork-ledger-f688b314d72f6cc3121ab39ce225e5e6d07c547a.tar.bz2 fork-ledger-f688b314d72f6cc3121ab39ce225e5e6d07c547a.zip |
Merge pull request #178 from georgek/regex
Add highlighting for multiple line comments
Diffstat (limited to 'lisp/ldg-fonts.el')
-rw-r--r-- | lisp/ldg-fonts.el | 30 |
1 files changed, 29 insertions, 1 deletions
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) |