Fixes bug 904, failure to highly pending postings. Adds two new faces for pending and cleared posting.
This commit is contained in:
parent
70bbc81299
commit
86d0fd87c4
4 changed files with 53 additions and 11 deletions
|
|
@ -672,6 +672,11 @@ Default face for pending (!) transactions
|
|||
Default face for other transactions
|
||||
@item ledger-font-posting-account-face
|
||||
Face for Ledger accounts
|
||||
@item ledger-font-posting-account-cleared-face
|
||||
Face for cleared Ledger accounts
|
||||
@item ledger-font-posting-account-pending-face
|
||||
Face for Ledger pending accounts
|
||||
|
||||
@item ledger-font-posting-amount-face
|
||||
Face for Ledger amounts
|
||||
@item ledger-occur-narrowed-face
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(require 'ldg-regex)
|
||||
|
||||
(defgroup ledger-faces nil "Ledger mode highlighting" :group 'ledger)
|
||||
(defface ledger-font-uncleared-face
|
||||
`((t :foreground "#dc322f" :weight bold ))
|
||||
|
|
@ -57,6 +59,16 @@
|
|||
"Face for Ledger accounts"
|
||||
:group 'ledger-faces)
|
||||
|
||||
(defface ledger-font-posting-account-cleared-face
|
||||
`((t :foreground "#657b83" ))
|
||||
"Face for Ledger accounts"
|
||||
:group 'ledger-faces)
|
||||
|
||||
(defface ledger-font-posting-account-pending-face
|
||||
`((t :foreground "#cb4b16" ))
|
||||
"Face for Ledger accounts"
|
||||
:group 'ledger-faces)
|
||||
|
||||
(defface ledger-font-posting-amount-face
|
||||
`((t :foreground "yellow" ))
|
||||
"Face for Ledger amounts"
|
||||
|
|
@ -99,16 +111,17 @@
|
|||
|
||||
|
||||
(defvar ledger-font-lock-keywords
|
||||
'(("^[0-9]+[-/.=][-/.=0-9]+\\s-\\!\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\(\\( ;\\| ;\\|$\\)\\)" 2 'ledger-font-pending-face)
|
||||
("^[0-9]+[-/.=][-/.=0-9]+\\s-\\*\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\(\\( ;\\| ;\\|$\\)\\)" 2 'ledger-font-cleared-face)
|
||||
("^[0-9]+[-/.=][-/.=0-9]+\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\(\\( ;\\| ;\\|$\\)\\)" 2 'ledger-font-uncleared-face)
|
||||
("^\\s-+\\([*]\\s-*\\)?\\(\\([[(]\\)?[^*:
|
||||
]+?:\\([^]);
|
||||
]\\|\\s-\\)+?\\([])]\\)?\\)\\( \\| \\|$\\)"
|
||||
`((,ledger-payee-pending-regex 2 'ledger-font-pending-face)
|
||||
(,ledger-payee-cleared-regex 2 'ledger-font-cleared-face)
|
||||
(,ledger-payee-uncleared-regex 2 'ledger-font-uncleared-face)
|
||||
(,ledger-posting-account-cleared-regex
|
||||
2 'ledger-font-posting-account-cleared-face)
|
||||
(,ledger-posting-account-pending-regex
|
||||
2 'ledger-font-posting-account-pending-face) ; works
|
||||
(,ledger-posting-account-all-regex
|
||||
2 'ledger-font-posting-account-face) ; works
|
||||
("\\( \\| \\|^\\)\\(;.*\\)" 2 'ledger-font-comment-face) ; works
|
||||
("^\\([~=].+\\)" 1 ledger-font-other-face)
|
||||
("^\\([A-Za-z]+ .+\\)" 1 ledger-font-other-face))
|
||||
(,ledger-comment-regex 2 'ledger-font-comment-face) ; works
|
||||
(,ledger-other-entries-regex 1 ledger-font-other-face))
|
||||
"Expressions to highlight in Ledger mode.")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -136,14 +136,14 @@ point at beginning of the commodity."
|
|||
(match-end 3)) (point))))
|
||||
|
||||
(defvar ledger-post-account-regex
|
||||
"\\(^[ \t]+\\)\\(.+?\\)\\( \\|\n\\)")
|
||||
"\\(^[ \t]+\\)\\([!*]?.+?\\)\\( \\|$\\)")
|
||||
|
||||
(defun ledger-next-account (&optional end)
|
||||
"Move point to the beginning of the next account, or status marker (!*), as long as it is not past END.
|
||||
Return the column of the beginning of the account and leave point
|
||||
at beginning of account"
|
||||
(if (> end (point))
|
||||
(when (re-search-forward ledger-post-account-regex (1+ end) t)
|
||||
(when (re-search-forward ledger-posting-account-all-regex (1+ end) t)
|
||||
;; the 1+ is to make sure we can catch the newline
|
||||
(goto-char (match-beginning 2))
|
||||
(current-column))))
|
||||
|
|
|
|||
|
|
@ -24,6 +24,30 @@
|
|||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(defvar ledger-other-entries-regex
|
||||
"^\\(\\([~=].+\\)\\|\\(^\\([A-Za-z]+ .+\\)\\)\\)")
|
||||
|
||||
(defvar ledger-comment-regex
|
||||
"\\( \\| \\|^\\)\\(;.*\\)")
|
||||
(defvar ledger-payee-pending-regex
|
||||
"^[0-9]+[-/.=][-/.=0-9]+\\s-\\!\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\(\\( ;\\| ;\\|$\\)\\)")
|
||||
|
||||
(defvar ledger-payee-cleared-regex
|
||||
"^[0-9]+[-/.=][-/.=0-9]+\\s-\\*\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\(\\( ;\\| ;\\|$\\)\\)")
|
||||
|
||||
(defvar ledger-payee-uncleared-regex
|
||||
"^[0-9]+[-/.=][-/.=0-9]+\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\(\\( ;\\| ;\\|$\\)\\)")
|
||||
|
||||
|
||||
(defvar ledger-posting-account-all-regex
|
||||
"\\(^[ \t]+\\)\\(.+?\\)\\( \\|$\\)")
|
||||
|
||||
(defvar ledger-posting-account-cleared-regex
|
||||
"\\(^[ \t]+\\)\\(\\*.+?\\)\\( \\|$\\)")
|
||||
|
||||
(defvar ledger-posting-account-pending-regex
|
||||
"\\(^[ \t]+\\)\\(!.+?\\)\\( \\|$\\)")
|
||||
|
||||
(defvar ledger-date-regex
|
||||
"\\([0-9]+\\)[/-]\\([0-9]+\\)[/-]\\([0-9]+\\)")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue