Improve finding boundaries of elements for fontification. Also added P for price directives.
This commit is contained in:
parent
a66001382c
commit
1bd67755fa
3 changed files with 27 additions and 2 deletions
|
|
@ -52,7 +52,7 @@
|
|||
(interactive "d")
|
||||
(save-excursion
|
||||
(goto-char position)
|
||||
(let ((extents (ledger-navigate-find-xact-extents position))
|
||||
(let ((extents (ledger-navigate-find-element-extents position))
|
||||
(state (ledger-transaction-state)))
|
||||
(if (and ledger-fontify-xact-state-overrides state)
|
||||
(cond ((eq state 'cleared)
|
||||
|
|
@ -115,7 +115,7 @@ Fontify the first line of an xact"
|
|||
'ledger-font-comment-face)))
|
||||
|
||||
(defun ledger-fontify-directive-at (position)
|
||||
(let ((extents (ledger-navigate-find-xact-extents position))
|
||||
(let ((extents (ledger-navigate-find-element-extents position))
|
||||
(face 'ledger-font-default-face))
|
||||
(cond ((looking-at "=")
|
||||
(setq face 'ledger-font-auto-xact-face))
|
||||
|
|
@ -153,6 +153,8 @@ Fontify the first line of an xact"
|
|||
(setq face 'ledger-font-include-directive-face))
|
||||
((looking-at "payee")
|
||||
(setq face 'ledger-font-payee-directive-face))
|
||||
((looking-at "P")
|
||||
(setq face 'ledger-font-price-directive-face))
|
||||
((looking-at "tag")
|
||||
(setq face 'ledger-font-tag-directive-face)))
|
||||
(ledger-fontify-set-face extents face)))
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@
|
|||
"Default face for pending (!) payees"
|
||||
:group 'ledger-faces)
|
||||
|
||||
|
||||
|
||||
(defface ledger-font-xact-highlight-face
|
||||
`((t :inherit ledger-occur-xact-face))
|
||||
"Default face for transaction under point"
|
||||
|
|
@ -95,6 +97,11 @@
|
|||
"Default face for other transactions"
|
||||
:group 'ledger-faces)
|
||||
|
||||
(defface ledger-font-price-directive-face
|
||||
`((t :inherit ledger-font-directive-face))
|
||||
"Default face for other transactions"
|
||||
:group 'ledger-faces)
|
||||
|
||||
(defface ledger-font-apply-directive-face
|
||||
`((t :inherit ledger-font-directive-face))
|
||||
"Default face for other transactions"
|
||||
|
|
|
|||
|
|
@ -91,4 +91,20 @@ Requires empty line separating xacts."
|
|||
(list (ledger-navigate-beginning-of-xact)
|
||||
(ledger-navigate-end-of-xact))))
|
||||
|
||||
(defun ledger-navigate-find-directive-extents (pos)
|
||||
(goto-char pos)
|
||||
(list (progn (beginning-of-line)
|
||||
(point))
|
||||
(progn (end-of-line)
|
||||
(point))))
|
||||
|
||||
(defun ledger-navigate-find-element-extents (pos)
|
||||
"return list containing beginning and end of the entity surrounding point"
|
||||
(interactive "d")
|
||||
(save-excursion
|
||||
(goto-char pos)
|
||||
(beginning-of-line)
|
||||
(if (looking-at "[ 0-9]")
|
||||
(ledger-navigate-find-xact-extents pos)
|
||||
(ledger-navigate-find-directive-extents pos))))
|
||||
;;; ledger-navigate.el ends here
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue