From 62977ea23a68e3da6da0183b858abd38c3c0ec9f Mon Sep 17 00:00:00 2001 From: thdox Date: Sun, 8 Feb 2015 16:29:23 +0100 Subject: SC2112 'function' keyword is non-standard. Delete it. http://www.shellcheck.net/ [ci skip] --- tools/prepare-commit-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/prepare-commit-msg b/tools/prepare-commit-msg index ab351760..e8150dd1 100755 --- a/tools/prepare-commit-msg +++ b/tools/prepare-commit-msg @@ -5,7 +5,7 @@ # Add [ci skip] to the commit message unless there are changes to files # that are relevant for testing such as src/*, test/*, ledger3.texi, ... -function add_ci_skip() +add_ci_skip () { pattern="$1"; shift source="$1" -- cgit v1.2.3 From a60ff5dc22d4aca9fdba000c9c928f4ae38adae4 Mon Sep 17 00:00:00 2001 From: thdox Date: Sun, 8 Feb 2015 16:31:26 +0100 Subject: SC2069 The order of the 2>&1 and the redirect matters. The 2>&1 has to be last. http://www.shellcheck.net/ [ci skip] --- tools/prepare-commit-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/prepare-commit-msg b/tools/prepare-commit-msg index e8150dd1..5045fe7a 100755 --- a/tools/prepare-commit-msg +++ b/tools/prepare-commit-msg @@ -11,7 +11,7 @@ add_ci_skip () source="$1" # Don't add [ci skip] if it's already in the commit message source - grep '\[ci skip\]' "$source" 2>&1 >/dev/null + grep '\[ci skip\]' "$source" >/dev/null 2>&1 [ $? -eq 0 ] && return if [ $(git diff --cached --name-only | grep --count "$pattern") -eq 0 ]; then -- cgit v1.2.3 From 9d82674c889a831418a792ba6505e57c8d4ca225 Mon Sep 17 00:00:00 2001 From: thdox Date: Sun, 8 Feb 2015 16:33:40 +0100 Subject: SC2086 Double quote to prevent globbing and word splitting. http://www.shellcheck.net/ [ci skip] --- tools/prepare-commit-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/prepare-commit-msg b/tools/prepare-commit-msg index 5045fe7a..585b5397 100755 --- a/tools/prepare-commit-msg +++ b/tools/prepare-commit-msg @@ -15,7 +15,7 @@ add_ci_skip () [ $? -eq 0 ] && return if [ $(git diff --cached --name-only | grep --count "$pattern") -eq 0 ]; then - tempfile=$(mktemp $0.XXXXXX) + tempfile=$(mktemp "$0".XXXXXX) cat - "$1" < "$tempfile" # It seems the changes to be committed are irrelevant for the continuous -- cgit v1.2.3 From 47203b7e746e0002068323bc4d12d5f6baa3bbe3 Mon Sep 17 00:00:00 2001 From: thdox Date: Sun, 8 Feb 2015 16:50:36 +0100 Subject: Add version.texi, and some random texi generated files. [ci skip] --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 16ee2784..e0bba1a6 100644 --- a/.gitignore +++ b/.gitignore @@ -43,17 +43,20 @@ doc/*.html doc/*.info doc/*.info-* doc/*.ky +doc/*.kys doc/*.log doc/*.pdf doc/*.pg doc/*.toc doc/*.tp doc/*.vr +doc/*.vrs doc/.dirstamp doc/html/ doc/latex/ doc/refman.pdf doc/report/ +doc/version.texi elisp-comp install-sh intl/ -- cgit v1.2.3 From c397f6f53af170598872ec4620f1356d8bbcdea7 Mon Sep 17 00:00:00 2001 From: thdox Date: Tue, 10 Feb 2015 21:29:00 +0100 Subject: Improve quoting [ci skip] --- tools/prepare-commit-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/prepare-commit-msg b/tools/prepare-commit-msg index 585b5397..d2f927c0 100755 --- a/tools/prepare-commit-msg +++ b/tools/prepare-commit-msg @@ -15,7 +15,7 @@ add_ci_skip () [ $? -eq 0 ] && return if [ $(git diff --cached --name-only | grep --count "$pattern") -eq 0 ]; then - tempfile=$(mktemp "$0".XXXXXX) + tempfile=$(mktemp "${0}.XXXXXX") cat - "$1" < "$tempfile" # It seems the changes to be committed are irrelevant for the continuous -- cgit v1.2.3 From f8dd075e25fae467ad13776eb366a8eb4799f68a Mon Sep 17 00:00:00 2001 From: thdox Date: Sun, 8 Feb 2015 16:34:27 +0100 Subject: [emacs] M-x add-dir-local-variable RET emacs-lisp-mode RET indent-tabs-mode RET nil RET [ci skip] --- .dir-locals.el | 66 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/.dir-locals.el b/.dir-locals.el index edafaded..ca104fb0 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1,30 +1,36 @@ -((nil . ((tab-width . 2) - (sentence-end-double-space . t) - (bug-reference-url-format - . "http://bugs.ledger-cli.org/show_bug.cgi?id=%s"))) - (c-mode . ((c-file-style . "ledger") - (c-style-alist - ("ledger" - (indent-tabs-mode) - (c-basic-offset . 2) - (c-comment-only-line-offset 0 . 0) - (c-hanging-braces-alist - (substatement-open before after) - (arglist-cont-nonempty)) - (c-offsets-alist - (statement-block-intro . +) - (knr-argdecl-intro . 5) - (substatement-open . 0) - (substatement-label . 0) - (label . 0) - (case-label . 0) - (statement-case-open . 0) - (statement-cont . +) - (arglist-intro . +) - (arglist-close . +) - (inline-open . 0) - (brace-list-open . 0) - (topmost-intro-cont first c-lineup-topmost-intro-cont - c-lineup-gnu-DEFUN-intro-cont)) - (c-special-indent-hook . c-gnu-impose-minimum) - (c-block-comment-prefix . "")))))) +;;; Directory Local Variables +;;; For more information see (info "(emacs) Directory Variables") + +((nil + (tab-width . 2) + (sentence-end-double-space . t) + (bug-reference-url-format . "http://bugs.ledger-cli.org/show_bug.cgi?id=%s")) + (c-mode + (c-file-style . "ledger") + (c-style-alist + ("ledger" + (indent-tabs-mode) + (c-basic-offset . 2) + (c-comment-only-line-offset 0 . 0) + (c-hanging-braces-alist + (substatement-open before after) + (arglist-cont-nonempty)) + (c-offsets-alist + (statement-block-intro . +) + (knr-argdecl-intro . 5) + (substatement-open . 0) + (substatement-label . 0) + (label . 0) + (case-label . 0) + (statement-case-open . 0) + (statement-cont . +) + (arglist-intro . +) + (arglist-close . +) + (inline-open . 0) + (brace-list-open . 0) + (topmost-intro-cont first c-lineup-topmost-intro-cont c-lineup-gnu-DEFUN-intro-cont)) + (c-special-indent-hook . c-gnu-impose-minimum) + (c-block-comment-prefix . "")))) + (emacs-lisp-mode + (indent-tabs-mode))) + -- cgit v1.2.3 From 8162cc783da82b5383e6403c80930034582bb366 Mon Sep 17 00:00:00 2001 From: thdox Date: Sun, 8 Feb 2015 16:40:24 +0100 Subject: [emacs] C-x h M-x untabify RET C-x h M-x indent-region RET [ci skip] --- contrib/raw/dotemacs.el | 82 +++++++------- contrib/raw/ledger-matching.el | 92 ++++++++-------- lisp/ledger-commodities.el | 8 +- lisp/ledger-complete.el | 4 +- lisp/ledger-exec.el | 2 +- lisp/ledger-fontify.el | 242 ++++++++++++++++++++--------------------- lisp/ledger-init.el | 4 +- lisp/ledger-mode.el | 20 ++-- lisp/ledger-navigate.el | 162 +++++++++++++-------------- lisp/ledger-occur.el | 30 ++--- lisp/ledger-post.el | 4 +- lisp/ledger-reconcile.el | 224 +++++++++++++++++++------------------- lisp/ledger-regex.el | 28 ++--- lisp/ledger-report.el | 76 ++++++------- lisp/ledger-schedule.el | 168 ++++++++++++++-------------- lisp/ledger-sort.el | 14 +-- lisp/ledger-state.el | 4 +- lisp/ledger-xact.el | 4 +- 18 files changed, 584 insertions(+), 584 deletions(-) diff --git a/contrib/raw/dotemacs.el b/contrib/raw/dotemacs.el index b270042e..a4babed7 100644 --- a/contrib/raw/dotemacs.el +++ b/contrib/raw/dotemacs.el @@ -1,5 +1,5 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Ledger +;; Ledger ;; Maybe later add this to the expense repo once it settles (add-to-list 'load-path "/home/adamsrl/.emacs.d/addons/ledger") @@ -104,19 +104,19 @@ (defun ledger-expense-shortcut () "Updates the ER and Project metadata with the current values of the shortcut variables." - (interactive) - (when (eq major-mode 'ledger-mode) - (if (or (eql *ledger-expense-shortcut-ER* "") - (eql *ledger-expense-shortcut-Proj* "")) - (message "Run ledger-expense-shortcut-setup first.") - (save-excursion - (search-forward "; ER:") - (kill-line nil) - (insert " " *ledger-expense-shortcut-ER*)) - (save-excursion - (search-forward "; PROJECT:") - (kill-line nil) - (insert " " *ledger-expense-shortcut-Proj*))))) + (interactive) + (when (eq major-mode 'ledger-mode) + (if (or (eql *ledger-expense-shortcut-ER* "") + (eql *ledger-expense-shortcut-Proj* "")) + (message "Run ledger-expense-shortcut-setup first.") + (save-excursion + (search-forward "; ER:") + (kill-line nil) + (insert " " *ledger-expense-shortcut-ER*)) + (save-excursion + (search-forward "; PROJECT:") + (kill-line nil) + (insert " " *ledger-expense-shortcut-Proj*))))) (defun ledger-expense-split () "Splits the current transaction between internal and projects." @@ -158,33 +158,33 @@ (defun ledger-expense-personal () "Makes the expense an personal one, eliminating metadata and receipts." - (interactive) - (when (eq major-mode 'ledger-mode) ; I made this local now, should only trigger in ldg-mode - (save-excursion - (end-of-line) - (re-search-backward "^[0-9]\\{4\\}/") - (let ((begin (point)) - (end (save-excursion (re-search-forward "^$")))) - (when (re-search-forward "^ Dest:Projects" end t) - (replace-match " Other:Personal")) - (goto-char begin) - (save-excursion - (when (re-search-forward "^ +; ER:" end t) - (beginning-of-line) - (kill-line 1))) - (save-excursion - (when (re-search-forward "^ +; PROJECT:" end t) - (beginning-of-line) - (kill-line 1))) - (save-excursion - (when (re-search-forward "^ +; CATEGORY:" end t) - (beginning-of-line) - (kill-line 1))) - (save-excursion - (when (re-search-forward "^ +; RECEIPT:" end t) - (beginning-of-line) - (kill-line 1))) - (ledger-toggle-current-entry))))) + (interactive) + (when (eq major-mode 'ledger-mode) ; I made this local now, should only trigger in ldg-mode + (save-excursion + (end-of-line) + (re-search-backward "^[0-9]\\{4\\}/") + (let ((begin (point)) + (end (save-excursion (re-search-forward "^$")))) + (when (re-search-forward "^ Dest:Projects" end t) + (replace-match " Other:Personal")) + (goto-char begin) + (save-excursion + (when (re-search-forward "^ +; ER:" end t) + (beginning-of-line) + (kill-line 1))) + (save-excursion + (when (re-search-forward "^ +; PROJECT:" end t) + (beginning-of-line) + (kill-line 1))) + (save-excursion + (when (re-search-forward "^ +; CATEGORY:" end t) + (beginning-of-line) + (kill-line 1))) + (save-excursion + (when (re-search-forward "^ +; RECEIPT:" end t) + (beginning-of-line) + (kill-line 1))) + (ledger-toggle-current-entry))))) (defun ledger-expense-show-receipt () "Uses the Receipt buffer to show the receipt of the txn we're on." diff --git a/contrib/raw/ledger-matching.el b/contrib/raw/ledger-matching.el index 7c568126..b8e62dd9 100644 --- a/contrib/raw/ledger-matching.el +++ b/contrib/raw/ledger-matching.el @@ -202,13 +202,13 @@ (defun ledger-receipt-skip () "Move the current image to the Skip directory because its not relevant." - (rename-file (concat ledger-matching-sourcedir "/" - ledger-matching-image-name) - (concat ledger-matching-sourcedir "/Skip/" - ledger-matching-image-name)) + (rename-file (concat ledger-matching-sourcedir "/" + ledger-matching-image-name) + (concat ledger-matching-sourcedir "/Skip/" + ledger-matching-image-name)) - ;; Update the receipt screen at the same offset - (ledger-matching-update-current-image)) + ;; Update the receipt screen at the same offset + (ledger-matching-update-current-image)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Items below are speed entry macros, and should eventually migrate to their own file. @@ -242,19 +242,19 @@ (defun ledger-expense-shortcut () "Updates the ER and Project metadata with the current values of the shortcut variables." - (interactive) - (when (eq major-mode 'ledger-mode) - (if (or (eql *ledger-expense-shortcut-ER* "") - (eql *ledger-expense-shortcut-Proj* "")) - (message "Run ledger-expense-shortcut-setup first.") - (save-excursion - (search-forward "; ER:") - (kill-line nil) - (insert " " *ledger-expense-shortcut-ER*)) - (save-excursion - (search-forward "; PROJECT:") - (kill-line nil) - (insert " " *ledger-expense-shortcut-Proj*))))) + (interactive) + (when (eq major-mode 'ledger-mode) + (if (or (eql *ledger-expense-shortcut-ER* "") + (eql *ledger-expense-shortcut-Proj* "")) + (message "Run ledger-expense-shortcut-setup first.") + (save-excursion + (search-forward "; ER:") + (kill-line nil) + (insert " " *ledger-expense-shortcut-ER*)) + (save-excursion + (search-forward "; PROJECT:") + (kill-line nil) + (insert " " *ledger-expense-shortcut-Proj*))))) (defun ledger-expense-split () "Splits the current transaction between internal and projects." @@ -296,33 +296,33 @@ (defun ledger-expense-personal () "Makes the expense an personal one, eliminating metadata and receipts." - (interactive) - (when (eq major-mode 'ledger-mode) ; I made this local now, should only trigger in ldg-mode - (save-excursion - (end-of-line) - (re-search-backward "^[0-9]\\{4\\}/") - (let ((begin (point)) - (end (save-excursion (re-search-forward "^$")))) - (when (re-search-forward "^ Dest:Projects" end t) - (replace-match " Other:Personal")) - (goto-char begin) - (save-excursion - (when (re-search-forward "^ +; ER:" end t) - (beginning-of-line) - (kill-line 1))) - (save-excursion - (when (re-search-forward "^ +; PROJECT:" end t) - (beginning-of-line) - (kill-line 1))) - (save-excursion - (when (re-search-forward "^ +; CATEGORY:" end t) - (beginning-of-line) - (kill-line 1))) - (save-excursion - (when (re-search-forward "^ +; RECEIPT:" end t) - (beginning-of-line) - (kill-line 1))) - (ledger-toggle-current-entry))))) + (interactive) + (when (eq major-mode 'ledger-mode) ; I made this local now, should only trigger in ldg-mode + (save-excursion + (end-of-line) + (re-search-backward "^[0-9]\\{4\\}/") + (let ((begin (point)) + (end (save-excursion (re-search-forward "^$")))) + (when (re-search-forward "^ Dest:Projects" end t) + (replace-match " Other:Personal")) + (goto-char begin) + (save-excursion + (when (re-search-forward "^ +; ER:" end t) + (beginning-of-line) + (kill-line 1))) + (save-excursion + (when (re-search-forward "^ +; PROJECT:" end t) + (beginning-of-line) + (kill-line 1))) + (save-excursion + (when (re-search-forward "^ +; CATEGORY:" end t) + (beginning-of-line) + (kill-line 1))) + (save-excursion + (when (re-search-forward "^ +; RECEIPT:" end t) + (beginning-of-line) + (kill-line 1))) + (ledger-toggle-current-entry))))) (defun ledger-expense-show-receipt () "Uses the Receipt buffer to show the receipt of the txn we're on." diff --git a/lisp/ledger-commodities.el b/lisp/ledger-commodities.el index 5ffebf3b..ea6319ba 100644 --- a/lisp/ledger-commodities.el +++ b/lisp/ledger-commodities.el @@ -91,8 +91,8 @@ Returns a list with (value commodity)." (error "Can't add different commodities, %S to %S" c1 c2))) (defun ledger-strip (str char) - "Return STR with CHAR removed." - (replace-regexp-in-string char "" str)) + "Return STR with CHAR removed." + (replace-regexp-in-string char "" str)) (defun ledger-string-to-number (str &optional decimal-comma) "improve builtin string-to-number by handling internationalization, and return nil if number can't be parsed" @@ -105,7 +105,7 @@ Returns a list with (value commodity)." (string-to-number nstr))) (defun ledger-number-to-string (n &optional decimal-comma) - "number-to-string that handles comma as decimal." + "number-to-string that handles comma as decimal." (let ((str (number-to-string n))) (when (or decimal-comma (assoc "decimal-comma" ledger-environment-alist)) @@ -124,7 +124,7 @@ longer ones are after the value." (concat commodity " " str)))) (defun ledger-read-commodity-string (prompt) - "Read an amount from mini-buffer using PROMPT." + "Read an amount from mini-buffer using PROMPT." (let ((str (read-from-minibuffer (concat prompt " (" ledger-reconcile-default-commodity "): "))) comm) diff --git a/lisp/ledger-complete.el b/lisp/ledger-complete.el index 2fae9911..2345fd02 100644 --- a/lisp/ledger-complete.el +++ b/lisp/ledger-complete.el @@ -157,7 +157,7 @@ (ledger-accounts))))) (defun ledger-trim-trailing-whitespace (str) - (replace-regexp-in-string "[ \t]*$" "" str)) + (replace-regexp-in-string "[ \t]*$" "" str)) (defun ledger-fully-complete-xact () "Completes a transaction if there is another matching payee in the buffer. @@ -235,7 +235,7 @@ ledger-magic-tab would cycle properly" pcomplete-seen pcomplete-norm-func pcomplete-args pcomplete-last pcomplete-index pcomplete-autolist - (completions (pcomplete-completions)) + (completions (pcomplete-completions)) (result (pcomplete-do-complete pcomplete-stub completions)) (pcomplete-termination-string "")) (and result diff --git a/lisp/ledger-exec.el b/lisp/ledger-exec.el index 8902d839..05bca776 100644 --- a/lisp/ledger-exec.el +++ b/lisp/ledger-exec.el @@ -53,7 +53,7 @@ (setq buffer-read-only t))) (defun ledger-exec-success-p (ledger-output-buffer) - "Return t if the ledger output in LEDGER-OUTPUT-BUFFER is successful." + "Return t if the ledger output in LEDGER-OUTPUT-BUFFER is successful." (with-current-buffer ledger-output-buffer (goto-char (point-min)) (if (and (> (buffer-size) 1) (looking-at (regexp-quote "While"))) diff --git a/lisp/ledger-fontify.el b/lisp/ledger-fontify.el index 8dbe1bd5..2d4f850e 100644 --- a/lisp/ledger-fontify.el +++ b/lisp/ledger-fontify.el @@ -38,45 +38,45 @@ :group 'ledger) (defun ledger-fontify-buffer-part (&optional beg end len) -"Fontify buffer from BEG to END, length LEN." - (save-excursion - (unless beg (setq beg (point-min))) - (unless end (setq end (point-max))) - (goto-char beg) - (beginning-of-line) - (while (< (point) end) - (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)))) - (ledger-navigate-next-xact-or-directive)))) + "Fontify buffer from BEG to END, length LEN." + (save-excursion + (unless beg (setq beg (point-min))) + (unless end (setq end (point-max))) + (goto-char beg) + (beginning-of-line) + (while (< (point) end) + (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)))) + (ledger-navigate-next-xact-or-directive)))) (defun ledger-fontify-xact-at (position) "Fontify the xact at POSITION." - (interactive "d") - (save-excursion - (goto-char 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) - (ledger-fontify-set-face extents 'ledger-font-xact-cleared-face)) - ((eq state 'pending) - (ledger-fontify-set-face extents 'ledger-font-xact-pending-face))) - (ledger-fontify-xact-by-line extents))))) + (interactive "d") + (save-excursion + (goto-char 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) + (ledger-fontify-set-face extents 'ledger-font-xact-cleared-face)) + ((eq state 'pending) + (ledger-fontify-set-face extents 'ledger-font-xact-pending-face))) + (ledger-fontify-xact-by-line extents))))) (defun ledger-fontify-xact-by-line (extents) - "Do line-by-line detailed fontification of xact in EXTENTS." - (save-excursion - (ledger-fontify-xact-start (car extents)) - (while (< (point) (cadr extents)) - (if (looking-at "[ \t]+;") - (ledger-fontify-set-face (list (point) (progn - (end-of-line) - (point))) 'ledger-font-comment-face) - (ledger-fontify-posting (point))) - (forward-line)))) + "Do line-by-line detailed fontification of xact in EXTENTS." + (save-excursion + (ledger-fontify-xact-start (car extents)) + (while (< (point) (cadr extents)) + (if (looking-at "[ \t]+;") + (ledger-fontify-set-face (list (point) (progn + (end-of-line) + (point))) 'ledger-font-comment-face) + (ledger-fontify-posting (point))) + (forward-line)))) (defun ledger-fontify-xact-start (pos) "POS should be at the beginning of a line starting an xact. @@ -102,97 +102,97 @@ Fontify the first line of an xact" (forward-line))) (defun ledger-fontify-posting (pos) - "Fontify the posting at POS." - (let* ((state nil) - (end-of-line-comment nil) - (end (progn (end-of-line) - (point))) - (start (progn (beginning-of-line) - (point)))) - - ;; Look for a posting status flag - (set-match-data nil 'reseat) - (re-search-forward " \\([*!]\\) " end t) - (if (match-string 1) - (setq state (ledger-state-from-string (match-string 1)))) - (beginning-of-line) - (re-search-forward "[[:graph:]]\\([ \t][ \t]\\)" end 'end) ;; find the end of the account, or end of line - - (when (<= (point) end) ;; we are still on the line - (ledger-fontify-set-face (list start (point)) - (cond ((eq state 'cleared) - 'ledger-font-posting-account-cleared-face) - ((eq state 'pending) - 'ledger-font-posting-account-pending-face) - (t - 'ledger-font-posting-account-face))) - - - (when (< (point) end) ;; there is still more to fontify - (setq start (point)) ;; update start of next font region - (setq end-of-line-comment (re-search-forward ";" end 'end)) ;; find the end of the line, or start of a comment - (ledger-fontify-set-face (list start (point) ) - (cond ((eq state 'cleared) - 'ledger-font-posting-amount-cleared-face) - ((eq state 'pending) - 'ledger-font-posting-amount-pending-face) - (t - 'ledger-font-posting-amount-face))) - (when end-of-line-comment - (setq start (point)) - (end-of-line) - (ledger-fontify-set-face (list (- start 1) (point)) ;; subtract 1 from start because we passed the semi-colon - 'ledger-font-comment-face)))))) + "Fontify the posting at POS." + (let* ((state nil) + (end-of-line-comment nil) + (end (progn (end-of-line) + (point))) + (start (progn (beginning-of-line) + (point)))) + + ;; Look for a posting status flag + (set-match-data nil 'reseat) + (re-search-forward " \\([*!]\\) " end t) + (if (match-string 1) + (setq state (ledger-state-from-string (match-string 1)))) + (beginning-of-line) + (re-search-forward "[[:graph:]]\\([ \t][ \t]\\)" end 'end) ;; find the end of the account, or end of line + + (when (<= (point) end) ;; we are still on the line + (ledger-fontify-set-face (list start (point)) + (cond ((eq state 'cleared) + 'ledger-font-posting-account-cleared-face) + ((eq state 'pending) + 'ledger-font-posting-account-pending-face) + (t + 'ledger-font-posting-account-face))) + + + (when (< (point) end) ;; there is still more to fontify + (setq start (point)) ;; update start of next font region + (setq end-of-line-comment (re-search-forward ";" end 'end)) ;; find the end of the line, or start of a comment + (ledger-fontify-set-face (list start (point) ) + (cond ((eq state 'cleared) + 'ledger-font-posting-amount-cleared-face) + ((eq state 'pending) + 'ledger-font-posting-amount-pending-face) + (t + 'ledger-font-posting-amount-face))) + (when end-of-line-comment + (setq start (point)) + (end-of-line) + (ledger-fontify-set-face (list (- start 1) (point)) ;; subtract 1 from start because we passed the semi-colon + 'ledger-font-comment-face)))))) (defun ledger-fontify-directive-at (pos) - "Fontify the directive at POS." - (let ((extents (ledger-navigate-find-element-extents pos)) - (face 'ledger-font-default-face)) - (cond ((looking-at "=") - (setq face 'ledger-font-auto-xact-face)) - ((looking-at "~") - (setq face 'ledger-font-periodic-xact-face)) - ((looking-at "[;#%|\\*]") - (setq face 'ledger-font-comment-face)) - ((looking-at "\\(year\\)\\|Y") - (setq face 'ledger-font-year-directive-face)) - ((looking-at "account") - (setq face 'ledger-font-account-directive-face)) - ((looking-at "apply") - (setq face 'ledger-font-apply-directive-face)) - ((looking-at "alias") - (setq face 'ledger-font-alias-directive-face)) - ((looking-at "assert") - (setq face 'ledger-font-assert-directive-face)) - ((looking-at "\\(bucket\\)\\|A") - (setq face 'ledger-font-bucket-directive-face)) - ((looking-at "capture") - (setq face 'ledger-font-capture-directive-face)) - ((looking-at "check") - (setq face 'ledger-font-check-directive-face)) - ((looking-at "commodity") - (setq face 'ledger-font-commodity-directive-face)) - ((looking-at "define") - (setq face 'ledger-font-define-directive-face)) - ((looking-at "end") - (setq face 'ledger-font-end-directive-face)) - ((looking-at "expr") - (setq face 'ledger-font-expr-directive-face)) - ((looking-at "fixed") - (setq face 'ledger-font-fixed-directive-face)) - ((looking-at "include") - (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))) + "Fontify the directive at POS." + (let ((extents (ledger-navigate-find-element-extents pos)) + (face 'ledger-font-default-face)) + (cond ((looking-at "=") + (setq face 'ledger-font-auto-xact-face)) + ((looking-at "~") + (setq face 'ledger-font-periodic-xact-face)) + ((looking-at "[;#%|\\*]") + (setq face 'ledger-font-comment-face)) + ((looking-at "\\(year\\)\\|Y") + (setq face 'ledger-font-year-directive-face)) + ((looking-at "account") + (setq face 'ledger-font-account-directive-face)) + ((looking-at "apply") + (setq face 'ledger-font-apply-directive-face)) + ((looking-at "alias") + (setq face 'ledger-font-alias-directive-face)) + ((looking-at "assert") + (setq face 'ledger-font-assert-directive-face)) + ((looking-at "\\(bucket\\)\\|A") + (setq face 'ledger-font-bucket-directive-face)) + ((looking-at "capture") + (setq face 'ledger-font-capture-directive-face)) + ((looking-at "check") + (setq face 'ledger-font-check-directive-face)) + ((looking-at "commodity") + (setq face 'ledger-font-commodity-directive-face)) + ((looking-at "define") + (setq face 'ledger-font-define-directive-face)) + ((looking-at "end") + (setq face 'ledger-font-end-directive-face)) + ((looking-at "expr") + (setq face 'ledger-font-expr-directive-face)) + ((looking-at "fixed") + (setq face 'ledger-font-fixed-directive-face)) + ((looking-at "include") + (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))) (defun ledger-fontify-set-face (extents face) - "Set the text in EXTENTS to FACE." - (put-text-property (car extents) (cadr extents) 'face face)) + "Set the text in EXTENTS to FACE." + (put-text-property (car extents) (cadr extents) 'face face)) (provide 'ledger-fontify) diff --git a/lisp/ledger-init.el b/lisp/ledger-init.el index 49d74098..04d5f656 100644 --- a/lisp/ledger-init.el +++ b/lisp/ledger-init.el @@ -35,7 +35,7 @@ (defvar ledger-default-date-format "%Y/%m/%d") (defun ledger-init-parse-initialization (buffer) - "Parse the .ledgerrc file in BUFFER." + "Parse the .ledgerrc file in BUFFER." (with-current-buffer buffer (let (environment-alist) (goto-char (point-min)) @@ -56,7 +56,7 @@ environment-alist))) (defun ledger-init-load-init-file () - "Load and parse the .ledgerrc file." + "Load and parse the .ledgerrc file." (interactive) (let ((init-base-name (file-name-nondirectory ledger-init-file-name))) (if (get-buffer init-base-name) ;; init file already loaded, parse it and leave it diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el index 4e2beff6..3b01aa10 100644 --- a/lisp/ledger-mode.el +++ b/lisp/ledger-mode.el @@ -63,7 +63,7 @@ (defun ledger-mode-dump-variable (var) "Format VAR for dump to buffer." - (if var + (if var (insert (format " %s: %S\n" (symbol-name var) (eval var))))) (defun ledger-mode-dump-group (group) @@ -78,7 +78,7 @@ (defun ledger-mode-dump-configuration () "Dump all customizations." - (interactive) + (interactive) (find-file "ledger-mode-dump") (ledger-mode-dump-group 'ledger)) @@ -99,11 +99,11 @@ (defun ledger-read-account-with-prompt (prompt) "Read an account from the minibuffer with PROMPT." - (let ((context (ledger-context-at-point))) + (let ((context (ledger-context-at-point))) (ledger-read-string-with-default prompt - (if (eq (ledger-context-current-field context) 'account) - (regexp-quote (ledger-context-field-value context 'account)) - nil)))) + (if (eq (ledger-context-current-field context) 'account) + (regexp-quote (ledger-context-field-value context 'account)) + nil)))) (defun ledger-read-date (prompt) "Return user-supplied date after `PROMPT', defaults to today." @@ -222,7 +222,7 @@ With a prefix argument, remove the effective date." (defun ledger-mode-remove-extra-lines () "Get rid of multiple empty lines." - (goto-char (point-min)) + (goto-char (point-min)) (while (re-search-forward "\n\n\\(\n\\)+" nil t) (replace-match "\n\n"))) @@ -338,10 +338,10 @@ With a prefix argument, remove the effective date." '(ledger-font-lock-keywords t t nil nil (font-lock-fontify-region-function . ledger-fontify-buffer-part)))) - (set (make-local-variable 'pcomplete-parse-arguments-function) 'ledger-parse-arguments) - (set (make-local-variable 'pcomplete-command-completion-function) 'ledger-complete-at-point) + (set (make-local-variable 'pcomplete-parse-arguments-function) 'ledger-parse-arguments) + (set (make-local-variable 'pcomplete-command-completion-function) 'ledger-complete-at-point) (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t) - (add-hook 'after-save-hook 'ledger-report-redo) + (add-hook 'after-save-hook 'ledger-report-redo) (add-hook 'post-command-hook 'ledger-highlight-xact-under-point nil t) diff --git a/lisp/ledger-navigate.el b/lisp/ledger-navigate.el index 904faf8c..4da857a7 100644 --- a/lisp/ledger-navigate.el +++ b/lisp/ledger-navigate.el @@ -39,49 +39,49 @@ (goto-char (point-max)))) (defun ledger-navigate-start-xact-or-directive-p () - "Return t if at the beginning of an empty or all-whitespace line." - (not (looking-at "[ \t]\\|\\(^$\\)"))) + "Return t if at the beginning of an empty or all-whitespace line." + (not (looking-at "[ \t]\\|\\(^$\\)"))) (defun ledger-navigate-next-xact-or-directive () - "Move to the beginning of the next xact or directive." - (interactive) - (beginning-of-line) - (if (ledger-navigate-start-xact-or-directive-p) ; if we are the start of an xact, move forward to the next xact - (progn - (forward-line) - (if (not (ledger-navigate-start-xact-or-directive-p)) ; we have moved forward and are not at another xact, recurse forward - (ledger-navigate-next-xact-or-directive))) - (while (not (or (eobp) ; we didn't start off at the beginning of an xact - (ledger-navigate-start-xact-or-directive-p))) - (forward-line)))) + "Move to the beginning of the next xact or directive." + (interactive) + (beginning-of-line) + (if (ledger-navigate-start-xact-or-directive-p) ; if we are the start of an xact, move forward to the next xact + (progn + (forward-line) + (if (not (ledger-navigate-start-xact-or-directive-p)) ; we have moved forward and are not at another xact, recurse forward + (ledger-navigate-next-xact-or-directive))) + (while (not (or (eobp) ; we didn't start off at the beginning of an xact + (ledger-navigate-start-xact-or-directive-p))) + (forward-line)))) (defun ledger-navigate-prev-xact-or-directive () "Move point to beginning of previous xact." - (interactive) - (let ((context (car (ledger-context-at-point)))) - (when (equal context 'acct-transaction) - (ledger-navigate-beginning-of-xact)) - (beginning-of-line) - (re-search-backward "^[[:graph:]]" nil t))) + (interactive) + (let ((context (car (ledger-context-at-point)))) + (when (equal context 'acct-transaction) + (ledger-navigate-beginning-of-xact)) + (beginning-of-line) + (re-search-backward "^[[:graph:]]" nil t))) (defun ledger-navigate-beginning-of-xact () - "Move point to the beginning of the current xact." - (interactive) - ;; need to start at the beginning of a line incase we are in the first line of an xact already. - (beginning-of-line) - (let ((sreg (concat "^\\(=\\|~\\|" ledger-iso-date-regexp "\\)"))) - (unless (looking-at sreg) - (re-search-backward sreg nil t) - (beginning-of-line))) - (point)) + "Move point to the beginning of the current xact." + (interactive) + ;; need to start at the beginning of a line incase we are in the first line of an xact already. + (beginning-of-line) + (let ((sreg (concat "^\\(=\\|~\\|" ledger-iso-date-regexp "\\)"))) + (unless (looking-at sreg) + (re-search-backward sreg nil t) + (beginning-of-line))) + (point)) (defun ledger-navigate-end-of-xact () "Move point to end of xact." - (interactive) + (interactive) (ledger-navigate-next-xact-or-directive) - (re-search-backward ".$") - (end-of-line) - (point)) + (re-search-backward ".$") + (end-of-line) + (point)) (defun ledger-navigate-to-line (line-number) "Rapidly move point to line LINE-NUMBER." @@ -95,61 +95,61 @@ Requires empty line separating xacts." (save-excursion (goto-char pos) (list (ledger-navigate-beginning-of-xact) - (ledger-navigate-end-of-xact)))) + (ledger-navigate-end-of-xact)))) (defun ledger-navigate-find-directive-extents (pos) "Return the extents of the directive at POS." - (goto-char pos) - (let ((begin (progn (beginning-of-line) - (point))) - (end (progn (end-of-line) - (+ 1 (point))))) - ;; handle block comments here - (beginning-of-line) - (if (looking-at " *;") - (progn - (while (and (looking-at " *;") - (> (point) (point-min))) - (forward-line -1)) - ;; We are either at the beginning of the buffer, or we found - ;; a line outside the comment. If we are not at the - ;; beginning of the buffer then we need to move forward a - ;; line. - (if (> (point) (point-min)) - (progn (forward-line 1) - (beginning-of-line))) - (setq begin (point)) - (goto-char pos) - (beginning-of-line) - (while (and (looking-at " *;") - (< (point) (point-max))) - (forward-line 1)) - (setq end (point)))) - (list begin end))) + (goto-char pos) + (let ((begin (progn (beginning-of-line) + (point))) + (end (progn (end-of-line) + (+ 1 (point))))) + ;; handle block comments here + (beginning-of-line) + (if (looking-at " *;") + (progn + (while (and (looking-at " *;") + (> (point) (point-min))) + (forward-line -1)) + ;; We are either at the beginning of the buffer, or we found + ;; a line outside the comment. If we are not at the + ;; beginning of the buffer then we need to move forward a + ;; line. + (if (> (point) (point-min)) + (progn (forward-line 1) + (beginning-of-line))) + (setq begin (point)) + (goto-char pos) + (beginning-of-line) + (while (and (looking-at " *;") + (< (point) (point-max))) + (forward-line 1)) + (setq end (point)))) + (list begin end))) (defun ledger-navigate-block-comment (pos) "Move past the block comment at POS, and return its extents." - (interactive "d") - (goto-char pos) - (let ((begin (progn (beginning-of-line) - (point))) - (end (progn (end-of-line) - (point)))) - ;; handle block comments here - (beginning-of-line) - (if (looking-at " *;") - (progn - (while (and (looking-at " *;") - (> (point) (point-min))) - (forward-line -1)) - (setq begin (point)) - (goto-char pos) - (beginning-of-line) - (while (and (looking-at " *;") - (< (point) (point-max))) - (forward-line 1)) - (setq end (point)))) - (list begin end))) + (interactive "d") + (goto-char pos) + (let ((begin (progn (beginning-of-line) + (point))) + (end (progn (end-of-line) + (point)))) + ;; handle block comments here + (beginning-of-line) + (if (looking-at " *;") + (progn + (while (and (looking-at " *;") + (> (point) (point-min))) + (forward-line -1)) + (setq begin (point)) + (goto-char pos) + (beginning-of-line) + (while (and (looking-at " *;") + (< (point) (point-max))) + (forward-line 1)) + (setq end (point)))) + (list begin end))) (defun ledger-navigate-find-element-extents (pos) diff --git a/lisp/ledger-occur.el b/lisp/ledger-occur.el index a4fde2e1..2ee56e7b 100644 --- a/lisp/ledger-occur.el +++ b/lisp/ledger-occur.el @@ -118,7 +118,7 @@ currently active." Argument OVL-BOUNDS contains bounds for the transactions to be left visible." (let* ((beg (caar ovl-bounds)) (end (cadar ovl-bounds))) - (ledger-occur-remove-overlays) + (ledger-occur-remove-overlays) (ledger-occur-make-invisible-overlay (point-min) (1- beg)) (dolist (visible (cdr ovl-bounds)) (ledger-occur-make-visible-overlay beg end) @@ -143,25 +143,25 @@ Argument OVL-BOUNDS contains bounds for the transactions to be left visible." (while (not (eobp)) ;; if something found (when (setq endpoint (re-search-forward regex nil 'end)) - (setq bounds (ledger-navigate-find-element-extents endpoint)) - (push bounds lines) - ;; move to the end of the xact, no need to search inside it more + (setq bounds (ledger-navigate-find-element-extents endpoint)) + (push bounds lines) + ;; move to the end of the xact, no need to search inside it more (goto-char (cadr bounds)))) (nreverse lines)))) (defun ledger-occur-compress-matches (buffer-matches) "identify sequential xacts to reduce number of overlays required" - (if buffer-matches - (let ((points (list)) - (current-beginning (caar buffer-matches)) - (current-end (cadar buffer-matches))) - (dolist (match (cdr buffer-matches)) - (if (< (- (car match) current-end) 2) - (setq current-end (cadr match)) - (push (list current-beginning current-end) points) - (setq current-beginning (car match)) - (setq current-end (cadr match)))) - (nreverse (push (list current-beginning current-end) points))))) + (if buffer-matches + (let ((points (list)) + (current-beginning (caar buffer-matches)) + (current-end (cadar buffer-matches))) + (dolist (match (cdr buffer-matches)) + (if (< (- (car match) current-end) 2) + (setq current-end (cadr match)) + (push (list current-beginning current-end) points) + (setq current-beginning (car match)) + (setq current-end (cadr match)))) + (nreverse (push (list current-beginning current-end) points))))) (provide 'ledger-occur) diff --git a/lisp/ledger-post.el b/lisp/ledger-post.el index e0c7aaee..527a2044 100644 --- a/lisp/ledger-post.el +++ b/lisp/ledger-post.el @@ -95,8 +95,8 @@ at beginning of account" (current-column)))) (defun ledger-post-align-xact (pos) - "Align all the posting in the xact at POS." - (interactive "d") + "Align all the posting in the xact at POS." + (interactive "d") (let ((bounds (ledger-navigate-find-xact-extents pos))) (ledger-post-align-postings (car bounds) (cadr bounds)))) diff --git a/lisp/ledger-reconcile.el b/lisp/ledger-reconcile.el index f9a5c21b..2396748a 100644 --- a/lisp/ledger-reconcile.el +++ b/lisp/ledger-reconcile.el @@ -77,7 +77,7 @@ Default is ledger-default-date-format." :group 'ledger-reconcile) (defcustom ledger-reconcile-buffer-header "Reconciling account %s\n\n" - "Default header string for the reconcile buffer. + "Default header string for the reconcile buffer. If non-nil, the name of the account being reconciled will be substituted into the '%s'. If nil, no header will be displayed." @@ -85,7 +85,7 @@ If non-nil, the name of the account being reconciled will be substituted :group 'ledger-reconcile) (defcustom ledger-reconcile-buffer-line-format "%(date)s %-4(code)s %-50(payee)s %-30(account)s %15(amount)s\n" - "Format string for the ledger reconcile posting format. + "Format string for the ledger reconcile posting format. Available fields are date, status, code, payee, account, amount. The format for each field is %WIDTH(FIELD), WIDTH can be preced by a minus sign which mean to left justify and pad the @@ -124,12 +124,12 @@ Possible values are '(date)', '(amount)', '(payee)' or '(0)' for no sorting, i.e "If S is shorter than LEN, pad it with PADDING on the left." (let ((extra (max 0 (- len (length s))))) (concat (make-string extra (string-to-char padding)) - s))) + s))) (defun ledger-reconcile-s-pad-right (len padding s) "If S is shorter than LEN, pad it with PADDING on the right." (let ((extra (max 0 (- len (length s))))) (concat s - (make-string extra (string-to-char padding))))) + (make-string extra (string-to-char padding))))) (defun ledger-reconcile-s-left (len s) "Return up to the LEN first chars of S." (if (> (length s) len) @@ -139,7 +139,7 @@ Possible values are '(date)', '(amount)', '(payee)' or '(0)' for no sorting, i.e "Return up to the LEN last chars of S." (let ((l (length s))) (if (> l len) - (substring s (- l len) l) + (substring s (- l len) l) s))) (defun ledger-reconcile-truncate-right (str len) @@ -253,9 +253,9 @@ Return the number of uncleared xacts found." (with-current-buffer recon-buf (ledger-reconcile-refresh) (set-buffer-modified-p nil)) - (when curbufwin - (select-window curbufwin) - (goto-char curpoint))))) + (when curbufwin + (select-window curbufwin) + (goto-char curpoint))))) (defun ledger-reconcile-add () "Use ledger xact to add a new transaction." @@ -281,34 +281,34 @@ Return the number of uncleared xacts found." (defun ledger-reconcile-visit (&optional come-back) "Recenter ledger buffer on transaction and COME-BACK if non-nil." (interactive) - (beginning-of-line) - (let* ((where (get-text-property (1+ (point)) 'where)) - (target-buffer (if where - (ledger-reconcile-get-buffer where) - nil)) - (cur-win (get-buffer-window (get-buffer ledger-recon-buffer-name)))) - (when target-buffer - (switch-to-buffer-other-window target-buffer) - (ledger-navigate-to-line (cdr where)) - (forward-char) - (recenter) - (ledger-highlight-xact-under-point) - (forward-char -1) - (when (and come-back cur-win) - (select-window cur-win) - (get-buffer ledger-recon-buffer-name))))) + (beginning-of-line) + (let* ((where (get-text-property (1+ (point)) 'where)) + (target-buffer (if where + (ledger-reconcile-get-buffer where) + nil)) + (cur-win (get-buffer-window (get-buffer ledger-recon-buffer-name)))) + (when target-buffer + (switch-to-buffer-other-window target-buffer) + (ledger-navigate-to-line (cdr where)) + (forward-char) + (recenter) + (ledger-highlight-xact-under-point) + (forward-char -1) + (when (and come-back cur-win) + (select-window cur-win) + (get-buffer ledger-recon-buffer-name))))) (defun ledger-reconcile-save () "Save the ledger buffer." (interactive) - (let ((cur-buf (current-buffer)) - (cur-point (point))) - (dolist (buf (cons ledger-buf ledger-bufs)) - (with-current-buffer buf - (basic-save-buffer))) - (switch-to-buffer-other-window cur-buf) - (goto-char cur-point))) + (let ((cur-buf (current-buffer)) + (cur-point (point))) + (dolist (buf (cons ledger-buf ledger-bufs)) + (with-current-buffer buf + (basic-save-buffer))) + (switch-to-buffer-other-window cur-buf) + (goto-char cur-point))) (defun ledger-reconcile-finish () @@ -369,55 +369,55 @@ POSTING is used in `ledger-clear-whole-transactions' is nil." (nth 0 posting))))) ;; return line-no of posting (defun ledger-reconcile-compile-format-string (fstr) - "Return a function that implements the format string in FSTR." - (let (fields - (start 0)) - (while (string-match "(\\(.*?\\))" fstr start) - (setq fields (cons (intern (match-string 1 fstr)) fields)) - (setq start (match-end 0))) - (setq fields (list* 'format (replace-regexp-in-string "(.*?)" "" fstr) (nreverse fields))) - `(lambda (date code status payee account amount) - ,fields))) + "Return a function that implements the format string in FSTR." + (let (fields + (start 0)) + (while (string-match "(\\(.*?\\))" fstr start) + (setq fields (cons (intern (match-string 1 fstr)) fields)) + (setq start (match-end 0))) + (setq fields (list* 'format (replace-regexp-in-string "(.*?)" "" fstr) (nreverse fields))) + `(lambda (date code status payee account amount) + ,fields))) (defun ledger-reconcile-format-posting (beg where fmt date code status payee account amount) - "Format posting for the reconcile buffer." - (insert (funcall fmt date code status payee account amount)) - - ; Set face depending on cleared status - (if status - (if (eq status 'pending) - (set-text-properties beg (1- (point)) - (list 'face 'ledger-font-reconciler-pending-face - 'where where)) - (set-text-properties beg (1- (point)) - (list 'face 'ledger-font-reconciler-cleared-face - 'where where))) - (set-text-properties beg (1- (point)) - (list 'face 'ledger-font-reconciler-uncleared-face - 'where where)))) + "Format posting for the reconcile buffer." + (insert (funcall fmt date code status payee account amount)) + + ; Set face depending on cleared status + (if status + (if (eq status 'pending) + (set-text-properties beg (1- (point)) + (list 'face 'ledger-font-reconciler-pending-face + 'where where)) + (set-text-properties beg (1- (point)) + (list 'face 'ledger-font-reconciler-cleared-face + 'where where))) + (set-text-properties beg (1- (point)) + (list 'face 'ledger-font-reconciler-uncleared-face + 'where where)))) (defun ledger-reconcile-format-xact (xact fmt) - "Format XACT using FMT." - (let ((date-format (or (cdr (assoc "date-format" ledger-environment-alist)) - ledger-default-date-format))) - (dolist (posting (nthcdr 5 xact)) - (let ((beg (point)) - (where (ledger-marker-where-xact-is xact posting))) - (ledger-reconcile-format-posting beg - where - fmt - (format-time-string date-format (nth 2 xact)) ; date - (if (nth 3 xact) (nth 3 xact) "") ; code - (nth 3 posting) ; status + "Format XACT using FMT." + (let ((date-format (or (cdr (assoc "date-format" ledger-environment-alist)) + ledger-default-date-format))) + (dolist (posting (nthcdr 5 xact)) + (let ((beg (point)) + (where (ledger-marker-where-xact-is xact posting))) + (ledger-reconcile-format-posting beg + where + fmt + (format-time-string date-format (nth 2 xact)) ; date + (if (nth 3 xact) (nth 3 xact) "") ; code + (nth 3 posting) ; status (ledger-reconcile-truncate-right - (nth 4 xact) ; payee - ledger-reconcile-buffer-payee-max-chars) + (nth 4 xact) ; payee + ledger-reconcile-buffer-payee-max-chars) (ledger-reconcile-truncate-left - (nth 1 posting) ; account - ledger-reconcile-buffer-account-max-chars) - (nth 2 posting)))))) ; amount + (nth 1 posting) ; account + ledger-reconcile-buffer-account-max-chars) + (nth 2 posting)))))) ; amount (defun ledger-do-reconcile (&optional sort) "SORT the uncleared transactions in the account and display them in the *Reconcile* buffer. @@ -437,10 +437,10 @@ Return a count of the uncleared transactions." (unless (eobp) (if (looking-at "(") (read (current-buffer))))))) ;current-buffer is the *temp* created above - (fmt (ledger-reconcile-compile-format-string ledger-reconcile-buffer-line-format))) + (fmt (ledger-reconcile-compile-format-string ledger-reconcile-buffer-line-format))) (if (and ledger-success (> (length xacts) 0)) (progn - (insert (format ledger-reconcile-buffer-header account)) + (insert (format ledger-reconcile-buffer-header account)) (dolist (xact xacts) (ledger-reconcile-format-xact xact fmt)) (goto-char (point-max)) @@ -493,11 +493,11 @@ moved and recentered. If they aren't strange things happen." (pop-to-buffer rbuf))) (defun ledger-reconcile-check-valid-account (account) - "Check to see if ACCOUNT exists in the ledger file" - (if (> (length account) 0) - (save-excursion - (goto-char (point-min)) - (search-forward account nil t)))) + "Check to see if ACCOUNT exists in the ledger file" + (if (> (length account) 0) + (save-excursion + (goto-char (point-min)) + (search-forward account nil t)))) (defun ledger-reconcile () "Start reconciling, prompt for account." @@ -506,38 +506,38 @@ moved and recentered. If they aren't strange things happen." (buf (current-buffer)) (rbuf (get-buffer ledger-recon-buffer-name))) - (when (ledger-reconcile-check-valid-account account) - (add-hook 'after-save-hook 'ledger-reconcile-refresh-after-save nil t) - - (if rbuf ;; *Reconcile* already exists - (with-current-buffer rbuf - (set 'ledger-acct account) ;; already buffer local - (when (not (eq buf rbuf)) - ;; called from some other ledger-mode buffer - (ledger-reconcile-quit-cleanup) - (setq ledger-buf buf)) ;; should already be buffer-local - - (unless (get-buffer-window rbuf) - (ledger-reconcile-open-windows buf rbuf))) - - ;; no recon-buffer, starting from scratch. - - (with-current-buffer (setq rbuf - (get-buffer-create ledger-recon-buffer-name)) - (ledger-reconcile-open-windows buf rbuf) - (ledger-reconcile-mode) - (make-local-variable 'ledger-target) - (set (make-local-variable 'ledger-buf) buf) - (set (make-local-variable 'ledger-acct) account))) - - ;; Narrow the ledger buffer - (with-current-buffer rbuf - (save-excursion - (if ledger-narrow-on-reconcile - (ledger-occur account))) - (if (> (ledger-reconcile-refresh) 0) - (ledger-reconcile-change-target)) - (ledger-display-balance))))) + (when (ledger-reconcile-check-valid-account account) + (add-hook 'after-save-hook 'ledger-reconcile-refresh-after-save nil t) + + (if rbuf ;; *Reconcile* already exists + (with-current-buffer rbuf + (set 'ledger-acct account) ;; already buffer local + (when (not (eq buf rbuf)) + ;; called from some other ledger-mode buffer + (ledger-reconcile-quit-cleanup) + (setq ledger-buf buf)) ;; should already be buffer-local + + (unless (get-buffer-window rbuf) + (ledger-reconcile-open-windows buf rbuf))) + + ;; no recon-buffer, starting from scratch. + + (with-current-buffer (setq rbuf + (get-buffer-create ledger-recon-buffer-name)) + (ledger-reconcile-open-windows buf rbuf) + (ledger-reconcile-mode) + (make-local-variable 'ledger-target) + (set (make-local-variable 'ledger-buf) buf) + (set (make-local-variable 'ledger-acct) account))) + + ;; Narrow the ledger buffer + (with-current-buffer rbuf + (save-excursion + (if ledger-narrow-on-reconcile + (ledger-occur account))) + (if (> (ledger-reconcile-refresh) 0) + (ledger-reconcile-change-target)) + (ledger-display-balance))))) (defvar ledger-reconcile-mode-abbrev-table) @@ -548,7 +548,7 @@ moved and recentered. If they aren't strange things happen." (defmacro ledger-reconcile-change-sort-key-and-refresh (sort-by) "Set the sort-key to SORT-BY." - `(lambda () + `(lambda () (interactive) (setq ledger-reconcile-sort-key ,sort-by) diff --git a/lisp/ledger-regex.el b/lisp/ledger-regex.el index 41231845..9d8394df 100644 --- a/lisp/ledger-regex.el +++ b/lisp/ledger-regex.el @@ -108,8 +108,8 @@ defs (list `(defmacro - ,(intern (concat "ledger-regex-" (symbol-name name))) - (&optional string) + ,(intern (concat "ledger-regex-" (symbol-name name))) + (&optional string) ,(format "Return the match string for the %s" name) (match-string ,(intern (concat "ledger-regex-" (symbol-name name) @@ -153,9 +153,9 @@ defs (list `(defmacro - ,(intern (concat "ledger-regex-" (symbol-name name) - "-" (symbol-name var))) - (&optional string) + ,(intern (concat "ledger-regex-" (symbol-name name) + "-" (symbol-name var))) + (&optional string) ,(format "Return the sub-group match for the %s %s." name var) (match-string @@ -333,8 +333,8 @@ "\\)")) (defconst ledger-xact-start-regex - (concat "^" ledger-iso-date-regexp ;; subexp 1 - "\\(=" ledger-iso-date-regexp "\\)?" + (concat "^" ledger-iso-date-regexp ;; subexp 1 + "\\(=" ledger-iso-date-regexp "\\)?" )) (defconst ledger-xact-after-date-regex @@ -345,17 +345,17 @@ )) (defconst ledger-posting-regex - (concat "^[ \t]+ ?" ;; initial white space - "\\([*!]\\)? ?" ;; state, subexpr 1 - "\\([[:print:]]+\\([ \t][ \t]\\)\\)" ;; account, subexpr 2 - "\\([^;\n]*\\)" ;; amount, subexpr 4 - "\\(.*\\)" ;; comment, subexpr 5 - )) + (concat "^[ \t]+ ?" ;; initial white space + "\\([*!]\\)? ?" ;; state, subexpr 1 + "\\([[:print:]]+\\([ \t][ \t]\\)\\)" ;; account, subexpr 2 + "\\([^;\n]*\\)" ;; amount, subexpr 4 + "\\(.*\\)" ;; comment, subexpr 5 + )) (defconst ledger-directive-start-regex - "[=~;#%|\\*[A-Za-z]") + "[=~;#%|\\*[A-Za-z]") (provide 'ledger-regex) diff --git a/lisp/ledger-report.el b/lisp/ledger-report.el index c477707f..e10e9672 100644 --- a/lisp/ledger-report.el +++ b/lisp/ledger-report.el @@ -57,7 +57,7 @@ specifier." '(("ledger-file" . ledger-report-ledger-file-format-specifier) ("payee" . ledger-report-payee-format-specifier) ("account" . ledger-report-account-format-specifier) - ("tagname" . ledger-report-tagname-format-specifier) + ("tagname" . ledger-report-tagname-format-specifier) ("tagvalue" . ledger-report-tagvalue-format-specifier)) "An alist mapping ledger report format specifiers to implementing functions. @@ -67,14 +67,14 @@ text that should replace the format specifier." :group 'ledger-report) (defcustom ledger-report-auto-refresh t - "If t then automatically rerun the report when the ledger buffer is saved." - :type 'boolean - :group 'ledger-report) + "If t then automatically rerun the report when the ledger buffer is saved." + :type 'boolean + :group 'ledger-report) (defcustom ledger-report-auto-refresh-sticky-cursor nil - "If t then try to place cursor at same relative position as it was before auto-refresh." - :type 'boolean - :group 'ledger-report) + "If t then try to place cursor at same relative position as it was before auto-refresh." + :type 'boolean + :group 'ledger-report) (defvar ledger-report-buffer-name "*Ledger Report*") @@ -91,10 +91,10 @@ text that should replace the format specifier." (defvar ledger-report-cursor-line-number nil) (defun ledger-report-reverse-report () - "Reverse the order of the report." - (interactive) - (ledger-report-reverse-lines) - (setq ledger-report-is-reversed (not ledger-report-is-reversed))) + "Reverse the order of the report." + (interactive) + (ledger-report-reverse-lines) + (setq ledger-report-is-reversed (not ledger-report-is-reversed))) (defun ledger-report-reverse-lines () (goto-char (point-min)) @@ -203,7 +203,7 @@ used to generate the buffer, navigating the buffer, etc." (set (make-local-variable 'ledger-buf) buf) (set (make-local-variable 'ledger-report-name) report-name) (set (make-local-variable 'ledger-original-window-cfg) wcfg) - (set (make-local-variable 'ledger-report-is-reversed) nil) + (set (make-local-variable 'ledger-report-is-reversed) nil) (ledger-do-report (ledger-report-cmd report-name edit)) (shrink-window-if-larger-than-buffer) (set-buffer-modified-p nil) @@ -387,30 +387,30 @@ Optional EDIT the command." (defun ledger-report-redo () "Redo the report in the current ledger report buffer." (interactive) - (let ((cur-buf (current-buffer))) - (if (and ledger-report-auto-refresh - (or (string= (format-mode-line 'mode-name) "Ledger") - (string= (format-mode-line 'mode-name) "Ledger-Report")) - (get-buffer ledger-report-buffer-name)) - (progn - - (pop-to-buffer (get-buffer ledger-report-buffer-name)) - (shrink-window-if-larger-than-buffer) - (setq buffer-read-only nil) - (setq ledger-report-cursor-line-number (line-number-at-pos)) - (erase-buffer) - (ledger-do-report ledger-report-cmd) - (setq buffer-read-only nil) - (if ledger-report-is-reversed (ledger-report-reverse-lines)) - (if ledger-report-auto-refresh-sticky-cursor (forward-line (- ledger-report-cursor-line-number 5))) - (pop-to-buffer cur-buf))))) + (let ((cur-buf (current-buffer))) + (if (and ledger-report-auto-refresh + (or (string= (format-mode-line 'mode-name) "Ledger") + (string= (format-mode-line 'mode-name) "Ledger-Report")) + (get-buffer ledger-report-buffer-name)) + (progn + + (pop-to-buffer (get-buffer ledger-report-buffer-name)) + (shrink-window-if-larger-than-buffer) + (setq buffer-read-only nil) + (setq ledger-report-cursor-line-number (line-number-at-pos)) + (erase-buffer) + (ledger-do-report ledger-report-cmd) + (setq buffer-read-only nil) + (if ledger-report-is-reversed (ledger-report-reverse-lines)) + (if ledger-report-auto-refresh-sticky-cursor (forward-line (- ledger-report-cursor-line-number 5))) + (pop-to-buffer cur-buf))))) (defun ledger-report-quit () - "Quit the ledger report buffer." - (interactive) - (ledger-report-goto) - (set-window-configuration ledger-original-window-cfg) - (kill-buffer (get-buffer ledger-report-buffer-name))) + "Quit the ledger report buffer." + (interactive) + (ledger-report-goto) + (set-window-configuration ledger-original-window-cfg) + (kill-buffer (get-buffer ledger-report-buffer-name))) (defun ledger-report-edit-reports () "Edit the defined ledger reports." @@ -418,10 +418,10 @@ Optional EDIT the command." (customize-variable 'ledger-reports)) (defun ledger-report-edit-report () - (interactive) - "Edit the current report command in the mini buffer and re-run the report" - (setq ledger-report-cmd (ledger-report-read-command ledger-report-cmd)) - (ledger-report-redo)) + (interactive) + "Edit the current report command in the mini buffer and re-run the report" + (setq ledger-report-cmd (ledger-report-read-command ledger-report-cmd)) + (ledger-report-redo)) (defun ledger-report-read-new-name () "Read the name for a new report from the minibuffer." diff --git a/lisp/ledger-schedule.el b/lisp/ledger-schedule.el index d66fdbab..1fbbcb59 100644 --- a/lisp/ledger-schedule.el +++ b/lisp/ledger-schedule.el @@ -60,21 +60,21 @@ :group 'ledger-schedule) (defcustom ledger-schedule-week-days '(("Mo" 1) - ("Tu" 2) - ("We" 3) - ("Th" 4) - ("Fr" 5) - ("Sa" 6) - ("Su" 7)) - "List of weekday abbreviations. There must be exactly seven + ("Tu" 2) + ("We" 3) + ("Th" 4) + ("Fr" 5) + ("Sa" 6) + ("Su" 7)) + "List of weekday abbreviations. There must be exactly seven entries each with a two character abbreviation for a day and the number of that day in the week. " - :type '(alist :value-type (group integer)) - :group 'ledger-schedule) + :type '(alist :value-type (group integer)) + :group 'ledger-schedule) (defsubst between (val low high) - "Return TRUE if VAL > LOW and < HIGH." - (and (>= val low) (<= val high))) + "Return TRUE if VAL > LOW and < HIGH." + (and (>= val low) (<= val high))) (defun ledger-schedule-days-in-month (month year) "Return number of days in the MONTH, MONTH is from 1 to 12. @@ -86,8 +86,8 @@ If YEAR is nil, assume it is not a leap year" (error "Month out of range, MONTH=%S" month))) (defun ledger-schedule-encode-day-of-week (day-string) - "Return the numerical day of week corresponding to DAY-STRING." - (cadr (assoc day-string ledger-schedule-week-days))) + "Return the numerical day of week corresponding to DAY-STRING." + (cadr (assoc day-string ledger-schedule-week-days))) ;; Macros to handle date expressions @@ -173,10 +173,10 @@ the transaction should be logged for that day." xact-list))) (defun ledger-schedule-read-descriptor-tree (descriptor-string) - "Read DESCRIPTOR-STRING and return a form that evaluates dates." - (ledger-schedule-transform-auto-tree - (split-string - (substring descriptor-string 1 (string-match "]" descriptor-string)) " "))) + "Read DESCRIPTOR-STRING and return a form that evaluates dates." + (ledger-schedule-transform-auto-tree + (split-string + (substring descriptor-string 1 (string-match "]" descriptor-string)) " "))) (defun ledger-schedule-transform-auto-tree (descriptor-string-list) "Take DESCRIPTOR-STRING-LIST, and return a string with a lambda function of date." @@ -202,84 +202,84 @@ the transaction should be logged for that day." (defun ledger-schedule-compile-constraints (descriptor-string) "Return a list with the year, month and day fields split." (let ((fields (split-string descriptor-string "[/\\-]" t))) - (if (string-match "[A-Za-z]" descriptor-string) - (ledger-schedule-constrain-day (nth 0 fields) (nth 1 fields) (nth 2 fields)) - (list 'and - (ledger-schedule-constrain-day (nth 0 fields) (nth 1 fields) (nth 2 fields)) - (ledger-schedule-constrain-year (nth 0 fields) (nth 1 fields) (nth 2 fields)) - (ledger-schedule-constrain-month (nth 0 fields) (nth 1 fields) (nth 2 fields)))))) + (if (string-match "[A-Za-z]" descriptor-string) + (ledger-schedule-constrain-day (nth 0 fields) (nth 1 fields) (nth 2 fields)) + (list 'and + (ledger-schedule-constrain-day (nth 0 fields) (nth 1 fields) (nth 2 fields)) + (ledger-schedule-constrain-year (nth 0 fields) (nth 1 fields) (nth 2 fields)) + (ledger-schedule-constrain-month (nth 0 fields) (nth 1 fields) (nth 2 fields)))))) (defun ledger-schedule-constrain-year (year-desc month-desc day-desc) - "Return a form that constrains the year. + "Return a form that constrains the year. YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the date descriptor." - (cond ((string= year-desc "*") t) - ((/= 0 (string-to-number year-desc)) - `(memq (nth 5 (decode-time date)) ',(mapcar 'string-to-number (split-string year-desc ",")))) - (t - (error "Improperly specified year constraint: %s %s %s" year-desc month-desc day-desc)))) + (cond ((string= year-desc "*") t) + ((/= 0 (string-to-number year-desc)) + `(memq (nth 5 (decode-time date)) ',(mapcar 'string-to-number (split-string year-desc ",")))) + (t + (error "Improperly specified year constraint: %s %s %s" year-desc month-desc day-desc)))) (defun ledger-schedule-constrain-month (year-desc month-desc day-desc) - "Return a form that constrains the month. + "Return a form that constrains the month. YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the date descriptor." - (cond ((string= month-desc "*") - t) ;; always match - ((string= month-desc "E") ;; Even - `(evenp (nth 4 (decode-time date)))) - ((string= month-desc "O") ;; Odd - `(oddp (nth 4 (decode-time date)))) - ((/= 0 (string-to-number month-desc)) ;; Starts with number - `(memq (nth 4 (decode-time date)) ',(mapcar 'string-to-number (split-string month-desc ",")))) - (t - (error "Improperly specified month constraint: %s %s %s" year-desc month-desc day-desc)))) + (cond ((string= month-desc "*") + t) ;; always match + ((string= month-desc "E") ;; Even + `(evenp (nth 4 (decode-time date)))) + ((string= month-desc "O") ;; Odd + `(oddp (nth 4 (decode-time date)))) + ((/= 0 (string-to-number month-desc)) ;; Starts with number + `(memq (nth 4 (decode-time date)) ',(mapcar 'string-to-number (split-string month-desc ",")))) + (t + (error "Improperly specified month constraint: %s %s %s" year-desc month-desc day-desc)))) (defun ledger-schedule-constrain-day (year-desc month-desc day-desc) - "Return a form that constrains the day. + "Return a form that constrains the day. YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the date descriptor." - (cond ((string= day-desc "*") - t) - ((string-match "[A-Za-z]" day-desc) ;; There is something other than digits and commas - (ledger-schedule-parse-complex-date year-desc month-desc day-desc)) - ((/= 0 (string-to-number day-desc)) - `(memq (nth 3 (decode-time date)) ',(mapcar 'string-to-number (split-string day-desc ",")))) - (t - (error "Improperly specified day constraint: %s %s %s" year-desc month-desc day-desc)))) + (cond ((string= day-desc "*") + t) + ((string-match "[A-Za-z]" day-desc) ;; There is something other than digits and commas + (ledger-schedule-parse-complex-date year-desc month-desc day-desc)) + ((/= 0 (string-to-number day-desc)) + `(memq (nth 3 (decode-time date)) ',(mapcar 'string-to-number (split-string day-desc ",")))) + (t + (error "Improperly specified day constraint: %s %s %s" year-desc month-desc day-desc)))) (defun ledger-schedule-parse-complex-date (year-desc month-desc day-desc) - "Parse day descriptors that have repeats." - (let ((years (mapcar 'string-to-number (split-string year-desc ","))) - (months (mapcar 'string-to-number (split-string month-desc ","))) - (day-parts (split-string day-desc "+")) - (every-nth (string-match "+" day-desc))) - (if every-nth - (let ((base-day (string-to-number (car day-parts))) - (increment (string-to-number (substring (cadr day-parts) 0 - (string-match "[A-Za-z]" (cadr day-parts))))) - (day-of-week (ledger-schedule-encode-day-of-week - (substring (cadr day-parts) (string-match "[A-Za-z]" (cadr day-parts)))))) - (ledger-schedule-constrain-every-count-day day-of-week increment (encode-time 0 0 0 base-day (car months) (car years)))) - (let ((count (string-to-number (substring (car day-parts) 0 1))) - (day-of-week (ledger-schedule-encode-day-of-week - (substring (car day-parts) (string-match "[A-Za-z]" (car day-parts)))))) - (ledger-schedule-constrain-day-in-month count day-of-week))))) + "Parse day descriptors that have repeats." + (let ((years (mapcar 'string-to-number (split-string year-desc ","))) + (months (mapcar 'string-to-number (split-string month-desc ","))) + (day-parts (split-string day-desc "+")) + (every-nth (string-match "+" day-desc))) + (if every-nth + (let ((base-day (string-to-number (car day-parts))) + (increment (string-to-number (substring (cadr day-parts) 0 + (string-match "[A-Za-z]" (cadr day-parts))))) + (day-of-week (ledger-schedule-encode-day-of-week + (substring (cadr day-parts) (string-match "[A-Za-z]" (cadr day-parts)))))) + (ledger-schedule-constrain-every-count-day day-of-week increment (encode-time 0 0 0 base-day (car months) (car years)))) + (let ((count (string-to-number (substring (car day-parts) 0 1))) + (day-of-week (ledger-schedule-encode-day-of-week + (substring (car day-parts) (string-match "[A-Za-z]" (car day-parts)))))) + (ledger-schedule-constrain-day-in-month count day-of-week))))) (defun ledger-schedule-list-upcoming-xacts (candidate-items early horizon) - "Search CANDIDATE-ITEMS for xacts that occur within the period today - EARLY to today + HORIZON." - (let ((start-date (time-subtract (current-time) (days-to-time early))) - test-date items) - (loop for day from 0 to (+ early horizon) by 1 do - (setq test-date (time-add start-date (days-to-time day))) - (dolist (candidate candidate-items items) - (if (funcall (car candidate) test-date) - (setq items (append items (list (list test-date (cadr candidate)))))))) - items)) + "Search CANDIDATE-ITEMS for xacts that occur within the period today - EARLY to today + HORIZON." + (let ((start-date (time-subtract (current-time) (days-to-time early))) + test-date items) + (loop for day from 0 to (+ early horizon) by 1 do + (setq test-date (time-add start-date (days-to-time day))) + (dolist (candidate candidate-items items) + (if (funcall (car candidate) test-date) + (setq items (append items (list (list test-date (cadr candidate)))))))) + items)) (defun ledger-schedule-create-auto-buffer (candidate-items early horizon ledger-buf) "Format CANDIDATE-ITEMS for display." @@ -290,7 +290,7 @@ date descriptor." (with-current-buffer schedule-buf (erase-buffer) (dolist (candidate candidates) - (insert (format-time-string date-format (car candidate) ) " " (cadr candidate) "\n")) + (insert (format-time-string date-format (car candidate) ) " " (cadr candidate) "\n")) (ledger-mode)) (length candidates))) @@ -311,15 +311,15 @@ Use a prefix arg to change the default value" (read-number "Look forward: " ledger-schedule-look-forward)) (list ledger-schedule-file ledger-schedule-look-backward ledger-schedule-look-forward))) (if (and file - (file-exists-p file)) - (progn - (ledger-schedule-create-auto-buffer - (ledger-schedule-scan-transactions file) - look-backward - look-forward - (current-buffer)) - (pop-to-buffer ledger-schedule-buffer-name)) - (error "Could not find ledger schedule file at %s" file))) + (file-exists-p file)) + (progn + (ledger-schedule-create-auto-buffer + (ledger-schedule-scan-transactions file) + look-backward + look-forward + (current-buffer)) + (pop-to-buffer ledger-schedule-buffer-name)) + (error "Could not find ledger schedule file at %s" file))) (provide 'ledger-schedule) diff --git a/lisp/ledger-sort.el b/lisp/ledger-sort.el index 870e298c..23e93dc9 100644 --- a/lisp/ledger-sort.el +++ b/lisp/ledger-sort.el @@ -28,17 +28,17 @@ (defun ledger-sort-find-start () - "Find the beginning of a sort region" + "Find the beginning of a sort region" (if (re-search-forward ";.*Ledger-mode:.*Start sort" nil t) (match-end 0))) (defun ledger-sort-find-end () - "Find the end of a sort region" + "Find the end of a sort region" (if (re-search-forward ";.*Ledger-mode:.*End sort" nil t) (match-end 0))) (defun ledger-sort-insert-start-mark () - "Insert a marker to start a sort region" + "Insert a marker to start a sort region" (interactive) (save-excursion (goto-char (point-min)) @@ -48,7 +48,7 @@ (insert "\n; Ledger-mode: Start sort\n\n")) (defun ledger-sort-insert-end-mark () - "Insert a marker to end a sort region" + "Insert a marker to end a sort region" (interactive) (save-excursion (goto-char (point-min)) @@ -64,7 +64,7 @@ (defun ledger-sort-region (beg end) "Sort the region from BEG to END in chronological order." (interactive "r") ;; load beg and end from point and mark - ;; automagically + ;; automagically (let ((new-beg beg) (new-end end) point-delta @@ -77,14 +77,14 @@ (save-excursion (save-restriction (goto-char beg) - ;; make sure point is at the beginning of a xact + ;; make sure point is at the beginning of a xact (ledger-navigate-next-xact) (unless (looking-at ledger-payee-any-status-regex) (ledger-navigate-next-xact)) (setq new-beg (point)) (goto-char end) (ledger-navigate-next-xact) - ;; make sure end of region is at the beginning of next record + ;; make sure end of region is at the beginning of next record ;; after the region (setq new-end (point)) (narrow-to-region new-beg new-end) diff --git a/lisp/ledger-state.el b/lisp/ledger-state.el index 47805f15..73e3c72c 100644 --- a/lisp/ledger-state.el +++ b/lisp/ledger-state.el @@ -114,8 +114,8 @@ dropped." (when (not (eq (ledger-state-from-char (char-after)) 'comment)) (insert (ledger-char-from-state cur-status) " ") (if (and (search-forward " " (line-end-position) t) - (looking-at " ")) - (delete-char 2))) + (looking-at " ")) + (delete-char 2))) (forward-line)) (setq new-status nil))) diff --git a/lisp/ledger-xact.el b/lisp/ledger-xact.el index bad36e7a..64f69cbe 100644 --- a/lisp/ledger-xact.el +++ b/lisp/ledger-xact.el @@ -185,8 +185,8 @@ correct chronological place in the buffer." (goto-char (point-min)) (if (looking-at "Error: ") (error (concat "Error in ledger-add-transaction: " (buffer-string))) - (ledger-post-align-postings (point-min) (point-max)) - (buffer-string))) + (ledger-post-align-postings (point-min) (point-max)) + (buffer-string))) "\n")) (progn (insert (car args) " \n\n") -- cgit v1.2.3 From 8a98bd83b90df24ad780419a4acd9e14f61c4d7c Mon Sep 17 00:00:00 2001 From: thdox Date: Mon, 22 Dec 2014 10:21:20 +0100 Subject: Add instructions for Fedora 20. [ci skip] --- acprep | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/acprep b/acprep index 9e661aad..1165c2b9 100755 --- a/acprep +++ b/acprep @@ -616,8 +616,8 @@ class PrepareBuild(CommandLineApp): self.execute(*packages) if exists('/etc/redhat-release'): - release = open('/etc/redhat-release') - if release.readline().startswith('CentOS'): + release = open('/etc/redhat-release').readline() + if release.startswith('CentOS'): self.log.info('Looks like you are using YUM on CentOS') packages = [ 'sudo', 'yum', 'install', @@ -648,6 +648,31 @@ class PrepareBuild(CommandLineApp): self.log.info('Looks like you are using Cygwin') self.log.info('Please install the dependencies manually.') + elif release.startswith('Fedora release 20'): + self.log.info('Looks like you are using YUM on Fedora 20') + packages = [ + 'sudo', 'yum', 'install', + 'boost-devel', + 'bzip2-devel', + 'cmake', + 'doxygen', + 'gcc', + 'gcc-c++', + 'gettext', + 'gettext-devel', + 'gmp-devel', + 'lcov', + 'libedit-devel', + 'mpfr-devel', + 'ninja-build', + 'python-devel', + 'sloccount', + 'texinfo', + 'zlib-devel' + ] + self.log.info('Executing: ' + ' '.join(packages)) + self.execute(*packages) + ######################################################################### # Determine the system's basic configuration # ######################################################################### -- cgit v1.2.3 From fde30f19774f9b933722f9bdf33cce59df129980 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Wed, 18 Feb 2015 21:33:22 +0100 Subject: [tests] Allow testing of multi-line examples --- test/DocTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/DocTests.py b/test/DocTests.py index cbad9ca7..04241188 100755 --- a/test/DocTests.py +++ b/test/DocTests.py @@ -113,7 +113,7 @@ class DocTests: else: return None - command = shlex.split(command) + command = filter(lambda x: x != '\n', shlex.split(command)) if command[0] == '$': command.remove('$') index = command.index('ledger') command[index] = self.ledger -- cgit v1.2.3 From ebd2334db391c371e3e7efc1a140d469626cf24d Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Sun, 15 Feb 2015 07:52:53 +0100 Subject: [doc] Use ASCII single quote instead of apostrophe --- doc/ledger.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ledger.1 b/doc/ledger.1 index 67c24470..ed1828c5 100644 --- a/doc/ledger.1 +++ b/doc/ledger.1 @@ -1215,7 +1215,7 @@ Convert .Ar value to a character string. .It Sy today -Return today’s date. +Return today's date. .It Sy total Return the total of the posting. .It Sy total_expr -- cgit v1.2.3 From f59abd4c765b08cbd5f18ec851b1d78a766a1c93 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Sun, 15 Feb 2015 08:25:35 +0100 Subject: [ledger] Remove --full-help option since it is the same as --help. --- doc/ledger.1 | 4 ---- src/global.cc | 3 --- src/global.h | 1 - 3 files changed, 8 deletions(-) diff --git a/doc/ledger.1 b/doc/ledger.1 index ed1828c5..c22b9018 100644 --- a/doc/ledger.1 +++ b/doc/ledger.1 @@ -560,7 +560,6 @@ The latest available price is used. .It Fl \-file Ar FILE Read journal data from .Ar FILE . -.\".It Fl \-full-help .It Fl \-first Ar INT Print the first .Ar INT @@ -628,9 +627,6 @@ can be a handy way to remember which options do what. This help screen is also printed if .Nm is run without a command. -.\".It Fl \-help-calc -.\".It Fl \-help-comm -.\".It Fl \-help-disp .It Fl \-immediate Evaluate calculations immediately rather than lazily. .\".It Fl \-import diff --git a/src/global.cc b/src/global.cc index c144e3be..bdaabd5a 100644 --- a/src/global.cc +++ b/src/global.cc @@ -316,9 +316,6 @@ option_t * global_scope_t::lookup_option(const char * p) case 'd': OPT(debug_); break; - case 'f': - OPT(full_help); - break; case 'h': OPT_(help); break; diff --git a/src/global.h b/src/global.h index 454fc64e..5d849777 100644 --- a/src/global.h +++ b/src/global.h @@ -147,7 +147,6 @@ See LICENSE file included with the distribution for details and disclaimer."); void visit_man_page() const; - OPTION_(global_scope_t, full_help, DO() { parent->visit_man_page(); }); // -H OPTION_(global_scope_t, help, DO() { parent->visit_man_page(); }); // -h OPTION__ -- cgit v1.2.3 From d5e1308d07e9a7d9da33aed6f7f617b2209cba40 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Sun, 15 Feb 2015 08:39:58 +0100 Subject: [ledger] Remove --cache option and all boost serialisation related code. --- doc/ledger.1 | 1 - doc/ledger3.texi | 3 - src/CMakeLists.txt | 2 - src/account.h | 20 ---- src/amount.cc | 79 -------------- src/amount.h | 10 -- src/annotate.h | 48 --------- src/archive.cc | 295 ----------------------------------------------------- src/archive.h | 92 ----------------- src/balance.h | 12 --- src/commodity.h | 61 ----------- src/expr.h | 13 --- src/exprbase.h | 15 --- src/flags.h | 22 ---- src/item.h | 36 ------- src/journal.h | 35 ------- src/mask.h | 19 ---- src/op.h | 27 ----- src/pool.h | 20 ---- src/post.h | 18 ---- src/predicate.h | 13 --- src/scope.h | 99 ------------------ src/session.cc | 20 +--- src/session.h | 2 - src/system.hh.in | 79 -------------- src/times.h | 86 ---------------- src/value.h | 28 ----- src/xact.h | 72 ------------- 28 files changed, 1 insertion(+), 1226 deletions(-) delete mode 100644 src/archive.cc delete mode 100644 src/archive.h diff --git a/doc/ledger.1 b/doc/ledger.1 index c22b9018..19b4db31 100644 --- a/doc/ledger.1 +++ b/doc/ledger.1 @@ -401,7 +401,6 @@ Specify the format to use for the report. .It Fl \-by-payee Pq Fl P Group postings in the register report by common payee names. -.\".It Fl \-cache Ar FILE .It Fl \-check-payees Enable strict and pedantic checking for payees as well as accounts, commodities and tags. diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 08d0d2db..651253fd 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -5867,9 +5867,6 @@ sessions with multiple reports per session. @ftable @option -@item --cache @var{FIXME} -@value{FIXME:UNDOCUMENTED} - @item --check-payees Enable strict and pedantic checking for payees as well as accounts, commodities and tags. This only works in conjunction with diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dc8b60fc..a368d378 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,7 +28,6 @@ set(LEDGER_SOURCES textual.cc temps.cc journal.cc - archive.cc account.cc xact.cc post.cc @@ -80,7 +79,6 @@ set(LEDGER_INCLUDES account.h amount.h annotate.h - archive.h balance.h chain.h commodity.h diff --git a/src/account.h b/src/account.h index 76e839eb..7fae93e1 100644 --- a/src/account.h +++ b/src/account.h @@ -289,26 +289,6 @@ public: } bool children_with_xdata() const; std::size_t children_with_flags(xdata_t::flags_t flags) const; - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object >(*this); - ar & boost::serialization::base_object(*this); - ar & parent; - ar & name; - ar & note; - ar & depth; - ar & accounts; - ar & posts; - ar & _fullname; - } -#endif // HAVE_BOOST_SERIALIZATION }; std::ostream& operator<<(std::ostream& out, const account_t& account); diff --git a/src/amount.cc b/src/amount.cc index 6ddcdb4f..b0898bfb 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -93,20 +93,6 @@ struct amount_t::bigint_t : public supports_flags<> } return true; } - -#if HAVE_BOOST_SERIALIZATION -private: - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) - { - ar & boost::serialization::base_object >(*this); - ar & val; - ar & prec; - ar & refc; - } -#endif // HAVE_BOOST_SERIALIZATION }; bool amount_t::is_initialized = false; @@ -1331,69 +1317,4 @@ void put_amount(property_tree::ptree& st, const amount_t& amt, st.put("quantity", amt.quantity_string()); } -#if HAVE_BOOST_SERIALIZATION - -template -void amount_t::serialize(Archive& ar, const unsigned int /* version */) -{ - ar & is_initialized; - ar & quantity; - ar & commodity_; -} - -#endif // HAVE_BOOST_SERIALIZATION - } // namespace ledger - -#if HAVE_BOOST_SERIALIZATION -namespace boost { -namespace serialization { - -template -void serialize(Archive& ar, MP_INT& mpz, const unsigned int /* version */) -{ - ar & mpz._mp_alloc; - ar & mpz._mp_size; - ar & mpz._mp_d; -} - -template -void serialize(Archive& ar, MP_RAT& mpq, const unsigned int /* version */) -{ - ar & mpq._mp_num; - ar & mpq._mp_den; -} - -template -void serialize(Archive& ar, long unsigned int& integer, - const unsigned int /* version */) -{ - ar & make_binary_object(&integer, sizeof(long unsigned int)); -} - -} // namespace serialization -} // namespace boost - -BOOST_CLASS_EXPORT(ledger::annotated_commodity_t) - -template void boost::serialization::serialize(boost::archive::binary_iarchive&, - MP_INT&, const unsigned int); -template void boost::serialization::serialize(boost::archive::binary_oarchive&, - MP_INT&, const unsigned int); -template void boost::serialization::serialize(boost::archive::binary_iarchive&, - MP_RAT&, const unsigned int); -template void boost::serialization::serialize(boost::archive::binary_oarchive&, - MP_RAT&, const unsigned int); -template void boost::serialization::serialize(boost::archive::binary_iarchive&, - long unsigned int&, - const unsigned int); -template void boost::serialization::serialize(boost::archive::binary_oarchive&, - long unsigned int&, - const unsigned int); - -template void ledger::amount_t::serialize(boost::archive::binary_iarchive&, - const unsigned int); -template void ledger::amount_t::serialize(boost::archive::binary_oarchive&, - const unsigned int); - -#endif // HAVE_BOOST_SERIALIZATION diff --git a/src/amount.h b/src/amount.h index ea5cadd6..4c959177 100644 --- a/src/amount.h +++ b/src/amount.h @@ -743,16 +743,6 @@ public: bool valid() const; -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */); -#endif // HAVE_BOOST_SERIALIZATION - /*@}*/ }; diff --git a/src/annotate.h b/src/annotate.h index c0fbcd3d..c2b2ec9d 100644 --- a/src/annotate.h +++ b/src/annotate.h @@ -107,21 +107,6 @@ struct annotation_t : public supports_flags<>, assert(*this); return true; } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object >(*this); - ar & price; - ar & date; - ar & tag; - } -#endif // HAVE_BOOST_SERIALIZATION }; void put_annotation(property_tree::ptree& pt, const annotation_t& details); @@ -162,21 +147,6 @@ struct keep_details_t return keep_price || keep_date || keep_tag; } bool keep_any(const commodity_t& comm) const; - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & keep_price; - ar & keep_date; - ar & keep_tag; - ar & only_actuals; - } -#endif // HAVE_BOOST_SERIALIZATION }; inline std::ostream& operator<<(std::ostream& out, @@ -250,24 +220,6 @@ public: virtual void write_annotations(std::ostream& out, bool no_computed_annotations = false) const; - -#if HAVE_BOOST_SERIALIZATION -private: - explicit annotated_commodity_t() : ptr(NULL) { - TRACE_CTOR(annotated_commodity_t, ""); - } - - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object(*this); - ar & ptr; - ar & details; - } -#endif // HAVE_BOOST_SERIALIZATION }; inline annotated_commodity_t& diff --git a/src/archive.cc b/src/archive.cc deleted file mode 100644 index 9ae04e85..00000000 --- a/src/archive.cc +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (c) 2003-2015, John Wiegley. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of New Artisans LLC nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#if HAVE_BOOST_SERIALIZATION - -#include "archive.h" -#include "amount.h" -#include "commodity.h" -#include "pool.h" -#include "scope.h" -#include "account.h" -#include "post.h" -#include "xact.h" - -#define LEDGER_MAGIC 0x4c454447 -#define ARCHIVE_VERSION 0x03000006 - -//BOOST_IS_ABSTRACT(ledger::scope_t) -BOOST_CLASS_EXPORT(ledger::scope_t) -BOOST_CLASS_EXPORT(ledger::child_scope_t) -BOOST_CLASS_EXPORT(ledger::symbol_scope_t) -BOOST_CLASS_EXPORT(ledger::call_scope_t) -BOOST_CLASS_EXPORT(ledger::account_t) -BOOST_CLASS_EXPORT(ledger::item_t) -BOOST_CLASS_EXPORT(ledger::post_t) -BOOST_CLASS_EXPORT(ledger::xact_base_t) -BOOST_CLASS_EXPORT(ledger::xact_t) -BOOST_CLASS_EXPORT(ledger::auto_xact_t) -BOOST_CLASS_EXPORT(ledger::period_xact_t) - -template void ledger::journal_t::serialize(boost::archive::binary_oarchive&, - const unsigned int); -template void ledger::journal_t::serialize(boost::archive::binary_iarchive&, - const unsigned int); -namespace ledger { - -namespace { - bool read_header_bits(std::istream& in) { - uint32_t bytes; - - assert(sizeof(uint32_t) == 4); - in.read(reinterpret_cast(&bytes), sizeof(uint32_t)); - if (bytes != LEDGER_MAGIC) { - DEBUG("archive.journal", "Magic bytes not present"); - return false; - } - - in.read(reinterpret_cast(&bytes), sizeof(uint32_t)); - if (bytes != ARCHIVE_VERSION) { - DEBUG("archive.journal", "Archive version mismatch"); - return false; - } - - return true; - } - - void write_header_bits(std::ostream& out) { - uint32_t bytes; - - assert(sizeof(uint32_t) == 4); - bytes = LEDGER_MAGIC; - out.write(reinterpret_cast(&bytes), sizeof(uint32_t)); - - bytes = ARCHIVE_VERSION; - out.write(reinterpret_cast(&bytes), sizeof(uint32_t)); - } -} - -bool archive_t::read_header() -{ - uintmax_t size = file_size(file); - if (size < 8) - return false; - - // Open the stream, read the version number and the list of sources - ifstream stream(file, std::ios::binary); - if (! read_header_bits(stream)) - return false; - - boost::archive::binary_iarchive iarchive(stream); - - DEBUG("archive.journal", "Reading header from archive"); - iarchive >> *this; - - DEBUG("archive.journal", - "Version number: " << std::hex << ARCHIVE_VERSION << std::dec); - DEBUG("archive.journal", "Number of sources: " << sources.size()); - -#if DEBUG_ON - foreach (const journal_t::fileinfo_t& i, sources) - DEBUG("archive.journal", "Loaded source: " << *i.filename); -#endif - - return true; -} - -bool archive_t::should_load(const std::list& data_files) -{ - std::size_t found = 0; - - DEBUG("archive.journal", "Should the archive be loaded?"); - - if (! exists(file)) { - DEBUG("archive.journal", "No, it does not exist"); - return false; - } - - if (! read_header()) { - DEBUG("archive.journal", "No, header failed to read"); - return false; - } - - if (data_files.empty()) { - DEBUG("archive.journal", "No, there were no data files!"); - return false; - } - - if (sources.empty()) { - DEBUG("archive.journal", "No, there were no sources!"); - return false; - } - - if (data_files.size() != sources.size()) { - DEBUG("archive.journal", "No, number of sources doesn't match: " - << data_files.size() << " != " << sources.size()); - return false; - } - - foreach (const path& p, data_files) { - DEBUG("archive.journal", "Scanning for data file: " << p); - - if (! exists(p)) { - DEBUG("archive.journal", "No, an input source no longer exists: " << p); - return false; - } - - foreach (const journal_t::fileinfo_t& i, sources) { - assert(! i.from_stream); - assert(i.filename); - - DEBUG("archive.journal", "Comparing against source file: " << *i.filename); - - if (*i.filename == p) { - if (! exists(*i.filename)) { - DEBUG("archive.journal", - "No, a referent source no longer exists: " << *i.filename); - return false; - } - - if (i.modtime != posix_time::from_time_t(last_write_time(p))) { - DEBUG("archive.journal", "No, a source's modtime has changed: " << p); - return false; - } - - if (i.size != file_size(p)) { - DEBUG("archive.journal", "No, a source's size has changed: " << p); - return false; - } - - found++; - } - } - } - - if (found != data_files.size()) { - DEBUG("archive.journal", "No, not every source's name matched"); - return false; - } - - DEBUG("archive.journal", "Yes, it should be loaded!"); - return true; -} - -bool archive_t::should_save(journal_t& journal) -{ - std::list data_files; - - DEBUG("archive.journal", "Should the archive be saved?"); - - if (journal.was_loaded) { - DEBUG("archive.journal", "No, it's one we loaded before"); - return false; - } - - if (journal.sources.empty()) { - DEBUG("archive.journal", "No, there were no sources!"); - return false; - } - - foreach (const journal_t::fileinfo_t& i, journal.sources) { - if (i.from_stream) { - DEBUG("archive.journal", "No, one source was from a stream"); - return false; - } - - if (! exists(*i.filename)) { - DEBUG("archive.journal", - "No, a source no longer exists: " << *i.filename); - return false; - } - - data_files.push_back(*i.filename); - } - - if (should_load(data_files)) { - DEBUG("archive.journal", "No, because it's still loadable"); - return false; - } - - DEBUG("archive.journal", "Yes, it should be saved!"); - return true; -} - -void archive_t::save(journal_t& journal) -{ - INFO_START(archive, "Saved journal file cache"); - - ofstream stream(file, std::ios::binary); - - write_header_bits(stream); - sources = journal.sources; - -#if DEBUG_ON - foreach (const journal_t::fileinfo_t& i, sources) - DEBUG("archive.journal", "Saving source: " << *i.filename); -#endif - - boost::archive::binary_oarchive oa(stream); - - DEBUG("archive.journal", "Creating archive with version " - << std::hex << ARCHIVE_VERSION << std::dec); - oa << *this; - - DEBUG("archive.journal", - "Archiving journal with " << sources.size() << " sources"); - oa << journal; - - INFO_FINISH(archive); -} - -bool archive_t::load(journal_t& journal) -{ - INFO_START(archive, "Read cached journal file"); - - ifstream stream(file, std::ios::binary); - if (! read_header_bits(stream)) - return false; - - boost::archive::binary_iarchive iarchive(stream); - - // Skip past the archive header, it was already read in before - archive_t temp; - iarchive >> temp; - - iarchive >> journal; - journal.was_loaded = true; - - INFO_FINISH(archive); - - return true; -} - -} // namespace ledger - -#endif // HAVE_BOOST_SERIALIZATION diff --git a/src/archive.h b/src/archive.h deleted file mode 100644 index 485f9606..00000000 --- a/src/archive.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2003-2015, John Wiegley. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of New Artisans LLC nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @defgroup report Reporting - */ - -/** - * @file archive.h - * @author John Wiegley - * - * @ingroup report - */ -#ifndef _ARCHIVE_H -#define _ARCHIVE_H - -#include "journal.h" - -namespace ledger { - -class archive_t -{ - path file; - - std::list sources; - -public: - archive_t() { - TRACE_CTOR(archive_t, ""); - } - archive_t(const path& _file) : file(_file) { - TRACE_CTOR(archive_t, "const path&"); - } - archive_t(const archive_t& ar) : file(ar.file) { - TRACE_CTOR(archive_t, "copy"); - } - ~archive_t() { - TRACE_DTOR(archive_t); - } - - bool read_header(); - - bool should_load(const std::list& data_files); - bool should_save(journal_t& journal); - - void save(journal_t& journal); - bool load(journal_t& journal); - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & sources; - } -#endif // HAVE_BOOST_SERIALIZATION -}; - -} // namespace ledger - -#endif // _ARCHIVE_H diff --git a/src/balance.h b/src/balance.h index 752bb4d6..c9ef9658 100644 --- a/src/balance.h +++ b/src/balance.h @@ -594,18 +594,6 @@ public: } return true; } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & amounts; - } -#endif // HAVE_BOOST_SERIALIZATION }; inline std::ostream& operator<<(std::ostream& out, const balance_t& bal) { diff --git a/src/commodity.h b/src/commodity.h index 3d1ddf04..53ed3a9f 100644 --- a/src/commodity.h +++ b/src/commodity.h @@ -68,19 +68,6 @@ struct price_point_t bool operator==(const price_point_t& other) const { return when == other.when && price == other.price; } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & when; - ar & price; - } -#endif // HAVE_BOOST_SERIALIZATION }; class commodity_t @@ -138,28 +125,6 @@ protected: virtual ~base_t() { TRACE_DTOR(commodity_t::base_t); } - -#if HAVE_BOOST_SERIALIZATION - private: - base_t() { - TRACE_CTOR(base_t, ""); - } - - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object >(*this); - ar & symbol; - ar & precision; - ar & name; - ar & note; - ar & smaller; - ar & larger; - } -#endif // HAVE_BOOST_SERIALIZATION }; shared_ptr base; @@ -315,32 +280,6 @@ public: struct compare_by_commodity { bool operator()(const amount_t * left, const amount_t * right) const; }; - -#if HAVE_BOOST_SERIALIZATION -private: - supports_flags temp_flags; - -protected: - explicit commodity_t() - : delegates_flags(temp_flags), parent_(NULL), - annotated(false) { - TRACE_CTOR(commodity_t, ""); - } - -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object >(*this); - ar & base; - ar & parent_; - ar & qualified_symbol; - ar & annotated; - } -#endif // HAVE_BOOST_SERIALIZATION }; inline std::ostream& operator<<(std::ostream& out, const commodity_t& comm) { diff --git a/src/expr.h b/src/expr.h index 384cc661..041a5297 100644 --- a/src/expr.h +++ b/src/expr.h @@ -106,19 +106,6 @@ public: virtual string context_to_str() const; virtual void print(std::ostream& out) const; virtual void dump(std::ostream& out) const; - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object(*this); - ar & ptr; - } -#endif // HAVE_BOOST_SERIALIZATION }; /** diff --git a/src/exprbase.h b/src/exprbase.h index b88fcd7d..dcaa69ca 100644 --- a/src/exprbase.h +++ b/src/exprbase.h @@ -231,21 +231,6 @@ public: out << std::endl << _("--- Result value ---") << std::endl; return calc(); } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & context; - ar & str; - if (Archive::is_loading::value) - compiled = false; - } -#endif // HAVE_BOOST_SERIALIZATION }; template diff --git a/src/flags.h b/src/flags.h index f3593517..82ebaac1 100644 --- a/src/flags.h +++ b/src/flags.h @@ -90,17 +90,6 @@ public: void drop_flags(const flags_t arg) { _flags = static_cast(static_cast(_flags) & static_cast(~arg)); } - -#if HAVE_BOOST_SERIALIZATION -private: - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) - { - ar & _flags; - } -#endif // HAVE_BOOST_SERIALIZATION }; template @@ -193,17 +182,6 @@ public: void drop_flags(const flags_t arg) { _flags.drop_flags(arg); } - -#if HAVE_BOOST_SERIALIZATION -private: - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) - { - ar & _flags; - } -#endif // HAVE_BOOST_SERIALIZATION }; #endif // _FLAGS_H diff --git a/src/item.h b/src/item.h index 458cb378..ba812175 100644 --- a/src/item.h +++ b/src/item.h @@ -78,23 +78,6 @@ struct position_t } return *this; } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & pathname; - ar & beg_pos; - ar & beg_line; - ar & end_pos; - ar & end_line; - ar & sequence; - } -#endif // HAVE_BOOST_SERIALIZATION }; class item_t : public supports_flags, public scope_t @@ -226,25 +209,6 @@ public: const string& name); bool valid() const; - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object >(*this); - ar & boost::serialization::base_object(*this); - ar & _state; - ar & _date; - ar & _date_aux; - ar & note; - ar & pos; - ar & metadata; - } -#endif // HAVE_BOOST_SERIALIZATION }; value_t get_comment(item_t& item); diff --git a/src/journal.h b/src/journal.h index 613b2b96..324315b1 100644 --- a/src/journal.h +++ b/src/journal.h @@ -100,21 +100,6 @@ public: ~fileinfo_t() throw() { TRACE_DTOR(journal_t::fileinfo_t); } - -#if HAVE_BOOST_SERIALIZATION - private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & filename; - ar & size; - ar & modtime; - ar & from_stream; - } -#endif // HAVE_BOOST_SERIALIZATION }; account_t * master; @@ -215,26 +200,6 @@ public: private: std::size_t read_textual(parse_context_stack_t& context); - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & master; - ar & bucket; - ar & xacts; - ar & auto_xacts; - ar & period_xacts; - ar & sources; - ar & payee_mappings; - ar & account_mappings; - ar & checksum_map; - } -#endif // HAVE_BOOST_SERIALIZATION }; } // namespace ledger diff --git a/src/mask.h b/src/mask.h index 2b579768..dce23440 100644 --- a/src/mask.h +++ b/src/mask.h @@ -124,25 +124,6 @@ public: } return true; } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - string temp; - if (Archive::is_loading::value) { - ar & temp; - *this = temp; - } else { - temp = str(); - ar & temp; - } - } -#endif // HAVE_BOOST_SERIALIZATION }; inline std::ostream& operator<<(std::ostream& out, const mask_t& mask) { diff --git a/src/op.h b/src/op.h index c45ffb08..d94c2534 100644 --- a/src/op.h +++ b/src/op.h @@ -314,33 +314,6 @@ private: value_t calc_call(scope_t& scope, ptr_op_t * locus, const int depth); value_t calc_cons(scope_t& scope, ptr_op_t * locus, const int depth); value_t calc_seq(scope_t& scope, ptr_op_t * locus, const int depth); - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & refc; - ar & kind; - if (Archive::is_loading::value || ! left_ || ! left_->is_function()) { - ar & left_; - } else { - ptr_op_t temp_op; - ar & temp_op; - } - if (Archive::is_loading::value || is_value() || is_ident() || - (kind > UNARY_OPERATORS && - (! has_right() || ! right()->is_function()))) { - ar & data; - } else { - variant temp_data; - ar & temp_data; - } - } -#endif // HAVE_BOOST_SERIALIZATION }; inline expr_t::ptr_op_t diff --git a/src/pool.h b/src/pool.h index d24df78c..2e9d93f1 100644 --- a/src/pool.h +++ b/src/pool.h @@ -132,26 +132,6 @@ public: parse_price_expression(const std::string& str, const bool add_prices = true, const optional& moment = none); - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & current_pool; - ar & commodities; - ar & annotated_commodities; - ar & null_commodity; - ar & default_commodity; - ar & keep_base; - ar & price_db; - ar & quote_leeway; - ar & get_quotes; - } -#endif // HAVE_BOOST_SERIALIZATION }; } // namespace ledger diff --git a/src/post.h b/src/post.h index 1e5fc569..0fb45e90 100644 --- a/src/post.h +++ b/src/post.h @@ -255,24 +255,6 @@ public: } } }; - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object(*this); - ar & xact; - ar & account; - ar & amount; - ar & amount_expr; - ar & cost; - ar & assigned_amount; - } -#endif // HAVE_BOOST_SERIALIZATION }; class journal_t; diff --git a/src/predicate.h b/src/predicate.h index 30d07223..e8c5b31c 100644 --- a/src/predicate.h +++ b/src/predicate.h @@ -90,19 +90,6 @@ public: .to_boolean() : true); } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object(*this); - ar & what_to_keep; - } -#endif // HAVE_BOOST_SERIALIZATION }; } // namespace ledger diff --git a/src/scope.h b/src/scope.h index 8ad3afac..ba1144b2 100644 --- a/src/scope.h +++ b/src/scope.h @@ -83,20 +83,6 @@ struct symbol_t bool operator==(const symbol_t& sym) const { return kind == sym.kind || name == sym.name; } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & kind; - ar & name; - ar & definition; - } -#endif // HAVE_BOOST_SERIALIZATION }; class empty_scope_t; @@ -127,16 +113,6 @@ public: virtual bool type_required() const { return false; } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive&, const unsigned int /* version */) {} -#endif // HAVE_BOOST_SERIALIZATION }; class empty_scope_t : public scope_t @@ -184,19 +160,6 @@ public: return parent->lookup(kind, name); return NULL; } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object(*this); - ar & parent; - } -#endif // HAVE_BOOST_SERIALIZATION }; class bind_scope_t : public child_scope_t @@ -233,19 +196,6 @@ public: return def; return child_scope_t::lookup(kind, name); } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object(*this); - ar & grandchild; - } -#endif // HAVE_BOOST_SERIALIZATION }; template @@ -323,19 +273,6 @@ public: virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind, const string& name); - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object(*this); - ar & symbols; - } -#endif // HAVE_BOOST_SERIALIZATION }; class context_scope_t : public child_scope_t @@ -365,24 +302,6 @@ public: virtual bool type_required() const { return required; } - -#if HAVE_BOOST_SERIALIZATION -protected: - explicit context_scope_t() { - TRACE_CTOR(context_scope_t, ""); - } - - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object(*this); - ar & value_type_context; - ar & required; - } -#endif // HAVE_BOOST_SERIALIZATION }; class call_scope_t : public context_scope_t @@ -480,24 +399,6 @@ public: bool empty() const { return args.size() == 0; } - -#if HAVE_BOOST_SERIALIZATION -protected: - explicit call_scope_t() : depth(0) { - TRACE_CTOR(call_scope_t, ""); - } - - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object(*this); - ar & args; - //ar & ptr; - } -#endif // HAVE_BOOST_SERIALIZATION }; template <> diff --git a/src/session.cc b/src/session.cc index b0d31be9..7736023d 100644 --- a/src/session.cc +++ b/src/session.cc @@ -37,7 +37,6 @@ #include "journal.h" #include "iterators.h" #include "filters.h" -#include "archive.h" namespace ledger { @@ -128,16 +127,6 @@ std::size_t session_t::read_data(const string& master_account) if (HANDLED(value_expr_)) journal->value_expr = HANDLER(value_expr_).str(); - -#if HAVE_BOOST_SERIALIZATION - optional cache; - if (HANDLED(cache_) && master_account.empty()) - cache = archive_t(HANDLED(cache_).str()); - - if (! (cache && - cache->should_load(HANDLER(file_).data_files) && - cache->load(*journal.get()))) { -#endif // HAVE_BOOST_SERIALIZATION if (price_db_path) { if (exists(*price_db_path)) { parsing_context.push(*price_db_path); @@ -191,12 +180,6 @@ std::size_t session_t::read_data(const string& master_account) << "] == journal->xacts.size() [" << journal->xacts.size() << "]"); assert(xact_count == journal->xacts.size()); -#if HAVE_BOOST_SERIALIZATION - if (cache && cache->should_save(*journal.get())) - cache->save(*journal.get()); - } -#endif // HAVE_BOOST_SERIALIZATION - if (populated_data_files) HANDLER(file_).data_files.clear(); @@ -333,8 +316,7 @@ option_t * session_t::lookup_option(const char * p) OPT_CH(price_exp_); break; case 'c': - OPT(cache_); - else OPT(check_payees); + OPT(check_payees); break; case 'd': OPT(download); // -Q diff --git a/src/session.h b/src/session.h index b287b19e..f9aee389 100644 --- a/src/session.h +++ b/src/session.h @@ -97,7 +97,6 @@ public: void report_options(std::ostream& out) { - HANDLER(cache_).report(out); HANDLER(check_payees).report(out); HANDLER(day_break).report(out); HANDLER(download).report(out); @@ -126,7 +125,6 @@ public: * Option handlers */ - OPTION(session_t, cache_); OPTION(session_t, check_payees); OPTION(session_t, day_break); OPTION(session_t, download); // -Q diff --git a/src/system.hh.in b/src/system.hh.in index eaf4b1ac..8de27ad6 100644 --- a/src/system.hh.in +++ b/src/system.hh.in @@ -71,7 +71,6 @@ #define HAVE_BOOST_PYTHON @HAVE_BOOST_PYTHON@ #define HAVE_BOOST_REGEX_UNICODE @HAVE_BOOST_REGEX_UNICODE@ -#define HAVE_BOOST_SERIALIZATION 0 #define DEBUG_MODE @DEBUG_MODE@ #define NO_ASSERTS @NO_ASSERTS@ @@ -239,86 +238,8 @@ typedef std::ostream::pos_type ostream_pos_type; #endif #define _f(str) boost::format(_(str)) -#if HAVE_BOOST_SERIALIZATION - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace boost { -namespace serialization { - -template -void serialize(Archive& ar, boost::filesystem::path& p, const unsigned int) -{ - std::string s; - if (Archive::is_saving::value) - s = p.string(); - - ar & s; - - if (Archive::is_loading::value) - p = s; -} - -template -void serialize(Archive& ar, boost::intrusive_ptr& ptr, const unsigned int) -{ - if (Archive::is_saving::value) { - T * p = ptr.get(); - ar & p; - } - else if (Archive::is_loading::value) { - T * p; - ar & p; - ptr.reset(p); - } -} - -template -void serialize(Archive&, boost::any&, const unsigned int) { - // jww (2012-03-29): Should we really ignore any fields entirely? - // These occur inside value_t::storage_t::data's variant. -} - -template -void serialize(Archive&, boost::blank&, const unsigned int) {} - -template -void serialize(Archive&, boost::function&, const unsigned int) {} - -template -void serialize(Archive& ar, istream_pos_type& pos, const unsigned int) -{ - ar & make_binary_object(&pos, sizeof(istream_pos_type)); -} - -} // namespace serialization -} // namespace boost - -#else // HAVE_BOOST_SERIALIZATION - #include -#endif // HAVE_BOOST_SERIALIZATION - #if HAVE_BOOST_PYTHON #include diff --git a/src/times.h b/src/times.h index c1bfb1cc..421d1462 100644 --- a/src/times.h +++ b/src/times.h @@ -153,20 +153,6 @@ struct date_traits_t has_month == traits.has_month && has_day == traits.has_day); } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & has_year; - ar & has_month; - ar & has_day; - } -#endif // HAVE_BOOST_SERIALIZATION }; struct date_duration_t @@ -247,19 +233,6 @@ struct date_duration_t } static date_t find_nearest(const date_t& date, skip_quantum_t skip); - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & quantum; - ar & length; - } -#endif // HAVE_BOOST_SERIALIZATION }; class date_specifier_t @@ -343,21 +316,6 @@ public: return out.str(); } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & year; - ar & month; - ar & day; - ar & wday; - } -#endif // HAVE_BOOST_SERIALIZATION }; class date_range_t @@ -420,20 +378,6 @@ public: return out.str(); } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & range_begin; - ar & range_end; - ar & end_inclusive; - } -#endif // HAVE_BOOST_SERIALIZATION }; class date_specifier_or_range_t @@ -490,18 +434,6 @@ public: return out.str(); } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & specifier_or_range; - } -#endif // HAVE_BOOST_SERIALIZATION }; class date_interval_t : public equality_comparable @@ -594,24 +526,6 @@ public: date_interval_t& operator++(); void dump(std::ostream& out); - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & range; - ar & start; - ar & finish; - ar & aligned; - ar & next; - ar & duration; - ar & end_of_duration; - } -#endif // HAVE_BOOST_SERIALIZATION }; void times_initialize(); diff --git a/src/value.h b/src/value.h index c224ce04..810d34f9 100644 --- a/src/value.h +++ b/src/value.h @@ -227,20 +227,6 @@ public: data = false; type = VOID; } - -#if HAVE_BOOST_SERIALIZATION - private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & data; - ar & type; - ar & refc; - } -#endif // HAVE_BOOST_SERIALIZATION }; private: @@ -965,20 +951,6 @@ public: * Debugging methods. */ bool valid() const; - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & true_value; - ar & false_value; - ar & storage; - } -#endif // HAVE_BOOST_SERIALIZATION }; #define NULL_VALUE (value_t()) diff --git a/src/xact.h b/src/xact.h index 3ca57953..37a20972 100644 --- a/src/xact.h +++ b/src/xact.h @@ -87,20 +87,6 @@ public: virtual bool valid() const { return true; } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object(*this); - ar & journal; - ar & posts; - } -#endif // HAVE_BOOST_SERIALIZATION }; class xact_t : public xact_base_t @@ -142,20 +128,6 @@ public: const string& name); virtual bool valid() const; - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object(*this); - ar & code; - ar & payee; - } -#endif // HAVE_BOOST_SERIALIZATION }; class auto_xact_t : public xact_base_t @@ -176,21 +148,6 @@ public: bool _overwrite_existing) : tag_data(_tag_data), overwrite_existing(_overwrite_existing), apply_to_post(NULL) {} - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - deferred_tag_data_t() : apply_to_post(NULL) {} - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & tag_data; - ar & overwrite_existing; - ar & apply_to_post; - } -#endif // HAVE_BOOST_SERIALIZATION }; typedef std::list deferred_notes_list; @@ -236,21 +193,6 @@ private: } virtual void extend_xact(xact_base_t& xact, parse_context_t& context); - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object(*this); - ar & predicate; - ar & check_exprs; - ar & deferred_notes; - } -#endif // HAVE_BOOST_SERIALIZATION }; class period_xact_t : public xact_base_t @@ -284,20 +226,6 @@ class period_xact_t : public xact_base_t return string(_("generated periodic transaction")); } } - -#if HAVE_BOOST_SERIALIZATION -private: - /** Serialization. */ - - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int /* version */) { - ar & boost::serialization::base_object(*this); - ar & period; - ar & period_string; - } -#endif // HAVE_BOOST_SERIALIZATION }; typedef std::list xacts_list; -- cgit v1.2.3 From bd427a9d325a635873035e7960b005951944df6d Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Sun, 15 Feb 2015 09:27:01 +0100 Subject: [doc] Add documentation for several options --- doc/ledger.1 | 68 ++++++++++++++++++++++++++++++++++++++------------ doc/ledger3.texi | 75 ++++++++++++++++++++++++++++---------------------------- 2 files changed, 90 insertions(+), 53 deletions(-) diff --git a/doc/ledger.1 b/doc/ledger.1 index 19b4db31..daf4822a 100644 --- a/doc/ledger.1 +++ b/doc/ledger.1 @@ -191,7 +191,8 @@ Show any gains (or losses) in commodity values over time. Only show the top .Ar number postings. -.\".It Fl \-historical Pq Fl H +.It Fl \-historical Pq Fl H +Value commodities at the time of their acquisition. .It Fl \-invert Invert the value of amounts shown. .It Fl \-market Pq Fl V @@ -366,7 +367,9 @@ Alias for Ignore init files and environment variables for the .Nm run. -.\".It Fl \-auto-match +.It Fl \-auto-match +Automatically match accounts from ledger journal for transactions +during csv convert. .It Fl \-aux-date Show auxiliary dates for all calculations. Alias for @@ -378,7 +381,9 @@ running totals. Specify the format to use for the .Ic balance report. -.\".It Fl \-base +.It Fl \-base +Reduce convertible commodities down the bottom of the conversion, e.g. +display time in seconds. .It Fl \-basis Pq Fl B Report the cost basis on all posting. Alias for @@ -460,7 +465,12 @@ Print dates using Refer to .Xr strftime 3 for details on the format string syntax. -.\" .It Fl \-datetime-format Ar FMT +.It Fl \-datetime-format Ar DATETIMEFMT +Print datetimes using +.Ar DATETIMEFMT . +Refer to +.Xr strftime 3 +for details on the format string syntax. .It Fl \-date-width Ar INT Specify the width, in characters, of the date column in the .Ic register @@ -550,7 +560,9 @@ Related to the .Ic equity command. Gives current account balances in the form of a register report. -.\".It Fl \-exact +.It Fl \-exact +Report beginning and ending of periods by the date of the first and last +posting occurring in that period. .It Fl \-exchange Ar COMMODITY Oo , Ar COMMODITY, ... Oc Pq Fl X Display values in terms of the given .Ar COMMODITY . @@ -628,7 +640,10 @@ is also printed if is run without a command. .It Fl \-immediate Evaluate calculations immediately rather than lazily. -.\".It Fl \-import +.It Fl \-import Ar FILE +Import +.Ar FILE +as Python module. .It Fl \-init-file Ar FILE Pq Fl i Read .Ar FILE @@ -673,7 +688,9 @@ purchased. .It Fl \-lots Report the date and price at which each commodity was purchased in a balance report. -.\".It Fl \-lots-actual +.It Fl \-lots-actual +Preserve the uniqueness of commodities so they aren't merged during +reporting without printing the lot annotations. .It Fl \-market Pq Fl V Use the latest market value for all commodities. .It Fl \-master-account Ar STR @@ -837,9 +854,23 @@ of the transaction. Show all postings in a transaction, similar to .Fl \-related but show both sides of each transaction. -.\".It Fl \-revalued -.\".It Fl \-revalued-only -.\".It Fl \-revalued-total Ar EXPR +.It Fl \-revalued +Report discrepancy in values for manual reports by inserting + +postings. +This is implied when using +the +.Fl \-exchange Pq Fl X +or +.Fl \-market Pq Fl V +option. +.It Fl \-revalued-only +Show only + +postings. +.It Fl \-revalued-total +Display the sum of the revalued postings as the running total, which serves +to show unrealized capital in a gain/losses report. .\".It Fl \-rich-data .It Fl \-seed Ar INT Set the random seed to @@ -852,8 +883,9 @@ Execute a .Nm script. .It Fl \-sort Ar EXPR Pq Fl S -Sort the register report based on the value expression given to sort. -.\".It Fl \-sort-all +Sort the register report based on the value expression +.Ar EXPR . +.\".It Fl \-sort-all Ar EXPR .It Fl \-sort-xacts Sort the posting within transactions using the given value expression. .It Fl \-start-of-week Ar STR @@ -879,7 +911,10 @@ entries. Only useful on a register report. Alias for .It Fl \-time-colon Display the value for commodities based on seconds as hours and minutes. Thus 8100s will be displayed as 2:15h instead of 2.25h. -.\".It Fl \-time-report +.It Fl \-time-report +Add two columns to the +.Ic balance +report to show the earliest checkin and checkout times for timelog entries. .It Fl \-total Ar EXPR Pq Fl T Define a value expression used to calculate the total in reports. .It Fl \-total-data Pq Fl J @@ -931,7 +966,8 @@ precision. Show the values used by each tag when used in combination with the .Ic tags command. -.\".It Fl \-value-expr Ar EXPR +.It Fl \-value-expr Ar EXPR +Set a global value expression annotation. .It Fl \-verbose Print detailed information on the execution of .Nm . @@ -941,7 +977,9 @@ slowdown. When combined with .Fl \-debug Ar CODE .Nm will produce memory trace information. -.\".It Fl \-verify-memory +.It Fl \-verify-memory +Verify that every constructed object is properly destructed. This is for +debugging purposes only. .It Fl \-version Print version information and exit. .It Fl \-weekly Pq Fl W diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 651253fd..60d0ec2e 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -5468,7 +5468,7 @@ Redirect output to @file{FILE}. Specify an options file. @item --import @var{FILE} -@value{FIXME:UNDOCUMENTED} +Import @var{FILE} as Python module. @item --account @var{STR} @itemx -a @var{STR} @@ -5733,8 +5733,9 @@ Set expected freshness of prices in @var{INT} minutes. @itemx -Q Download quotes using the script named @file{getquote}. -@item --getquote @var{FILE} -Sets the path to a user-defined script to download commodity prices. +@c FIXME: The option doesn't exist currently. +@c @item --getquote @var{FILE} +@c Sets the path to a user-defined script to download commodity prices. @item --quantity @itemx -O @@ -5884,7 +5885,6 @@ days by day. @c @end smallexample @c @smallexample @c output: @c @end smallexample -@value{FIXME:UNDOCUMENTED} @item --decimal-comma Direct Ledger to parse journals using the European standard comma as @@ -5892,8 +5892,9 @@ a decimal separator, not the usual period. @item --download @itemx -Q -Direct Ledger to download prices using the script defined via the option -@option{--getquote @var{FILE}}. +Direct Ledger to download prices. +@c using the script defined via the option +@c @option{--getquote @var{FILE}}. @item --explicit @c see test/baseline/opt-explicit.test @@ -5903,11 +5904,12 @@ Direct Ledger to download prices using the script defined via the option @itemx -f @var{FILE} Specify the input @file{FILE} for this invocation. -@item --getquote @var{FILE} -@cindex getquote -@cindex download prices -Tell ledger where to find the user defined script to download prices -information. +@c FIXME: The option doesn't exist currently. +@c @item --getquote @var{FILE} +@c @cindex getquote +@c @cindex download prices +@c Tell ledger where to find the user defined script to download prices +@c information. @item --input-date-format @var{DATE_FORMAT} Specify the input date format for journal entries. For example, @@ -5990,8 +5992,9 @@ based commodity as real hours and minutes. For example 8100 seconds by default will be displayed as 2.25 whereas with the @option{--time-colon} option they will be displayed as 2:15. -@item --value-expr @var{FIXME} -@value{FIXME:UNDOCUMENTED} +@item --value-expr @var{VEXPR} +Set a global value expression annotation. +@c needs example @end ftable @@ -6051,9 +6054,8 @@ Set the width in characters of the amount column in the Anonymize registry output, mostly for sending in bug reports. @item --auto-match -@c Automatically match accounts from ledger journal when using convert command -@c see test/baseline/opt-auto-match.dat -@value{FIXME:UNDOCUMENTED} +Automatically match accounts from ledger journal for transactions +during csv convert. @item --aux-date @itemx --effective @@ -6077,10 +6079,8 @@ Strings}). The default is: @end smallexample @item --base -@c Report commodity in the base commodity s instead of h -@c Does this apply to other commodities too? -@c see test/baseline/opt-base.test/ -@value{FIXME:UNDOCUMENTED} +Reduce convertible commodities down the bottom of the conversion, e.g. +display time in seconds. This also applies to custom commodity conversions. @item --basis @itemx -B @@ -6200,10 +6200,7 @@ Specify the width, in characters, of the date column in the @command{register} report. @item --datetime-format @var{DATETIME_FORMAT} -@c Specify the format ledger should use to print datetimes in -@c @command{balance} @option{--timelog-report} reports. -@c see test/baseline/opt-datetime-format.test -@value{FIXME:UNDOCUMENTED} +Specify the format ledger should use to print datetimes. @item --dc Display register or balance in debit/credit format If you use @@ -6311,7 +6308,8 @@ command}). Gives current account balances in the form of a register report. @item --exact -@value{FIXME:UNDOCUMENTED} +Report beginning and ending of periods by the date of the first and last +posting occurring in that period. @item --exchange @var{COMMODITY} @itemx -X @var{COMMODITY} @@ -6389,10 +6387,10 @@ Print the first @var{INT} entries. Opposite of @option{--tail @item --historical @itemx -H -@value{FIXME:UNDOCUMENTED} +Value commodities at the time of their acquisition. @item --immediate -@value{FIXME:UNDOCUMENTED} +Evaluate calculations immediately rather than lazily. @item --inject Use @code{Expected} amounts in calculations. In case you know @@ -6433,8 +6431,8 @@ Report the date and price at which each commodity was purchased in a balance report. @item --lots-actual -@c see test/baseline/opt-lots-actual.test -@value{FIXME:UNDOCUMENTED} +Preserve the uniqueness of commodities so they aren't merged during +reporting without printing the lot annotations. @item --market @itemx -V @@ -6589,15 +6587,16 @@ Show all postings in a transaction, similar to @option{--related} but show both @emph{sides} of each transaction. @item --revalued -@c see test/baeline/opt-revalued.test -@value{FIXME:UNDOCUMENTED} +Report discrepancy in values for manual reports by inserting @code{} +postings. This is implied when using the @option{--exchange} or +@option{--market} option. @item --revalued-only -@c see test/baeline/opt-revalued-only.test -@value{FIXME:UNDOCUMENTED} +Show only @code{} postings. @item --revalued-total @var{FIXME} -@value{FIXME:UNDOCUMENTED} +Display the sum of the revalued postings as the running total, which serves +to show unrealized capital in a gain/losses report. @item --rich-data @itemx --detail @@ -6637,9 +6636,8 @@ Report only the last @var{INT} entries. Only useful in a @command{register} report. @item --time-report -@c Display begin and end time for each timelog entry in balance reports -@c see test/baseline/opt-time-report.test -@value{FIXME:UNDOCUMENTED} +Add two columns to the balance report to show the earliest checkin and +checkout times for timelog entries. @item --total @var{VEXPR} @itemx -T @var{VEXPR} @@ -9708,7 +9706,8 @@ slowdown. When combined with @option{--debug @var{CODE}} ledger will produce memory trace information. @item --verify-memory -@value{FIXME:UNDOCUMENTED} +Verify that every constructed object is properly destructed. This is for +debugging purposes only. @item --version Print version information and exit. -- cgit v1.2.3 From 82cdeff4715bd67df141510b0bacfdc363b50f6c Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Sun, 15 Feb 2015 09:41:00 +0100 Subject: [doc] Whitespace edit to end each sentence with two spaces. --- doc/ledger.1 | 58 ++++++------ doc/ledger3.texi | 278 +++++++++++++++++++++++++++---------------------------- 2 files changed, 168 insertions(+), 168 deletions(-) diff --git a/doc/ledger.1 b/doc/ledger.1 index daf4822a..1a8a43b8 100644 --- a/doc/ledger.1 +++ b/doc/ledger.1 @@ -310,7 +310,7 @@ fit inside the If .Ar INT is zero, then the -account name will be truncated on the right. If +account name will be truncated on the right. If .Ar INT is greater than @@ -321,7 +321,7 @@ desired width. .It Fl \-account Ar EXPR Prepend .Ar EXPR -to all accounts reported. That is, the option +to all accounts reported. That is, the option .Fl \-account Ar \*q'Personal'\*q would tack .Ar Personal: @@ -346,7 +346,7 @@ transactions used. .It Fl \-add-budget Show only un-budgeted postings. .It Fl \-amount Ar EXPR Pq Fl t -Apply the given value expression to the posting amount. Using +Apply the given value expression to the posting amount. Using .Fl \-amount Ar EXPR you can apply an arbitrary transformation to the postings. @@ -391,12 +391,12 @@ Alias for .It Fl \-begin Ar DATE Pq Fl b Specify the start .Ar DATE -of all calculations. Transactions before +of all calculations. Transactions before that date will be ignored. .It Fl \-bold-if Ar EXPR Print the entire line in bold if the given value expression is true. .It Fl \-budget -Only display budgeted items. In a +Only display budgeted items. In a .Ic register report this displays transaction in the budget, in a balance report this displays accounts in the budget. @@ -428,7 +428,7 @@ Make the .Ic register report .Ar INT -characters wide. By default +characters wide. By default .Nm will use all available columns in your terminal. .It Fl \-cost @@ -511,7 +511,7 @@ but not This is a display predicate, which means it only affects display, not the total calculations. .It Fl \-deviation -Report each posting's deviation from the average. It is only meaningful +Report each posting's deviation from the average. It is only meaningful in the .Ic register No and Ic prices reports. @@ -546,7 +546,7 @@ distribution. Downloaded quote price are then appended to the price database, usually specified using the environment variable .Ev LEDGER_PRICE_DB . .It Fl \-effective -Show auxiliary dates for all calculations. Alias for +Show auxiliary dates for all calculations. Alias for .Fl \-aux-date . .It Fl \-empty Pq Fl E Include empty accounts in report. @@ -574,15 +574,15 @@ Read journal data from .It Fl \-first Ar INT Print the first .Ar INT -entries. Opposite of +entries. Opposite of .Fl \-last Ar INT . Alias for .Fl \-head . .It Fl \-flat -Force the full names of accounts to be used in the balance report. The +Force the full names of accounts to be used in the balance report. The balance report will not use an indented tree. .It Fl \-force-color -Output TTY color codes even if the TTY doesn't support them. Useful +Output TTY color codes even if the TTY doesn't support them. Useful for TTYs that don't advertise their capabilities correctly. .It Fl \-force-pager Force @@ -628,7 +628,7 @@ register report. .It Fl \-head Ar INT Print the first .Ar INT -entries. Opposite of +entries. Opposite of .Fl \-tail Ar INT . Alias for .Fl \-first @@ -668,9 +668,9 @@ Change the sign of all reported values. .It Fl \-last Ar INT . Report only the last .Ar INT -entries. Opposite of +entries. Opposite of .Fl \-first Ar INT . -Only useful on a register report. Alias for +Only useful on a register report. Alias for .Fl \-tail . .It Fl \-leeway Ar INT Pq Fl Z Alias for @@ -729,7 +729,7 @@ Suppress printing the final total line in a balance report. .It Fl \-now Ar DATE Use .Ar DATE -as the current date. This affects the output when using +as the current date. This affects the output when using .Fl \-period , .Fl \-begin , .Fl \-end , @@ -754,7 +754,7 @@ Use .Ar STR as the pager program. .It Fl \-payee -Sets a value expression for formatting the payee. In the +Sets a value expression for formatting the payee. In the .Ic register report this prevents the second entry from having a date and payee for each transaction. @@ -771,7 +771,7 @@ Calculate the percentage value of each account in a balance reports. Only works for account that have a single commodity. .It Fl \-period Ar PERIOD Pq Fl p Define a period expression that sets the time period during which -transactions are to be accounted. For a +transactions are to be accounted. For a .Ic register report only the transactions that satisfy the period expression with be displayed. @@ -804,12 +804,12 @@ Use the price of the commodity purchase for performing calculations. .It Fl \-price-exp Ar STR Pq Fl Z Set the expected freshness of price quotes, in .Ar INT -minutes. That +minutes. That is, if the last known quote for any commodity is older than this value, and if .Fl \-download is being used, then the Internet will be -consulted again for a newer price. Otherwise, the old price is still +consulted again for a newer price. Otherwise, the old price is still considered to be fresh enough. Alias for .Fl \-leeway . @@ -820,7 +820,7 @@ report. .It Fl \-pricedb-format Ar FMT Set the format expected for the historical price file. .It Fl \-primary-date -Show primary dates for all calculations. Alias for +Show primary dates for all calculations. Alias for .Fl \-actual-dates .It Fl \-quantity Pq Fl O Report commodity totals (this is the default). @@ -906,7 +906,7 @@ Report register as a single subtotal. .It Fl \-tail Ar INT Report only the last .Ar INT -entries. Only useful on a register report. Alias for +entries. Only useful on a register report. Alias for .Fl \-last Ar INT .It Fl \-time-colon Display the value for commodities based on seconds as hours and minutes. @@ -922,12 +922,12 @@ Show only dates and totals to format the output for plots. .It Fl \-total-width Ar INT Set the width of the total field in the register report. .It Fl \-trace Ar INT -Enable tracing. The +Enable tracing. The .Ar INT specifies the level of trace desired. .It Fl \-truncate Ar STR Indicates how truncation should happen when the contents of columns -exceed their width. Valid arguments for +exceed their width. Valid arguments for .Ar STR are .Ar leading , @@ -947,14 +947,14 @@ Show generated unrealized gain and loss accounts in the balance report. .It Fl \-unrealized-gains Allow the user to specify what account name should be used for -unrealized gains. Defaults to +unrealized gains. Defaults to .Sy "Equity:Unrealized Gains" . Often set in one's .Pa ~/.ledgerrc file to change the default. .It Fl \-unrealized-losses Allow the user to specify what account name should be used for -unrealized gains. Defaults to +unrealized gains. Defaults to .Sy "Equity:Unrealized Losses" . Often set in one's .Pa ~/.ledgerrc @@ -972,13 +972,13 @@ Set a global value expression annotation. Print detailed information on the execution of .Nm . .It Fl \-verify -Enable additional assertions during run-time. This causes a significant +Enable additional assertions during run-time. This causes a significant slowdown. When combined with .Fl \-debug Ar CODE .Nm will produce memory trace information. .It Fl \-verify-memory -Verify that every constructed object is properly destructed. This is for +Verify that every constructed object is properly destructed. This is for debugging purposes only. .It Fl \-version Print version information and exit. @@ -993,7 +993,7 @@ Shorthand for .El .Sh PRE-COMMANDS Pre-commands are useful when you aren't sure how a command or option -will work. The difference between a pre-command and a regular command +will work. The difference between a pre-command and a regular command is that pre-commands ignore the journal data file completely, nor is the user's init file read. .Bl -tag -width -indent @@ -1225,7 +1225,7 @@ Return .Ar value rounded to .Ar n -digits. Does not affect formatting. +digits. Does not affect formatting. .\".It Sy scrub .\".It Sy status .\".It Sy strip diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 60d0ec2e..a48c2dc8 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -58,7 +58,7 @@ @c the documentation itself, in that case the journal example data @c needs to be specially marked as well using @smallexample @c input:UUID, @c again with the UUID being the UUID of the corresponding ledger example -@c command. If multiple inputs with the same UUID are found they will be +@c command. If multiple inputs with the same UUID are found they will be @c concatenated together and given as one set of data to the example command. @c @c @smallexample @c input:35CB2A3 @@ -288,7 +288,7 @@ Here is a good place for an aside on the use of the word ``account''. Most private people consider an account to be something that holds money at an institution for them. Ledger uses a more general definition of the word. An account is anywhere money can go. Other -finance programs use ``categories'', Ledger uses accounts. So, for +finance programs use ``categories'', Ledger uses accounts. So, for example, if you buy some groceries at Trader Joe's, then more groceries at Whole Food Market, you might assign the transactions like this @@ -382,8 +382,8 @@ acprep script, that does a lot of the footwork: @end smallexample See the `help` subcommand to `acprep`, which explains some of its many -options. You can run `make check` to confirm the result, and `make -install` to install. If these intructions do not work for you can check the +options. You can run `make check` to confirm the result, and `make +install` to install. If these intructions do not work for you can check the `INSTALL.md` in the source directory for more up do date build instructions. @node Getting help, , Building the program, Introduction to Ledger @@ -1530,7 +1530,7 @@ Accounts}). @cindex posting format details @strong{The format is very flexible and it isn't necessary that you -indent and space out things exactly as shown. The only requirements +indent and space out things exactly as shown. The only requirements are that the start of the transaction (the date typically) is at the beginning of the first line of the transaction, and the accounts are indented by at least one space. If you omit the leading spaces in the @@ -1551,7 +1551,7 @@ Ledger has a starting point. At some convenient point in time you knew the balances and outstanding obligation of every financial account you have. Those amounts form the -basis of the opening entry for ledger. For example if you chose the +basis of the opening entry for ledger. For example if you chose the beginning of 2011 as the date to start tracking finances with ledger, your opening balance entry could look like this: @@ -1660,7 +1660,7 @@ Dollars, Euros, Pounds, Francs, Shares etc. are all just ``commodities''. Holdings in stocks, bonds, mutual funds and other financial instruments can be labeled using whatever is convenient for you (stock ticker symbols are suggested for publicly traded assets).@footnote{You -can track @emph{anything}, even time or distance traveled. As long as +can track @emph{anything}, even time or distance traveled. As long as it cannot be created or destroyed inside your accounting system.} For the rest of this manual, we will only use the word ``commodities'' @@ -1691,7 +1691,7 @@ business trip to Europe from the US: @end smallexample This says that $66.00 came out of checking and turned into 50 -Euros. The implied exchange rate was $1.32. Then 35.00 Euros were +Euros. The implied exchange rate was $1.32. Then 35.00 Euros were spent on Dinner in Munich. Running a ledger balance report shows: @@ -1748,7 +1748,7 @@ commodity name must be enclosed in double quotes @samp{"}: Buying stock is a typical example that many will use that involves multiple commodities in the same transaction. The type of the share (AAPL for Apple Inc.) and the share purchase price in the currency -unit you made the purchase in ($ for AAPL). Yes, the typical +unit you made the purchase in ($ for AAPL). Yes, the typical convention is as follows: @smallexample @c input:validate @@ -1842,8 +1842,8 @@ Assets:Checking because its amount is null. @findex --exchange @var{COMMODITY} Ledger allows you to have very detailed control over how your -commodities are valued. You can fine tune the results given using the -@option{--market} or @option{--exchange @var{COMMODITY}} options. There +commodities are valued. You can fine tune the results given using the +@option{--market} or @option{--exchange @var{COMMODITY}} options. There are now several points of interception; you can specify the valuation method: @@ -1874,7 +1874,7 @@ The reference date the price should be relative. @item target A string identifying the ``target'' commodity, or the commodity the -returned price should be in. This argument is null if @option{--market} +returned price should be in. This argument is null if @option{--market} was used instead of @option{--exchange @var{COMMODITY}}. @end table @@ -1883,7 +1883,7 @@ The valuation function should return an amount. If you've written your function in Python, you can return something like @samp{Amount("$100")}. If the function returns an explicit value, that value is always used, regardless of the commodity, the date, or -the desired target commodity. For example, +the desired target commodity. For example, @smallexample define myfunc_seven(s, d, t) = 7 EUR @@ -2116,7 +2116,7 @@ postings, just as if it were a normal transaction. @item ; # % | * A line beginning with a semicolon, pound, percent, bar or asterisk -indicates a comment, and is ignored. Comments will not be returned in +indicates a comment, and is ignored. Comments will not be returned in a ``print'' response. @item indented ; @@ -2300,7 +2300,7 @@ bucket Assets:Checking @findex register Directs Ledger to replace any account matching a regex with the given -account. For example: +account. For example: @smallexample @c input:validate capture Expenses:Deductible:Medical Medical @@ -2361,7 +2361,7 @@ The @code{default} sub-directive marks this as the ``default'' commodity. @item define @c instance_t::define_directive in textual.cc -Allows you to define value expressions for future use. For example: +Allows you to define value expressions for future use. For example: @smallexample @c input:validate define var_name=$100 @@ -2513,7 +2513,7 @@ is the equivalent of: @c TODO: the following paragraph seems to be false, the automated tests @c fail, if anything appears after end apply tag. -@c Note that anything following @code{end apply tag} is ignored. placing +@c Note that anything following @code{end apply tag} is ignored. Placing @c the name of the tag that is being closed is a simple way to keep @c track. @@ -2992,13 +2992,13 @@ You can gang up multiple tags by sharing colons: @findex payees @findex --by-payee -``Payee'' is a special metadata field. If set on a posting, it will be +``Payee'' is a special metadata field. If set on a posting, it will be used as the payee name for that posting. This affects the @command{register} report, the @command{payees} report, and the @option{--by-payee} option. This is useful when for example you deposit 4 checks at a time to the -bank. On the bank statement, there is just one amount @samp{$400}, but +bank. On the bank statement, there is just one amount @samp{$400}, but you can specify from whom each check came from, as shown by example below: @@ -3132,7 +3132,7 @@ the amount expression with parentheses: If at the end of a posting's amount (and after the cost too, if there is one) there is an equals sign, then Ledger will verify that the total value for that account as of that posting matches the amount -specified. See @option{--permissive} option to relax the balance assertions checks. +specified. See @option{--permissive} option to relax the balance assertions checks. There are two forms of this features: balance assertions, and balance assignments. @@ -3834,7 +3834,7 @@ the generated posting. @findex --effective In the real world, transactions do not take place instantaneously. -Purchases can take several days to post to a bank account. And you may +Purchases can take several days to post to a bank account. And you may pay ahead for something for which you want to distribute costs. With Ledger you can control every aspect of the timing of a transaction. @@ -3882,7 +3882,7 @@ $ ledger --effective --begin 2008/01/01 --end 2008/01/14 bal Income @noindent gives you your cash basis income in the same two weeks. -Another use is distributing costs out in time. As an example, suppose +Another use is distributing costs out in time. As an example, suppose you just prepaid into a local vegetable co-op that sustains you through the winter. It costs $225 to join the program, so you write a check. You don't want your October grocery budget to be blown @@ -3929,7 +3929,7 @@ $ ledger --effective register Groceries A periodic transaction starts with a @samp{~} followed by a period expression. Periodic transactions are used for budgeting and forecasting only, they have no effect without the @option{--budget} -option specified. For examples and details, @pxref{Budgeting and +option specified. For examples and details, @pxref{Budgeting and Forecasting}. @node Concrete Example of Automated Transactions, , Periodic Transactions, Automated Transactions @@ -4043,7 +4043,7 @@ may be excluded from reports by using @option{--real}. The power of Ledger comes from the incredible flexibility in its reporting commands, combined with formatting commands. Some options control what is included in the calculations, and formatting controls -how it is displayed. The combinations are infinite. This chapter will +how it is displayed. The combinations are infinite. This chapter will show you the basics of combining various options and commands. In the next chapters you will find details about the specific commands and options. @@ -4181,7 +4181,7 @@ $ ledger bal Expenses and not (Expenses:Drinks or Expenses:Candy or Expenses:Gif @subsection Controlling Formatting These examples all use the default formatting for the balance -report. Customizing the formatting can easily allowing to see only what +report. Customizing the formatting can easily allowing to see only what you want, or interface Ledger with other programs. @node Typical queries, Advanced Reports, Balance Reports, Building Reports @@ -4373,7 +4373,7 @@ third line is where we calculate and display the percentages. The for the account in this line. The @code{parent.total} command gives the total for the next level up in the tree. @code{percent} formats their ratio as a percentage. The fourth line tells ledger to display -the current market value of the line. The last two characters +the current market value of the line. The last two characters @samp{%/} tell Ledger what to do for the last line, in this case, nothing. @@ -4387,13 +4387,13 @@ nothing. @findex --display @var{EXPR} If you have the ``Gnuplot'' program installed, you can graph any of the -above register reports. The script to do this is included in the ledger -distribution, and is named @file{contrib/report}. Install @file{report} +above register reports. The script to do this is included in the ledger +distribution, and is named @file{contrib/report}. Install @file{report} anywhere along your @env{PATH}, and then use @file{report} instead of -@file{ledger} when doing a register report. The only thing to keep in +@file{ledger} when doing a register report. The only thing to keep in mind is that you must specify @option{--amount-data (-j)} or @option{--total-data (-J)} to indicate whether ``Gnuplot'' should plot -the amount, or the running total. For example, this command plots total +the amount, or the running total. For example, this command plots total monthly expenses made on your MasterCard. @smallexample @@ -4416,7 +4416,7 @@ report -J reg ^income ^expenses # cash flow report report -J -l "Ua>=@{\$0.01@}" reg ^assets ^liab -# net worth report starting last February. the use of a display +# net worth report starting last February. the use of a display # predicate (-d) is needed, otherwise the balance will start at # zero, and thus the y-axis will not reflect the true balance @@ -4571,9 +4571,9 @@ Transaction Number,Date,Description,Memo,Amount Debit,Amount Credit,Balance,Chec 1113648,12/12/2011,"Withdrawal","Tuscan IT #00037657",-29.73,,00001908.37,, @end smallexample -Unfortunately, as it stands Ledger cannot read it, but you can. Ledger +Unfortunately, as it stands Ledger cannot read it, but you can. Ledger expects the first line to contain a description of the fields on each -line of the file. The fields ledger can recognize contain these +line of the file. The fields ledger can recognize contain these case-insensitive strings @code{date}, @code{posted}, @code{code}, @code{payee} or @code{desc} or @code{description}, @code{amount}, @code{cost}, @code{total}, and @code{note}. @@ -4600,7 +4600,7 @@ scripting. If there are columns in the bank data you would like to keep in your ledger data, besides the primary fields described above, you can name them in the field descriptor list and Ledger will include them in the -transaction as meta data if it doesn't recognize the field name. For +transaction as meta data if it doesn't recognize the field name. For example, if you want to capture the bank transaction number and it occurs in the first column of the data use: @@ -4615,21 +4615,21 @@ from the file above. @findex --account @var{STR} @findex --rich-data -The @command{convert} command accepts three options. They are +The @command{convert} command accepts three options. They are @option{--invert} which inverts the amount field, @option{--account @var{STR}} which you can use to specify the account to balance against, and @option{--rich-data} which stores -additional metadata as tags. There is, for example, -a UUID field. If an entry with the same UUID tag is already included in +additional metadata as tags. There is, for example, +a UUID field. If an entry with the same UUID tag is already included in the normal ledger file (specified via @option{--file @var{FILE} (-f)} or via the environment variable @env{LEDGER_FILE}) this entry will not be printed again. You can also use @command{convert} with @code{payee} and @code{account} -directives. First, you can use the @code{payee} and @code{alias} -directive to rewrite the @code{payee} field based on some rules. Then +directives. First, you can use the @code{payee} and @code{alias} +directive to rewrite the @code{payee} field based on some rules. Then you can use the account and its @code{payee} directive to specify the -account. I use it like this, for example: +account. I use it like this, for example: @smallexample @c input:validate payee Aldi @@ -4640,7 +4640,7 @@ account Aufwand:Einkauf:Lebensmittel Note that it may be necessary for the output of @samp{ledger convert} to be passed through @code{ledger print} a second time if you want to -match on the new payee field. During the @code{ledger convert} run, +match on the new payee field. During the @code{ledger convert} run, only the original payee name as specified in the csv data seems to be used. @@ -4726,7 +4726,7 @@ Using Babel, it is possible to record financial transactions conveniently in an org file and subsequently generate the financial reports required. -As of Org mode 7.01, Ledger support is provided. Check the Babel +As of Org mode 7.01, Ledger support is provided. Check the Babel documentation on Worg for instructions on how to achieve this but I currently do this directly as follows: @@ -4738,7 +4738,7 @@ I currently do this directly as follows: @end smallexample Once Ledger support in Babel has been enabled, we can proceed to -include Ledger entries within an org file. There are three ways (at +include Ledger entries within an org file. There are three ways (at least) in which these can be included: @enumerate @@ -4777,7 +4777,7 @@ The first two are described in more detail in this short tutorial. The easiest, albeit possibly least useful, way in which to use Ledger within an org file is to use a single source block to record all Ledger -entries. The following is an example source block: +entries. The following is an example source block: @smallexample #+name: allinone @@ -4807,11 +4807,11 @@ entries. The following is an example source block: @end smallexample In this example, we have combined both expenses and income into one set -of Ledger entries. We can now generate register and balance reports (as +of Ledger entries. We can now generate register and balance reports (as well as many other types of reports) using Babel to invoke Ledger with -specific arguments. The arguments are passed to Ledger using the -@code{:cmdline} header argument. In the code block above, there is no -such argument so the system takes the default. For Ledger code blocks, +specific arguments. The arguments are passed to Ledger using the +@code{:cmdline} header argument. In the code block above, there is no +such argument so the system takes the default. For Ledger code blocks, the default @code{:cmdline} argument is @code{bal} and the result of evaluating this code block (@kbd{C-c C-c}) would be: @@ -4841,16 +4841,16 @@ Evaluating the code block again would generate a different report. Having to change the actual directive on the code block and re-evaluate makes it difficult to have more than one view of your transactions and -financial state. Eventually, Babel will support passing arguments to +financial state. Eventually, Babel will support passing arguments to @code{#+call} evaluations of code blocks but this support is missing -currently. Instead, we can use the concepts of literary programming, as +currently. Instead, we can use the concepts of literary programming, as implemented by the @code{noweb} features of Babel, to help us. @node Multiple Ledger source blocks with @code{noweb}, Income Entries, Embedded Ledger example with single source block, Org mode with Babel @subsubsection Multiple Ledger source blocks with @code{noweb} The @code{noweb} feature of Babel allows us to expand references to -other code blocks within a code block. For Ledger, this can be used to +other code blocks within a code block. For Ledger, this can be used to group transactions according to type, say, and then bring various sets of transactions together to generate reports. @@ -4861,9 +4861,9 @@ these into expenses and income, as follows: @subsubsection Income Entries The first set of entries relates to income, either monthly pay or -interest, all typically going into one of my bank accounts. Here, I have +interest, all typically going into one of my bank accounts. Here, I have placed several entries, but we could have had each entry in a separate -@code{src} block. Note that all code blocks you wish to refer to later +@code{src} block. Note that all code blocks you wish to refer to later must have the @code{:noweb yes} header argument specified. @smallexample @@ -4891,7 +4891,7 @@ must have the @code{:noweb yes} header argument specified. @subsubsection Expenses The following entries relate to personal expenses, such as rent and -food. Again, these have all been placed in a single @code{src} block but +food. Again, these have all been placed in a single @code{src} block but could have been done individually. @smallexample @@ -4911,8 +4911,8 @@ could have been done individually. Given the ledger entries defined above in the income and expenses code blocks, we can now refer to these using the noweb expansion directives, -@code{<>}. We can now define different code blocks to generate -specific reports for those transactions. Below are two examples, one to +@code{<>}. We can now define different code blocks to generate +specific reports for those transactions. Below are two examples, one to generate a balance report and one to generate a register report of all transactions. @@ -4922,7 +4922,7 @@ transactions. The overall balance of your account and expenditure with a breakdown according to category is specified by passing the @code{:cmdline bal} -argument to Ledger. This code block can now be evaluated (@kbd{C-c C-c}) +argument to Ledger. This code block can now be evaluated (@kbd{C-c C-c}) and the results generated by incorporating the transactions referred to by the @code{<>} and @code{<>} lines. @@ -4968,7 +4968,7 @@ to tell Ledger to exclude sub-accounts in the report. @findex --monthly You can also generate a monthly register (the @command{reg} command) by -executing the following @code{src} block. This presents a summary of +executing the following @code{src} block. This presents a summary of transactions for each monthly period (the @option{--monthly (-M)} argument) with a running total in the final column (which should be 0 at the end if all the entries are correct). @@ -4994,7 +4994,7 @@ the end if all the entries are correct). @end smallexample We could also generate a monthly report on our assets showing how these -are increasing (or decreasing!). In this case, the final column will be +are increasing (or decreasing!). In this case, the final column will be the running total of the assets in our ledger. @smallexample @@ -5015,7 +5015,7 @@ the running total of the assets in our ledger. @subsubsection Summary This short tutorial shows how Ledger entries can be embedded in an org -file and manipulated using Babel. However, only simple Ledger features +file and manipulated using Babel. However, only simple Ledger features have been illustrated; please refer to the Ledger documentation for examples of more complex operations on a ledger. @@ -5028,7 +5028,7 @@ ledger can generate a graph of the relationship between your various commodities. The output file is in the ``dot'' format. This is probably not very interesting, unless you have many different -commodities valued in terms of each other. For example, multiple +commodities valued in terms of each other. For example, multiple currencies and multiple investments valued in those currencies. @node The @command{xml} command, @command{prices} and @command{pricedb} commands, The @command{pricemap} command, Reports in other Formats @@ -5223,7 +5223,7 @@ pricedb database files. The @command{accounts} command reports all of the accounts in the journal. Following the command with a regular expression will limit the -output to accounts matching the regex. The output is sorted by name. +output to accounts matching the regex. The output is sorted by name. Using the @option{--count} option will tell you how many entries use each account. @@ -5233,7 +5233,7 @@ each account. The @command{payees} command reports all of the unique payees in the journal. Using the @option{--count} option will tell you how many -entries use each payee. To filter the payees displayed you must use the +entries use each payee. To filter the payees displayed you must use the prefix @@: @smallexample @@ -5317,7 +5317,7 @@ $ ledger xact 4/9 viva dining "DM 11.50" @end smallexample @command{draft} and @command{entry} are both synonyms of -@command{xact}. @command{entry} is provided for backwards compatibility +@command{xact}. @command{entry} is provided for backwards compatibility with Ledger 2.X. @node @command{stats}, @command{select}, @command{xact}, Reports about your Journals @@ -5346,7 +5346,7 @@ with Ledger 2.X. @node Basic Usage, Command-Line Quick Reference, Command-Line Syntax, Command-Line Syntax @section Basic Usage -This chapter describes Ledger's features and options. You may wish to +This chapter describes Ledger's features and options. You may wish to survey this to get an overview before diving into the @ref{Ledger Tutorial} and more detailed examples that follow. @@ -5565,7 +5565,7 @@ Accounts, tags or commodities not previously declared will cause errors. @item --check-payees Enable strict and pedantic checking for payees as well as accounts, -commodities and tags. This only works in conjunction with +commodities and tags. This only works in conjunction with @option{--strict} or @option{--pedantic}. @item --immediate @@ -5795,7 +5795,7 @@ database. Display the man page for ledger. @item --init-file @var{FILE} -Specify the location of the init file. The default is @file{~/.ledgerrc}. +Specify the location of the init file. The default is @file{~/.ledgerrc}. @item --options Display the options in effect for this Ledger invocation, along with @@ -5829,7 +5829,7 @@ $ ledger --options bal --cleared @noindent For the source column, a value starting with a @samp{-} or @samp{--} indicated the source was a command-line argument. If the entry starts -with a @samp{$}, the source was an environment variable. If the source +with a @samp{$}, the source was an environment variable. If the source is @code{?normalize} the value was set internally by ledger, in a function called @code{normalize_options}. @@ -5837,14 +5837,14 @@ a function called @code{normalize_options}. Execute a ledger script. @item --trace @var{INT} -Enable tracing. The @var{INT} specifies the level of trace desired. +Enable tracing. The @var{INT} specifies the level of trace desired. @item --verbose @itemx -v Print detailed information on the execution of Ledger. @item --verify -Enable additional assertions during run-time. This causes a significant +Enable additional assertions during run-time. This causes a significant slowdown. When combined with @option{--debug @var{CODE}} ledger will produce memory trace information. @@ -5870,7 +5870,7 @@ sessions with multiple reports per session. @item --check-payees Enable strict and pedantic checking for payees as well as accounts, -commodities and tags. This only works in conjunction with +commodities and tags. This only works in conjunction with @option{--strict} or @option{--pedantic}. @item --day-break @@ -5912,7 +5912,7 @@ Specify the input @file{FILE} for this invocation. @c information. @item --input-date-format @var{DATE_FORMAT} -Specify the input date format for journal entries. For example, +Specify the input date format for journal entries. For example, @smallexample $ ledger convert Export.csv --input-date-format "%m/%d/%Y" @@ -5965,10 +5965,10 @@ Specify the location of the price entry data file. @item --price-exp @var{INT} @itemx -Z @var{INT} @itemx --leeway @var{INT} -Set the expected freshness of price quotes, in @var{INT} minutes. That +Set the expected freshness of price quotes, in @var{INT} minutes. That is, if the last known quote for any commodity is older than this value, and if @option{--download} is being used, then the Internet will be -consulted again for a newer price. Otherwise, the old price is still +consulted again for a newer price. Otherwise, the old price is still considered to be fresh enough. @item --strict @@ -5981,7 +5981,7 @@ a misspelled commodity or account) it will issue a warning giving you the file and line number of the problem. @item --recursive-aliases -Normally, ledger only expands aliases once. With this option, ledger +Normally, ledger only expands aliases once. With this option, ledger tries to expand the result of alias expansion recursively, until no more expansions apply. @@ -6012,14 +6012,14 @@ sessions with multiple reports per session. @item --abbrev-len @var{INT} Set the minimum length an account can be abbreviated to if it doesn't -fit inside the @code{account-width}. If @var{INT} is zero, then the -account name will be truncated on the right. If @var{INT} is greater +fit inside the @code{account-width}. If @var{INT} is zero, then the +account name will be truncated on the right. If @var{INT} is greater than @code{account-width} then the account will be truncated on the left, with no shortening of the account names in order to fit into the desired width. @item --account @var{STR} -Prepend @var{STR} to all accounts reported. That is, the option +Prepend @var{STR} to all accounts reported. That is, the option @samp{--account Personal} would tack @samp{Personal:} to the beginning of every account reported in a balance report or register report. @@ -6038,7 +6038,7 @@ Show only unbudgeted postings. @item --amount @var{EXPR} @itemx -t @var{EXPR} Apply the given value expression to the posting amount (@pxref{Value -Expressions}). Using @option{--amount @var{EXPR}} you can apply an +Expressions}). Using @option{--amount @var{EXPR}} you can apply an arbitrary transformation to the postings. @item --amount-data @@ -6068,7 +6068,7 @@ running totals. @item --balance-format @var{FORMAT_STRING} Specify the format to use for the @command{balance} report (@pxref{Format -Strings}). The default is: +Strings}). The default is: @smallexample "%(justify(scrub(display_total), 20, -1, true, color))" @@ -6080,7 +6080,7 @@ Strings}). The default is: @item --base Reduce convertible commodities down the bottom of the conversion, e.g. -display time in seconds. This also applies to custom commodity conversions. +display time in seconds. This also applies to custom commodity conversions. @item --basis @itemx -B @@ -6088,7 +6088,7 @@ display time in seconds. This also applies to custom commodity conversions. Report the cost basis on all posting. @item --begin @var{DATE} -Specify the start @var{DATE} of all calculations. Transactions before +Specify the start @var{DATE} of all calculations. Transactions before that date will be ignored. @item --bold-if @var{VEXPR} @@ -6104,7 +6104,7 @@ list all transactions since the beginning of December and print in bold any posting greater than $100. @item --budget -Only display budgeted items. In a register report this +Only display budgeted items. In a register report this displays transactions in the budget, in a balance report this displays accounts in the budget (@pxref{Budgeting and Forecasting}). @@ -6132,7 +6132,7 @@ calculation. @item --cleared-format @var{FORMAT_STRING} @c FIXME thdox: to keep? Specify the format to use for the @command{cleared} report (@pxref{Format -Strings}). The default is: +Strings}). The default is: @smallexample "%(justify(scrub(get_at(total_expr, 0)), 16, 16 + prepend_width, " @@ -6148,7 +6148,7 @@ Strings}). The default is: @item --collapse @itemx -n -By default ledger prints all accounts in an account tree. With +By default ledger prints all accounts in an account tree. With @option{--collapse} it prints only the top level account specified. @item --collapse-if-zero @@ -6265,11 +6265,11 @@ And with @option{--dc} it becomes this: Limit the depth of the account tree. In a balance report, for example, a @samp{--depth 2} statement will print balances only for accounts with two levels, i.e. @samp{Expenses:Entertainment} but not -@samp{Expenses:Entertainment:Dining}. This is a display predicate, which +@samp{Expenses:Entertainment:Dining}. This is a display predicate, which means it only affects display, not the total calculations. @item --deviation -Report each posting’s deviation from the average. It is only meaningful +Report each posting’s deviation from the average. It is only meaningful in the register and prices reports. @item --display @var{EXPR} @@ -6300,7 +6300,7 @@ Include empty accounts in the report and in average calculations. @item --end @var{DATE} Specify the end @var{DATE} for a transaction to be considered in the -report. All transactions on or after this date are ignored. +report. All transactions on or after this date are ignored. @item --equity Related to the @command{equity} command (@pxref{The @command{equity} @@ -6313,7 +6313,7 @@ posting occurring in that period. @item --exchange @var{COMMODITY} @itemx -X @var{COMMODITY} -Display values in terms of the given @var{COMMODITY}. The latest +Display values in terms of the given @var{COMMODITY}. The latest available price is used. The syntax @option{-X @var{COMMODITY1}:@var{COMMODITY2}} displays values in @var{COMMODITY1} in terms of @var{COMMODITY2} using the latest available price, but @@ -6326,11 +6326,11 @@ available for reporting in terms of @var{COMMODITY2}, but only a few should be displayed that way. @item --flat -Force the full names of accounts to be used in the balance report. The +Force the full names of accounts to be used in the balance report. The balance report will not use an indented tree. @item --force-color -Output TTY color codes even if the TTY doesn't support them. Useful +Output TTY color codes even if the TTY doesn't support them. Useful for TTYs that don't advertise their capabilities correctly. @item --force-pager @@ -6360,7 +6360,7 @@ them. @item --group-by @var{EXPR} Group transactions together in the @command{register} report. @var{EXPR} can be anything, although most common would be @code{payee} -or @code{commodity}. The @code{tags()} function is also useful here. +or @code{commodity}. The @code{tags()} function is also useful here. @item --group-title-format @var{FORMAT_STRING} Set the format for the headers that separates the report sections of @@ -6376,13 +6376,13 @@ $ ledger reg Expenses --group-by "payee" --group-title-format "----------------- 2011/06/02 AAA Dues Expenses:Auto:Misc $ 215.00 $ 215.00 ------------------------ ABC Towing and Wrecking --------------------- -2011/03/17 ABC Towing and Wrec.. Expenses:Auto:Hobbies $ 48.20 $ 48.20 +2011/03/17 ABC Towing and Wrec.. Expenses:Auto:Hobbies $ 48.20 $ 48.20 ... @end smallexample @item --head @var{INT} @itemx --first @var{INT} -Print the first @var{INT} entries. Opposite of @option{--tail +Print the first @var{INT} entries. Opposite of @option{--tail @var{INT}}. @item --historical @@ -6485,7 +6485,7 @@ Redirect the output of ledger to the file defined in @file{FILE}. Direct output to @var{FILE} pager program. @item --payee @var{VEXPR} -Sets a value expression for formatting the payee. In the +Sets a value expression for formatting the payee. In the @command{register} report this prevents the second entry from having a date and payee for each transaction. @@ -6503,13 +6503,13 @@ Only works for accounts that have a single commodity. @item --period @var{PERIOD_EXPRESSION} Define a period expression that sets the time period during which -transactions are to be accounted. For a @command{register} report only +transactions are to be accounted. For a @command{register} report only the transactions that satisfy the period expression with be displayed. For a @command{balance} report only those transactions will be accounted in the final balances. @item --pivot @var{TAG} -Produce a balance pivot report @emph{around} the given @var{TAG}. For +Produce a balance pivot report @emph{around} the given @var{TAG}. For example, if you have multiple cars and track each fuel purchase in @samp{Expenses:Auto:Fuel} and tag each fuel purchase with a tag identifying which car the purchase was for @samp{; Car: Prius}, then the @@ -6530,11 +6530,11 @@ $ ledger bal Fuel --pivot "Car" --period "this year" @xref{Metadata values}. @item --plot-amount-format @var{FORMAT_STRING} -Define the output format for an amount data plot. @xref{Visualizing +Define the output format for an amount data plot. @xref{Visualizing with Gnuplot}. @item --plot-total-format @var{FORMAT_STRING} -Define the output format for a total data plot. @xref{Visualizing with +Define the output format for a total data plot. @xref{Visualizing with Gnuplot}. @item --prepend-format @var{FORMAT_STRING} @@ -6623,7 +6623,7 @@ Sort the postings within transactions using the given value expression. @item --start-of-week @var{INT} Tell ledger to use a particular day of the week to start its ``weekly'' -summary. @samp{--start-of-week=1} specifies Monday as the start of the +summary. @samp{--start-of-week=1} specifies Monday as the start of the week. @item --subtotal @@ -6632,7 +6632,7 @@ week. @item --tail @var{INT} @itemx --last @var{INT} -Report only the last @var{INT} entries. Only useful in +Report only the last @var{INT} entries. Only useful in a @command{register} report. @item --time-report @@ -6652,8 +6652,8 @@ Set the width of the total field in the register report. @item --truncate @var{CODE} Indicates how truncation should happen when the contents of columns -exceed their width. Valid arguments are @samp{leading}, @samp{middle}, -and @samp{trailing}. The default is smarter than any of these three, +exceed their width. Valid arguments are @samp{leading}, @samp{middle}, +and @samp{trailing}. The default is smarter than any of these three, as it considers sub-names within the account name (that style is called ``abbreviate''). @@ -6670,12 +6670,12 @@ report. @item --unrealized-gains @var{STR} Allow the user to specify what account name should be used for -unrealized gains. Defaults to @samp{"Equity:Unrealized Gains"}. +unrealized gains. Defaults to @samp{"Equity:Unrealized Gains"}. Often set in one's @file{~/.ledgerrc} file to change the default. @item --unrealized-losses @var{STR} Allow the user to specify what account name should be used for -unrealized gains. Defaults to @samp{"Equity:Unrealized Losses"}. +unrealized gains. Defaults to @samp{"Equity:Unrealized Losses"}. Often set in one's @file{~/.ledgerrc} file to change the default. @item --unround @@ -6721,9 +6721,9 @@ are using. @item --file @var{FILE} @itemx -f @var{FILE} -Read @file{FILE} as a ledger file. @var{FILE} can be @samp{-} which is -a synonym for @samp{/dev/stdin}. This command may be used multiple -times. Typically, the environment variable @env{LEDGER_FILE} is set, +Read @file{FILE} as a ledger file. @var{FILE} can be @samp{-} which is +a synonym for @samp{/dev/stdin}. This command may be used multiple +times. Typically, the environment variable @env{LEDGER_FILE} is set, rather than using this command-line option. @item --output @var{FILE} @@ -6978,7 +6978,7 @@ least, using the absolute value of the total. For more on how to use value expressions, see @ref{Value Expressions}. @item --pivot @var{TAG} -Produce a pivot table around the @var{TAG} provided. This requires +Produce a pivot table around the @var{TAG} provided. This requires meta data using valued tags. @item --wide @@ -6987,11 +6987,11 @@ Cause the default @command{register} report to assume 132 columns instead of 80. @item --head @var{INT} -Cause only the first @var{INT} transactions to be printed. This is +Cause only the first @var{INT} transactions to be printed. This is different from using the command-line utility @file{head}, which would -limit to the first @var{INT} postings. @option{--tail @var{INT}} outputs -only the last @var{INT} transactions. Both options may be used -simultaneously. If a negative amount is given, it will invert the +limit to the first @var{INT} postings. @option{--tail @var{INT}} outputs +only the last @var{INT} transactions. Both options may be used +simultaneously. If a negative amount is given, it will invert the meaning of the flag (instead of the first five transactions being printed, for example, it would print all but the first five). @@ -7095,7 +7095,7 @@ Define the output format for the @command{balance} report. The default @end smallexample @item --cleared-format @var{FORMAT_STRING} -Define the format for the cleared report. The default is: +Define the format for the cleared report. The default is: @smallexample "%(justify(scrub(get_at(display_total, 0)), 16, 16 + int(prepend_width), @@ -7163,7 +7163,7 @@ Set the format for @command{csv} reports. The default is: @item --plot-amount-format @var{FORMAT_STRING} Set the format for amount plots, using the @option{--amount-data (-j)} -option. The default is: +option. The default is: @smallexample "%(format_date(date, \"%Y-%m-%d\")) %(quantity(scrub(display_amount)))\n" @@ -7178,14 +7178,14 @@ option. The default is: @end smallexample @item --pricedb-format @var{FORMAT_STRING} -Set the format expected for the historical price file. The default is: +Set the format expected for the historical price file. The default is: @smallexample "P %(datetime) %(display_account) %(scrub(display_amount))\n" @end smallexample @item --prices-format @var{FORMAT_STRING} -Set the format for the @command{prices} report. The default is: +Set the format for the @command{prices} report. The default is: @smallexample "%(date) %-8(display_account) %(justify(scrub(display_amount), 12, @@ -7224,10 +7224,10 @@ The format of the file can be changed by telling ledger to use the @item --price-exp @var{INT} @itemx -Z @var{INT} -Set the expected freshness of price quotes, in @var{INT} minutes. That +Set the expected freshness of price quotes, in @var{INT} minutes. That is, if the last known quote for any commodity is older than this value, and if @option{--download} is being used, then the Internet will be -consulted again for a newer price. Otherwise, the old price is still +consulted again for a newer price. Otherwise, the old price is still considered to be fresh enough. @item --download @@ -7285,7 +7285,7 @@ etc. When you specify @option{--market (-V)}, or @option{--exchange @var{COMMODITY} (-X)}, you are requesting that some or all of the commodities be valuated as of today (or whatever @option{--now -@var{DATE}} is set to). But what does such a valuation mean? This +@var{DATE}} is set to). But what does such a valuation mean? This meaning is governed by the presence of a @var{VALUE} meta-data property, whose content is an expression used to compute that value. @@ -7325,7 +7325,7 @@ they cannot have a different future value: @end smallexample This says the future valuation is the same as the valuation at the time -of posting. post.date equals the posting's date, while just 'date' is +of posting. @code{post.date} equals the posting's date, while just 'date' is the value of @option{--now @var{DATE}} (defaults to today). Or how about valuating miles based on a reimbursement rate during a @@ -7928,7 +7928,7 @@ Useful for specifying a date in plain terms. For example, you could say @item expr comment =~ /REGEX/ A regular expression that matches against a posting's comment -field. This searches only a posting's field, not the transaction's note +field. This searches only a posting's field, not the transaction's note or comment field. For example, @code{ledger reg "expr" "comment =~ /landline/"} will match: @@ -7953,7 +7953,7 @@ instead. @item expr note =~ /REGEX/ A regular expression that matches against a transaction's note field. This searches all comments in the transaction, including comments on -individual postings. Thus, @samp{ledger reg "expr" "note =~ /landline/"} +individual postings. Thus, @samp{ledger reg "expr" "note =~ /landline/"} will match both all the three examples below: @smallexample @@ -8030,7 +8030,7 @@ Assets:Cash ¤ 123,45 @defun ansify_if value color bool Render the given @var{expression} as a string, applying the proper ANSI escape codes to display it in the given @var{color} if @var{bool} is true. It -typically checks the value of the option @option{--color}. Since ANSI escape +typically checks the value of the option @option{--color}. Since ANSI escape codes include non-printable character sequences, such as escape @kbd{^[} the following example may not appear as the final result on the commandline. @smallexample @c command:4D836EE,with_input:3406FC1 @@ -8111,13 +8111,13 @@ Expenses:Office Supplies ¤ 123,00 @end defun @defun format_date date format -Return the @var{date} as a string using @var{format}. See strftime (3) +Return the @var{date} as a string using @var{format}. See strftime (3) for format string details. @smallexample @c command:9605B13,with_input:3406FC1 $ ledger -f expr.dat --format "%(format_date(date, '%A, %B %d. %Y'))\n" reg assets @end smallexample @smallexample @c output:9605B13 -Friday, January 16. 2015 +Friday, January 16. 2015 @end smallexample @end defun @@ -8143,7 +8143,7 @@ of the field in the first line is given by @var{first_width}. For subsequent lines the width is given by @var{latter_width}. If @var{latter_width=-1}, then @var{first_width} is use for all lines. If @var{right_justify=true} then the field is right justify within -the width of the field. If it is @var{false}, then the field is left +the width of the field. If it is @var{false}, then the field is left justified and padded to the full width of the field. If @var{colorize} is true, then ledger will honor color settings. @smallexample @c command:082FB27,with_input:3406FC1 @@ -8360,12 +8360,12 @@ $ ledger -f expr.dat --format "»%(trim(' Trimmed '))«\n" reg assets Format strings may be used to change the output format of reports. They are specified by passing a formatting string to the @option{--format -@var{FORMAT_STRING} (-F)} option. Within that string, constructs are +@var{FORMAT_STRING} (-F)} option. Within that string, constructs are allowed which make it possible to display the various parts of an account or posting in custom ways. There are several additional flags that allow you to define formats -for specific reports. These are useful to define in your configuration +for specific reports. These are useful to define in your configuration file and will allow you to run ledger reports from the command-line without having to enter a new format for each command. @@ -8703,7 +8703,7 @@ Return the current date and time. If the @option{--now @var{DATE}} option is defined it will return that value. @item today -Return the current date. If the @option{--now @var{DATE}} option is +Return the current date. If the @option{--now @var{DATE}} option is defined it will return that value. @item to_datetime @@ -8884,7 +8884,7 @@ of the field in the first line is given by @code{first_width}. For subsequent lines the width is given by @code{latter_width}. If @code{latter_width=-1}, then @code{first_width} is use for all lines. If @code{right_justify=true} then the field is right justify within -the width of the field. If it is @code{false}, then the field is left +the width of the field. If it is @code{false}, then the field is left justified and padded to the full width of the field. If @code{colorize} is true, then ledger will honor color settings. @@ -9646,7 +9646,7 @@ Ignore init files and environment variables for the ledger run. @item --debug @var{CODE} If Ledger has been built with debug options this will provide extra -data during the run. The following are the available @var{CODES} to +data during the run. The following are the available @var{CODES} to debug: @multitable @columnfractions .32 .43 .27 @@ -9679,7 +9679,7 @@ debug: @ @item --trace @var{INT} -Enable tracing. The @var{INT} specifies the level of trace desired: +Enable tracing. The @var{INT} specifies the level of trace desired: @multitable @columnfractions .3 .7 @item @code{LOG_OFF} @tab 0 @@ -9701,7 +9701,7 @@ Enable tracing. The @var{INT} specifies the level of trace desired: Print detailed information on the execution of Ledger. @item --verify -Enable additional assertions during run-time. This causes a significant +Enable additional assertions during run-time. This causes a significant slowdown. When combined with @option{--debug @var{CODE}} ledger will produce memory trace information. @@ -9719,7 +9719,7 @@ Print version information and exit. @cindex pre-commands Pre-commands are useful when you aren't sure how a command or option -will work. The difference between a pre-command and a regular command +will work. The difference between a pre-command and a regular command is that pre-commands ignore the journal data file completely, nor is the user's init file read. @@ -9964,10 +9964,10 @@ GnuCash file import. The option @option{--performance (-g)}. @item -The balance report now defaults to showing all relevant accounts. This -is the opposite of 2.x. That is, @command{bal} in 3.0 does what @samp{-s -bal} did in 2.x. To see 2.6 behavior, use @option{--collapse (-n)} -option in 3.0, like @samp{bal -n}. The @option{--subtotal (-s)} option +The balance report now defaults to showing all relevant accounts. This +is the opposite of 2.x. That is, @command{bal} in 3.0 does what @samp{-s +bal} did in 2.x. To see 2.6 behavior, use @option{--collapse (-n)} +option in 3.0, like @samp{bal -n}. The @option{--subtotal (-s)} option no longer has any effect on balance reports. @end itemize -- cgit v1.2.3 From 49080919e1764a895a07264eee12098840abca82 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Wed, 18 Feb 2015 21:53:34 +0100 Subject: [doc] Add documentation for command-line options --- doc/ledger.1 | 123 +++++++++++++++++++++++++++++++++++++++++++++++-------- doc/ledger3.texi | 4 +- 2 files changed, 109 insertions(+), 18 deletions(-) diff --git a/doc/ledger.1 b/doc/ledger.1 index 1a8a43b8..8284dfa4 100644 --- a/doc/ledger.1 +++ b/doc/ledger.1 @@ -1150,6 +1150,12 @@ toward -infinity. The name of the .Nm data file from whence the posting came. +.It Fn format string +Evaluate +.Ar string +as format just like the +.Fl \-format +option. .It Fn format_date date format Return the .Ar date @@ -1158,18 +1164,56 @@ as a string using Refer to .Xr strftime 3 for format string details. -.\".It Fn get_at -.\".It Fn has_meta +.It Fn format_datetime datetime format +Return the +.Ar datetime +as a string using +.Ar format . +Refer to +.Xr strftime 3 +for format string details. +.It Fn get_at seq index +Return value at +.Ar index +from +.Ar seq . +Used internally to construct different reports. +.It Fn has_meta +Return true if the posting has metadata named +.Ar tag , +false otherwise. .It Fn has_tag tag Return true if the posting has metadata named .Ar tag , false otherwise. -.\".It Fn is_seq +.It Fn is_seq value +Return true if +.Ar value +is a sequence. Used internally. .It Fn join value Replace all newlines in .Ar value with .Li \en . +.It Fn justify value first_width latter_width right_justify colorize +Right or left justify the string representing +.Ar value . +The width of the field in the first line is given by +.Ar first_width . +For subsequent lines the width is given by +.Ar latter_width . +If +.Ar latter_width +is -1, +.Ar first_width +is used for all lines. +If +.Ar right_justify +is true then the field is right justified within the width of the field. If it +is false, then the field is left justified and padded to the full width of the +field. If +.Ar colorize +is true, then ledger will honor color settings. .It Fn market value datetime Return the price of .Ar value @@ -1179,8 +1223,13 @@ Note that .Ar datetime must be surrounded by brackets in order to be parsed correctly, e.g. .Bq 2012/03/23 . -.\".It Sy meta -.I.\"t Sy note +.It Fn meta +Return the value of metadata named +.Ar name . +.It Sy note +Return the note for the posting. +.It Sy now +Return the current datetime. .\".It Sy null .It Sy options A variable that allows access to the values of the given command-line options @@ -1206,7 +1255,11 @@ in relation to .Ar value_b . .\".It Sy post .\" A variable scope -.\".It Sy print +.It Fn print value +Print +.Ar value +to stdout. +Used internally for debugging. .It Fn quantity value Return the quantity of .Ar value @@ -1226,23 +1279,54 @@ Return rounded to .Ar n digits. Does not affect formatting. -.\".It Sy scrub +.It Sy should_bold +Return true if expression given to +.Fl \-bold-if +evaluates to true. Internal use only! +.It Fn scrub value +Clean +.Ar value +using various transformations such as round, +stripping value annotations, and more. .\".It Sy status -.\".It Sy strip +.It Fn strip value +Strip value annotation from +.Ar value . .\".It Sy subcount .It Fn tag name Return the value of tag named .Ar name . -.\".It Fn to_amount value -.\".It Fn to_balance value -.\".It Fn to_boolean value -.\".It Fn to_date value -.\".It Fn to_datetime value +.It Fn to_amount value +Convert +.Ar value +to an amount. Internal use only! +.It Fn to_balance value +Convert +.Ar value +to a balance. Internal use only! +.It Fn to_boolean value +Convert +.Ar value +to a boolean. Internal use only! +.It Fn to_date value +Convert +.Ar value +to a date. Internal use only! +.It Fn to_datetime value +Convert +.Ar value +to a datetime. Internal use only! .It Fn to_int value Return the integer value for .Ar value . -.\".It Fn to_mask value -.\".It Fn to_sequence value +.It Fn to_mask value +Convert +.Ar value +to a mask. Internal use only! +.It Fn to_sequence value +Convert +.Ar value +to a sequence. Internal use only! .It Fn to_string value Convert .Ar value @@ -1258,7 +1342,14 @@ option. .It Fn trim value Trim leading and trailing whitespace from .Ar value . -.\".It Fn truncate +.It Fn truncated string, total_len, account_len +Truncate +.Ar string +to +.Ar total_len +enusring that each account is at least +.Ar account_len +long. .\".It Sy uncleared .It Sy virtual Return true if the transaction is virtual, e.g automated, false otherwise. diff --git a/doc/ledger3.texi b/doc/ledger3.texi index a48c2dc8..3caf4d14 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -8141,8 +8141,8 @@ Friday, January 16. 2015 Right or left justify the string representing @var{value}. The width of the field in the first line is given by @var{first_width}. For subsequent lines the width is given by @var{latter_width}. If -@var{latter_width=-1}, then @var{first_width} is use for all lines. -If @var{right_justify=true} then the field is right justify within +@var{latter_width=-1}, then @var{first_width} is used for all lines. +If @var{right_justify=true} then the field is right justified within the width of the field. If it is @var{false}, then the field is left justified and padded to the full width of the field. If @var{colorize} is true, then ledger will honor color settings. -- cgit v1.2.3 From fd22653f84f9662fa8acee02a712a8657fa0024b Mon Sep 17 00:00:00 2001 From: thdox Date: Thu, 19 Feb 2015 23:51:30 +0100 Subject: Correct an output. [ci skip] --- doc/ledger3.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 3caf4d14..487a515b 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -8117,7 +8117,7 @@ for format string details. $ ledger -f expr.dat --format "%(format_date(date, '%A, %B %d. %Y'))\n" reg assets @end smallexample @smallexample @c output:9605B13 -Friday, January 16. 2015 +Friday, January 16. 2015 @end smallexample @end defun -- cgit v1.2.3 From 80eaac43bf4f2fc09105d15f6a7ef1ea904e90a1 Mon Sep 17 00:00:00 2001 From: thdox Date: Thu, 19 Feb 2015 23:54:08 +0100 Subject: Improve documentation about Asset Allocation. [ci skip] --- doc/ledger3.texi | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 487a515b..8323b10c 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -4283,11 +4283,11 @@ invested in equities, and partially invested in bonds and cash. Below is the asset allocation for each of the instruments listed above: @multitable @columnfractions .2 .2 .3 .3 -@item @tab Domestic @tab Global @tab -@item Symbol @tab Equity @tab Equity @tab bonds/cash -@item VIFSX @tab 100% @tab @tab -@item VTHRX @tab 24.0% @tab 56.3% @tab 19.7% -@item VSGBX @tab @tab @tab 100% +@item @tab Domestic @tab Global @tab +@item Symbol @tab Equity @tab Equity @tab bonds/cash +@item VIFSX @tab 100% @tab @tab +@item VTHRX @tab 24.0% @tab 56.3% @tab 19.7% +@item VSGBX @tab @tab @tab 100% @end multitable These numbers are available from the prospectus of any publicly @@ -4296,7 +4296,7 @@ and a single bond issue is 100% bonds. We track purchases of specific investments using the symbol of that investment as its commodity. How do we tell Ledger that a share of -VTHRX is 24% Global equity etc.? Enter automatic transactions and +VTHRX is 24% Domestic equity? Enter automatic transactions and virtual accounts. At the top of our ledger we enter automatic transactions that describe @@ -4307,12 +4307,9 @@ actual balances. For the three instruments listed above, those automatic transactions would look like: -@smallexample @c input:validate -; -; automatic calculations for asset allocation tracking -; +@smallexample @c input:582C8C2 = expr ( commodity == 'VIFSX' ) - (Allocation:Equities:Domestic) 1.000 + (Allocation:Equities:Domestic) 1.000 = expr ( commodity == 'VTHRX' ) (Allocation:Equities:Global) 0.240 @@ -4321,6 +4318,18 @@ would look like: = expr ( commodity == 'VBMFX') (Allocation:Bonds/Cash) 1.000 + +2015-01-01 Buy VIFSX + Assets:Broker 100 VIFSX + Assets:Cash $-10000 + +2015-01-01 Buy VTHRX + Assets:Broker 10 VTHRX + Assets:Cash $-10000 + +2015-01-01 Buy VBMFX + Assets:Broker 1 VBMFX + Assets:Cash $-10000 @end smallexample How do these work? First the @samp{=} sign at the beginning of the @@ -4339,23 +4348,21 @@ the various asset classes how do we get a report that tells us our current allocation? Using the balance command and some tricky formatting! -@c TODO: does not @c command:validate due to multiple lines -@smallexample +@smallexample @c command:582C8C2 ledger bal Allocation --current --format "\ %-17((depth_spacer)+(partial_account))\ %10(percent(market(display_total), market(parent.total)))\ %16(market(display_total))\n%/" @end smallexample -@noindent Which yields: -@smallexample -Allocation 100.00% $100000.00 - Bonds/Cash 38.94% $38940.00 - Equities 61.06% $61060.00 - Domestic 95.31% $58196.29 - Global 4.69% $2863.71 +@smallexample @c result:582C8C2 + Allocation 100.00% $30000 + Bonds/Cash 39.90% $11970 + Equities 60.10% $18030 + Domestic 86.69% $15630 + Global 13.31% $2400 @end smallexample Let's look at the Ledger invocation a bit closer. The command above is -- cgit v1.2.3 From e197a4137ab0d69ee3bc1c156e90f9fc6fa23ef0 Mon Sep 17 00:00:00 2001 From: thdox Date: Thu, 19 Feb 2015 23:54:37 +0100 Subject: Add validation for @smallexample. [ci skip] --- doc/ledger3.texi | 109 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 49 deletions(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 8323b10c..f473e85f 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -1383,7 +1383,7 @@ $ ledger --real --no-total bal If more asset accounts are needed as the source of a posting, just list them as you would normally, for example: -@smallexample +@smallexample @c input:validate 2004/03/25 Payment for books (paid from Checking) Expenses:Books $100.00 Assets:Checking $-50.00 @@ -1599,7 +1599,7 @@ Beneath these top level accounts you can have any level of detail you desire. For example, if you want to keep specific track of how much you spend on burgers and fries, you could have the following: -@smallexample +@smallexample @c input:validate Expenses:Food:Hamburgers and Fries @end smallexample @@ -1885,14 +1885,14 @@ your function in Python, you can return something like that value is always used, regardless of the commodity, the date, or the desired target commodity. For example, -@smallexample +@smallexample @c input:validate define myfunc_seven(s, d, t) = 7 EUR @end smallexample In order to specify a fixed price, but still valuate that price into the target commodity, use something like this: -@smallexample +@smallexample @c input:validate define myfunc_five(s, d, t) = market(5 EUR, d, t) @end smallexample @@ -1900,14 +1900,14 @@ The @code{value} directive sets the valuation used for all commodities used in the rest of the data stream. This is the fallback, if nothing more specific is found. -@smallexample +@smallexample @c input:validate value myfunc_seven @end smallexample You can set a specific valuation function on a per-commodity basis. Instead of defining a function, you can also pass a lambda. -@smallexample +@smallexample @c input:validate commodity $ value s, d, t -> 6 EUR @end smallexample @@ -1915,7 +1915,7 @@ commodity $ Each account can also provide a default valuation function for any commodities transferred to that account. -@smallexample +@smallexample @c input:validate account Expenses:Food5 value myfunc_five @end smallexample @@ -1923,7 +1923,7 @@ account Expenses:Food5 The metadata field @samp{Value}, if found, overrides the valuation function on a transaction-wide or per-posting basis. -@smallexample +@smallexample @c input:validate = @@XACT and Food ; Value:: 8 EUR (Equity) $1 @@ -2006,10 +2006,9 @@ In order to combat inconsistency you can define allowable accounts and payees. For simplicity, create a separate text file and define accounts and payees like -@smallexample +@smallexample @c input:validate account Expenses account Expenses:Utilities -... @end smallexample Using the @option{--strict} option will cause Ledger to complain if any @@ -2025,7 +2024,7 @@ Warning: "FinanceData/Master.dat", line 15: Unknown account 'Allocation:Equities If you have a large Ledger register already created use the @command{accounts} command to get started: -@smallexample +@smallexample @c command:validate $ ledger accounts >> Accounts.dat @end smallexample @@ -2444,15 +2443,14 @@ payee KFC The @code{alias} sub-directive provides a regex which, if it matches a parsed payee, the declared payee name is substituted: -@smallexample +@smallexample @c input:validate 2012-02-27 KENTUCKY FRIED CHICKEN ; will be read as being 'KFC' -... @end smallexample The @code{uuid} sub-directive specifies that a transaction with exactly the uuid given should have the declared payee name substituted: -@smallexample +@smallexample @c input:validate 2014-05-13 UNHELPFUL PAYEE ; will be read as being 'KFC' ; UUID: 2a2e21d434356f886c84371eebac6e44f1337fda @end smallexample @@ -2580,7 +2578,7 @@ with a home currency, such as the dollar @samp{$}. It is recommended that these pricing options be set in the price database file, which defaults to @file{~/.pricedb}. The syntax for this command is: -@smallexample +@smallexample @c input:validate N SYMBOL @end smallexample @@ -3002,7 +3000,7 @@ bank. On the bank statement, there is just one amount @samp{$400}, but you can specify from whom each check came from, as shown by example below: -@smallexample @c input:validate +@smallexample @c input:9B43E57 2010-06-17 Sample Assets:Bank $400.00 Income:Check1 $-100.00 ; Payee: Person One @@ -3011,14 +3009,20 @@ below: Income:Check4 $-100.00 ; Payee: Person Four @end smallexample -When reporting this, it appears as: +When reporting with -@smallexample -10-Jun-17 Sample Assets:Bank $400.00 $400.00 - Person One Income:Check1 $-100.00 $300.00 - Person Two Income:Check2 $-100.00 $200.00 - Person Three Income:Check3 $-100.00 $100.00 - Person Four Income:Check4 $-100.00 0 +@smallexample @c command:9B43E57 +$ ledger reg +@end smallexample + +it appears as: + +@smallexample @c output:9B43E57 +10-Jun-17 Sample Assets:Bank $400.00 $400.00 + Person One Income:Check1 $-100.00 $300.00 + Person Two Income:Check2 $-100.00 $200.00 + Person Three Income:Check3 $-100.00 $100.00 + Person Four Income:Check4 $-100.00 0 @end smallexample This shows that they are all in the same transaction (which is why the @@ -3572,13 +3576,13 @@ If you use the functional form, you can either specify a function name, or a lambda expression. Here's a function that yields the price as $10 in whatever commodity is being requested: -@smallexample +@smallexample @c input:validate define ten_dollars(s, date, t) = market($10, date, t) @end smallexample I can now use that in a lot value expression as follows: -@smallexample +@smallexample @c input:validate 2012-04-10 My Broker Assets:Brokerage:Cash $375.00 Assets:Brokerage -5 AAPL @{$50.00@} ((ten_dollars)) @@@@ $375.00 @@ -4190,8 +4194,7 @@ you want, or interface Ledger with other programs. A query such as the following shows all expenses since last October, sorted by total: -@c TODO: does not validate with @c command:validate, because "last oct" is split at the space -@smallexample +@smallexample @c command:validate $ ledger -b "last oct" -S T bal ^expenses @end smallexample @@ -5243,8 +5246,10 @@ journal. Using the @option{--count} option will tell you how many entries use each payee. To filter the payees displayed you must use the prefix @@: -@smallexample +@smallexample @c command:validate $ ledger payees @@Nic +@end smallexample +@smallexample Nicolas Nicolas BOILABUS Oudtshoorn Municipality @@ -6374,8 +6379,10 @@ Set the format for the headers that separates the report sections of a grouped report. Only has an effect with a @option{--group-by @var{EXPR}} register report. -@smallexample +@smallexample @c command:validate $ ledger reg Expenses --group-by "payee" --group-title-format "------------------------ %-20(value) ---------------------\n" +@end smallexample +@smallexample ------------------------ 7-Eleven --------------------- 2011/08/13 7-Eleven Expenses:Auto:Misc $ 5.80 $ 5.80 @@ -6522,8 +6529,10 @@ example, if you have multiple cars and track each fuel purchase in identifying which car the purchase was for @samp{; Car: Prius}, then the command: -@smallexample +@smallexample @c command:validate $ ledger bal Fuel --pivot "Car" --period "this year" +@end smallexample +@smallexample $ 3491.26 Car $ 1084.22 M3:Expenses:Auto:Fuel $ 149.65 MG V11:Expenses:Auto:Fuel @@ -6746,7 +6755,7 @@ settings. To specify options in the init file, use the same syntax as on the command-line, but put each option on its own line. Here is an example init file: -@smallexample +@smallexample @c input:validate --price-db ~/finance/.pricedb --wide ; ~/.ledgerrc ends here @@ -7049,8 +7058,7 @@ register report, for example, but they will not be displayed. This is useful for seeing last month's checking postings, against a running balance which includes all posting values: -@c TODO: does not @c command:validate due to space in "last month" -@smallexample +@smallexample @c command:validate $ ledger -d "d>=[last month]" reg checking @end smallexample @@ -7058,8 +7066,7 @@ The output from this command is very different from the following, whose running total includes only postings from the last month onward: -@c TODO: does not @c command:validate due to space in "last month" -@smallexample +@smallexample @c command:validate $ ledger -p "last month" reg checking @end smallexample @@ -7215,7 +7222,7 @@ settings can be placed in this file manually, to prevent downloading quotes for a specific commodity, for example. This is done by adding a line like the following: -@smallexample +@smallexample @c input:validate ; Don't download quotes for the dollar, or timelog values N $ N h @@ -7453,7 +7460,7 @@ command-line always take precedence over environment variable settings, however. Note that you may also permanently specify option values by placing option settings in the file @file{~/.ledgerrc} one option per line, for example: -@smallexample +@smallexample @c input:validate --pager /bin/cat @end smallexample @@ -7591,7 +7598,7 @@ These two periodic transactions give the usual monthly expenses, as well as one typical yearly expense. For help on finding out what your average monthly expenses are for any category, use a command like: -@smallexample +@smallexample @c command:validate $ ledger -p "this year" --monthly --average balance ^expenses @end smallexample @@ -7724,7 +7731,7 @@ constrain which transactions are printed. For example, the following command shows only transactions from the beginning of the current month, while still calculating the running balance based on all transactions: -@smallexample +@smallexample @c command:validate $ ledger -d "d>[this month]" register checking @end smallexample @@ -7733,7 +7740,7 @@ running total in terms of all transactions in the register. The following, simpler command is similar, but totals only the displayed postings: -@smallexample +@smallexample @c command:validate $ ledger -b "this month" register checking @end smallexample @@ -7939,7 +7946,7 @@ field. This searches only a posting's field, not the transaction's note or comment field. For example, @code{ledger reg "expr" "comment =~ /landline/"} will match: -@smallexample +@smallexample @c input:validate 2014/1/29 Phone bill Assets:Checking $50.00 Expenses:Phone $-50.00 ; landline bill @@ -7947,7 +7954,7 @@ or comment field. For example, @code{ledger reg "expr" "comment =~ but will not match: -@smallexample +@smallexample @c input:validate 2014/1/29 Phone bill ; landline bill ; landline bill Assets:Checking $50.00 @@ -7963,19 +7970,19 @@ This searches all comments in the transaction, including comments on individual postings. Thus, @samp{ledger reg "expr" "note =~ /landline/"} will match both all the three examples below: -@smallexample +@smallexample @c input:validate 2014/1/29 Phone bill Assets:Checking $50.00 Expenses:Phone $-50.00 ; landline bill @end smallexample -@smallexample +@smallexample @c input:validate 2014/1/29 Phone bill ; landline bill Assets:Checking $50.00 Expenses:Phone $-50.00 @end smallexample -@smallexample +@smallexample @c input:validate 2014/1/29 Phone bill ; landline bill Assets:Checking $50.00 @@ -9751,8 +9758,10 @@ and apply it against a model transaction. @item period @var{PERIOD_EXPRESSION} Evaluate the given period and report how Ledger interprets it: -@smallexample -$ ledger period "this year" +@smallexample @c command:51F6A2C +$ ledger period "this year" --now 2011-01-01 +@end smallexample +@smallexample @c result:51F6A2C --- Period expression tokens --- TOK_THIS: this TOK_YEAR: year @@ -9775,8 +9784,10 @@ END_REACHED: Evaluate the given arguments and report how Ledger interprets it against the following model transaction: -@smallexample +@smallexample @c command:validate $ ledger query "/Book/" +@end smallexample +@smallexample --- Input arguments --- ("/Book/") @@ -9904,7 +9915,7 @@ The test scripts take the remainder of the @code{test} line and use it as command-line arguments for ledger, the text enclosed in @code{test} and @code{end test} is expected output, for example: -@smallexample +@smallexample @c input:validate ; This is the journal data year 2014 12/24 (C0d3) Santa Claus -- cgit v1.2.3 From a48e3014baa105576d18c28fc8a83c44b11623c3 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Fri, 20 Feb 2015 13:59:51 +0100 Subject: [tests] Clean-up test/DocTests.py * Replace hard-coded strings with token variables * Use os.path.join to create file paths --- test/DocTests.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/test/DocTests.py b/test/DocTests.py index 04241188..07cb616e 100755 --- a/test/DocTests.py +++ b/test/DocTests.py @@ -19,13 +19,15 @@ class DocTests: self.verbose = args.verbose self.tests = args.examples - self.examples = dict() - self.test_files = list() - self.testin_token = 'command' - self.testout_token = 'output' - self.testdat_token = 'input' + self.examples = dict() + self.test_files = list() + self.testin_token = 'command' + self.testout_token = 'output' + self.testdat_token = 'input' self.validate_token = 'validate' - self.testwithdat_token = 'with_input' + self.validate_cmd_token = 'validate-command' + self.validate_dat_token = 'validate-data' + self.testwithdat_token = 'with_input' def read_example(self): endexample = re.compile(r'^@end\s+smallexample\s*$') @@ -35,7 +37,7 @@ class DocTests: self.current_line += 1 if len(line) <= 0 or endexample.match(line): break # Replace special texinfo character sequences with their ASCII counterpart - example += line.replace("@@","@").replace("@{","{").replace("@}","}") + example += re.sub(r'@([@{}])', r'\1', line) return example def test_id(self, example): @@ -78,9 +80,9 @@ class DocTests: if test_id == self.validate_token: test_id = "Val-" + str(test_begin_line) if test_kind == self.testin_token: - test_kind = "validate-command" + test_kind = self.validate_cmd_token elif test_kind == self.testdat_token: - test_kind = "validate-data" + test_kind = self.validate_dat_token try: self.examples[test_id] except KeyError: @@ -105,11 +107,11 @@ class DocTests: try: command = example[self.testin_token][self.testin_token] except KeyError: - if 'validate-data' in example: + if self.validate_dat_token in example: command = '$ ledger bal' - elif 'validate-command' in example: + elif self.validate_cmd_token in example: validate_command = True - command = example['validate-command']['validate-command'] + command = example[self.validate_cmd_token][self.validate_cmd_token] else: return None @@ -145,7 +147,7 @@ class DocTests: for test_id in tests: validation = False - if "validate-data" in self.examples[test_id] or "validate-command" in self.examples[test_id]: + if self.validate_dat_token in self.examples[test_id] or self.validate_cmd_token in self.examples[test_id]: validation = True example = self.examples[test_id] try: @@ -167,7 +169,7 @@ class DocTests: input = self.examples[with_input][self.testdat_token][self.testdat_token] except KeyError: try: - input = example['validate-data']['validate-data'] + input = example[self.validate_dat_token][self.validate_dat_token] except KeyError: input = None @@ -175,16 +177,16 @@ class DocTests: test_file_created = False if findex: scriptpath = os.path.dirname(os.path.realpath(__file__)) - test_input_dir = scriptpath + '/../test/input/' + test_input_dir = os.path.join(scriptpath, '..', 'test', 'input') test_file = command[findex] if not os.path.exists(test_file): if input: test_file_created = True with open(test_file, 'w') as f: f.write(input) - elif os.path.exists(test_input_dir + test_file): - command[findex] = test_input_dir + test_file error = False + elif os.path.exists(os.path.join(test_input_dir, test_file)): + command[findex] = os.path.join(test_input_dir, test_file) try: verify = subprocess.check_output(command, stderr=subprocess.STDOUT) except: -- cgit v1.2.3 From f5b8fe59565ead295dce0a42b701703e24ca8e40 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Fri, 20 Feb 2015 14:00:57 +0100 Subject: [tests] Add output when skipping incomplete tests in test/DocTests.py --- test/DocTests.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/DocTests.py b/test/DocTests.py index 07cb616e..671c4d35 100755 --- a/test/DocTests.py +++ b/test/DocTests.py @@ -173,7 +173,7 @@ class DocTests: except KeyError: input = None - if command and (output or validation): + if command and (output != None or validation): test_file_created = False if findex: scriptpath = os.path.dirname(os.path.realpath(__file__)) @@ -208,6 +208,12 @@ class DocTests: for line in unified_diff(output.split('\n'), verify.split('\n'), fromfile='generated', tofile='expected'): print(line) print + else: + if self.verbose > 0: + print test_id, ':', 'Skipped' + else: + sys.stdout.write('X') + if not self.verbose: print if len(failed) > 0: -- cgit v1.2.3 From 34f8c482414775cfb75de32b4181150642a4610d Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Fri, 20 Feb 2015 14:02:16 +0100 Subject: [tests] Improve error reporting for test/DocTests.py --- test/DocTests.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/DocTests.py b/test/DocTests.py index 671c4d35..6f0276da 100755 --- a/test/DocTests.py +++ b/test/DocTests.py @@ -184,23 +184,25 @@ class DocTests: test_file_created = True with open(test_file, 'w') as f: f.write(input) - error = False elif os.path.exists(os.path.join(test_input_dir, test_file)): command[findex] = os.path.join(test_input_dir, test_file) + try: + error = None try: verify = subprocess.check_output(command, stderr=subprocess.STDOUT) - except: - verify = str() - error = True - valid = (output == verify) or (not error and validation) + valid = (output == verify) or (not error and validation) + except subprocess.CalledProcessError, e: + error = e.output + valid = False + failed.add(test_id) if valid and test_file_created: os.remove(test_file) if self.verbose > 0: - print test_id, ':', 'Passed' if valid else 'FAILED' + print test_id, ':', 'Passed' if valid else 'FAILED: {}'.format(error) if error else 'FAILED' else: sys.stdout.write('.' if valid else 'E') - if not valid: + if not (valid or error): failed.add(test_id) if self.verbose > 1: print ' '.join(command) -- cgit v1.2.3 From c1e409e6934ba298cc71dfb7c6a0079d2038b09d Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Fri, 20 Feb 2015 14:07:57 +0100 Subject: [doc] Add support for additional input files in test/DocTests.py by allowing file: and with_file: options on examples. --- doc/ledger3.texi | 13 +++++++++++++ test/DocTests.py | 14 ++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 3caf4d14..ea4c0e89 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -88,6 +88,19 @@ @c $ 36.84 Expenses:Food:Dining @c @end smallexample @c +@c To pass additional input to ledger for certain commands, e.g. convert add +@c with_file:filename to the example command and add a file:UUID to an example +@c that holds the additional input, where UUID is the UUID of the command, +@c e.g.: +@c +@c @smallexample @c file:download.csv +@c 767718,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-8.80,,00001640.04,, +@c @end smallexample +@c +@c @smallexample @c command:94FD2B6,with_file:download.csv +@c $ ledger -f sample.dat convert download.csv +@c @end smallexample +@c @c Additionally DocTests.py will pass --args-only and --columns 80 to ledger @c to ignore any default arguments from the environment or .ledgerrc. @c diff --git a/test/DocTests.py b/test/DocTests.py index 6f0276da..f5746ec4 100755 --- a/test/DocTests.py +++ b/test/DocTests.py @@ -24,10 +24,12 @@ class DocTests: self.testin_token = 'command' self.testout_token = 'output' self.testdat_token = 'input' + self.testfile_token = 'file' self.validate_token = 'validate' self.validate_cmd_token = 'validate-command' self.validate_dat_token = 'validate-data' self.testwithdat_token = 'with_input' + self.testwithfile_token = 'with_file' def read_example(self): endexample = re.compile(r'^@end\s+smallexample\s*$') @@ -44,8 +46,8 @@ class DocTests: return hashlib.sha1(example.rstrip()).hexdigest()[0:7].upper() def find_examples(self): - startexample = re.compile(r'^@smallexample\s+@c\s+(%s|%s|%s)(?::([\dA-Fa-f]+|validate))?(?:,(.*))?' - % (self.testin_token, self.testout_token, self.testdat_token)) + startexample = re.compile(r'^@smallexample\s+@c\s+(%s|%s|%s|%s)(?::([\dA-Fa-f]+|validate))?(?:,(.*))?' + % (self.testin_token, self.testout_token, self.testdat_token, self.testfile_token)) while True: line = self.file.readline() self.current_line += 1 @@ -187,6 +189,14 @@ class DocTests: elif os.path.exists(os.path.join(test_input_dir, test_file)): command[findex] = os.path.join(test_input_dir, test_file) try: + convert_idx = command.index('convert') + convert_file = command[convert_idx+1] + convert_data = example[self.testfile_token][self.testfile_token] + if not os.path.exists(convert_file): + with open(convert_file, 'w') as f: + f.write(convert_data) + except ValueError: + pass error = None try: verify = subprocess.check_output(command, stderr=subprocess.STDOUT) -- cgit v1.2.3 From cad6bbd3865db9c023862656bd6fa3c5ee3bb1e5 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Fri, 20 Feb 2015 23:09:09 +0100 Subject: [doc] Fix skipped doc tests --- doc/ledger3.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 12956d61..936a69e0 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -4373,7 +4373,7 @@ ledger bal Allocation --current --format "\ Which yields: -@smallexample @c result:582C8C2 +@smallexample @c output:582C8C2 Allocation 100.00% $30000 Bonds/Cash 39.90% $11970 Equities 60.10% $18030 @@ -9774,7 +9774,7 @@ Evaluate the given period and report how Ledger interprets it: @smallexample @c command:51F6A2C $ ledger period "this year" --now 2011-01-01 @end smallexample -@smallexample @c result:51F6A2C +@smallexample @c output:51F6A2C --- Period expression tokens --- TOK_THIS: this TOK_YEAR: year -- cgit v1.2.3 From 6f6d4ec26cf10d8e2af45b54efaf1b05272c1c02 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Fri, 20 Feb 2015 23:09:26 +0100 Subject: [tests] Minor test/DocTests.py clean up --- test/DocTests.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/test/DocTests.py b/test/DocTests.py index f5746ec4..ac681bc2 100755 --- a/test/DocTests.py +++ b/test/DocTests.py @@ -158,22 +158,13 @@ class DocTests: failed.add(test_id) continue - try: - output = example[self.testout_token][self.testout_token] - except KeyError: - output = None - - try: - input = example[self.testdat_token][self.testdat_token] - except KeyError: - try: - with_input = example[self.testin_token]['opts'][self.testwithdat_token] - input = self.examples[with_input][self.testdat_token][self.testdat_token] - except KeyError: - try: - input = example[self.validate_dat_token][self.validate_dat_token] - except KeyError: - input = None + output = example.get(self.testout_token, {}).get(self.testout_token) + input = example.get(self.testdat_token, {}).get(self.testdat_token) + if not input: + with_input = example.get(self.testin_token, {}).get('opts', {}).get(self.testwithdat_token) + input = self.examples.get(with_input, {}).get(self.testdat_token, {}).get(self.testdat_token) + if not input: + input = example.get(self.validate_dat_token, {}).get(self.validate_dat_token) if command and (output != None or validation): test_file_created = False -- cgit v1.2.3 From 459f587012121f8b81f06c9eb807337c5178009e Mon Sep 17 00:00:00 2001 From: thdox Date: Thu, 12 Feb 2015 23:46:37 +0100 Subject: Improve documentation about --rich-data. Conflicts: doc/ledger.1 --- doc/ledger.1 | 11 ++++++++++- doc/ledger3.texi | 6 ++---- test/baseline/opt-rich-data.test | 10 ++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/doc/ledger.1 b/doc/ledger.1 index 8284dfa4..8925e6f9 100644 --- a/doc/ledger.1 +++ b/doc/ledger.1 @@ -510,6 +510,12 @@ but not .Sy Expenses:Entertainment:Dining . This is a display predicate, which means it only affects display, not the total calculations. +.It Fl \-detail +Related to +.Ic convert +command. Synonym to +.Fl \-rich-data +option. .It Fl \-deviation Report each posting's deviation from the average. It is only meaningful in the @@ -871,7 +877,10 @@ postings. .It Fl \-revalued-total Display the sum of the revalued postings as the running total, which serves to show unrealized capital in a gain/losses report. -.\".It Fl \-rich-data +.It Fl \-rich-data +When generating ledger transaction from CSV file using the +.Ic convert +command, add CSV, Imported, and UUID meta-data. .It Fl \-seed Ar INT Set the random seed to .Ar INT diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 936a69e0..56796374 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -6629,10 +6629,8 @@ to show unrealized capital in a gain/losses report. @item --rich-data @itemx --detail -@c When generating ledger transaction from csv using the convert command -@c add CSV, Imported, and UUID meta-data. -@c see test/baeline/opt-rich-data.test -@value{FIXME:UNDOCUMENTED} +When generating ledger transaction from CSV file using the +@command{convert} command, add CSV, Imported, and UUID meta-data. @item --seed @var{INT} Set the random seed to @var{INT} for the @code{generate} command. diff --git a/test/baseline/opt-rich-data.test b/test/baseline/opt-rich-data.test index fbb73ebe..265af531 100644 --- a/test/baseline/opt-rich-data.test +++ b/test/baseline/opt-rich-data.test @@ -1,3 +1,13 @@ +test -f /dev/null convert test/baseline/feat-convert-with-directives.dat --now '2014/08/01' +2012/01/01 * KFC + Expenses:Unknown $10 + Equity:Unknown + +2012/01/02 * REWE SAGT DANKE 123454321 + Expenses:Unknown 10€ + Equity:Unknown +end test + test -f /dev/null convert test/baseline/feat-convert-with-directives.dat --detail --now '2014/08/01' 2012/01/01 * KFC ; CSV: 2012/01/01,KFC,$10 -- cgit v1.2.3 From a931f0ea33a2b5d28aeecc938747db979096b58c Mon Sep 17 00:00:00 2001 From: thdox Date: Fri, 13 Feb 2015 21:57:36 +0100 Subject: Add example for --rich-data option. And add explanation for associated tags. [ci skip] Conflicts: doc/ledger3.texi --- doc/ledger3.texi | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 56796374..8b20784b 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -4638,14 +4638,43 @@ from the file above. @findex --account @var{STR} @findex --rich-data -The @command{convert} command accepts three options. They are -@option{--invert} which inverts the amount field, -@option{--account @var{STR}} which you can use to specify the account to -balance against, and @option{--rich-data} which stores -additional metadata as tags. There is, for example, -a UUID field. If an entry with the same UUID tag is already included in -the normal ledger file (specified via @option{--file @var{FILE} (-f)} or -via the environment variable @env{LEDGER_FILE}) this entry will not be +The @command{convert} command accepts three options. They are +@option{--invert} which inverts the amount field, @option{--account +@var{STR}} which you can use to specify the account to balance against, +and @option{--rich-data} which stores additional metadata as tags. + +Using following command on the two first lines of the above csv file, + +@smallexample +$ ledger convert download.csv --input-date-format "%m/%d/%Y" \ + --invert --account Assets:MyBank --rich-data +@end smallexample + +you will get the result below: + +@smallexample +2011/12/13 * Withdrawal ;ACE HARDWARE 16335 S HOUGHTON RD + ; CSV: 767718,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-8.80,,00001640.04,, + ; Imported: 2012/01/13 + ; UUID: dfdc3c3d5c54c6967dd39d5b4e4fd1ea76e87233 + Expenses:Unknown 8.8 + Assets:MyBank + +2011/12/13 * Withdrawal ;ACE HARDWARE 16335 S HOUGHTON RD + ; CSV: 767406,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-1.03,,00001648.84,, + ; Imported: 2012/01/13 + ; UUID: 63086448b1f29f7fd6efb11ea40660185a213f9d + Expenses:Unknown 1.03 + Assets:MyBank +@end smallexample + +The three added metadata are: @samp{CSV} as the original line from csv +file, @samp{Imported} as the date when the csv file was imported into +Ledger, and @samp{UUID} as a checksum of original csv line. + +If an entry with the same @samp{UUID} tag is already included in the +normal ledger file (specified via @option{--file @var{FILE} (-f)} or via +the environment variable @env{LEDGER_FILE}) this entry will not be printed again. You can also use @command{convert} with @code{payee} and @code{account} -- cgit v1.2.3 From b2487b8aadd11195a131cae4c40485c1a796b86a Mon Sep 17 00:00:00 2001 From: thdox Date: Wed, 18 Feb 2015 19:36:04 +0100 Subject: Add TODO tag Because DocTests.py not able (yet?) to handle multi-line ledger commands. --- doc/ledger3.texi | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 8b20784b..48d1449e 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -4645,6 +4645,7 @@ and @option{--rich-data} which stores additional metadata as tags. Using following command on the two first lines of the above csv file, +@c TODO: does not @c command:validate due to multiple lines @smallexample $ ledger convert download.csv --input-date-format "%m/%d/%Y" \ --invert --account Assets:MyBank --rich-data -- cgit v1.2.3 From e0f7b637cf339838334b42ab02f84ead4efa3635 Mon Sep 17 00:00:00 2001 From: thdox Date: Wed, 18 Feb 2015 23:30:32 +0100 Subject: Add UUID to rich-data test. --- doc/ledger3.texi | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 48d1449e..4c108331 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -4643,17 +4643,23 @@ The @command{convert} command accepts three options. They are @var{STR}} which you can use to specify the account to balance against, and @option{--rich-data} which stores additional metadata as tags. -Using following command on the two first lines of the above csv file, +Using the two first lines of the above csv file, -@c TODO: does not @c command:validate due to multiple lines -@smallexample +@smallexample @c input:DD85579 +767718,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-8.80,,00001640.04,, +767406,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-1.03,,00001648.84,, +@end smallexample + +and launching the below command, + +@smallexample @c command:DD85579 $ ledger convert download.csv --input-date-format "%m/%d/%Y" \ --invert --account Assets:MyBank --rich-data @end smallexample -you will get the result below: +you will get the result: -@smallexample +@smallexample @c result:DD85579 2011/12/13 * Withdrawal ;ACE HARDWARE 16335 S HOUGHTON RD ; CSV: 767718,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-8.80,,00001640.04,, ; Imported: 2012/01/13 -- cgit v1.2.3 From 557ef398e69815c99b11aba0eb96b902089bc080 Mon Sep 17 00:00:00 2001 From: thdox Date: Sat, 21 Feb 2015 19:11:36 +0100 Subject: Update to be compliant with file & with_file. --- doc/ledger3.texi | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 4c108331..81777d09 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -4645,21 +4645,23 @@ and @option{--rich-data} which stores additional metadata as tags. Using the two first lines of the above csv file, -@smallexample @c input:DD85579 +@smallexample @c file:B2EA7E8 +,date,payee,note,amount,,,code, 767718,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-8.80,,00001640.04,, 767406,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-1.03,,00001648.84,, @end smallexample and launching the below command, -@smallexample @c command:DD85579 +@smallexample @c command:B2EA7E8,with_file:download.csv $ ledger convert download.csv --input-date-format "%m/%d/%Y" \ - --invert --account Assets:MyBank --rich-data + --invert --account Assets:MyBank --rich-data \ + --file sample.dat --now=2012/01/13 \ @end smallexample you will get the result: -@smallexample @c result:DD85579 +@smallexample @c output:B2EA7E8 2011/12/13 * Withdrawal ;ACE HARDWARE 16335 S HOUGHTON RD ; CSV: 767718,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-8.80,,00001640.04,, ; Imported: 2012/01/13 -- cgit v1.2.3 From 78bf3698982bec208bd17fbf0c61b25133acfb1c Mon Sep 17 00:00:00 2001 From: thdox Date: Sat, 21 Feb 2015 21:05:31 +0100 Subject: Small typo. --- doc/ledger3.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 81777d09..5e1faf7e 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -4656,7 +4656,7 @@ and launching the below command, @smallexample @c command:B2EA7E8,with_file:download.csv $ ledger convert download.csv --input-date-format "%m/%d/%Y" \ --invert --account Assets:MyBank --rich-data \ - --file sample.dat --now=2012/01/13 \ + --file sample.dat --now=2012/01/13 @end smallexample you will get the result: -- cgit v1.2.3 From 2778a24356d7a374a2d7db821b8907e4026acdc2 Mon Sep 17 00:00:00 2001 From: thdox Date: Sat, 21 Feb 2015 21:25:12 +0100 Subject: Small typo. --- doc/ledger3.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 5e1faf7e..a4e055d0 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -6668,7 +6668,7 @@ to show unrealized capital in a gain/losses report. @item --rich-data @itemx --detail When generating ledger transaction from CSV file using the -@command{convert} command, add CSV, Imported, and UUID meta-data. +@command{convert} command, add CSV, Imported, and UUID metadata. @item --seed @var{INT} Set the random seed to @var{INT} for the @code{generate} command. -- cgit v1.2.3 From 80e432a7b269f247e87884f42e49f4d72ca35fe1 Mon Sep 17 00:00:00 2001 From: thdox Date: Sun, 22 Feb 2015 16:07:54 +0100 Subject: Fix sorting for option --auto-match. See http://en.cppreference.com/w/cpp/algorithm/max_element and http://www.cplusplus.com/reference/algorithm/max_element/ The sorting for max requires < (and not >). --- src/lookup.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lookup.cc b/src/lookup.cc index 6dbeb502..3b6707e5 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -54,7 +54,7 @@ namespace { struct usage_sorter { bool operator()(const account_use_pair& left, const account_use_pair& right) const { - return left.second > right.second; + return left.second < right.second; } }; } -- cgit v1.2.3 From 788ffc2a4bfdb95782163eeb463ff9c05947a311 Mon Sep 17 00:00:00 2001 From: thdox Date: Sun, 22 Feb 2015 16:51:57 +0100 Subject: Update test for --auto-match option. --- test/baseline/opt-auto-match.test | 47 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/test/baseline/opt-auto-match.test b/test/baseline/opt-auto-match.test index 7c3fb40a..54a1053b 100644 --- a/test/baseline/opt-auto-match.test +++ b/test/baseline/opt-auto-match.test @@ -14,17 +14,58 @@ Expenses:Food 20.00 EUR Liabilities:CC -20.00 EUR +test --input-date-format "%Y-%m-%d" convert test/baseline/opt-auto-match.dat +2012/03/01 * Food + Expenses:Unknown 10 + Equity:Unknown + +2012/03/02 * Phone + Expenses:Unknown 10 + Equity:Unknown + +2012/03/02 * Dining + Expenses:Unknown 10 + Equity:Unknown +end test + test --input-date-format "%Y-%m-%d" --auto-match convert test/baseline/opt-auto-match.dat 2012/03/01 * Food - Assets:Cash 10 + Expenses:Food 10 Equity:Unknown 2012/03/02 * Phone - Assets:Cash 10 + Expenses:Phone 10 Equity:Unknown 2012/03/02 * Dining - Liabilities:CC 10 + Expenses:Food 10 Equity:Unknown end test +test --input-date-format "%Y-%m-%d" --account Assets:Bank convert test/baseline/opt-auto-match.dat +2012/03/01 * Food + Expenses:Unknown 10 + Assets:Bank + +2012/03/02 * Phone + Expenses:Unknown 10 + Assets:Bank + +2012/03/02 * Dining + Expenses:Unknown 10 + Assets:Bank +end test + +test --input-date-format "%Y-%m-%d" --auto-match --account Assets:Bank convert test/baseline/opt-auto-match.dat +2012/03/01 * Food + Expenses:Food 10 + Assets:Bank + +2012/03/02 * Phone + Expenses:Phone 10 + Assets:Bank + +2012/03/02 * Dining + Expenses:Food 10 + Assets:Bank +end test -- cgit v1.2.3 From 49166d09b76adffdf94a21c2c2ea07fc83ea0e32 Mon Sep 17 00:00:00 2001 From: thdox Date: Sun, 22 Feb 2015 16:58:22 +0100 Subject: Fix UUID of --rich-data test. --- doc/ledger3.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index a4e055d0..4095babb 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -4645,7 +4645,7 @@ and @option{--rich-data} which stores additional metadata as tags. Using the two first lines of the above csv file, -@smallexample @c file:B2EA7E8 +@smallexample @c file:01B0350 ,date,payee,note,amount,,,code, 767718,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-8.80,,00001640.04,, 767406,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-1.03,,00001648.84,, @@ -4653,7 +4653,7 @@ Using the two first lines of the above csv file, and launching the below command, -@smallexample @c command:B2EA7E8,with_file:download.csv +@smallexample @c command:01B0350,with_file:download.csv $ ledger convert download.csv --input-date-format "%m/%d/%Y" \ --invert --account Assets:MyBank --rich-data \ --file sample.dat --now=2012/01/13 @@ -4661,7 +4661,7 @@ $ ledger convert download.csv --input-date-format "%m/%d/%Y" \ you will get the result: -@smallexample @c output:B2EA7E8 +@smallexample @c output:01B0350 2011/12/13 * Withdrawal ;ACE HARDWARE 16335 S HOUGHTON RD ; CSV: 767718,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-8.80,,00001640.04,, ; Imported: 2012/01/13 -- cgit v1.2.3 From af065bbcbe9e88b370a98806d36fe1a4531015c5 Mon Sep 17 00:00:00 2001 From: thdox Date: Sun, 22 Feb 2015 18:19:13 +0100 Subject: Minor documentation fixes. --- doc/ledger3.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index a4e055d0..8a2455af 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -2859,7 +2859,7 @@ default is uncleared. To mark a transaction cleared, put an asterisk @end smallexample @noindent -To mark it pending, use a !: +To mark it pending, use a @samp{!}: @smallexample @c input:validate 2012-03-10 ! KFC @@ -3503,7 +3503,7 @@ sensitive to this difference. If you buy a stock last year, and ask for its value today, Ledger will consult its price database to see what the most recent price for that stock is. You can short-circuit this lookup by ``fixing'' the price -at the time of a transaction. This is done using @{=AMOUNT@}: +at the time of a transaction. This is done using @samp{@{=AMOUNT@}}: @smallexample 2012-04-10 My Broker -- cgit v1.2.3 From 3c9463214c160ddeefb0e8998cf62e4142723dd1 Mon Sep 17 00:00:00 2001 From: thdox Date: Sun, 22 Feb 2015 18:19:35 +0100 Subject: Improve documentation of --base option. --- doc/ledger3.texi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 8a2455af..d7227ed1 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -1155,6 +1155,8 @@ $ ledger --no-total balance Billable Project -50.0m Project:XYZ @end smallexample +@findex C + This example works because ledger already knows how to handle seconds, minutes and hours, as part of its time tracking support. Defining other equivalences is simple. The following is an example that @@ -6143,7 +6145,8 @@ Strings}). The default is: @item --base Reduce convertible commodities down the bottom of the conversion, e.g. -display time in seconds. This also applies to custom commodity conversions. +display time in seconds. This also applies to custom commodity +conversions (@pxref{Commodity equivalences}). @item --basis @itemx -B -- cgit v1.2.3 From 73e3ecc6b865ecff63ccda307d4dbf70ec55a9c4 Mon Sep 17 00:00:00 2001 From: thdox Date: Mon, 23 Feb 2015 23:31:21 +0100 Subject: Fix alignment of cleared-format with 4 spaces as separator. --- doc/ledger3.texi | 4 ++-- src/report.h | 2 +- test/baseline/cmd-cleared.test | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 4a3d51e0..a2083e38 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -651,7 +651,7 @@ $ ledger -f drewr3.dat cleared $ -20.00 0 MasterCard $ 200.00 0 Mortgage:Principal $ -243.60 0 Tithe ----------------- ---------------- --------- +---------------- ---------------- --------- $ -243.60 0 @end smallexample @@ -7172,7 +7172,7 @@ Define the format for the cleared report. The default is: %-(ansify_if(partial_account(options.flat), blue if color))\n%/ %$1 %$2 %$3\n%/ %(prepend_width ? \" \" * int(prepend_width) : \"\") - ---------------- ---------------- ---------\n" + ---------------- ---------------- ---------\n" @end smallexample @item --register-format @var{FORMAT_STRING} diff --git a/src/report.h b/src/report.h index 67e95884..c54c8444 100644 --- a/src/report.h +++ b/src/report.h @@ -496,7 +496,7 @@ public: "%-(ansify_if(partial_account(options.flat), blue if color))\n%/" "%$1 %$2 %$3\n%/" "%(prepend_width ? \" \" * int(prepend_width) : \"\")" - "---------------- ---------------- ---------\n"); + "---------------- ---------------- ---------\n"); }); OPTION(report_t, color); diff --git a/test/baseline/cmd-cleared.test b/test/baseline/cmd-cleared.test index 501d207f..91219a40 100644 --- a/test/baseline/cmd-cleared.test +++ b/test/baseline/cmd-cleared.test @@ -30,7 +30,7 @@ test cleared -20 0 F -30 -30 12-Feb-26 G -40 0 H ----------------- ---------------- --------- +---------------- ---------------- --------- 0 0 end test -- cgit v1.2.3 From 69e692dbc54ab6e72d1baad6dcecca55ac2d6077 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Mon, 23 Feb 2015 15:53:20 -0700 Subject: Fix indentation and position of Fedora test. The blame for this section was a bit of a cluster, but, as someone who's not using Fedora, this makes the most logical sense. (Fedora is a version of RH, right?) --- acprep | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/acprep b/acprep index 1165c2b9..275f2c84 100755 --- a/acprep +++ b/acprep @@ -644,10 +644,6 @@ class PrepareBuild(CommandLineApp): ] self.log.info('Executing: ' + ' '.join(packages)) self.execute(*packages) - elif system.startswith('CYGWIN'): - self.log.info('Looks like you are using Cygwin') - self.log.info('Please install the dependencies manually.') - elif release.startswith('Fedora release 20'): self.log.info('Looks like you are using YUM on Fedora 20') packages = [ @@ -673,6 +669,10 @@ class PrepareBuild(CommandLineApp): self.log.info('Executing: ' + ' '.join(packages)) self.execute(*packages) + elif system.startswith('CYGWIN'): + self.log.info('Looks like you are using Cygwin') + self.log.info('Please install the dependencies manually.') + ######################################################################### # Determine the system's basic configuration # ######################################################################### -- cgit v1.2.3 From ddf17b62460f17e0cca3b01a40e838544d683f91 Mon Sep 17 00:00:00 2001 From: thdox Date: Tue, 24 Feb 2015 10:46:18 +0100 Subject: Add baseline test for --init-file option. --- test/CheckBaselineTests.py | 1 - test/baseline/opt-init-file.dat | 1 + test/baseline/opt-init-file.test | 10 ++++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test/baseline/opt-init-file.dat create mode 100644 test/baseline/opt-init-file.test diff --git a/test/CheckBaselineTests.py b/test/CheckBaselineTests.py index 3c3e590b..dd6f4702 100755 --- a/test/CheckBaselineTests.py +++ b/test/CheckBaselineTests.py @@ -33,7 +33,6 @@ class CheckBaselineTests (CheckOptions): 'help-comm', 'help-disp', 'import', - 'init-file', 'no-color', 'options', 'price-db', diff --git a/test/baseline/opt-init-file.dat b/test/baseline/opt-init-file.dat new file mode 100644 index 00000000..92c5307a --- /dev/null +++ b/test/baseline/opt-init-file.dat @@ -0,0 +1 @@ +--decimal-comma diff --git a/test/baseline/opt-init-file.test b/test/baseline/opt-init-file.test new file mode 100644 index 00000000..128814e1 --- /dev/null +++ b/test/baseline/opt-init-file.test @@ -0,0 +1,10 @@ +2012-03-17 Quick + Expenses:Food 12,50 € + Assets:Cash + +test --init-file test/baseline/opt-init-file.dat bal + -12,50 € Assets:Cash + 12,50 € Expenses:Food +-------------------- + 0 +end test -- cgit v1.2.3 From fce467fba9ebce81c0235916ff4848f50f1f1f21 Mon Sep 17 00:00:00 2001 From: thdox Date: Tue, 24 Feb 2015 10:49:16 +0100 Subject: Remove --cache from untested options in CheckBaselinetests.py As per commit d5e1308d07e9a7d9da33aed6f7f617b2209cba40 --- test/CheckBaselineTests.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/CheckBaselineTests.py b/test/CheckBaselineTests.py index dd6f4702..e44c576d 100755 --- a/test/CheckBaselineTests.py +++ b/test/CheckBaselineTests.py @@ -21,7 +21,6 @@ class CheckBaselineTests (CheckOptions): self.untested_options = [ 'anon', 'args-only', - 'cache', 'debug', 'download', 'file', -- cgit v1.2.3 From 83bde60ec1c8bb7efcb9145ee8ebb4b3bceb3789 Mon Sep 17 00:00:00 2001 From: thdox Date: Tue, 24 Feb 2015 10:52:56 +0100 Subject: Remove --*help* from untested options in CheckBaselineTests.py As per commit f59abd4c765b08cbd5f18ec851b1d78a766a1c93 --- test/CheckBaselineTests.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/CheckBaselineTests.py b/test/CheckBaselineTests.py index e44c576d..e3c8f385 100755 --- a/test/CheckBaselineTests.py +++ b/test/CheckBaselineTests.py @@ -26,11 +26,7 @@ class CheckBaselineTests (CheckOptions): 'file', 'force-color', 'force-pager', - 'full-help', 'help', - 'help-calc', - 'help-comm', - 'help-disp', 'import', 'no-color', 'options', -- cgit v1.2.3 From 72cb48727d979c8a20298ccdb9c711b0ce7a8a03 Mon Sep 17 00:00:00 2001 From: thdox Date: Tue, 24 Feb 2015 10:54:57 +0100 Subject: Add --no-pager to untested options of CheckBaselineTests.py As per comment in Pull Request #382 --- test/CheckBaselineTests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/CheckBaselineTests.py b/test/CheckBaselineTests.py index e3c8f385..1bef0aa0 100755 --- a/test/CheckBaselineTests.py +++ b/test/CheckBaselineTests.py @@ -29,6 +29,7 @@ class CheckBaselineTests (CheckOptions): 'help', 'import', 'no-color', + 'no-pager' 'options', 'price-db', 'price-exp', -- cgit v1.2.3 From e6a967b860d529137df11b2a79b2153c68e48b96 Mon Sep 17 00:00:00 2001 From: thdox Date: Tue, 24 Feb 2015 18:47:40 +0100 Subject: Add baseline test for --script option. --- test/CheckBaselineTests.py | 1 - test/baseline/opt-script.dat | 3 +++ test/baseline/opt-script.test | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/baseline/opt-script.dat create mode 100644 test/baseline/opt-script.test diff --git a/test/CheckBaselineTests.py b/test/CheckBaselineTests.py index 1bef0aa0..563f8aa5 100755 --- a/test/CheckBaselineTests.py +++ b/test/CheckBaselineTests.py @@ -34,7 +34,6 @@ class CheckBaselineTests (CheckOptions): 'price-db', 'price-exp', 'revalued-total', - 'script', 'seed', 'trace', 'verbose', diff --git a/test/baseline/opt-script.dat b/test/baseline/opt-script.dat new file mode 100644 index 00000000..ac6085d5 --- /dev/null +++ b/test/baseline/opt-script.dat @@ -0,0 +1,3 @@ +--no-pager --columns=80 bal +--no-pager --columns=80 reg +--no-pager --columns=80 print diff --git a/test/baseline/opt-script.test b/test/baseline/opt-script.test new file mode 100644 index 00000000..041c15ee --- /dev/null +++ b/test/baseline/opt-script.test @@ -0,0 +1,15 @@ +2012-03-17 KFC + Expenses:Food 20 CAD + Assets:Cash + +test --script test/baseline/opt-script.dat + -20 CAD Assets:Cash + 20 CAD Expenses:Food +-------------------- + 0 +12-Mar-17 KFC Expenses:Food 20 CAD 20 CAD + Assets:Cash -20 CAD 0 +2012/03/17 KFC + Expenses:Food 20 CAD + Assets:Cash +end test -- cgit v1.2.3 From df944929f82b473bbd155eac826420f0b38644eb Mon Sep 17 00:00:00 2001 From: thdox Date: Tue, 24 Feb 2015 10:42:37 +0100 Subject: Add baseline test for --price-db option. --- test/CheckBaselineTests.py | 1 - test/baseline/opt-price-db.dat | 2 ++ test/baseline/opt-price-db.test | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/baseline/opt-price-db.dat create mode 100644 test/baseline/opt-price-db.test diff --git a/test/CheckBaselineTests.py b/test/CheckBaselineTests.py index 563f8aa5..8c51ddef 100755 --- a/test/CheckBaselineTests.py +++ b/test/CheckBaselineTests.py @@ -31,7 +31,6 @@ class CheckBaselineTests (CheckOptions): 'no-color', 'no-pager' 'options', - 'price-db', 'price-exp', 'revalued-total', 'seed', diff --git a/test/baseline/opt-price-db.dat b/test/baseline/opt-price-db.dat new file mode 100644 index 00000000..abc51a0a --- /dev/null +++ b/test/baseline/opt-price-db.dat @@ -0,0 +1,2 @@ +P 2012-03-16 06:47:12 CAD $2.50 +P 2012-03-17 06:47:12 CAD $3.50 diff --git a/test/baseline/opt-price-db.test b/test/baseline/opt-price-db.test new file mode 100644 index 00000000..06021e4a --- /dev/null +++ b/test/baseline/opt-price-db.test @@ -0,0 +1,8 @@ +2012-03-17 KFC + Expenses:Food 20 CAD + Assets:Cash + +test pricedb --price-db test/baseline/opt-price-db.dat +P 2012/03/16 06:47:12 CAD $2.5 +P 2012/03/17 06:47:12 CAD $3.5 +end test -- cgit v1.2.3 From 5cb3ca04a77c4da8785e4349c8c988fabab7f460 Mon Sep 17 00:00:00 2001 From: thdox Date: Tue, 24 Feb 2015 12:11:35 +0100 Subject: Improve documentation about --version and -v. --- doc/ledger3.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index a2083e38..d1ee8f7f 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -5517,7 +5517,6 @@ Generate transactions based on previous postings. Print summary of all options. @item --version -@itemx -v Print version information and exit. @item --file @var{FILE} @@ -5917,7 +5916,7 @@ produce memory trace information. @value{FIXME:UNDOCUMENTED} @item --version -@value{FIXME:UNDOCUMENTED} +Print version information and exit. @end ftable @@ -9764,6 +9763,7 @@ Enable tracing. The @var{INT} specifies the level of trace desired: @ @item --verbose +@itemx -v Print detailed information on the execution of Ledger. @item --verify -- cgit v1.2.3 From fd8386eb236b0092ff30c3c38b4e0d24c6fccc60 Mon Sep 17 00:00:00 2001 From: thdox Date: Tue, 24 Feb 2015 12:31:40 +0100 Subject: Minor documentation consistency fixes about --leeway option. --- doc/ledger3.texi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index d1ee8f7f..f541743b 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -5790,6 +5790,7 @@ Group postings together, similar to the balance report. Use @file{FILE} for retrieving stored commodity prices. @item --price-exp @var{INT} +@itemx --leeway @var{INT} @itemx -Z @var{INT} Set expected freshness of prices in @var{INT} minutes. @@ -6027,8 +6028,8 @@ Quiet balance assertions. Specify the location of the price entry data file. @item --price-exp @var{INT} -@itemx -Z @var{INT} @itemx --leeway @var{INT} +@itemx -Z @var{INT} Set the expected freshness of price quotes, in @var{INT} minutes. That is, if the last known quote for any commodity is older than this value, and if @option{--download} is being used, then the Internet will be @@ -7288,6 +7289,7 @@ The format of the file can be changed by telling ledger to use the @option{--pricedb-format @var{FORMAT_STRING}} you define. @item --price-exp @var{INT} +@itemx --leeway @var{INT} @itemx -Z @var{INT} Set the expected freshness of price quotes, in @var{INT} minutes. That is, if the last known quote for any commodity is older than this value, -- cgit v1.2.3 From 87d938f9c3c3b25f03f07251a649f003e48602d0 Mon Sep 17 00:00:00 2001 From: thdox Date: Sun, 22 Feb 2015 16:52:21 +0100 Subject: Improve documentation for --auto-match option. --- doc/ledger.1 | 7 ++++--- doc/ledger3.texi | 22 +++++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/doc/ledger.1 b/doc/ledger.1 index 8925e6f9..b5b61b27 100644 --- a/doc/ledger.1 +++ b/doc/ledger.1 @@ -368,8 +368,9 @@ Ignore init files and environment variables for the .Nm run. .It Fl \-auto-match -Automatically match accounts from ledger journal for transactions -during csv convert. +When generating a ledger transaction from a CSV file using the +.Ic convert +command, automatically match an account from the Ledger journal. .It Fl \-aux-date Show auxiliary dates for all calculations. Alias for @@ -878,7 +879,7 @@ postings. Display the sum of the revalued postings as the running total, which serves to show unrealized capital in a gain/losses report. .It Fl \-rich-data -When generating ledger transaction from CSV file using the +When generating a ledger transaction from a CSV file using the .Ic convert command, add CSV, Imported, and UUID meta-data. .It Fl \-seed Ar INT diff --git a/doc/ledger3.texi b/doc/ledger3.texi index a4e055d0..e2502cbe 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -4635,13 +4635,16 @@ Ledger will include @samp{; transid: 767718} in the first transaction from the file above. @findex --invert +@findex --auto-match @findex --account @var{STR} @findex --rich-data -The @command{convert} command accepts three options. They are -@option{--invert} which inverts the amount field, @option{--account -@var{STR}} which you can use to specify the account to balance against, -and @option{--rich-data} which stores additional metadata as tags. +The @command{convert} command accepts four options. They are +@option{--invert} which inverts the amount field, @option{--auto-match} +which automatically matches an account from the Ledger journal for every +CSV line, @option{--account @var{STR}} which you can use to specify the +account to balance against, and @option{--rich-data} which stores +additional tag/value pairs. Using the two first lines of the above csv file, @@ -4686,6 +4689,10 @@ normal ledger file (specified via @option{--file @var{FILE} (-f)} or via the environment variable @env{LEDGER_FILE}) this entry will not be printed again. +In the output above, the account is @samp{Expenses:Unknown} for CSV +lines. You can use the @option{--auto-match} option to automatically +match an account from your Ledger journal. + You can also use @command{convert} with @code{payee} and @code{account} directives. First, you can use the @code{payee} and @code{alias} directive to rewrite the @code{payee} field based on some rules. Then @@ -6117,8 +6124,9 @@ Set the width in characters of the amount column in the Anonymize registry output, mostly for sending in bug reports. @item --auto-match -Automatically match accounts from ledger journal for transactions -during csv convert. +When generating a ledger transaction from a CSV file using the +@command{convert} command, automatically match an account from the +Ledger journal. @item --aux-date @itemx --effective @@ -6667,7 +6675,7 @@ to show unrealized capital in a gain/losses report. @item --rich-data @itemx --detail -When generating ledger transaction from CSV file using the +When generating a ledger transaction from a CSV file using the @command{convert} command, add CSV, Imported, and UUID metadata. @item --seed @var{INT} -- cgit v1.2.3 From 71e77570b717563244673d4aa525a3b049762983 Mon Sep 17 00:00:00 2001 From: thdox Date: Tue, 24 Feb 2015 16:12:49 +0100 Subject: ledger --help actually prints the man page. --- doc/ledger.1 | 6 +----- doc/ledger3.texi | 16 ++++++++-------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/doc/ledger.1 b/doc/ledger.1 index 8925e6f9..237f05da 100644 --- a/doc/ledger.1 +++ b/doc/ledger.1 @@ -639,11 +639,7 @@ entries. Opposite of Alias for .Fl \-first .It Fl \-help -Print a summary of all the options, and what they are used for. This -can be a handy way to remember which options do what. This help screen -is also printed if -.Nm -is run without a command. +Print this man page. .It Fl \-immediate Evaluate calculations immediately rather than lazily. .It Fl \-import Ar FILE diff --git a/doc/ledger3.texi b/doc/ledger3.texi index f541743b..d134991d 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -403,10 +403,11 @@ install` to install. If these intructions do not work for you can check the @section Getting help @findex help -Ledger has a complete online help system based on GNU Info. This -manual can be searched directly from the command-line using the -following options: @code{ledger --help} brings up this entire manual in -your TTY. +Ledger has a complete online help system based on GNU Info. This manual +can be searched directly from the command-line using @code{info ledger}, +which will bring up this entire manual in your TTY. Alternatively, the +shorter man page can be accessed from the command-line either via +@code{man ledger} or @code{ledger --help} If you need help on how to use Ledger, or run into problems, you can join the Ledger mailing list at @@ -5514,7 +5515,7 @@ Generate transactions based on previous postings. @item --help @itemx -h -Print summary of all options. +Display the man page for @file{ledger}. @item --version Print version information and exit. @@ -5857,7 +5858,7 @@ database. @item --help @itemx -h -Display the man page for ledger. +Display the man page for @file{ledger}. @item --init-file @var{FILE} Specify the location of the init file. The default is @file{~/.ledgerrc}. @@ -6779,8 +6780,7 @@ variables}), instead of using actual command-line options: @item --help @itemx -h -Print a summary of all the options, and what they are used for. This -can be a handy way to remember which options do what. +Display the man page for @file{ledger}. @item --version Print the current version of ledger and exits. This is useful for -- cgit v1.2.3