Simplifies parsing of the beginning of an act. This allows fontifying effective dates.
This commit is contained in:
parent
a953fe6cbc
commit
07324cb6b2
2 changed files with 23 additions and 19 deletions
|
|
@ -79,20 +79,21 @@
|
||||||
Fontify the first line of an xact"
|
Fontify the first line of an xact"
|
||||||
(goto-char pos)
|
(goto-char pos)
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(let ((state nil))
|
(let ((state nil)
|
||||||
(re-search-forward ledger-xact-start-regex)
|
(cur-point (point)))
|
||||||
(ledger-fontify-set-face (list (match-beginning 1) (match-end 1)) 'ledger-font-posting-date-face)
|
(re-search-forward " ")
|
||||||
(save-match-data (setq state (ledger-state-from-string (match-string 5))))
|
(ledger-fontify-set-face (list cur-point (point)) 'ledger-font-posting-date-face)
|
||||||
(ledger-fontify-set-face (list (match-beginning 7) (match-end 7))
|
(re-search-forward ledger-xact-after-date-regex)
|
||||||
|
(save-match-data (setq state (ledger-state-from-string (match-string 1)))
|
||||||
|
(ledger-fontify-set-face (list (match-beginning 3) (match-end 3))
|
||||||
(cond ((eq state 'pending)
|
(cond ((eq state 'pending)
|
||||||
'ledger-font-payee-pending-face)
|
'ledger-font-payee-pending-face)
|
||||||
((eq state 'cleared)
|
((eq state 'cleared)
|
||||||
'ledger-font-payee-cleared-face)
|
'ledger-font-payee-cleared-face)
|
||||||
(t
|
(t
|
||||||
'ledger-font-payee-uncleared-face)))
|
'ledger-font-payee-uncleared-face))))
|
||||||
(ledger-fontify-set-face (list (match-beginning 8)
|
(ledger-fontify-set-face (list (match-beginning 4)
|
||||||
(match-end 8)) 'ledger-font-comment-face)))
|
(match-end 4)) 'ledger-font-comment-face)))
|
||||||
|
|
||||||
|
|
||||||
(defun ledger-fontify-posting (pos)
|
(defun ledger-fontify-posting (pos)
|
||||||
(let* ((state nil)
|
(let* ((state nil)
|
||||||
|
|
|
||||||
|
|
@ -334,11 +334,14 @@
|
||||||
|
|
||||||
(defconst ledger-xact-start-regex
|
(defconst ledger-xact-start-regex
|
||||||
(concat "^" ledger-iso-date-regexp ;; subexp 1
|
(concat "^" ledger-iso-date-regexp ;; subexp 1
|
||||||
;; "\\(=" ledger-iso-date-regexp "\\)?"
|
"\\(=" ledger-iso-date-regexp "\\)?"
|
||||||
" ?\\([ *!]\\)" ;; mark, subexp 5
|
))
|
||||||
" ?\\((.*)\\)?" ;; code, subexp 6
|
|
||||||
" ?\\([^;\n]+\\)" ;; desc, subexp 7
|
(defconst ledger-xact-after-date-regex
|
||||||
"\\(\n\\|;.*\\)" ;; comment, subexp 8
|
(concat " ?\\([ *!]\\)" ;; mark, subexp 1
|
||||||
|
" ?\\((.*)\\)?" ;; code, subexp 2
|
||||||
|
" ?\\([^;\n]+\\)" ;; desc, subexp 3
|
||||||
|
"\\(\n\\|;.*\\)" ;; comment, subexp 4
|
||||||
))
|
))
|
||||||
|
|
||||||
(defconst ledger-posting-regex
|
(defconst ledger-posting-regex
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue