summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2014-08-26 18:33:41 -0700
committerCraig Earls <enderw88@gmail.com>2014-08-26 18:33:41 -0700
commit403ca4f1a5b4a11eb4168e2e62709f4a09c3c202 (patch)
treeb345dbb14243c140ef891866b3ad75740d5103d1
parentbacde09ead2e7a193a65e939b74eeed1c360ca36 (diff)
downloadfork-ledger-403ca4f1a5b4a11eb4168e2e62709f4a09c3c202.tar.gz
fork-ledger-403ca4f1a5b4a11eb4168e2e62709f4a09c3c202.tar.bz2
fork-ledger-403ca4f1a5b4a11eb4168e2e62709f4a09c3c202.zip
Not working well, try something else on new-fontification-scheme-2
-rw-r--r--lisp/ledger-fontify.el20
-rw-r--r--lisp/ledger-mode.el12
-rw-r--r--lisp/ledger-regex.el2
3 files changed, 26 insertions, 8 deletions
diff --git a/lisp/ledger-fontify.el b/lisp/ledger-fontify.el
index 1023cd85..83c8753c 100644
--- a/lisp/ledger-fontify.el
+++ b/lisp/ledger-fontify.el
@@ -38,6 +38,7 @@
(defun ledger-fontify-whole-buffer ()
(interactive)
(save-excursion
+ (message "Ledger fontify whole buffer")
(goto-char (point-min))
(while (not (eobp))
(cond ((looking-at ledger-xact-start-regex)
@@ -53,13 +54,26 @@
(interactive)
(if (string= (format-mode-line 'mode-name) "Ledger")
(progn
- (add-hook 'post-command-hook 'ledger-fontify-buffer-part))))
+ (add-hook 'after-change-functions 'ledger-fontify-buffer-part)
+; (add-hook 'before-change-functions 'ledger-fontify-ensure-activation)
+ (message "ledger-fontify-activate called"))))
-(defun ledger-fontify-buffer-part ()
+(defun ledger-fontify-ensure-activation (beg end)
+ (if (string= (format-mode-line 'mode-name) "Ledger")
+ (add-hook 'after-change-functions 'ledger-fontify-buffer-part)))
+
+(defun ledger-fontify-buffer-part (beg end len)
(save-excursion
+ (message (concat "ledger-fontify-buffer-part: "
+ (int-to-string beg) " "
+ (int-to-string end) " "
+ (int-to-string len)
+ ))
+; (goto-char beg)
(backward-paragraph)
(forward-char)
- (cond ((looking-at ledger-xact-start-regex)
+ (cond ((or (looking-at ledger-xact-start-regex)
+ (looking-at ledger-posting-regex))
(ledger-fontify-xact-at (point)))
((looking-at ledger-directive-start-regex)
(ledger-fontify-directive-at (point))))))
diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el
index 9291bf8f..18928fe0 100644
--- a/lisp/ledger-mode.el
+++ b/lisp/ledger-mode.el
@@ -320,8 +320,8 @@ With a prefix argument, remove the effective date. "
(add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
(add-hook 'after-save-hook 'ledger-report-redo)
- (ledger-fontify-whole-buffer)
- (ledger-fontify-activate)
+ ;(ledger-fontify-whole-buffer)
+ ;(ledger-fontify-activate)
;(add-hook 'after-save-hook)
(add-hook 'post-command-hook 'ledger-highlight-xact-under-point nil t)
@@ -329,8 +329,12 @@ With a prefix argument, remove the effective date. "
(ledger-init-load-init-file)
- (set (make-local-variable 'indent-region-function) 'ledger-post-align-postings)
- (run-mode-hooks))
+ (setq font-lock-defaults
+ '(nil t nil nil nil
+ (font-lock-fontify-buffer-function . ledger-fontify-whole-buffer)
+ (font-lock-fontify-region-function . ledger-fontify-buffer-part)))
+
+ (set (make-local-variable 'indent-region-function) 'ledger-post-align-postings))
(defun ledger-set-year (newyear)
diff --git a/lisp/ledger-regex.el b/lisp/ledger-regex.el
index bc7e926b..460b50ce 100644
--- a/lisp/ledger-regex.el
+++ b/lisp/ledger-regex.el
@@ -336,7 +336,7 @@
(concat ledger-iso-date-regexp ;; subexp 1
" ?\\([ *!]\\)" ;; mark, subexp 5
" ?\\((.*)\\)?" ;; code, subexp 6
- " ?\\([[:word:] ]+\\)" ;; desc, subexp 7
+ " ?\\([^;\n]+\\)" ;; desc, subexp 7
"\\(\n\\|;.*\\)" ;; comment, subexp 8
))