From 70bbc81299704b57191b1313ea44bf955345079d Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Tue, 2 Apr 2013 11:11:20 -0700 Subject: Initial chapter on time-keeping in ledger3.texi --- doc/ledger3.texi | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 3382ab33..91dd794f 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -75,6 +75,7 @@ twinkling in their father's CRT. * Reporting Commands:: * Command-line Syntax:: * Budgeting and Forecasting:: +* Time Keeping:: * Value Expressions:: * Format Strings:: * Extending with Python:: @@ -6389,7 +6390,7 @@ weekly last august @end smallexample -@node Budgeting and Forecasting, Value Expressions, Command-line Syntax, Top +@node Budgeting and Forecasting, Time Keeping, Command-line Syntax, Top @chapter Budgeting and Forecasting @menu @@ -6485,8 +6486,37 @@ only, and not against the running total: ledger --forecast "d<[2010]" bal ^assets ^liabilities @end example +@node Time Keeping, Value Expressions, Budgeting and Forecasting, Top +@chapter Time Keeping -@node Value Expressions, Format Strings, Budgeting and Forecasting, Top + +Ledger directly supports ``timelog'' entries, which have this form: + +@smallexample + i 2013/03/28 22:13:00 ACCOUNT[ PAYEE] + o 2013/03/29 03:39:00 +@end smallexample + +This records a check-in to the given ACCOUNT, and a check-out. You can +be checked-in to multiple accounts at a time, if you wish, and they can +span multiple days (use @code{--day-break} to break them up in the +report). The number of seconds between is accumulated as time to that +ACCOUNT. If the checkout uses a capital ``O'', the transaction is marked +``cleared''. You can use an optional PAYEE for whatever meaning you like. + +Now, there are a few ways to generate this information. You can use the +@file{timeclock.el} package, which is part of Emacs. Or you can write a +simple script in whichever language you prefer to emit similar +information. Or you can use Org-mode's time-clocking abilities and the +org2tc script developed by John Wiegly. + +These timelog entries can appear in a separate file, or directly in your +main ledger file. The initial "i" and "o" count as Ledger "directives", +and are accepted anywhere that ordinary transactions are. + + + +@node Value Expressions, Format Strings, Time Keeping, Top @chapter Value Expressions Ledger uses value expressions to make calculations for many different -- cgit v1.2.3 From 86d0fd87c49e20b0f5262e7ae48234986584b750 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Tue, 2 Apr 2013 14:20:29 -0700 Subject: Fixes bug 904, failure to highly pending postings. Adds two new faces for pending and cleared posting. --- doc/ledger-mode.texi | 5 +++++ lisp/ldg-fonts.el | 31 ++++++++++++++++++++++--------- lisp/ldg-post.el | 4 ++-- lisp/ldg-regex.el | 24 ++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 11 deletions(-) (limited to 'doc') diff --git a/doc/ledger-mode.texi b/doc/ledger-mode.texi index 70a5d97a..34c38dae 100644 --- a/doc/ledger-mode.texi +++ b/doc/ledger-mode.texi @@ -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 diff --git a/lisp/ldg-fonts.el b/lisp/ldg-fonts.el index 3a7d1e0a..81196c10 100644 --- a/lisp/ldg-fonts.el +++ b/lisp/ldg-fonts.el @@ -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.") diff --git a/lisp/ldg-post.el b/lisp/ldg-post.el index 554b8578..f29d8af8 100644 --- a/lisp/ldg-post.el +++ b/lisp/ldg-post.el @@ -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)))) diff --git a/lisp/ldg-regex.el b/lisp/ldg-regex.el index 97fd6e2c..7c92bf15 100644 --- a/lisp/ldg-regex.el +++ b/lisp/ldg-regex.el @@ -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]+\\)") -- cgit v1.2.3