Merge commit 'af0da737fc4ef8f9ccebd3d43519610b8a8fcaa1' into next

Conflicts:
	lisp/ledger-reconcile.el
This commit is contained in:
Craig Earls 2015-02-25 22:01:33 -07:00
commit 1f803d6294
65 changed files with 1344 additions and 2235 deletions

View file

@ -1,30 +1,36 @@
((nil . ((tab-width . 2) ;;; Directory Local Variables
(sentence-end-double-space . t) ;;; For more information see (info "(emacs) Directory Variables")
(bug-reference-url-format
. "http://bugs.ledger-cli.org/show_bug.cgi?id=%s"))) ((nil
(c-mode . ((c-file-style . "ledger") (tab-width . 2)
(c-style-alist (sentence-end-double-space . t)
("ledger" (bug-reference-url-format . "http://bugs.ledger-cli.org/show_bug.cgi?id=%s"))
(indent-tabs-mode) (c-mode
(c-basic-offset . 2) (c-file-style . "ledger")
(c-comment-only-line-offset 0 . 0) (c-style-alist
(c-hanging-braces-alist ("ledger"
(substatement-open before after) (indent-tabs-mode)
(arglist-cont-nonempty)) (c-basic-offset . 2)
(c-offsets-alist (c-comment-only-line-offset 0 . 0)
(statement-block-intro . +) (c-hanging-braces-alist
(knr-argdecl-intro . 5) (substatement-open before after)
(substatement-open . 0) (arglist-cont-nonempty))
(substatement-label . 0) (c-offsets-alist
(label . 0) (statement-block-intro . +)
(case-label . 0) (knr-argdecl-intro . 5)
(statement-case-open . 0) (substatement-open . 0)
(statement-cont . +) (substatement-label . 0)
(arglist-intro . +) (label . 0)
(arglist-close . +) (case-label . 0)
(inline-open . 0) (statement-case-open . 0)
(brace-list-open . 0) (statement-cont . +)
(topmost-intro-cont first c-lineup-topmost-intro-cont (arglist-intro . +)
c-lineup-gnu-DEFUN-intro-cont)) (arglist-close . +)
(c-special-indent-hook . c-gnu-impose-minimum) (inline-open . 0)
(c-block-comment-prefix . "")))))) (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)))

3
.gitignore vendored
View file

@ -43,17 +43,20 @@ doc/*.html
doc/*.info doc/*.info
doc/*.info-* doc/*.info-*
doc/*.ky doc/*.ky
doc/*.kys
doc/*.log doc/*.log
doc/*.pdf doc/*.pdf
doc/*.pg doc/*.pg
doc/*.toc doc/*.toc
doc/*.tp doc/*.tp
doc/*.vr doc/*.vr
doc/*.vrs
doc/.dirstamp doc/.dirstamp
doc/html/ doc/html/
doc/latex/ doc/latex/
doc/refman.pdf doc/refman.pdf
doc/report/ doc/report/
doc/version.texi
elisp-comp elisp-comp
install-sh install-sh
intl/ intl/

29
acprep
View file

@ -616,8 +616,8 @@ class PrepareBuild(CommandLineApp):
self.execute(*packages) self.execute(*packages)
if exists('/etc/redhat-release'): if exists('/etc/redhat-release'):
release = open('/etc/redhat-release') release = open('/etc/redhat-release').readline()
if release.readline().startswith('CentOS'): if release.startswith('CentOS'):
self.log.info('Looks like you are using YUM on CentOS') self.log.info('Looks like you are using YUM on CentOS')
packages = [ packages = [
'sudo', 'yum', 'install', 'sudo', 'yum', 'install',
@ -644,6 +644,31 @@ class PrepareBuild(CommandLineApp):
] ]
self.log.info('Executing: ' + ' '.join(packages)) self.log.info('Executing: ' + ' '.join(packages))
self.execute(*packages) self.execute(*packages)
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)
elif system.startswith('CYGWIN'): elif system.startswith('CYGWIN'):
self.log.info('Looks like you are using Cygwin') self.log.info('Looks like you are using Cygwin')
self.log.info('Please install the dependencies manually.') self.log.info('Please install the dependencies manually.')

View file

@ -1,5 +1,5 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Ledger ;; Ledger
;; Maybe later add this to the expense repo once it settles ;; Maybe later add this to the expense repo once it settles
(add-to-list 'load-path "/home/adamsrl/.emacs.d/addons/ledger") (add-to-list 'load-path "/home/adamsrl/.emacs.d/addons/ledger")
@ -104,19 +104,19 @@
(defun ledger-expense-shortcut () (defun ledger-expense-shortcut ()
"Updates the ER and Project metadata with the current values of the shortcut variables." "Updates the ER and Project metadata with the current values of the shortcut variables."
(interactive) (interactive)
(when (eq major-mode 'ledger-mode) (when (eq major-mode 'ledger-mode)
(if (or (eql *ledger-expense-shortcut-ER* "") (if (or (eql *ledger-expense-shortcut-ER* "")
(eql *ledger-expense-shortcut-Proj* "")) (eql *ledger-expense-shortcut-Proj* ""))
(message "Run ledger-expense-shortcut-setup first.") (message "Run ledger-expense-shortcut-setup first.")
(save-excursion (save-excursion
(search-forward "; ER:") (search-forward "; ER:")
(kill-line nil) (kill-line nil)
(insert " " *ledger-expense-shortcut-ER*)) (insert " " *ledger-expense-shortcut-ER*))
(save-excursion (save-excursion
(search-forward "; PROJECT:") (search-forward "; PROJECT:")
(kill-line nil) (kill-line nil)
(insert " " *ledger-expense-shortcut-Proj*))))) (insert " " *ledger-expense-shortcut-Proj*)))))
(defun ledger-expense-split () (defun ledger-expense-split ()
"Splits the current transaction between internal and projects." "Splits the current transaction between internal and projects."
@ -158,33 +158,33 @@
(defun ledger-expense-personal () (defun ledger-expense-personal ()
"Makes the expense an personal one, eliminating metadata and receipts." "Makes the expense an personal one, eliminating metadata and receipts."
(interactive) (interactive)
(when (eq major-mode 'ledger-mode) ; I made this local now, should only trigger in ldg-mode (when (eq major-mode 'ledger-mode) ; I made this local now, should only trigger in ldg-mode
(save-excursion (save-excursion
(end-of-line) (end-of-line)
(re-search-backward "^[0-9]\\{4\\}/") (re-search-backward "^[0-9]\\{4\\}/")
(let ((begin (point)) (let ((begin (point))
(end (save-excursion (re-search-forward "^$")))) (end (save-excursion (re-search-forward "^$"))))
(when (re-search-forward "^ Dest:Projects" end t) (when (re-search-forward "^ Dest:Projects" end t)
(replace-match " Other:Personal")) (replace-match " Other:Personal"))
(goto-char begin) (goto-char begin)
(save-excursion (save-excursion
(when (re-search-forward "^ +; ER:" end t) (when (re-search-forward "^ +; ER:" end t)
(beginning-of-line) (beginning-of-line)
(kill-line 1))) (kill-line 1)))
(save-excursion (save-excursion
(when (re-search-forward "^ +; PROJECT:" end t) (when (re-search-forward "^ +; PROJECT:" end t)
(beginning-of-line) (beginning-of-line)
(kill-line 1))) (kill-line 1)))
(save-excursion (save-excursion
(when (re-search-forward "^ +; CATEGORY:" end t) (when (re-search-forward "^ +; CATEGORY:" end t)
(beginning-of-line) (beginning-of-line)
(kill-line 1))) (kill-line 1)))
(save-excursion (save-excursion
(when (re-search-forward "^ +; RECEIPT:" end t) (when (re-search-forward "^ +; RECEIPT:" end t)
(beginning-of-line) (beginning-of-line)
(kill-line 1))) (kill-line 1)))
(ledger-toggle-current-entry))))) (ledger-toggle-current-entry)))))
(defun ledger-expense-show-receipt () (defun ledger-expense-show-receipt ()
"Uses the Receipt buffer to show the receipt of the txn we're on." "Uses the Receipt buffer to show the receipt of the txn we're on."

View file

@ -202,13 +202,13 @@
(defun ledger-receipt-skip () (defun ledger-receipt-skip ()
"Move the current image to the Skip directory because its not relevant." "Move the current image to the Skip directory because its not relevant."
(rename-file (concat ledger-matching-sourcedir "/" (rename-file (concat ledger-matching-sourcedir "/"
ledger-matching-image-name) ledger-matching-image-name)
(concat ledger-matching-sourcedir "/Skip/" (concat ledger-matching-sourcedir "/Skip/"
ledger-matching-image-name)) ledger-matching-image-name))
;; Update the receipt screen at the same offset ;; Update the receipt screen at the same offset
(ledger-matching-update-current-image)) (ledger-matching-update-current-image))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Items below are speed entry macros, and should eventually migrate to their own file. ;; Items below are speed entry macros, and should eventually migrate to their own file.
@ -242,19 +242,19 @@
(defun ledger-expense-shortcut () (defun ledger-expense-shortcut ()
"Updates the ER and Project metadata with the current values of the shortcut variables." "Updates the ER and Project metadata with the current values of the shortcut variables."
(interactive) (interactive)
(when (eq major-mode 'ledger-mode) (when (eq major-mode 'ledger-mode)
(if (or (eql *ledger-expense-shortcut-ER* "") (if (or (eql *ledger-expense-shortcut-ER* "")
(eql *ledger-expense-shortcut-Proj* "")) (eql *ledger-expense-shortcut-Proj* ""))
(message "Run ledger-expense-shortcut-setup first.") (message "Run ledger-expense-shortcut-setup first.")
(save-excursion (save-excursion
(search-forward "; ER:") (search-forward "; ER:")
(kill-line nil) (kill-line nil)
(insert " " *ledger-expense-shortcut-ER*)) (insert " " *ledger-expense-shortcut-ER*))
(save-excursion (save-excursion
(search-forward "; PROJECT:") (search-forward "; PROJECT:")
(kill-line nil) (kill-line nil)
(insert " " *ledger-expense-shortcut-Proj*))))) (insert " " *ledger-expense-shortcut-Proj*)))))
(defun ledger-expense-split () (defun ledger-expense-split ()
"Splits the current transaction between internal and projects." "Splits the current transaction between internal and projects."
@ -296,33 +296,33 @@
(defun ledger-expense-personal () (defun ledger-expense-personal ()
"Makes the expense an personal one, eliminating metadata and receipts." "Makes the expense an personal one, eliminating metadata and receipts."
(interactive) (interactive)
(when (eq major-mode 'ledger-mode) ; I made this local now, should only trigger in ldg-mode (when (eq major-mode 'ledger-mode) ; I made this local now, should only trigger in ldg-mode
(save-excursion (save-excursion
(end-of-line) (end-of-line)
(re-search-backward "^[0-9]\\{4\\}/") (re-search-backward "^[0-9]\\{4\\}/")
(let ((begin (point)) (let ((begin (point))
(end (save-excursion (re-search-forward "^$")))) (end (save-excursion (re-search-forward "^$"))))
(when (re-search-forward "^ Dest:Projects" end t) (when (re-search-forward "^ Dest:Projects" end t)
(replace-match " Other:Personal")) (replace-match " Other:Personal"))
(goto-char begin) (goto-char begin)
(save-excursion (save-excursion
(when (re-search-forward "^ +; ER:" end t) (when (re-search-forward "^ +; ER:" end t)
(beginning-of-line) (beginning-of-line)
(kill-line 1))) (kill-line 1)))
(save-excursion (save-excursion
(when (re-search-forward "^ +; PROJECT:" end t) (when (re-search-forward "^ +; PROJECT:" end t)
(beginning-of-line) (beginning-of-line)
(kill-line 1))) (kill-line 1)))
(save-excursion (save-excursion
(when (re-search-forward "^ +; CATEGORY:" end t) (when (re-search-forward "^ +; CATEGORY:" end t)
(beginning-of-line) (beginning-of-line)
(kill-line 1))) (kill-line 1)))
(save-excursion (save-excursion
(when (re-search-forward "^ +; RECEIPT:" end t) (when (re-search-forward "^ +; RECEIPT:" end t)
(beginning-of-line) (beginning-of-line)
(kill-line 1))) (kill-line 1)))
(ledger-toggle-current-entry))))) (ledger-toggle-current-entry)))))
(defun ledger-expense-show-receipt () (defun ledger-expense-show-receipt ()
"Uses the Receipt buffer to show the receipt of the txn we're on." "Uses the Receipt buffer to show the receipt of the txn we're on."

View file

@ -191,7 +191,8 @@ Show any gains (or losses) in commodity values over time.
Only show the top Only show the top
.Ar number .Ar number
postings. postings.
.\".It Fl \-historical Pq Fl H .It Fl \-historical Pq Fl H
Value commodities at the time of their acquisition.
.It Fl \-invert .It Fl \-invert
Invert the value of amounts shown. Invert the value of amounts shown.
.It Fl \-market Pq Fl V .It Fl \-market Pq Fl V
@ -309,7 +310,7 @@ fit inside the
If If
.Ar INT .Ar INT
is zero, then the is zero, then the
account name will be truncated on the right. If account name will be truncated on the right. If
.Ar INT .Ar INT
is greater is greater
than than
@ -320,7 +321,7 @@ desired width.
.It Fl \-account Ar EXPR .It Fl \-account Ar EXPR
Prepend Prepend
.Ar EXPR .Ar EXPR
to all accounts reported. That is, the option to all accounts reported. That is, the option
.Fl \-account Ar \*q'Personal'\*q .Fl \-account Ar \*q'Personal'\*q
would tack would tack
.Ar Personal: .Ar Personal:
@ -345,7 +346,7 @@ transactions used.
.It Fl \-add-budget .It Fl \-add-budget
Show only un-budgeted postings. Show only un-budgeted postings.
.It Fl \-amount Ar EXPR Pq Fl t .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 .Fl \-amount Ar EXPR
you can apply an you can apply an
arbitrary transformation to the postings. arbitrary transformation to the postings.
@ -366,7 +367,10 @@ Alias for
Ignore init files and environment variables for the Ignore init files and environment variables for the
.Nm .Nm
run. run.
.\".It Fl \-auto-match .It Fl \-auto-match
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 .It Fl \-aux-date
Show auxiliary dates for all calculations. Show auxiliary dates for all calculations.
Alias for Alias for
@ -378,7 +382,9 @@ running totals.
Specify the format to use for the Specify the format to use for the
.Ic balance .Ic balance
report. 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 .It Fl \-basis Pq Fl B
Report the cost basis on all posting. Report the cost basis on all posting.
Alias for Alias for
@ -386,12 +392,12 @@ Alias for
.It Fl \-begin Ar DATE Pq Fl b .It Fl \-begin Ar DATE Pq Fl b
Specify the start Specify the start
.Ar DATE .Ar DATE
of all calculations. Transactions before of all calculations. Transactions before
that date will be ignored. that date will be ignored.
.It Fl \-bold-if Ar EXPR .It Fl \-bold-if Ar EXPR
Print the entire line in bold if the given value expression is true. Print the entire line in bold if the given value expression is true.
.It Fl \-budget .It Fl \-budget
Only display budgeted items. In a Only display budgeted items. In a
.Ic register .Ic register
report this displays transaction in the budget, in a balance report this report this displays transaction in the budget, in a balance report this
displays accounts in the budget. displays accounts in the budget.
@ -401,7 +407,6 @@ Specify the format to use for the
report. report.
.It Fl \-by-payee Pq Fl P .It Fl \-by-payee Pq Fl P
Group postings in the register report by common payee names. Group postings in the register report by common payee names.
.\".It Fl \-cache Ar FILE
.It Fl \-check-payees .It Fl \-check-payees
Enable strict and pedantic checking for payees as well as accounts, Enable strict and pedantic checking for payees as well as accounts,
commodities and tags. commodities and tags.
@ -424,7 +429,7 @@ Make the
.Ic register .Ic register
report report
.Ar INT .Ar INT
characters wide. By default characters wide. By default
.Nm .Nm
will use all available columns in your terminal. will use all available columns in your terminal.
.It Fl \-cost .It Fl \-cost
@ -461,7 +466,12 @@ Print dates using
Refer to Refer to
.Xr strftime 3 .Xr strftime 3
for details on the format string syntax. 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 .It Fl \-date-width Ar INT
Specify the width, in characters, of the date column in the Specify the width, in characters, of the date column in the
.Ic register .Ic register
@ -501,8 +511,14 @@ but not
.Sy Expenses:Entertainment:Dining . .Sy Expenses:Entertainment:Dining .
This is a display predicate, which means it only affects display, This is a display predicate, which means it only affects display,
not the total calculations. not the total calculations.
.It Fl \-detail
Related to
.Ic convert
command. Synonym to
.Fl \-rich-data
option.
.It Fl \-deviation .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 in the
.Ic register No and Ic prices .Ic register No and Ic prices
reports. reports.
@ -537,7 +553,7 @@ distribution. Downloaded quote price are then appended to the price
database, usually specified using the environment variable database, usually specified using the environment variable
.Ev LEDGER_PRICE_DB . .Ev LEDGER_PRICE_DB .
.It Fl \-effective .It Fl \-effective
Show auxiliary dates for all calculations. Alias for Show auxiliary dates for all calculations. Alias for
.Fl \-aux-date . .Fl \-aux-date .
.It Fl \-empty Pq Fl E .It Fl \-empty Pq Fl E
Include empty accounts in report. Include empty accounts in report.
@ -551,7 +567,9 @@ Related to the
.Ic equity .Ic equity
command. Gives current account balances in the form of a register command. Gives current account balances in the form of a register
report. 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 .It Fl \-exchange Ar COMMODITY Oo , Ar COMMODITY, ... Oc Pq Fl X
Display values in terms of the given Display values in terms of the given
.Ar COMMODITY . .Ar COMMODITY .
@ -560,19 +578,18 @@ The latest available price is used.
.It Fl \-file Ar FILE .It Fl \-file Ar FILE
Read journal data from Read journal data from
.Ar FILE . .Ar FILE .
.\".It Fl \-full-help
.It Fl \-first Ar INT .It Fl \-first Ar INT
Print the first Print the first
.Ar INT .Ar INT
entries. Opposite of entries. Opposite of
.Fl \-last Ar INT . .Fl \-last Ar INT .
Alias for Alias for
.Fl \-head . .Fl \-head .
.It Fl \-flat .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. balance report will not use an indented tree.
.It Fl \-force-color .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. for TTYs that don't advertise their capabilities correctly.
.It Fl \-force-pager .It Fl \-force-pager
Force Force
@ -618,22 +635,18 @@ register report.
.It Fl \-head Ar INT .It Fl \-head Ar INT
Print the first Print the first
.Ar INT .Ar INT
entries. Opposite of entries. Opposite of
.Fl \-tail Ar INT . .Fl \-tail Ar INT .
Alias for Alias for
.Fl \-first .Fl \-first
.It Fl \-help .It Fl \-help
Print a summary of all the options, and what they are used for. This Print this man page.
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 .It Fl \-immediate
Evaluate calculations immediately rather than lazily. 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 .It Fl \-init-file Ar FILE Pq Fl i
Read Read
.Ar FILE .Ar FILE
@ -658,9 +671,9 @@ Change the sign of all reported values.
.It Fl \-last Ar INT . .It Fl \-last Ar INT .
Report only the last Report only the last
.Ar INT .Ar INT
entries. Opposite of entries. Opposite of
.Fl \-first Ar INT . .Fl \-first Ar INT .
Only useful on a register report. Alias for Only useful on a register report. Alias for
.Fl \-tail . .Fl \-tail .
.It Fl \-leeway Ar INT Pq Fl Z .It Fl \-leeway Ar INT Pq Fl Z
Alias for Alias for
@ -678,7 +691,9 @@ purchased.
.It Fl \-lots .It Fl \-lots
Report the date and price at which each commodity was purchased in Report the date and price at which each commodity was purchased in
a balance report. 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 .It Fl \-market Pq Fl V
Use the latest market value for all commodities. Use the latest market value for all commodities.
.It Fl \-master-account Ar STR .It Fl \-master-account Ar STR
@ -717,7 +732,7 @@ Suppress printing the final total line in a balance report.
.It Fl \-now Ar DATE .It Fl \-now Ar DATE
Use Use
.Ar DATE .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 \-period ,
.Fl \-begin , .Fl \-begin ,
.Fl \-end , .Fl \-end ,
@ -742,7 +757,7 @@ Use
.Ar STR .Ar STR
as the pager program. as the pager program.
.It Fl \-payee .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 .Ic register
report this prevents the second entry from having report this prevents the second entry from having
a date and payee for each transaction. a date and payee for each transaction.
@ -759,7 +774,7 @@ Calculate the percentage value of each account in a balance reports.
Only works for account that have a single commodity. Only works for account that have a single commodity.
.It Fl \-period Ar PERIOD Pq Fl p .It Fl \-period Ar PERIOD Pq Fl p
Define a period expression that sets the time period during which 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 .Ic register
report only report only
the transactions that satisfy the period expression with be displayed. the transactions that satisfy the period expression with be displayed.
@ -792,12 +807,12 @@ Use the price of the commodity purchase for performing calculations.
.It Fl \-price-exp Ar STR Pq Fl Z .It Fl \-price-exp Ar STR Pq Fl Z
Set the expected freshness of price quotes, in Set the expected freshness of price quotes, in
.Ar INT .Ar INT
minutes. That minutes. That
is, if the last known quote for any commodity is older than this value, is, if the last known quote for any commodity is older than this value,
and if and if
.Fl \-download .Fl \-download
is being used, then the Internet will be 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. considered to be fresh enough.
Alias for Alias for
.Fl \-leeway . .Fl \-leeway .
@ -808,7 +823,7 @@ report.
.It Fl \-pricedb-format Ar FMT .It Fl \-pricedb-format Ar FMT
Set the format expected for the historical price file. Set the format expected for the historical price file.
.It Fl \-primary-date .It Fl \-primary-date
Show primary dates for all calculations. Alias for Show primary dates for all calculations. Alias for
.Fl \-actual-dates .Fl \-actual-dates
.It Fl \-quantity Pq Fl O .It Fl \-quantity Pq Fl O
Report commodity totals (this is the default). Report commodity totals (this is the default).
@ -842,10 +857,27 @@ of the transaction.
Show all postings in a transaction, similar to Show all postings in a transaction, similar to
.Fl \-related .Fl \-related
but show both sides of each transaction. but show both sides of each transaction.
.\".It Fl \-revalued .It Fl \-revalued
.\".It Fl \-revalued-only Report discrepancy in values for manual reports by inserting
.\".It Fl \-revalued-total Ar EXPR <Revalued>
.\".It Fl \-rich-data 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
<Revalued>
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
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 .It Fl \-seed Ar INT
Set the random seed to Set the random seed to
.Ar INT .Ar INT
@ -857,8 +889,9 @@ Execute a
.Nm .Nm
script. script.
.It Fl \-sort Ar EXPR Pq Fl S .It Fl \-sort Ar EXPR Pq Fl S
Sort the register report based on the value expression given to sort. Sort the register report based on the value expression
.\".It Fl \-sort-all .Ar EXPR .
.\".It Fl \-sort-all Ar EXPR
.It Fl \-sort-xacts .It Fl \-sort-xacts
Sort the posting within transactions using the given value expression. Sort the posting within transactions using the given value expression.
.It Fl \-start-of-week Ar STR .It Fl \-start-of-week Ar STR
@ -879,12 +912,15 @@ Report register as a single subtotal.
.It Fl \-tail Ar INT .It Fl \-tail Ar INT
Report only the last Report only the last
.Ar INT .Ar INT
entries. Only useful on a register report. Alias for entries. Only useful on a register report. Alias for
.Fl \-last Ar INT .Fl \-last Ar INT
.It Fl \-time-colon .It Fl \-time-colon
Display the value for commodities based on seconds as hours and minutes. Display the value for commodities based on seconds as hours and minutes.
Thus 8100s will be displayed as 2:15h instead of 2.25h. 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 .It Fl \-total Ar EXPR Pq Fl T
Define a value expression used to calculate the total in reports. Define a value expression used to calculate the total in reports.
.It Fl \-total-data Pq Fl J .It Fl \-total-data Pq Fl J
@ -892,12 +928,12 @@ Show only dates and totals to format the output for plots.
.It Fl \-total-width Ar INT .It Fl \-total-width Ar INT
Set the width of the total field in the register report. Set the width of the total field in the register report.
.It Fl \-trace Ar INT .It Fl \-trace Ar INT
Enable tracing. The Enable tracing. The
.Ar INT .Ar INT
specifies the level of trace desired. specifies the level of trace desired.
.It Fl \-truncate Ar STR .It Fl \-truncate Ar STR
Indicates how truncation should happen when the contents of columns Indicates how truncation should happen when the contents of columns
exceed their width. Valid arguments for exceed their width. Valid arguments for
.Ar STR .Ar STR
are are
.Ar leading , .Ar leading ,
@ -917,14 +953,14 @@ Show generated unrealized gain and loss accounts in the balance
report. report.
.It Fl \-unrealized-gains .It Fl \-unrealized-gains
Allow the user to specify what account name should be used for Allow the user to specify what account name should be used for
unrealized gains. Defaults to unrealized gains. Defaults to
.Sy "Equity:Unrealized Gains" . .Sy "Equity:Unrealized Gains" .
Often set in one's Often set in one's
.Pa ~/.ledgerrc .Pa ~/.ledgerrc
file to change the default. file to change the default.
.It Fl \-unrealized-losses .It Fl \-unrealized-losses
Allow the user to specify what account name should be used for Allow the user to specify what account name should be used for
unrealized gains. Defaults to unrealized gains. Defaults to
.Sy "Equity:Unrealized Losses" . .Sy "Equity:Unrealized Losses" .
Often set in one's Often set in one's
.Pa ~/.ledgerrc .Pa ~/.ledgerrc
@ -936,17 +972,20 @@ precision.
Show the values used by each tag when used in combination with the Show the values used by each tag when used in combination with the
.Ic tags .Ic tags
command. command.
.\".It Fl \-value-expr Ar EXPR .It Fl \-value-expr Ar EXPR
Set a global value expression annotation.
.It Fl \-verbose .It Fl \-verbose
Print detailed information on the execution of Print detailed information on the execution of
.Nm . .Nm .
.It Fl \-verify .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 slowdown. When combined with
.Fl \-debug Ar CODE .Fl \-debug Ar CODE
.Nm .Nm
will produce memory trace information. 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 .It Fl \-version
Print version information and exit. Print version information and exit.
.It Fl \-weekly Pq Fl W .It Fl \-weekly Pq Fl W
@ -960,7 +999,7 @@ Shorthand for
.El .El
.Sh PRE-COMMANDS .Sh PRE-COMMANDS
Pre-commands are useful when you aren't sure how a command or option 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 is that pre-commands ignore the journal data file completely, nor is
the user's init file read. the user's init file read.
.Bl -tag -width -indent .Bl -tag -width -indent
@ -1117,6 +1156,12 @@ toward -infinity.
The name of the The name of the
.Nm .Nm
data file from whence the posting came. 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 .It Fn format_date date format
Return the Return the
.Ar date .Ar date
@ -1125,18 +1170,56 @@ as a string using
Refer to Refer to
.Xr strftime 3 .Xr strftime 3
for format string details. for format string details.
.\".It Fn get_at .It Fn format_datetime datetime format
.\".It Fn has_meta 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 .It Fn has_tag tag
Return true if the posting has metadata named Return true if the posting has metadata named
.Ar tag , .Ar tag ,
false otherwise. 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 .It Fn join value
Replace all newlines in Replace all newlines in
.Ar value .Ar value
with with
.Li \en . .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 .It Fn market value datetime
Return the price of Return the price of
.Ar value .Ar value
@ -1146,8 +1229,13 @@ Note that
.Ar datetime .Ar datetime
must be surrounded by brackets in order to be parsed correctly, e.g. must be surrounded by brackets in order to be parsed correctly, e.g.
.Bq 2012/03/23 . .Bq 2012/03/23 .
.\".It Sy meta .It Fn meta
.I.\"t Sy note 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 null
.It Sy options .It Sy options
A variable that allows access to the values of the given command-line options A variable that allows access to the values of the given command-line options
@ -1173,7 +1261,11 @@ in relation to
.Ar value_b . .Ar value_b .
.\".It Sy post .\".It Sy post
.\" A variable scope .\" A variable scope
.\".It Sy print .It Fn print value
Print
.Ar value
to stdout.
Used internally for debugging.
.It Fn quantity value .It Fn quantity value
Return the quantity of Return the quantity of
.Ar value .Ar value
@ -1192,30 +1284,61 @@ Return
.Ar value .Ar value
rounded to rounded to
.Ar n .Ar n
digits. Does not affect formatting. 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 status
.\".It Sy strip .It Fn strip value
Strip value annotation from
.Ar value .
.\".It Sy subcount .\".It Sy subcount
.It Fn tag name .It Fn tag name
Return the value of tag named Return the value of tag named
.Ar name . .Ar name .
.\".It Fn to_amount value .It Fn to_amount value
.\".It Fn to_balance value Convert
.\".It Fn to_boolean value .Ar value
.\".It Fn to_date value to an amount. Internal use only!
.\".It Fn to_datetime value .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 .It Fn to_int value
Return the integer value for Return the integer value for
.Ar value . .Ar value .
.\".It Fn to_mask value .It Fn to_mask value
.\".It Fn to_sequence 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 .It Fn to_string value
Convert Convert
.Ar value .Ar value
to a character string. to a character string.
.It Sy today .It Sy today
Return todays date. Return today's date.
.It Sy total .It Sy total
Return the total of the posting. Return the total of the posting.
.It Sy total_expr .It Sy total_expr
@ -1225,7 +1348,14 @@ option.
.It Fn trim value .It Fn trim value
Trim leading and trailing whitespace from Trim leading and trailing whitespace from
.Ar value . .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 uncleared
.It Sy virtual .It Sy virtual
Return true if the transaction is virtual, e.g automated, false otherwise. Return true if the transaction is virtual, e.g automated, false otherwise.

File diff suppressed because it is too large Load diff

View file

@ -91,8 +91,8 @@ Returns a list with (value commodity)."
(error "Can't add different commodities, %S to %S" c1 c2))) (error "Can't add different commodities, %S to %S" c1 c2)))
(defun ledger-strip (str char) (defun ledger-strip (str char)
"Return STR with CHAR removed." "Return STR with CHAR removed."
(replace-regexp-in-string char "" str)) (replace-regexp-in-string char "" str))
(defun ledger-string-to-number (str &optional decimal-comma) (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" "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))) (string-to-number nstr)))
(defun ledger-number-to-string (n &optional decimal-comma) (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))) (let ((str (number-to-string n)))
(when (or decimal-comma (when (or decimal-comma
(assoc "decimal-comma" ledger-environment-alist)) (assoc "decimal-comma" ledger-environment-alist))
@ -124,7 +124,7 @@ longer ones are after the value."
(concat commodity " " str)))) (concat commodity " " str))))
(defun ledger-read-commodity-string (prompt) (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 (let ((str (read-from-minibuffer
(concat prompt " (" ledger-reconcile-default-commodity "): "))) (concat prompt " (" ledger-reconcile-default-commodity "): ")))
comm) comm)

View file

@ -157,7 +157,7 @@
(ledger-accounts))))) (ledger-accounts)))))
(defun ledger-trim-trailing-whitespace (str) (defun ledger-trim-trailing-whitespace (str)
(replace-regexp-in-string "[ \t]*$" "" str)) (replace-regexp-in-string "[ \t]*$" "" str))
(defun ledger-fully-complete-xact () (defun ledger-fully-complete-xact ()
"Completes a transaction if there is another matching payee in the buffer. "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-seen pcomplete-norm-func
pcomplete-args pcomplete-last pcomplete-index pcomplete-args pcomplete-last pcomplete-index
pcomplete-autolist pcomplete-autolist
(completions (pcomplete-completions)) (completions (pcomplete-completions))
(result (pcomplete-do-complete pcomplete-stub completions)) (result (pcomplete-do-complete pcomplete-stub completions))
(pcomplete-termination-string "")) (pcomplete-termination-string ""))
(and result (and result

View file

@ -53,7 +53,7 @@
(setq buffer-read-only t))) (setq buffer-read-only t)))
(defun ledger-exec-success-p (ledger-output-buffer) (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 (with-current-buffer ledger-output-buffer
(goto-char (point-min)) (goto-char (point-min))
(if (and (> (buffer-size) 1) (looking-at (regexp-quote "While"))) (if (and (> (buffer-size) 1) (looking-at (regexp-quote "While")))

View file

@ -38,45 +38,45 @@
:group 'ledger) :group 'ledger)
(defun ledger-fontify-buffer-part (&optional beg end len) (defun ledger-fontify-buffer-part (&optional beg end len)
"Fontify buffer from BEG to END, length LEN." "Fontify buffer from BEG to END, length LEN."
(save-excursion (save-excursion
(unless beg (setq beg (point-min))) (unless beg (setq beg (point-min)))
(unless end (setq end (point-max))) (unless end (setq end (point-max)))
(goto-char beg) (goto-char beg)
(beginning-of-line) (beginning-of-line)
(while (< (point) end) (while (< (point) end)
(cond ((or (looking-at ledger-xact-start-regex) (cond ((or (looking-at ledger-xact-start-regex)
(looking-at ledger-posting-regex)) (looking-at ledger-posting-regex))
(ledger-fontify-xact-at (point))) (ledger-fontify-xact-at (point)))
((looking-at ledger-directive-start-regex) ((looking-at ledger-directive-start-regex)
(ledger-fontify-directive-at (point)))) (ledger-fontify-directive-at (point))))
(ledger-navigate-next-xact-or-directive)))) (ledger-navigate-next-xact-or-directive))))
(defun ledger-fontify-xact-at (position) (defun ledger-fontify-xact-at (position)
"Fontify the xact at POSITION." "Fontify the xact at POSITION."
(interactive "d") (interactive "d")
(save-excursion (save-excursion
(goto-char position) (goto-char position)
(let ((extents (ledger-navigate-find-element-extents position)) (let ((extents (ledger-navigate-find-element-extents position))
(state (ledger-transaction-state))) (state (ledger-transaction-state)))
(if (and ledger-fontify-xact-state-overrides state) (if (and ledger-fontify-xact-state-overrides state)
(cond ((eq state 'cleared) (cond ((eq state 'cleared)
(ledger-fontify-set-face extents 'ledger-font-xact-cleared-face)) (ledger-fontify-set-face extents 'ledger-font-xact-cleared-face))
((eq state 'pending) ((eq state 'pending)
(ledger-fontify-set-face extents 'ledger-font-xact-pending-face))) (ledger-fontify-set-face extents 'ledger-font-xact-pending-face)))
(ledger-fontify-xact-by-line extents))))) (ledger-fontify-xact-by-line extents)))))
(defun ledger-fontify-xact-by-line (extents) (defun ledger-fontify-xact-by-line (extents)
"Do line-by-line detailed fontification of xact in EXTENTS." "Do line-by-line detailed fontification of xact in EXTENTS."
(save-excursion (save-excursion
(ledger-fontify-xact-start (car extents)) (ledger-fontify-xact-start (car extents))
(while (< (point) (cadr extents)) (while (< (point) (cadr extents))
(if (looking-at "[ \t]+;") (if (looking-at "[ \t]+;")
(ledger-fontify-set-face (list (point) (progn (ledger-fontify-set-face (list (point) (progn
(end-of-line) (end-of-line)
(point))) 'ledger-font-comment-face) (point))) 'ledger-font-comment-face)
(ledger-fontify-posting (point))) (ledger-fontify-posting (point)))
(forward-line)))) (forward-line))))
(defun ledger-fontify-xact-start (pos) (defun ledger-fontify-xact-start (pos)
"POS should be at the beginning of a line starting an xact. "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))) (forward-line)))
(defun ledger-fontify-posting (pos) (defun ledger-fontify-posting (pos)
"Fontify the posting at POS." "Fontify the posting at POS."
(let* ((state nil) (let* ((state nil)
(end-of-line-comment nil) (end-of-line-comment nil)
(end (progn (end-of-line) (end (progn (end-of-line)
(point))) (point)))
(start (progn (beginning-of-line) (start (progn (beginning-of-line)
(point)))) (point))))
;; Look for a posting status flag ;; Look for a posting status flag
(set-match-data nil 'reseat) (set-match-data nil 'reseat)
(re-search-forward " \\([*!]\\) " end t) (re-search-forward " \\([*!]\\) " end t)
(if (match-string 1) (if (match-string 1)
(setq state (ledger-state-from-string (match-string 1)))) (setq state (ledger-state-from-string (match-string 1))))
(beginning-of-line) (beginning-of-line)
(re-search-forward "[[:graph:]]\\([ \t][ \t]\\)" end 'end) ;; find the end of the account, or end 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 (when (<= (point) end) ;; we are still on the line
(ledger-fontify-set-face (list start (point)) (ledger-fontify-set-face (list start (point))
(cond ((eq state 'cleared) (cond ((eq state 'cleared)
'ledger-font-posting-account-cleared-face) 'ledger-font-posting-account-cleared-face)
((eq state 'pending) ((eq state 'pending)
'ledger-font-posting-account-pending-face) 'ledger-font-posting-account-pending-face)
(t (t
'ledger-font-posting-account-face))) 'ledger-font-posting-account-face)))
(when (< (point) end) ;; there is still more to fontify (when (< (point) end) ;; there is still more to fontify
(setq start (point)) ;; update start of next font region (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 (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) ) (ledger-fontify-set-face (list start (point) )
(cond ((eq state 'cleared) (cond ((eq state 'cleared)
'ledger-font-posting-amount-cleared-face) 'ledger-font-posting-amount-cleared-face)
((eq state 'pending) ((eq state 'pending)
'ledger-font-posting-amount-pending-face) 'ledger-font-posting-amount-pending-face)
(t (t
'ledger-font-posting-amount-face))) 'ledger-font-posting-amount-face)))
(when end-of-line-comment (when end-of-line-comment
(setq start (point)) (setq start (point))
(end-of-line) (end-of-line)
(ledger-fontify-set-face (list (- start 1) (point)) ;; subtract 1 from start because we passed the semi-colon (ledger-fontify-set-face (list (- start 1) (point)) ;; subtract 1 from start because we passed the semi-colon
'ledger-font-comment-face)))))) 'ledger-font-comment-face))))))
(defun ledger-fontify-directive-at (pos) (defun ledger-fontify-directive-at (pos)
"Fontify the directive at POS." "Fontify the directive at POS."
(let ((extents (ledger-navigate-find-element-extents pos)) (let ((extents (ledger-navigate-find-element-extents pos))
(face 'ledger-font-default-face)) (face 'ledger-font-default-face))
(cond ((looking-at "=") (cond ((looking-at "=")
(setq face 'ledger-font-auto-xact-face)) (setq face 'ledger-font-auto-xact-face))
((looking-at "~") ((looking-at "~")
(setq face 'ledger-font-periodic-xact-face)) (setq face 'ledger-font-periodic-xact-face))
((looking-at "[;#%|\\*]") ((looking-at "[;#%|\\*]")
(setq face 'ledger-font-comment-face)) (setq face 'ledger-font-comment-face))
((looking-at "\\(year\\)\\|Y") ((looking-at "\\(year\\)\\|Y")
(setq face 'ledger-font-year-directive-face)) (setq face 'ledger-font-year-directive-face))
((looking-at "account") ((looking-at "account")
(setq face 'ledger-font-account-directive-face)) (setq face 'ledger-font-account-directive-face))
((looking-at "apply") ((looking-at "apply")
(setq face 'ledger-font-apply-directive-face)) (setq face 'ledger-font-apply-directive-face))
((looking-at "alias") ((looking-at "alias")
(setq face 'ledger-font-alias-directive-face)) (setq face 'ledger-font-alias-directive-face))
((looking-at "assert") ((looking-at "assert")
(setq face 'ledger-font-assert-directive-face)) (setq face 'ledger-font-assert-directive-face))
((looking-at "\\(bucket\\)\\|A") ((looking-at "\\(bucket\\)\\|A")
(setq face 'ledger-font-bucket-directive-face)) (setq face 'ledger-font-bucket-directive-face))
((looking-at "capture") ((looking-at "capture")
(setq face 'ledger-font-capture-directive-face)) (setq face 'ledger-font-capture-directive-face))
((looking-at "check") ((looking-at "check")
(setq face 'ledger-font-check-directive-face)) (setq face 'ledger-font-check-directive-face))
((looking-at "commodity") ((looking-at "commodity")
(setq face 'ledger-font-commodity-directive-face)) (setq face 'ledger-font-commodity-directive-face))
((looking-at "define") ((looking-at "define")
(setq face 'ledger-font-define-directive-face)) (setq face 'ledger-font-define-directive-face))
((looking-at "end") ((looking-at "end")
(setq face 'ledger-font-end-directive-face)) (setq face 'ledger-font-end-directive-face))
((looking-at "expr") ((looking-at "expr")
(setq face 'ledger-font-expr-directive-face)) (setq face 'ledger-font-expr-directive-face))
((looking-at "fixed") ((looking-at "fixed")
(setq face 'ledger-font-fixed-directive-face)) (setq face 'ledger-font-fixed-directive-face))
((looking-at "include") ((looking-at "include")
(setq face 'ledger-font-include-directive-face)) (setq face 'ledger-font-include-directive-face))
((looking-at "payee") ((looking-at "payee")
(setq face 'ledger-font-payee-directive-face)) (setq face 'ledger-font-payee-directive-face))
((looking-at "P") ((looking-at "P")
(setq face 'ledger-font-price-directive-face)) (setq face 'ledger-font-price-directive-face))
((looking-at "tag") ((looking-at "tag")
(setq face 'ledger-font-tag-directive-face))) (setq face 'ledger-font-tag-directive-face)))
(ledger-fontify-set-face extents face))) (ledger-fontify-set-face extents face)))
(defun ledger-fontify-set-face (extents face) (defun ledger-fontify-set-face (extents face)
"Set the text in EXTENTS to FACE." "Set the text in EXTENTS to FACE."
(put-text-property (car extents) (cadr extents) 'face face)) (put-text-property (car extents) (cadr extents) 'face face))
(provide 'ledger-fontify) (provide 'ledger-fontify)

View file

@ -35,7 +35,7 @@
(defvar ledger-default-date-format "%Y/%m/%d") (defvar ledger-default-date-format "%Y/%m/%d")
(defun ledger-init-parse-initialization (buffer) (defun ledger-init-parse-initialization (buffer)
"Parse the .ledgerrc file in BUFFER." "Parse the .ledgerrc file in BUFFER."
(with-current-buffer buffer (with-current-buffer buffer
(let (environment-alist) (let (environment-alist)
(goto-char (point-min)) (goto-char (point-min))
@ -56,7 +56,7 @@
environment-alist))) environment-alist)))
(defun ledger-init-load-init-file () (defun ledger-init-load-init-file ()
"Load and parse the .ledgerrc file." "Load and parse the .ledgerrc file."
(interactive) (interactive)
(let ((init-base-name (file-name-nondirectory ledger-init-file-name))) (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 (if (get-buffer init-base-name) ;; init file already loaded, parse it and leave it

View file

@ -63,7 +63,7 @@
(defun ledger-mode-dump-variable (var) (defun ledger-mode-dump-variable (var)
"Format VAR for dump to buffer." "Format VAR for dump to buffer."
(if var (if var
(insert (format " %s: %S\n" (symbol-name var) (eval var))))) (insert (format " %s: %S\n" (symbol-name var) (eval var)))))
(defun ledger-mode-dump-group (group) (defun ledger-mode-dump-group (group)
@ -78,7 +78,7 @@
(defun ledger-mode-dump-configuration () (defun ledger-mode-dump-configuration ()
"Dump all customizations." "Dump all customizations."
(interactive) (interactive)
(find-file "ledger-mode-dump") (find-file "ledger-mode-dump")
(ledger-mode-dump-group 'ledger)) (ledger-mode-dump-group 'ledger))
@ -99,11 +99,11 @@
(defun ledger-read-account-with-prompt (prompt) (defun ledger-read-account-with-prompt (prompt)
"Read an account from the minibuffer with 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 (ledger-read-string-with-default prompt
(if (eq (ledger-context-current-field context) 'account) (if (eq (ledger-context-current-field context) 'account)
(regexp-quote (ledger-context-field-value context 'account)) (regexp-quote (ledger-context-field-value context 'account))
nil)))) nil))))
(defun ledger-read-date (prompt) (defun ledger-read-date (prompt)
"Return user-supplied date after `PROMPT', defaults to today." "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 () (defun ledger-mode-remove-extra-lines ()
"Get rid of multiple empty lines." "Get rid of multiple empty lines."
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward "\n\n\\(\n\\)+" nil t) (while (re-search-forward "\n\n\\(\n\\)+" nil t)
(replace-match "\n\n"))) (replace-match "\n\n")))
@ -338,10 +338,10 @@ With a prefix argument, remove the effective date."
'(ledger-font-lock-keywords t t nil nil '(ledger-font-lock-keywords t t nil nil
(font-lock-fontify-region-function . ledger-fontify-buffer-part)))) (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-parse-arguments-function) 'ledger-parse-arguments)
(set (make-local-variable 'pcomplete-command-completion-function) 'ledger-complete-at-point) (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 '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) (add-hook 'post-command-hook 'ledger-highlight-xact-under-point nil t)

View file

@ -39,49 +39,49 @@
(goto-char (point-max)))) (goto-char (point-max))))
(defun ledger-navigate-start-xact-or-directive-p () (defun ledger-navigate-start-xact-or-directive-p ()
"Return t if at the beginning of an empty or all-whitespace line." "Return t if at the beginning of an empty or all-whitespace line."
(not (looking-at "[ \t]\\|\\(^$\\)"))) (not (looking-at "[ \t]\\|\\(^$\\)")))
(defun ledger-navigate-next-xact-or-directive () (defun ledger-navigate-next-xact-or-directive ()
"Move to the beginning of the next xact or directive." "Move to the beginning of the next xact or directive."
(interactive) (interactive)
(beginning-of-line) (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 (if (ledger-navigate-start-xact-or-directive-p) ; if we are the start of an xact, move forward to the next xact
(progn (progn
(forward-line) (forward-line)
(if (not (ledger-navigate-start-xact-or-directive-p)) ; we have moved forward and are not at another xact, recurse forward (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))) (ledger-navigate-next-xact-or-directive)))
(while (not (or (eobp) ; we didn't start off at the beginning of an xact (while (not (or (eobp) ; we didn't start off at the beginning of an xact
(ledger-navigate-start-xact-or-directive-p))) (ledger-navigate-start-xact-or-directive-p)))
(forward-line)))) (forward-line))))
(defun ledger-navigate-prev-xact-or-directive () (defun ledger-navigate-prev-xact-or-directive ()
"Move point to beginning of previous xact." "Move point to beginning of previous xact."
(interactive) (interactive)
(let ((context (car (ledger-context-at-point)))) (let ((context (car (ledger-context-at-point))))
(when (equal context 'acct-transaction) (when (equal context 'acct-transaction)
(ledger-navigate-beginning-of-xact)) (ledger-navigate-beginning-of-xact))
(beginning-of-line) (beginning-of-line)
(re-search-backward "^[[:graph:]]" nil t))) (re-search-backward "^[[:graph:]]" nil t)))
(defun ledger-navigate-beginning-of-xact () (defun ledger-navigate-beginning-of-xact ()
"Move point to the beginning of the current xact." "Move point to the beginning of the current xact."
(interactive) (interactive)
;; need to start at the beginning of a line incase we are in the first line of an xact already. ;; need to start at the beginning of a line incase we are in the first line of an xact already.
(beginning-of-line) (beginning-of-line)
(let ((sreg (concat "^\\(=\\|~\\|" ledger-iso-date-regexp "\\)"))) (let ((sreg (concat "^\\(=\\|~\\|" ledger-iso-date-regexp "\\)")))
(unless (looking-at sreg) (unless (looking-at sreg)
(re-search-backward sreg nil t) (re-search-backward sreg nil t)
(beginning-of-line))) (beginning-of-line)))
(point)) (point))
(defun ledger-navigate-end-of-xact () (defun ledger-navigate-end-of-xact ()
"Move point to end of xact." "Move point to end of xact."
(interactive) (interactive)
(ledger-navigate-next-xact-or-directive) (ledger-navigate-next-xact-or-directive)
(re-search-backward ".$") (re-search-backward ".$")
(end-of-line) (end-of-line)
(point)) (point))
(defun ledger-navigate-to-line (line-number) (defun ledger-navigate-to-line (line-number)
"Rapidly move point to line LINE-NUMBER." "Rapidly move point to line LINE-NUMBER."
@ -95,61 +95,61 @@ Requires empty line separating xacts."
(save-excursion (save-excursion
(goto-char pos) (goto-char pos)
(list (ledger-navigate-beginning-of-xact) (list (ledger-navigate-beginning-of-xact)
(ledger-navigate-end-of-xact)))) (ledger-navigate-end-of-xact))))
(defun ledger-navigate-find-directive-extents (pos) (defun ledger-navigate-find-directive-extents (pos)
"Return the extents of the directive at POS." "Return the extents of the directive at POS."
(goto-char pos) (goto-char pos)
(let ((begin (progn (beginning-of-line) (let ((begin (progn (beginning-of-line)
(point))) (point)))
(end (progn (end-of-line) (end (progn (end-of-line)
(+ 1 (point))))) (+ 1 (point)))))
;; handle block comments here ;; handle block comments here
(beginning-of-line) (beginning-of-line)
(if (looking-at " *;") (if (looking-at " *;")
(progn (progn
(while (and (looking-at " *;") (while (and (looking-at " *;")
(> (point) (point-min))) (> (point) (point-min)))
(forward-line -1)) (forward-line -1))
;; We are either at the beginning of the buffer, or we found ;; We are either at the beginning of the buffer, or we found
;; a line outside the comment. If we are not at the ;; a line outside the comment. If we are not at the
;; beginning of the buffer then we need to move forward a ;; beginning of the buffer then we need to move forward a
;; line. ;; line.
(if (> (point) (point-min)) (if (> (point) (point-min))
(progn (forward-line 1) (progn (forward-line 1)
(beginning-of-line))) (beginning-of-line)))
(setq begin (point)) (setq begin (point))
(goto-char pos) (goto-char pos)
(beginning-of-line) (beginning-of-line)
(while (and (looking-at " *;") (while (and (looking-at " *;")
(< (point) (point-max))) (< (point) (point-max)))
(forward-line 1)) (forward-line 1))
(setq end (point)))) (setq end (point))))
(list begin end))) (list begin end)))
(defun ledger-navigate-block-comment (pos) (defun ledger-navigate-block-comment (pos)
"Move past the block comment at POS, and return its extents." "Move past the block comment at POS, and return its extents."
(interactive "d") (interactive "d")
(goto-char pos) (goto-char pos)
(let ((begin (progn (beginning-of-line) (let ((begin (progn (beginning-of-line)
(point))) (point)))
(end (progn (end-of-line) (end (progn (end-of-line)
(point)))) (point))))
;; handle block comments here ;; handle block comments here
(beginning-of-line) (beginning-of-line)
(if (looking-at " *;") (if (looking-at " *;")
(progn (progn
(while (and (looking-at " *;") (while (and (looking-at " *;")
(> (point) (point-min))) (> (point) (point-min)))
(forward-line -1)) (forward-line -1))
(setq begin (point)) (setq begin (point))
(goto-char pos) (goto-char pos)
(beginning-of-line) (beginning-of-line)
(while (and (looking-at " *;") (while (and (looking-at " *;")
(< (point) (point-max))) (< (point) (point-max)))
(forward-line 1)) (forward-line 1))
(setq end (point)))) (setq end (point))))
(list begin end))) (list begin end)))
(defun ledger-navigate-find-element-extents (pos) (defun ledger-navigate-find-element-extents (pos)

View file

@ -118,7 +118,7 @@ currently active."
Argument OVL-BOUNDS contains bounds for the transactions to be left visible." Argument OVL-BOUNDS contains bounds for the transactions to be left visible."
(let* ((beg (caar ovl-bounds)) (let* ((beg (caar ovl-bounds))
(end (cadar ovl-bounds))) (end (cadar ovl-bounds)))
(ledger-occur-remove-overlays) (ledger-occur-remove-overlays)
(ledger-occur-make-invisible-overlay (point-min) (1- beg)) (ledger-occur-make-invisible-overlay (point-min) (1- beg))
(dolist (visible (cdr ovl-bounds)) (dolist (visible (cdr ovl-bounds))
(ledger-occur-make-visible-overlay beg end) (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)) (while (not (eobp))
;; if something found ;; if something found
(when (setq endpoint (re-search-forward regex nil 'end)) (when (setq endpoint (re-search-forward regex nil 'end))
(setq bounds (ledger-navigate-find-element-extents endpoint)) (setq bounds (ledger-navigate-find-element-extents endpoint))
(push bounds lines) (push bounds lines)
;; move to the end of the xact, no need to search inside it more ;; move to the end of the xact, no need to search inside it more
(goto-char (cadr bounds)))) (goto-char (cadr bounds))))
(nreverse lines)))) (nreverse lines))))
(defun ledger-occur-compress-matches (buffer-matches) (defun ledger-occur-compress-matches (buffer-matches)
"identify sequential xacts to reduce number of overlays required" "identify sequential xacts to reduce number of overlays required"
(if buffer-matches (if buffer-matches
(let ((points (list)) (let ((points (list))
(current-beginning (caar buffer-matches)) (current-beginning (caar buffer-matches))
(current-end (cadar buffer-matches))) (current-end (cadar buffer-matches)))
(dolist (match (cdr buffer-matches)) (dolist (match (cdr buffer-matches))
(if (< (- (car match) current-end) 2) (if (< (- (car match) current-end) 2)
(setq current-end (cadr match)) (setq current-end (cadr match))
(push (list current-beginning current-end) points) (push (list current-beginning current-end) points)
(setq current-beginning (car match)) (setq current-beginning (car match))
(setq current-end (cadr match)))) (setq current-end (cadr match))))
(nreverse (push (list current-beginning current-end) points))))) (nreverse (push (list current-beginning current-end) points)))))
(provide 'ledger-occur) (provide 'ledger-occur)

View file

@ -95,8 +95,8 @@ at beginning of account"
(current-column)))) (current-column))))
(defun ledger-post-align-xact (pos) (defun ledger-post-align-xact (pos)
"Align all the posting in the xact at POS." "Align all the posting in the xact at POS."
(interactive "d") (interactive "d")
(let ((bounds (ledger-navigate-find-xact-extents pos))) (let ((bounds (ledger-navigate-find-xact-extents pos)))
(ledger-post-align-postings (car bounds) (cadr bounds)))) (ledger-post-align-postings (car bounds) (cadr bounds))))

View file

@ -77,7 +77,7 @@ Default is ledger-default-date-format."
:group 'ledger-reconcile) :group 'ledger-reconcile)
(defcustom ledger-reconcile-buffer-header "Reconciling account %s\n\n" (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 If non-nil, the name of the account being reconciled will be substituted
into the '%s'. If nil, no header will be displayed." 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) :group 'ledger-reconcile)
(defcustom ledger-reconcile-buffer-line-format "%(date)s %-4(code)s %-50(payee)s %-30(account)s %15(amount)s\n" (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, Available fields are date, status, code, payee, account,
amount. The format for each field is %WIDTH(FIELD), WIDTH can be 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 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." "If S is shorter than LEN, pad it with PADDING on the left."
(let ((extra (max 0 (- len (length s))))) (let ((extra (max 0 (- len (length s)))))
(concat (make-string extra (string-to-char padding)) (concat (make-string extra (string-to-char padding))
s))) s)))
(defun ledger-reconcile-s-pad-right (len padding s) (defun ledger-reconcile-s-pad-right (len padding s)
"If S is shorter than LEN, pad it with PADDING on the right." "If S is shorter than LEN, pad it with PADDING on the right."
(let ((extra (max 0 (- len (length s))))) (let ((extra (max 0 (- len (length s)))))
(concat s (concat s
(make-string extra (string-to-char padding))))) (make-string extra (string-to-char padding)))))
(defun ledger-reconcile-s-left (len s) (defun ledger-reconcile-s-left (len s)
"Return up to the LEN first chars of S." "Return up to the LEN first chars of S."
(if (> (length s) len) (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." "Return up to the LEN last chars of S."
(let ((l (length s))) (let ((l (length s)))
(if (> l len) (if (> l len)
(substring s (- l len) l) (substring s (- l len) l)
s))) s)))
(defun ledger-reconcile-truncate-right (str len) (defun ledger-reconcile-truncate-right (str len)
@ -253,9 +253,9 @@ Return the number of uncleared xacts found."
(with-current-buffer recon-buf (with-current-buffer recon-buf
(ledger-reconcile-refresh) (ledger-reconcile-refresh)
(set-buffer-modified-p nil)) (set-buffer-modified-p nil))
(when curbufwin (when curbufwin
(select-window curbufwin) (select-window curbufwin)
(goto-char curpoint))))) (goto-char curpoint)))))
(defun ledger-reconcile-add () (defun ledger-reconcile-add ()
"Use ledger xact to add a new transaction." "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) (defun ledger-reconcile-visit (&optional come-back)
"Recenter ledger buffer on transaction and COME-BACK if non-nil." "Recenter ledger buffer on transaction and COME-BACK if non-nil."
(interactive) (interactive)
(beginning-of-line) (beginning-of-line)
(let* ((where (get-text-property (1+ (point)) 'where)) (let* ((where (get-text-property (1+ (point)) 'where))
(target-buffer (if where (target-buffer (if where
(ledger-reconcile-get-buffer where) (ledger-reconcile-get-buffer where)
nil)) nil))
(cur-win (get-buffer-window (get-buffer ledger-recon-buffer-name)))) (cur-win (get-buffer-window (get-buffer ledger-recon-buffer-name))))
(when target-buffer (when target-buffer
(switch-to-buffer-other-window target-buffer) (switch-to-buffer-other-window target-buffer)
(ledger-navigate-to-line (cdr where)) (ledger-navigate-to-line (cdr where))
(forward-char) (forward-char)
(recenter) (recenter)
(ledger-highlight-xact-under-point) (ledger-highlight-xact-under-point)
(forward-char -1) (forward-char -1)
(when (and come-back cur-win) (when (and come-back cur-win)
(select-window cur-win) (select-window cur-win)
(get-buffer ledger-recon-buffer-name))))) (get-buffer ledger-recon-buffer-name)))))
(defun ledger-reconcile-save () (defun ledger-reconcile-save ()
"Save the ledger buffer." "Save the ledger buffer."
(interactive) (interactive)
(let ((cur-buf (current-buffer)) (let ((cur-buf (current-buffer))
(cur-point (point))) (cur-point (point)))
(dolist (buf (cons ledger-buf ledger-bufs)) (dolist (buf (cons ledger-buf ledger-bufs))
(with-current-buffer buf (with-current-buffer buf
(basic-save-buffer))) (basic-save-buffer)))
(switch-to-buffer-other-window cur-buf) (switch-to-buffer-other-window cur-buf)
(goto-char cur-point))) (goto-char cur-point)))
(defun ledger-reconcile-finish () (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 (nth 0 posting))))) ;; return line-no of posting
(defun ledger-reconcile-compile-format-string (fstr) (defun ledger-reconcile-compile-format-string (fstr)
"Return a function that implements the format string in FSTR." "Return a function that implements the format string in FSTR."
(let (fields (let (fields
(start 0)) (start 0))
(while (string-match "(\\(.*?\\))" fstr start) (while (string-match "(\\(.*?\\))" fstr start)
(setq fields (cons (intern (match-string 1 fstr)) fields)) (setq fields (cons (intern (match-string 1 fstr)) fields))
(setq start (match-end 0))) (setq start (match-end 0)))
(setq fields (list* 'format (replace-regexp-in-string "(.*?)" "" fstr) (nreverse fields))) (setq fields (list* 'format (replace-regexp-in-string "(.*?)" "" fstr) (nreverse fields)))
`(lambda (date code status payee account amount) `(lambda (date code status payee account amount)
,fields))) ,fields)))
(defun ledger-reconcile-format-posting (beg where fmt date code status payee account amount) (defun ledger-reconcile-format-posting (beg where fmt date code status payee account amount)
"Format posting for the reconcile buffer." "Format posting for the reconcile buffer."
(insert (funcall fmt date code status payee account amount)) (insert (funcall fmt date code status payee account amount))
; Set face depending on cleared status ; Set face depending on cleared status
(if status (if status
(if (eq status 'pending) (if (eq status 'pending)
(set-text-properties beg (1- (point)) (set-text-properties beg (1- (point))
(list 'face 'ledger-font-reconciler-pending-face (list 'face 'ledger-font-reconciler-pending-face
'where where)) 'where where))
(set-text-properties beg (1- (point)) (set-text-properties beg (1- (point))
(list 'face 'ledger-font-reconciler-cleared-face (list 'face 'ledger-font-reconciler-cleared-face
'where where))) 'where where)))
(set-text-properties beg (1- (point)) (set-text-properties beg (1- (point))
(list 'face 'ledger-font-reconciler-uncleared-face (list 'face 'ledger-font-reconciler-uncleared-face
'where where)))) 'where where))))
(defun ledger-reconcile-format-xact (xact fmt) (defun ledger-reconcile-format-xact (xact fmt)
"Format XACT using FMT." "Format XACT using FMT."
(let ((date-format (or (cdr (assoc "date-format" ledger-environment-alist)) (let ((date-format (or (cdr (assoc "date-format" ledger-environment-alist))
ledger-default-date-format))) ledger-default-date-format)))
(dolist (posting (nthcdr 5 xact)) (dolist (posting (nthcdr 5 xact))
(let ((beg (point)) (let ((beg (point))
(where (ledger-marker-where-xact-is xact posting))) (where (ledger-marker-where-xact-is xact posting)))
(ledger-reconcile-format-posting beg (ledger-reconcile-format-posting beg
where where
fmt fmt
(format-time-string date-format (nth 2 xact)) ; date (format-time-string date-format (nth 2 xact)) ; date
(if (nth 3 xact) (nth 3 xact) "") ; code (if (nth 3 xact) (nth 3 xact) "") ; code
(nth 3 posting) ; status (nth 3 posting) ; status
(ledger-reconcile-truncate-right (ledger-reconcile-truncate-right
(nth 4 xact) ; payee (nth 4 xact) ; payee
ledger-reconcile-buffer-payee-max-chars) ledger-reconcile-buffer-payee-max-chars)
(ledger-reconcile-truncate-left (ledger-reconcile-truncate-left
(nth 1 posting) ; account (nth 1 posting) ; account
ledger-reconcile-buffer-account-max-chars) ledger-reconcile-buffer-account-max-chars)
(nth 2 posting)))))) ; amount (nth 2 posting)))))) ; amount
(defun ledger-do-reconcile (&optional sort) (defun ledger-do-reconcile (&optional sort)
"SORT the uncleared transactions in the account and display them in the *Reconcile* buffer. "SORT the uncleared transactions in the account and display them in the *Reconcile* buffer.
@ -437,7 +437,7 @@ Return a count of the uncleared transactions."
(unless (eobp) (unless (eobp)
(if (looking-at "(") (if (looking-at "(")
(read (current-buffer))))))) ;current-buffer is the *temp* created above (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)) (if (and ledger-success (> (length xacts) 0))
(progn (progn
(if ledger-reconcile-buffer-header (if ledger-reconcile-buffer-header
@ -494,11 +494,11 @@ moved and recentered. If they aren't strange things happen."
(pop-to-buffer rbuf))) (pop-to-buffer rbuf)))
(defun ledger-reconcile-check-valid-account (account) (defun ledger-reconcile-check-valid-account (account)
"Check to see if ACCOUNT exists in the ledger file" "Check to see if ACCOUNT exists in the ledger file"
(if (> (length account) 0) (if (> (length account) 0)
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
(search-forward account nil t)))) (search-forward account nil t))))
(defun ledger-reconcile () (defun ledger-reconcile ()
"Start reconciling, prompt for account." "Start reconciling, prompt for account."
@ -507,38 +507,38 @@ moved and recentered. If they aren't strange things happen."
(buf (current-buffer)) (buf (current-buffer))
(rbuf (get-buffer ledger-recon-buffer-name))) (rbuf (get-buffer ledger-recon-buffer-name)))
(when (ledger-reconcile-check-valid-account account) (when (ledger-reconcile-check-valid-account account)
(add-hook 'after-save-hook 'ledger-reconcile-refresh-after-save nil t) (add-hook 'after-save-hook 'ledger-reconcile-refresh-after-save nil t)
(if rbuf ;; *Reconcile* already exists (if rbuf ;; *Reconcile* already exists
(with-current-buffer rbuf (with-current-buffer rbuf
(set 'ledger-acct account) ;; already buffer local (set 'ledger-acct account) ;; already buffer local
(when (not (eq buf rbuf)) (when (not (eq buf rbuf))
;; called from some other ledger-mode buffer ;; called from some other ledger-mode buffer
(ledger-reconcile-quit-cleanup) (ledger-reconcile-quit-cleanup)
(setq ledger-buf buf)) ;; should already be buffer-local (setq ledger-buf buf)) ;; should already be buffer-local
(unless (get-buffer-window rbuf) (unless (get-buffer-window rbuf)
(ledger-reconcile-open-windows buf rbuf))) (ledger-reconcile-open-windows buf rbuf)))
;; no recon-buffer, starting from scratch. ;; no recon-buffer, starting from scratch.
(with-current-buffer (setq rbuf (with-current-buffer (setq rbuf
(get-buffer-create ledger-recon-buffer-name)) (get-buffer-create ledger-recon-buffer-name))
(ledger-reconcile-open-windows buf rbuf) (ledger-reconcile-open-windows buf rbuf)
(ledger-reconcile-mode) (ledger-reconcile-mode)
(make-local-variable 'ledger-target) (make-local-variable 'ledger-target)
(set (make-local-variable 'ledger-buf) buf) (set (make-local-variable 'ledger-buf) buf)
(set (make-local-variable 'ledger-acct) account))) (set (make-local-variable 'ledger-acct) account)))
;; Narrow the ledger buffer ;; Narrow the ledger buffer
(with-current-buffer rbuf (with-current-buffer rbuf
(save-excursion (save-excursion
(if ledger-narrow-on-reconcile (if ledger-narrow-on-reconcile
(ledger-occur account))) (ledger-occur account)))
(if (> (ledger-reconcile-refresh) 0) (if (> (ledger-reconcile-refresh) 0)
(ledger-reconcile-change-target)) (ledger-reconcile-change-target))
(ledger-display-balance))))) (ledger-display-balance)))))
(defvar ledger-reconcile-mode-abbrev-table) (defvar ledger-reconcile-mode-abbrev-table)
@ -549,7 +549,7 @@ moved and recentered. If they aren't strange things happen."
(defmacro ledger-reconcile-change-sort-key-and-refresh (sort-by) (defmacro ledger-reconcile-change-sort-key-and-refresh (sort-by)
"Set the sort-key to SORT-BY." "Set the sort-key to SORT-BY."
`(lambda () `(lambda ()
(interactive) (interactive)
(setq ledger-reconcile-sort-key ,sort-by) (setq ledger-reconcile-sort-key ,sort-by)

View file

@ -108,8 +108,8 @@
defs defs
(list (list
`(defmacro `(defmacro
,(intern (concat "ledger-regex-" (symbol-name name))) ,(intern (concat "ledger-regex-" (symbol-name name)))
(&optional string) (&optional string)
,(format "Return the match string for the %s" name) ,(format "Return the match string for the %s" name)
(match-string (match-string
,(intern (concat "ledger-regex-" (symbol-name name) ,(intern (concat "ledger-regex-" (symbol-name name)
@ -153,9 +153,9 @@
defs defs
(list (list
`(defmacro `(defmacro
,(intern (concat "ledger-regex-" (symbol-name name) ,(intern (concat "ledger-regex-" (symbol-name name)
"-" (symbol-name var))) "-" (symbol-name var)))
(&optional string) (&optional string)
,(format "Return the sub-group match for the %s %s." ,(format "Return the sub-group match for the %s %s."
name var) name var)
(match-string (match-string
@ -333,8 +333,8 @@
"\\)")) "\\)"))
(defconst ledger-xact-start-regex (defconst ledger-xact-start-regex
(concat "^" ledger-iso-date-regexp ;; subexp 1 (concat "^" ledger-iso-date-regexp ;; subexp 1
"\\(=" ledger-iso-date-regexp "\\)?" "\\(=" ledger-iso-date-regexp "\\)?"
)) ))
(defconst ledger-xact-after-date-regex (defconst ledger-xact-after-date-regex
@ -345,17 +345,17 @@
)) ))
(defconst ledger-posting-regex (defconst ledger-posting-regex
(concat "^[ \t]+ ?" ;; initial white space (concat "^[ \t]+ ?" ;; initial white space
"\\([*!]\\)? ?" ;; state, subexpr 1 "\\([*!]\\)? ?" ;; state, subexpr 1
"\\([[:print:]]+\\([ \t][ \t]\\)\\)" ;; account, subexpr 2 "\\([[:print:]]+\\([ \t][ \t]\\)\\)" ;; account, subexpr 2
"\\([^;\n]*\\)" ;; amount, subexpr 4 "\\([^;\n]*\\)" ;; amount, subexpr 4
"\\(.*\\)" ;; comment, subexpr 5 "\\(.*\\)" ;; comment, subexpr 5
)) ))
(defconst ledger-directive-start-regex (defconst ledger-directive-start-regex
"[=~;#%|\\*[A-Za-z]") "[=~;#%|\\*[A-Za-z]")
(provide 'ledger-regex) (provide 'ledger-regex)

View file

@ -57,7 +57,7 @@ specifier."
'(("ledger-file" . ledger-report-ledger-file-format-specifier) '(("ledger-file" . ledger-report-ledger-file-format-specifier)
("payee" . ledger-report-payee-format-specifier) ("payee" . ledger-report-payee-format-specifier)
("account" . ledger-report-account-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)) ("tagvalue" . ledger-report-tagvalue-format-specifier))
"An alist mapping ledger report format specifiers to implementing functions. "An alist mapping ledger report format specifiers to implementing functions.
@ -67,14 +67,14 @@ text that should replace the format specifier."
:group 'ledger-report) :group 'ledger-report)
(defcustom ledger-report-auto-refresh t (defcustom ledger-report-auto-refresh t
"If t then automatically rerun the report when the ledger buffer is saved." "If t then automatically rerun the report when the ledger buffer is saved."
:type 'boolean :type 'boolean
:group 'ledger-report) :group 'ledger-report)
(defcustom ledger-report-auto-refresh-sticky-cursor nil (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." "If t then try to place cursor at same relative position as it was before auto-refresh."
:type 'boolean :type 'boolean
:group 'ledger-report) :group 'ledger-report)
(defvar ledger-report-buffer-name "*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) (defvar ledger-report-cursor-line-number nil)
(defun ledger-report-reverse-report () (defun ledger-report-reverse-report ()
"Reverse the order of the report." "Reverse the order of the report."
(interactive) (interactive)
(ledger-report-reverse-lines) (ledger-report-reverse-lines)
(setq ledger-report-is-reversed (not ledger-report-is-reversed))) (setq ledger-report-is-reversed (not ledger-report-is-reversed)))
(defun ledger-report-reverse-lines () (defun ledger-report-reverse-lines ()
(goto-char (point-min)) (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-buf) buf)
(set (make-local-variable 'ledger-report-name) report-name) (set (make-local-variable 'ledger-report-name) report-name)
(set (make-local-variable 'ledger-original-window-cfg) wcfg) (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)) (ledger-do-report (ledger-report-cmd report-name edit))
(shrink-window-if-larger-than-buffer) (shrink-window-if-larger-than-buffer)
(set-buffer-modified-p nil) (set-buffer-modified-p nil)
@ -387,30 +387,30 @@ Optional EDIT the command."
(defun ledger-report-redo () (defun ledger-report-redo ()
"Redo the report in the current ledger report buffer." "Redo the report in the current ledger report buffer."
(interactive) (interactive)
(let ((cur-buf (current-buffer))) (let ((cur-buf (current-buffer)))
(if (and ledger-report-auto-refresh (if (and ledger-report-auto-refresh
(or (string= (format-mode-line 'mode-name) "Ledger") (or (string= (format-mode-line 'mode-name) "Ledger")
(string= (format-mode-line 'mode-name) "Ledger-Report")) (string= (format-mode-line 'mode-name) "Ledger-Report"))
(get-buffer ledger-report-buffer-name)) (get-buffer ledger-report-buffer-name))
(progn (progn
(pop-to-buffer (get-buffer ledger-report-buffer-name)) (pop-to-buffer (get-buffer ledger-report-buffer-name))
(shrink-window-if-larger-than-buffer) (shrink-window-if-larger-than-buffer)
(setq buffer-read-only nil) (setq buffer-read-only nil)
(setq ledger-report-cursor-line-number (line-number-at-pos)) (setq ledger-report-cursor-line-number (line-number-at-pos))
(erase-buffer) (erase-buffer)
(ledger-do-report ledger-report-cmd) (ledger-do-report ledger-report-cmd)
(setq buffer-read-only nil) (setq buffer-read-only nil)
(if ledger-report-is-reversed (ledger-report-reverse-lines)) (if ledger-report-is-reversed (ledger-report-reverse-lines))
(if ledger-report-auto-refresh-sticky-cursor (forward-line (- ledger-report-cursor-line-number 5))) (if ledger-report-auto-refresh-sticky-cursor (forward-line (- ledger-report-cursor-line-number 5)))
(pop-to-buffer cur-buf))))) (pop-to-buffer cur-buf)))))
(defun ledger-report-quit () (defun ledger-report-quit ()
"Quit the ledger report buffer." "Quit the ledger report buffer."
(interactive) (interactive)
(ledger-report-goto) (ledger-report-goto)
(set-window-configuration ledger-original-window-cfg) (set-window-configuration ledger-original-window-cfg)
(kill-buffer (get-buffer ledger-report-buffer-name))) (kill-buffer (get-buffer ledger-report-buffer-name)))
(defun ledger-report-edit-reports () (defun ledger-report-edit-reports ()
"Edit the defined ledger reports." "Edit the defined ledger reports."
@ -418,10 +418,10 @@ Optional EDIT the command."
(customize-variable 'ledger-reports)) (customize-variable 'ledger-reports))
(defun ledger-report-edit-report () (defun ledger-report-edit-report ()
(interactive) (interactive)
"Edit the current report command in the mini buffer and re-run the report" "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)) (setq ledger-report-cmd (ledger-report-read-command ledger-report-cmd))
(ledger-report-redo)) (ledger-report-redo))
(defun ledger-report-read-new-name () (defun ledger-report-read-new-name ()
"Read the name for a new report from the minibuffer." "Read the name for a new report from the minibuffer."

View file

@ -60,21 +60,21 @@
:group 'ledger-schedule) :group 'ledger-schedule)
(defcustom ledger-schedule-week-days '(("Mo" 1) (defcustom ledger-schedule-week-days '(("Mo" 1)
("Tu" 2) ("Tu" 2)
("We" 3) ("We" 3)
("Th" 4) ("Th" 4)
("Fr" 5) ("Fr" 5)
("Sa" 6) ("Sa" 6)
("Su" 7)) ("Su" 7))
"List of weekday abbreviations. There must be exactly seven "List of weekday abbreviations. There must be exactly seven
entries each with a two character abbreviation for a day and the entries each with a two character abbreviation for a day and the
number of that day in the week. " number of that day in the week. "
:type '(alist :value-type (group integer)) :type '(alist :value-type (group integer))
:group 'ledger-schedule) :group 'ledger-schedule)
(defsubst between (val low high) (defsubst between (val low high)
"Return TRUE if VAL > LOW and < HIGH." "Return TRUE if VAL > LOW and < HIGH."
(and (>= val low) (<= val high))) (and (>= val low) (<= val high)))
(defun ledger-schedule-days-in-month (month year) (defun ledger-schedule-days-in-month (month year)
"Return number of days in the MONTH, MONTH is from 1 to 12. "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))) (error "Month out of range, MONTH=%S" month)))
(defun ledger-schedule-encode-day-of-week (day-string) (defun ledger-schedule-encode-day-of-week (day-string)
"Return the numerical day of week corresponding to DAY-STRING." "Return the numerical day of week corresponding to DAY-STRING."
(cadr (assoc day-string ledger-schedule-week-days))) (cadr (assoc day-string ledger-schedule-week-days)))
;; Macros to handle date expressions ;; Macros to handle date expressions
@ -173,10 +173,10 @@ the transaction should be logged for that day."
xact-list))) xact-list)))
(defun ledger-schedule-read-descriptor-tree (descriptor-string) (defun ledger-schedule-read-descriptor-tree (descriptor-string)
"Read DESCRIPTOR-STRING and return a form that evaluates dates." "Read DESCRIPTOR-STRING and return a form that evaluates dates."
(ledger-schedule-transform-auto-tree (ledger-schedule-transform-auto-tree
(split-string (split-string
(substring descriptor-string 1 (string-match "]" descriptor-string)) " "))) (substring descriptor-string 1 (string-match "]" descriptor-string)) " ")))
(defun ledger-schedule-transform-auto-tree (descriptor-string-list) (defun ledger-schedule-transform-auto-tree (descriptor-string-list)
"Take DESCRIPTOR-STRING-LIST, and return a string with a lambda function of date." "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) (defun ledger-schedule-compile-constraints (descriptor-string)
"Return a list with the year, month and day fields split." "Return a list with the year, month and day fields split."
(let ((fields (split-string descriptor-string "[/\\-]" t))) (let ((fields (split-string descriptor-string "[/\\-]" t)))
(if (string-match "[A-Za-z]" descriptor-string) (if (string-match "[A-Za-z]" descriptor-string)
(ledger-schedule-constrain-day (nth 0 fields) (nth 1 fields) (nth 2 fields)) (ledger-schedule-constrain-day (nth 0 fields) (nth 1 fields) (nth 2 fields))
(list 'and (list 'and
(ledger-schedule-constrain-day (nth 0 fields) (nth 1 fields) (nth 2 fields)) (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-year (nth 0 fields) (nth 1 fields) (nth 2 fields))
(ledger-schedule-constrain-month (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) (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 YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the
date descriptor." date descriptor."
(cond ((string= year-desc "*") t) (cond ((string= year-desc "*") t)
((/= 0 (string-to-number year-desc)) ((/= 0 (string-to-number year-desc))
`(memq (nth 5 (decode-time date)) ',(mapcar 'string-to-number (split-string year-desc ",")))) `(memq (nth 5 (decode-time date)) ',(mapcar 'string-to-number (split-string year-desc ","))))
(t (t
(error "Improperly specified year constraint: %s %s %s" year-desc month-desc day-desc)))) (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) (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 YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the
date descriptor." date descriptor."
(cond ((string= month-desc "*") (cond ((string= month-desc "*")
t) ;; always match t) ;; always match
((string= month-desc "E") ;; Even ((string= month-desc "E") ;; Even
`(evenp (nth 4 (decode-time date)))) `(evenp (nth 4 (decode-time date))))
((string= month-desc "O") ;; Odd ((string= month-desc "O") ;; Odd
`(oddp (nth 4 (decode-time date)))) `(oddp (nth 4 (decode-time date))))
((/= 0 (string-to-number month-desc)) ;; Starts with number ((/= 0 (string-to-number month-desc)) ;; Starts with number
`(memq (nth 4 (decode-time date)) ',(mapcar 'string-to-number (split-string month-desc ",")))) `(memq (nth 4 (decode-time date)) ',(mapcar 'string-to-number (split-string month-desc ","))))
(t (t
(error "Improperly specified month constraint: %s %s %s" year-desc month-desc day-desc)))) (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) (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 YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the
date descriptor." date descriptor."
(cond ((string= day-desc "*") (cond ((string= day-desc "*")
t) t)
((string-match "[A-Za-z]" day-desc) ;; There is something other than digits and commas ((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)) (ledger-schedule-parse-complex-date year-desc month-desc day-desc))
((/= 0 (string-to-number day-desc)) ((/= 0 (string-to-number day-desc))
`(memq (nth 3 (decode-time date)) ',(mapcar 'string-to-number (split-string day-desc ",")))) `(memq (nth 3 (decode-time date)) ',(mapcar 'string-to-number (split-string day-desc ","))))
(t (t
(error "Improperly specified day constraint: %s %s %s" year-desc month-desc day-desc)))) (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) (defun ledger-schedule-parse-complex-date (year-desc month-desc day-desc)
"Parse day descriptors that have repeats." "Parse day descriptors that have repeats."
(let ((years (mapcar 'string-to-number (split-string year-desc ","))) (let ((years (mapcar 'string-to-number (split-string year-desc ",")))
(months (mapcar 'string-to-number (split-string month-desc ","))) (months (mapcar 'string-to-number (split-string month-desc ",")))
(day-parts (split-string day-desc "+")) (day-parts (split-string day-desc "+"))
(every-nth (string-match "+" day-desc))) (every-nth (string-match "+" day-desc)))
(if every-nth (if every-nth
(let ((base-day (string-to-number (car day-parts))) (let ((base-day (string-to-number (car day-parts)))
(increment (string-to-number (substring (cadr day-parts) 0 (increment (string-to-number (substring (cadr day-parts) 0
(string-match "[A-Za-z]" (cadr day-parts))))) (string-match "[A-Za-z]" (cadr day-parts)))))
(day-of-week (ledger-schedule-encode-day-of-week (day-of-week (ledger-schedule-encode-day-of-week
(substring (cadr day-parts) (string-match "[A-Za-z]" (cadr day-parts)))))) (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)))) (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))) (let ((count (string-to-number (substring (car day-parts) 0 1)))
(day-of-week (ledger-schedule-encode-day-of-week (day-of-week (ledger-schedule-encode-day-of-week
(substring (car day-parts) (string-match "[A-Za-z]" (car day-parts)))))) (substring (car day-parts) (string-match "[A-Za-z]" (car day-parts))))))
(ledger-schedule-constrain-day-in-month count day-of-week))))) (ledger-schedule-constrain-day-in-month count day-of-week)))))
(defun ledger-schedule-list-upcoming-xacts (candidate-items early horizon) (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." "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))) (let ((start-date (time-subtract (current-time) (days-to-time early)))
test-date items) test-date items)
(loop for day from 0 to (+ early horizon) by 1 do (loop for day from 0 to (+ early horizon) by 1 do
(setq test-date (time-add start-date (days-to-time day))) (setq test-date (time-add start-date (days-to-time day)))
(dolist (candidate candidate-items items) (dolist (candidate candidate-items items)
(if (funcall (car candidate) test-date) (if (funcall (car candidate) test-date)
(setq items (append items (list (list test-date (cadr candidate)))))))) (setq items (append items (list (list test-date (cadr candidate))))))))
items)) items))
(defun ledger-schedule-create-auto-buffer (candidate-items early horizon ledger-buf) (defun ledger-schedule-create-auto-buffer (candidate-items early horizon ledger-buf)
"Format CANDIDATE-ITEMS for display." "Format CANDIDATE-ITEMS for display."
@ -290,7 +290,7 @@ date descriptor."
(with-current-buffer schedule-buf (with-current-buffer schedule-buf
(erase-buffer) (erase-buffer)
(dolist (candidate candidates) (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)) (ledger-mode))
(length candidates))) (length candidates)))
@ -311,15 +311,15 @@ Use a prefix arg to change the default value"
(read-number "Look forward: " ledger-schedule-look-forward)) (read-number "Look forward: " ledger-schedule-look-forward))
(list ledger-schedule-file ledger-schedule-look-backward ledger-schedule-look-forward))) (list ledger-schedule-file ledger-schedule-look-backward ledger-schedule-look-forward)))
(if (and file (if (and file
(file-exists-p file)) (file-exists-p file))
(progn (progn
(ledger-schedule-create-auto-buffer (ledger-schedule-create-auto-buffer
(ledger-schedule-scan-transactions file) (ledger-schedule-scan-transactions file)
look-backward look-backward
look-forward look-forward
(current-buffer)) (current-buffer))
(pop-to-buffer ledger-schedule-buffer-name)) (pop-to-buffer ledger-schedule-buffer-name))
(error "Could not find ledger schedule file at %s" file))) (error "Could not find ledger schedule file at %s" file)))
(provide 'ledger-schedule) (provide 'ledger-schedule)

View file

@ -28,17 +28,17 @@
(defun ledger-sort-find-start () (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) (if (re-search-forward ";.*Ledger-mode:.*Start sort" nil t)
(match-end 0))) (match-end 0)))
(defun ledger-sort-find-end () (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) (if (re-search-forward ";.*Ledger-mode:.*End sort" nil t)
(match-end 0))) (match-end 0)))
(defun ledger-sort-insert-start-mark () (defun ledger-sort-insert-start-mark ()
"Insert a marker to start a sort region" "Insert a marker to start a sort region"
(interactive) (interactive)
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
@ -48,7 +48,7 @@
(insert "\n; Ledger-mode: Start sort\n\n")) (insert "\n; Ledger-mode: Start sort\n\n"))
(defun ledger-sort-insert-end-mark () (defun ledger-sort-insert-end-mark ()
"Insert a marker to end a sort region" "Insert a marker to end a sort region"
(interactive) (interactive)
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
@ -64,7 +64,7 @@
(defun ledger-sort-region (beg end) (defun ledger-sort-region (beg end)
"Sort the region from BEG to END in chronological order." "Sort the region from BEG to END in chronological order."
(interactive "r") ;; load beg and end from point and mark (interactive "r") ;; load beg and end from point and mark
;; automagically ;; automagically
(let ((new-beg beg) (let ((new-beg beg)
(new-end end) (new-end end)
point-delta point-delta
@ -77,14 +77,14 @@
(save-excursion (save-excursion
(save-restriction (save-restriction
(goto-char beg) (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) (ledger-navigate-next-xact)
(unless (looking-at ledger-payee-any-status-regex) (unless (looking-at ledger-payee-any-status-regex)
(ledger-navigate-next-xact)) (ledger-navigate-next-xact))
(setq new-beg (point)) (setq new-beg (point))
(goto-char end) (goto-char end)
(ledger-navigate-next-xact) (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 ;; after the region
(setq new-end (point)) (setq new-end (point))
(narrow-to-region new-beg new-end) (narrow-to-region new-beg new-end)

View file

@ -114,8 +114,8 @@ dropped."
(when (not (eq (ledger-state-from-char (char-after)) 'comment)) (when (not (eq (ledger-state-from-char (char-after)) 'comment))
(insert (ledger-char-from-state cur-status) " ") (insert (ledger-char-from-state cur-status) " ")
(if (and (search-forward " " (line-end-position) t) (if (and (search-forward " " (line-end-position) t)
(looking-at " ")) (looking-at " "))
(delete-char 2))) (delete-char 2)))
(forward-line)) (forward-line))
(setq new-status nil))) (setq new-status nil)))

View file

@ -185,8 +185,8 @@ correct chronological place in the buffer."
(goto-char (point-min)) (goto-char (point-min))
(if (looking-at "Error: ") (if (looking-at "Error: ")
(error (concat "Error in ledger-add-transaction: " (buffer-string))) (error (concat "Error in ledger-add-transaction: " (buffer-string)))
(ledger-post-align-postings (point-min) (point-max)) (ledger-post-align-postings (point-min) (point-max))
(buffer-string))) (buffer-string)))
"\n")) "\n"))
(progn (progn
(insert (car args) " \n\n") (insert (car args) " \n\n")

View file

@ -28,7 +28,6 @@ set(LEDGER_SOURCES
textual.cc textual.cc
temps.cc temps.cc
journal.cc journal.cc
archive.cc
account.cc account.cc
xact.cc xact.cc
post.cc post.cc
@ -80,7 +79,6 @@ set(LEDGER_INCLUDES
account.h account.h
amount.h amount.h
annotate.h annotate.h
archive.h
balance.h balance.h
chain.h chain.h
commodity.h commodity.h

View file

@ -289,26 +289,6 @@ public:
} }
bool children_with_xdata() const; bool children_with_xdata() const;
std::size_t children_with_flags(xdata_t::flags_t flags) 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<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<supports_flags<> >(*this);
ar & boost::serialization::base_object<scope_t>(*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); std::ostream& operator<<(std::ostream& out, const account_t& account);

View file

@ -93,20 +93,6 @@ struct amount_t::bigint_t : public supports_flags<>
} }
return true; return true;
} }
#if HAVE_BOOST_SERIALIZATION
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */)
{
ar & boost::serialization::base_object<supports_flags<> >(*this);
ar & val;
ar & prec;
ar & refc;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
bool amount_t::is_initialized = false; 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()); st.put("quantity", amt.quantity_string());
} }
#if HAVE_BOOST_SERIALIZATION
template<class Archive>
void amount_t::serialize(Archive& ar, const unsigned int /* version */)
{
ar & is_initialized;
ar & quantity;
ar & commodity_;
}
#endif // HAVE_BOOST_SERIALIZATION
} // namespace ledger } // namespace ledger
#if HAVE_BOOST_SERIALIZATION
namespace boost {
namespace serialization {
template <class Archive>
void serialize(Archive& ar, MP_INT& mpz, const unsigned int /* version */)
{
ar & mpz._mp_alloc;
ar & mpz._mp_size;
ar & mpz._mp_d;
}
template <class Archive>
void serialize(Archive& ar, MP_RAT& mpq, const unsigned int /* version */)
{
ar & mpq._mp_num;
ar & mpq._mp_den;
}
template <class Archive>
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

View file

@ -743,16 +743,6 @@ public:
bool valid() const; bool valid() const;
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */);
#endif // HAVE_BOOST_SERIALIZATION
/*@}*/ /*@}*/
}; };

View file

@ -107,21 +107,6 @@ struct annotation_t : public supports_flags<>,
assert(*this); assert(*this);
return true; return true;
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<supports_flags<> >(*this);
ar & price;
ar & date;
ar & tag;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
void put_annotation(property_tree::ptree& pt, const annotation_t& details); 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; return keep_price || keep_date || keep_tag;
} }
bool keep_any(const commodity_t& comm) const; bool keep_any(const commodity_t& comm) const;
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
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, inline std::ostream& operator<<(std::ostream& out,
@ -250,24 +220,6 @@ public:
virtual void write_annotations(std::ostream& out, virtual void write_annotations(std::ostream& out,
bool no_computed_annotations = false) const; 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<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<commodity_t>(*this);
ar & ptr;
ar & details;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
inline annotated_commodity_t& inline annotated_commodity_t&

View file

@ -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 <system.hh>
#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<char *>(&bytes), sizeof(uint32_t));
if (bytes != LEDGER_MAGIC) {
DEBUG("archive.journal", "Magic bytes not present");
return false;
}
in.read(reinterpret_cast<char *>(&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<char *>(&bytes), sizeof(uint32_t));
bytes = ARCHIVE_VERSION;
out.write(reinterpret_cast<char *>(&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<path>& 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<path> 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

View file

@ -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<journal_t::fileinfo_t> 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<path>& 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<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & sources;
}
#endif // HAVE_BOOST_SERIALIZATION
};
} // namespace ledger
#endif // _ARCHIVE_H

View file

@ -594,18 +594,6 @@ public:
} }
return true; return true;
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
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) { inline std::ostream& operator<<(std::ostream& out, const balance_t& bal) {

View file

@ -68,19 +68,6 @@ struct price_point_t
bool operator==(const price_point_t& other) const { bool operator==(const price_point_t& other) const {
return when == other.when && price == other.price; return when == other.when && price == other.price;
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & when;
ar & price;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
class commodity_t class commodity_t
@ -138,28 +125,6 @@ protected:
virtual ~base_t() { virtual ~base_t() {
TRACE_DTOR(commodity_t::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<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<supports_flags<uint_least16_t> >(*this);
ar & symbol;
ar & precision;
ar & name;
ar & note;
ar & smaller;
ar & larger;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
shared_ptr<base_t> base; shared_ptr<base_t> base;
@ -315,32 +280,6 @@ public:
struct compare_by_commodity { struct compare_by_commodity {
bool operator()(const amount_t * left, const amount_t * right) const; bool operator()(const amount_t * left, const amount_t * right) const;
}; };
#if HAVE_BOOST_SERIALIZATION
private:
supports_flags<uint_least16_t> temp_flags;
protected:
explicit commodity_t()
: delegates_flags<uint_least16_t>(temp_flags), parent_(NULL),
annotated(false) {
TRACE_CTOR(commodity_t, "");
}
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<delegates_flags<uint_least16_t> >(*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) { inline std::ostream& operator<<(std::ostream& out, const commodity_t& comm) {

View file

@ -106,19 +106,6 @@ public:
virtual string context_to_str() const; virtual string context_to_str() const;
virtual void print(std::ostream& out) const; virtual void print(std::ostream& out) const;
virtual void dump(std::ostream& out) const; virtual void dump(std::ostream& out) const;
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<base_type>(*this);
ar & ptr;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
/** /**

View file

@ -231,21 +231,6 @@ public:
out << std::endl << _("--- Result value ---") << std::endl; out << std::endl << _("--- Result value ---") << std::endl;
return calc(); return calc();
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & context;
ar & str;
if (Archive::is_loading::value)
compiled = false;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
template <typename ResultType> template <typename ResultType>

View file

@ -90,17 +90,6 @@ public:
void drop_flags(const flags_t arg) { void drop_flags(const flags_t arg) {
_flags = static_cast<T>(static_cast<U>(_flags) & static_cast<U>(~arg)); _flags = static_cast<T>(static_cast<U>(_flags) & static_cast<U>(~arg));
} }
#if HAVE_BOOST_SERIALIZATION
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */)
{
ar & _flags;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
template <typename T = boost::uint_least8_t, typename U = T> template <typename T = boost::uint_least8_t, typename U = T>
@ -193,17 +182,6 @@ public:
void drop_flags(const flags_t arg) { void drop_flags(const flags_t arg) {
_flags.drop_flags(arg); _flags.drop_flags(arg);
} }
#if HAVE_BOOST_SERIALIZATION
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */)
{
ar & _flags;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
#endif // _FLAGS_H #endif // _FLAGS_H

View file

@ -316,9 +316,6 @@ option_t<global_scope_t> * global_scope_t::lookup_option(const char * p)
case 'd': case 'd':
OPT(debug_); OPT(debug_);
break; break;
case 'f':
OPT(full_help);
break;
case 'h': case 'h':
OPT_(help); OPT_(help);
break; break;

View file

@ -147,7 +147,6 @@ See LICENSE file included with the distribution for details and disclaimer.");
void visit_man_page() const; 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_(global_scope_t, help, DO() { parent->visit_man_page(); }); // -h
OPTION__ OPTION__

View file

@ -78,23 +78,6 @@ struct position_t
} }
return *this; return *this;
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
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<uint_least16_t>, public scope_t class item_t : public supports_flags<uint_least16_t>, public scope_t
@ -226,25 +209,6 @@ public:
const string& name); const string& name);
bool valid() const; bool valid() const;
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<supports_flags<uint_least16_t> >(*this);
ar & boost::serialization::base_object<scope_t>(*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); value_t get_comment(item_t& item);

View file

@ -100,21 +100,6 @@ public:
~fileinfo_t() throw() { ~fileinfo_t() throw() {
TRACE_DTOR(journal_t::fileinfo_t); TRACE_DTOR(journal_t::fileinfo_t);
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & filename;
ar & size;
ar & modtime;
ar & from_stream;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
account_t * master; account_t * master;
@ -215,26 +200,6 @@ public:
private: private:
std::size_t read_textual(parse_context_stack_t& context); std::size_t read_textual(parse_context_stack_t& context);
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
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 } // namespace ledger

View file

@ -54,7 +54,7 @@ namespace {
struct usage_sorter { struct usage_sorter {
bool operator()(const account_use_pair& left, bool operator()(const account_use_pair& left,
const account_use_pair& right) const { const account_use_pair& right) const {
return left.second > right.second; return left.second < right.second;
} }
}; };
} }

View file

@ -124,25 +124,6 @@ public:
} }
return true; return true;
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
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) { inline std::ostream& operator<<(std::ostream& out, const mask_t& mask) {

View file

@ -314,33 +314,6 @@ private:
value_t calc_call(scope_t& scope, ptr_op_t * locus, const int depth); 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_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); 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<class Archive>
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<ptr_op_t, value_t, string, expr_t::func_t> temp_data;
ar & temp_data;
}
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
inline expr_t::ptr_op_t inline expr_t::ptr_op_t

View file

@ -132,26 +132,6 @@ public:
parse_price_expression(const std::string& str, parse_price_expression(const std::string& str,
const bool add_prices = true, const bool add_prices = true,
const optional<datetime_t>& moment = none); const optional<datetime_t>& moment = none);
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
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 } // namespace ledger

View file

@ -255,24 +255,6 @@ public:
} }
} }
}; };
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<item_t>(*this);
ar & xact;
ar & account;
ar & amount;
ar & amount_expr;
ar & cost;
ar & assigned_amount;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
class journal_t; class journal_t;

View file

@ -90,19 +90,6 @@ public:
.to_boolean() : .to_boolean() :
true); true);
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<expr_t>(*this);
ar & what_to_keep;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
} // namespace ledger } // namespace ledger

View file

@ -496,7 +496,7 @@ public:
"%-(ansify_if(partial_account(options.flat), blue if color))\n%/" "%-(ansify_if(partial_account(options.flat), blue if color))\n%/"
"%$1 %$2 %$3\n%/" "%$1 %$2 %$3\n%/"
"%(prepend_width ? \" \" * int(prepend_width) : \"\")" "%(prepend_width ? \" \" * int(prepend_width) : \"\")"
"---------------- ---------------- ---------\n"); "---------------- ---------------- ---------\n");
}); });
OPTION(report_t, color); OPTION(report_t, color);

View file

@ -83,20 +83,6 @@ struct symbol_t
bool operator==(const symbol_t& sym) const { bool operator==(const symbol_t& sym) const {
return kind == sym.kind || name == sym.name; return kind == sym.kind || name == sym.name;
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & kind;
ar & name;
ar & definition;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
class empty_scope_t; class empty_scope_t;
@ -127,16 +113,6 @@ public:
virtual bool type_required() const { virtual bool type_required() const {
return false; return false;
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive&, const unsigned int /* version */) {}
#endif // HAVE_BOOST_SERIALIZATION
}; };
class empty_scope_t : public scope_t class empty_scope_t : public scope_t
@ -184,19 +160,6 @@ public:
return parent->lookup(kind, name); return parent->lookup(kind, name);
return NULL; return NULL;
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<scope_t>(*this);
ar & parent;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
class bind_scope_t : public child_scope_t class bind_scope_t : public child_scope_t
@ -233,19 +196,6 @@ public:
return def; return def;
return child_scope_t::lookup(kind, name); return child_scope_t::lookup(kind, name);
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<child_scope_t>(*this);
ar & grandchild;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
template <typename T> template <typename T>
@ -323,19 +273,6 @@ public:
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind, virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
const string& name); const string& name);
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<child_scope_t>(*this);
ar & symbols;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
class context_scope_t : public child_scope_t class context_scope_t : public child_scope_t
@ -365,24 +302,6 @@ public:
virtual bool type_required() const { virtual bool type_required() const {
return required; return required;
} }
#if HAVE_BOOST_SERIALIZATION
protected:
explicit context_scope_t() {
TRACE_CTOR(context_scope_t, "");
}
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<child_scope_t>(*this);
ar & value_type_context;
ar & required;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
class call_scope_t : public context_scope_t class call_scope_t : public context_scope_t
@ -480,24 +399,6 @@ public:
bool empty() const { bool empty() const {
return args.size() == 0; 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<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<context_scope_t>(*this);
ar & args;
//ar & ptr;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
template <> template <>

View file

@ -37,7 +37,6 @@
#include "journal.h" #include "journal.h"
#include "iterators.h" #include "iterators.h"
#include "filters.h" #include "filters.h"
#include "archive.h"
namespace ledger { namespace ledger {
@ -128,16 +127,6 @@ std::size_t session_t::read_data(const string& master_account)
if (HANDLED(value_expr_)) if (HANDLED(value_expr_))
journal->value_expr = HANDLER(value_expr_).str(); journal->value_expr = HANDLER(value_expr_).str();
#if HAVE_BOOST_SERIALIZATION
optional<archive_t> 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 (price_db_path) {
if (exists(*price_db_path)) { if (exists(*price_db_path)) {
parsing_context.push(*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() << "]"); << "] == journal->xacts.size() [" << journal->xacts.size() << "]");
assert(xact_count == 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) if (populated_data_files)
HANDLER(file_).data_files.clear(); HANDLER(file_).data_files.clear();
@ -333,8 +316,7 @@ option_t<session_t> * session_t::lookup_option(const char * p)
OPT_CH(price_exp_); OPT_CH(price_exp_);
break; break;
case 'c': case 'c':
OPT(cache_); OPT(check_payees);
else OPT(check_payees);
break; break;
case 'd': case 'd':
OPT(download); // -Q OPT(download); // -Q

View file

@ -97,7 +97,6 @@ public:
void report_options(std::ostream& out) void report_options(std::ostream& out)
{ {
HANDLER(cache_).report(out);
HANDLER(check_payees).report(out); HANDLER(check_payees).report(out);
HANDLER(day_break).report(out); HANDLER(day_break).report(out);
HANDLER(download).report(out); HANDLER(download).report(out);
@ -126,7 +125,6 @@ public:
* Option handlers * Option handlers
*/ */
OPTION(session_t, cache_);
OPTION(session_t, check_payees); OPTION(session_t, check_payees);
OPTION(session_t, day_break); OPTION(session_t, day_break);
OPTION(session_t, download); // -Q OPTION(session_t, download); // -Q

View file

@ -71,7 +71,6 @@
#define HAVE_BOOST_PYTHON @HAVE_BOOST_PYTHON@ #define HAVE_BOOST_PYTHON @HAVE_BOOST_PYTHON@
#define HAVE_BOOST_REGEX_UNICODE @HAVE_BOOST_REGEX_UNICODE@ #define HAVE_BOOST_REGEX_UNICODE @HAVE_BOOST_REGEX_UNICODE@
#define HAVE_BOOST_SERIALIZATION 0
#define DEBUG_MODE @DEBUG_MODE@ #define DEBUG_MODE @DEBUG_MODE@
#define NO_ASSERTS @NO_ASSERTS@ #define NO_ASSERTS @NO_ASSERTS@
@ -239,86 +238,8 @@ typedef std::ostream::pos_type ostream_pos_type;
#endif #endif
#define _f(str) boost::format(_(str)) #define _f(str) boost::format(_(str))
#if HAVE_BOOST_SERIALIZATION
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/binary_object.hpp>
#include <boost/serialization/optional.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/variant.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/export.hpp>
#include <boost/serialization/level.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/deque.hpp>
#include <boost/serialization/list.hpp>
#include <boost/serialization/map.hpp>
#include <boost/date_time/posix_time/time_serialize.hpp>
#include <boost/date_time/gregorian/greg_serialize.hpp>
#include <boost/ptr_container/serialize_ptr_deque.hpp>
namespace boost {
namespace serialization {
template <class Archive>
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 <class Archive, class T>
void serialize(Archive& ar, boost::intrusive_ptr<T>& 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 <class Archive>
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 <class Archive>
void serialize(Archive&, boost::blank&, const unsigned int) {}
template <class Archive, class T>
void serialize(Archive&, boost::function<T>&, const unsigned int) {}
template <class Archive>
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 <boost/ptr_container/ptr_deque.hpp> #include <boost/ptr_container/ptr_deque.hpp>
#endif // HAVE_BOOST_SERIALIZATION
#if HAVE_BOOST_PYTHON #if HAVE_BOOST_PYTHON
#include <boost/python.hpp> #include <boost/python.hpp>

View file

@ -153,20 +153,6 @@ struct date_traits_t
has_month == traits.has_month && has_month == traits.has_month &&
has_day == traits.has_day); has_day == traits.has_day);
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
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 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); 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<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & quantum;
ar & length;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
class date_specifier_t class date_specifier_t
@ -343,21 +316,6 @@ public:
return out.str(); return out.str();
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & year;
ar & month;
ar & day;
ar & wday;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
class date_range_t class date_range_t
@ -420,20 +378,6 @@ public:
return out.str(); return out.str();
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
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 class date_specifier_or_range_t
@ -490,18 +434,6 @@ public:
return out.str(); return out.str();
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & specifier_or_range;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
class date_interval_t : public equality_comparable<date_interval_t> class date_interval_t : public equality_comparable<date_interval_t>
@ -594,24 +526,6 @@ public:
date_interval_t& operator++(); date_interval_t& operator++();
void dump(std::ostream& out); void dump(std::ostream& out);
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
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(); void times_initialize();

View file

@ -227,20 +227,6 @@ public:
data = false; data = false;
type = VOID; type = VOID;
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & data;
ar & type;
ar & refc;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
private: private:
@ -965,20 +951,6 @@ public:
* Debugging methods. * Debugging methods.
*/ */
bool valid() const; bool valid() const;
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
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()) #define NULL_VALUE (value_t())

View file

@ -87,20 +87,6 @@ public:
virtual bool valid() const { virtual bool valid() const {
return true; return true;
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<item_t>(*this);
ar & journal;
ar & posts;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
class xact_t : public xact_base_t class xact_t : public xact_base_t
@ -142,20 +128,6 @@ public:
const string& name); const string& name);
virtual bool valid() const; virtual bool valid() const;
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<xact_base_t>(*this);
ar & code;
ar & payee;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
class auto_xact_t : public xact_base_t class auto_xact_t : public xact_base_t
@ -176,21 +148,6 @@ public:
bool _overwrite_existing) bool _overwrite_existing)
: tag_data(_tag_data), overwrite_existing(_overwrite_existing), : tag_data(_tag_data), overwrite_existing(_overwrite_existing),
apply_to_post(NULL) {} apply_to_post(NULL) {}
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
deferred_tag_data_t() : apply_to_post(NULL) {}
friend class boost::serialization::access;
template<class Archive>
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_tag_data_t> deferred_notes_list; typedef std::list<deferred_tag_data_t> deferred_notes_list;
@ -236,21 +193,6 @@ private:
} }
virtual void extend_xact(xact_base_t& xact, parse_context_t& context); virtual void extend_xact(xact_base_t& xact, parse_context_t& context);
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<xact_base_t>(*this);
ar & predicate;
ar & check_exprs;
ar & deferred_notes;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
class period_xact_t : public xact_base_t 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")); return string(_("generated periodic transaction"));
} }
} }
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */) {
ar & boost::serialization::base_object<xact_base_t>(*this);
ar & period;
ar & period_string;
}
#endif // HAVE_BOOST_SERIALIZATION
}; };
typedef std::list<xact_t *> xacts_list; typedef std::list<xact_t *> xacts_list;

View file

@ -21,25 +21,18 @@ class CheckBaselineTests (CheckOptions):
self.untested_options = [ self.untested_options = [
'anon', 'anon',
'args-only', 'args-only',
'cache',
'debug', 'debug',
'download', 'download',
'file', 'file',
'force-color', 'force-color',
'force-pager', 'force-pager',
'full-help',
'help', 'help',
'help-calc',
'help-comm',
'help-disp',
'import', 'import',
'init-file',
'no-color', 'no-color',
'no-pager'
'options', 'options',
'price-db',
'price-exp', 'price-exp',
'revalued-total', 'revalued-total',
'script',
'seed', 'seed',
'trace', 'trace',
'verbose', 'verbose',

View file

@ -19,13 +19,17 @@ class DocTests:
self.verbose = args.verbose self.verbose = args.verbose
self.tests = args.examples self.tests = args.examples
self.examples = dict() self.examples = dict()
self.test_files = list() self.test_files = list()
self.testin_token = 'command' self.testin_token = 'command'
self.testout_token = 'output' self.testout_token = 'output'
self.testdat_token = 'input' self.testdat_token = 'input'
self.testfile_token = 'file'
self.validate_token = 'validate' 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'
self.testwithfile_token = 'with_file'
def read_example(self): def read_example(self):
endexample = re.compile(r'^@end\s+smallexample\s*$') endexample = re.compile(r'^@end\s+smallexample\s*$')
@ -35,15 +39,15 @@ class DocTests:
self.current_line += 1 self.current_line += 1
if len(line) <= 0 or endexample.match(line): break if len(line) <= 0 or endexample.match(line): break
# Replace special texinfo character sequences with their ASCII counterpart # Replace special texinfo character sequences with their ASCII counterpart
example += line.replace("@@","@").replace("@{","{").replace("@}","}") example += re.sub(r'@([@{}])', r'\1', line)
return example return example
def test_id(self, example): def test_id(self, example):
return hashlib.sha1(example.rstrip()).hexdigest()[0:7].upper() return hashlib.sha1(example.rstrip()).hexdigest()[0:7].upper()
def find_examples(self): def find_examples(self):
startexample = re.compile(r'^@smallexample\s+@c\s+(%s|%s|%s)(?::([\dA-Fa-f]+|validate))?(?:,(.*))?' 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.testin_token, self.testout_token, self.testdat_token, self.testfile_token))
while True: while True:
line = self.file.readline() line = self.file.readline()
self.current_line += 1 self.current_line += 1
@ -78,9 +82,9 @@ class DocTests:
if test_id == self.validate_token: if test_id == self.validate_token:
test_id = "Val-" + str(test_begin_line) test_id = "Val-" + str(test_begin_line)
if test_kind == self.testin_token: if test_kind == self.testin_token:
test_kind = "validate-command" test_kind = self.validate_cmd_token
elif test_kind == self.testdat_token: elif test_kind == self.testdat_token:
test_kind = "validate-data" test_kind = self.validate_dat_token
try: try:
self.examples[test_id] self.examples[test_id]
except KeyError: except KeyError:
@ -105,15 +109,15 @@ class DocTests:
try: try:
command = example[self.testin_token][self.testin_token] command = example[self.testin_token][self.testin_token]
except KeyError: except KeyError:
if 'validate-data' in example: if self.validate_dat_token in example:
command = '$ ledger bal' command = '$ ledger bal'
elif 'validate-command' in example: elif self.validate_cmd_token in example:
validate_command = True validate_command = True
command = example['validate-command']['validate-command'] command = example[self.validate_cmd_token][self.validate_cmd_token]
else: else:
return None return None
command = shlex.split(command) command = filter(lambda x: x != '\n', shlex.split(command))
if command[0] == '$': command.remove('$') if command[0] == '$': command.remove('$')
index = command.index('ledger') index = command.index('ledger')
command[index] = self.ledger command[index] = self.ledger
@ -145,7 +149,7 @@ class DocTests:
for test_id in tests: for test_id in tests:
validation = False 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 validation = True
example = self.examples[test_id] example = self.examples[test_id]
try: try:
@ -154,51 +158,52 @@ class DocTests:
failed.add(test_id) failed.add(test_id)
continue continue
try: output = example.get(self.testout_token, {}).get(self.testout_token)
output = example[self.testout_token][self.testout_token] input = example.get(self.testdat_token, {}).get(self.testdat_token)
except KeyError: if not input:
output = None 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)
try: if command and (output != None or validation):
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['validate-data']['validate-data']
except KeyError:
input = None
if command and (output or validation):
test_file_created = False test_file_created = False
if findex: if findex:
scriptpath = os.path.dirname(os.path.realpath(__file__)) 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] test_file = command[findex]
if not os.path.exists(test_file): if not os.path.exists(test_file):
if input: if input:
test_file_created = True test_file_created = True
with open(test_file, 'w') as f: with open(test_file, 'w') as f:
f.write(input) f.write(input)
elif os.path.exists(test_input_dir + test_file): elif os.path.exists(os.path.join(test_input_dir, test_file)):
command[findex] = test_input_dir + test_file command[findex] = os.path.join(test_input_dir, test_file)
error = False 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: try:
verify = subprocess.check_output(command, stderr=subprocess.STDOUT) verify = subprocess.check_output(command, stderr=subprocess.STDOUT)
except: valid = (output == verify) or (not error and validation)
verify = str() except subprocess.CalledProcessError, e:
error = True error = e.output
valid = (output == verify) or (not error and validation) valid = False
failed.add(test_id)
if valid and test_file_created: if valid and test_file_created:
os.remove(test_file) os.remove(test_file)
if self.verbose > 0: 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: else:
sys.stdout.write('.' if valid else 'E') sys.stdout.write('.' if valid else 'E')
if not valid: if not (valid or error):
failed.add(test_id) failed.add(test_id)
if self.verbose > 1: if self.verbose > 1:
print ' '.join(command) print ' '.join(command)
@ -206,6 +211,12 @@ class DocTests:
for line in unified_diff(output.split('\n'), verify.split('\n'), fromfile='generated', tofile='expected'): for line in unified_diff(output.split('\n'), verify.split('\n'), fromfile='generated', tofile='expected'):
print(line) print(line)
print print
else:
if self.verbose > 0:
print test_id, ':', 'Skipped'
else:
sys.stdout.write('X')
if not self.verbose: if not self.verbose:
print print
if len(failed) > 0: if len(failed) > 0:

View file

@ -30,7 +30,7 @@ test cleared
-20 0 F -20 0 F
-30 -30 12-Feb-26 G -30 -30 12-Feb-26 G
-40 0 H -40 0 H
---------------- ---------------- --------- ---------------- ---------------- ---------
0 0 0 0
end test end test

View file

@ -14,17 +14,58 @@
Expenses:Food 20.00 EUR Expenses:Food 20.00 EUR
Liabilities:CC -20.00 EUR Liabilities:CC -20.00 EUR
test --input-date-format "%Y-%m-%d" --auto-match convert test/baseline/opt-auto-match.dat test --input-date-format "%Y-%m-%d" convert test/baseline/opt-auto-match.dat
2012/03/01 * Food 2012/03/01 * Food
Assets:Cash 10 Expenses:Unknown 10
Equity:Unknown Equity:Unknown
2012/03/02 * Phone 2012/03/02 * Phone
Assets:Cash 10 Expenses:Unknown 10
Equity:Unknown Equity:Unknown
2012/03/02 * Dining 2012/03/02 * Dining
Liabilities:CC 10 Expenses:Unknown 10
Equity:Unknown Equity:Unknown
end test end test
test --input-date-format "%Y-%m-%d" --auto-match convert test/baseline/opt-auto-match.dat
2012/03/01 * Food
Expenses:Food 10
Equity:Unknown
2012/03/02 * Phone
Expenses:Phone 10
Equity:Unknown
2012/03/02 * Dining
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

View file

@ -0,0 +1 @@
--decimal-comma

View file

@ -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

View file

@ -0,0 +1,2 @@
P 2012-03-16 06:47:12 CAD $2.50
P 2012-03-17 06:47:12 CAD $3.50

View file

@ -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

View file

@ -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' test -f /dev/null convert test/baseline/feat-convert-with-directives.dat --detail --now '2014/08/01'
2012/01/01 * KFC 2012/01/01 * KFC
; CSV: 2012/01/01,KFC,$10 ; CSV: 2012/01/01,KFC,$10

View file

@ -0,0 +1,3 @@
--no-pager --columns=80 bal
--no-pager --columns=80 reg
--no-pager --columns=80 print

View file

@ -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

View file

@ -5,17 +5,17 @@
# Add [ci skip] to the commit message unless there are changes to files # Add [ci skip] to the commit message unless there are changes to files
# that are relevant for testing such as src/*, test/*, ledger3.texi, ... # that are relevant for testing such as src/*, test/*, ledger3.texi, ...
function add_ci_skip() add_ci_skip ()
{ {
pattern="$1"; shift pattern="$1"; shift
source="$1" source="$1"
# Don't add [ci skip] if it's already in the commit message source # 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 [ $? -eq 0 ] && return
if [ $(git diff --cached --name-only | grep --count "$pattern") -eq 0 ]; then if [ $(git diff --cached --name-only | grep --count "$pattern") -eq 0 ]; then
tempfile=$(mktemp $0.XXXXXX) tempfile=$(mktemp "${0}.XXXXXX")
cat - "$1" <<EOF > "$tempfile" cat - "$1" <<EOF > "$tempfile"
# It seems the changes to be committed are irrelevant for the continuous # It seems the changes to be committed are irrelevant for the continuous