diff options
-rw-r--r-- | doc/ledger3.texi | 2 | ||||
-rw-r--r-- | lisp/ledger-mode.el | 2 | ||||
-rw-r--r-- | lisp/ledger-post.el | 14 | ||||
-rw-r--r-- | src/account.h | 6 | ||||
-rw-r--r-- | src/filters.cc | 2 | ||||
-rw-r--r-- | src/item.h | 6 | ||||
-rw-r--r-- | src/iterators.cc | 2 | ||||
-rw-r--r-- | src/parser.h | 2 | ||||
-rw-r--r-- | src/post.h | 6 | ||||
-rw-r--r-- | src/py_item.cc | 14 | ||||
-rw-r--r-- | src/times.h | 6 |
11 files changed, 24 insertions, 38 deletions
diff --git a/doc/ledger3.texi b/doc/ledger3.texi index 441b15d1..e70210ab 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -3432,7 +3432,7 @@ but is not required to be used with them: It should be noted that this is a convenience only for cases where you buy and sell whole lots. The @{@{$500.00@}@} is @emph{not} an attribute -of the commodity, whereas @{$5.00@} is. In fact, when you write +of the commodity, whereas @{$50.00@} is. In fact, when you write @{@{$500.00@}@}, Ledger just divides that value by 10 and sees @{$50.00@}. So if you use the print command to look at this transaction, you'll see the single braces form in the output. The diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el index 3b01aa10..f2eb4b21 100644 --- a/lisp/ledger-mode.el +++ b/lisp/ledger-mode.el @@ -159,7 +159,7 @@ Can indent, complete or align depending on context." (if (and (> (point) 1) (looking-back "\\([^ \t]\\)" 1)) (ledger-pcomplete interactively) - (ledger-post-align-postings)))) + (ledger-post-align-postings (line-beginning-position) (line-end-position))))) (defvar ledger-mode-abbrev-table) diff --git a/lisp/ledger-post.el b/lisp/ledger-post.el index 527a2044..21e856db 100644 --- a/lisp/ledger-post.el +++ b/lisp/ledger-post.el @@ -100,23 +100,15 @@ at beginning of account" (let ((bounds (ledger-navigate-find-xact-extents pos))) (ledger-post-align-postings (car bounds) (cadr bounds)))) -(defun ledger-post-align-postings (&optional beg end) - "Align all accounts and amounts between BEG and END, or the current line." - (interactive) +(defun ledger-post-align-postings (beg end) + "Align all accounts and amounts between BEG and END, or the current region, or, if no region, the current line." + (interactive "r") (save-excursion - (if (or (not (mark)) - (not (use-region-p))) - (set-mark (point))) - (let ((inhibit-modification-hooks t) - (mark-first (< (mark) (point))) acct-start-column acct-end-column acct-adjust amt-width amt-adjust (lines-left 1)) - (unless beg (setq beg (if mark-first (mark) (point)))) - (unless end (setq end (if mark-first (mark) (point)))) - ;; Extend region to whole lines (let ((start-marker (set-marker (make-marker) (save-excursion (goto-char beg) diff --git a/src/account.h b/src/account.h index 7fae93e1..7de4e560 100644 --- a/src/account.h +++ b/src/account.h @@ -261,11 +261,7 @@ public: mutable optional<xdata_t> xdata_; bool has_xdata() const { -#if BOOST_VERSION >= 105600 - return xdata_ != NULL; -#else - return xdata_; -#endif + return static_cast<bool>(xdata_); } void clear_xdata(); xdata_t& xdata() { diff --git a/src/filters.cc b/src/filters.cc index 2f97a0e5..b6530c04 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -707,7 +707,7 @@ namespace { insert_prices_in_map(price_map_t& _all_prices) : all_prices(_all_prices) {} - void operator()(datetime_t& date, const amount_t& price) { + void operator()(const datetime_t& date, const amount_t& price) { all_prices.insert(price_map_t::value_type(date, price)); } }; @@ -174,11 +174,7 @@ public: static bool use_aux_date; virtual bool has_date() const { -#if BOOST_VERSION >= 105600 - return _date != NULL; -#else - return _date; -#endif + return static_cast<bool>(_date); } virtual date_t date() const { diff --git a/src/iterators.cc b/src/iterators.cc index 21bec5d9..0225e210 100644 --- a/src/iterators.cc +++ b/src/iterators.cc @@ -96,7 +96,7 @@ namespace { TRACE_DTOR(create_price_xact); } - void operator()(datetime_t& date, const amount_t& price) { + void operator()(const datetime_t& date, const amount_t& price) { xact_t * xact; string symbol = price.commodity().symbol(); diff --git a/src/parser.h b/src/parser.h index e46fc719..25c4a7e3 100644 --- a/src/parser.h +++ b/src/parser.h @@ -118,7 +118,7 @@ public: ptr_op_t parse(std::istream& in, const parse_flags_t& flags = PARSE_DEFAULT, - const optional<string>& original_string = NULL); + const optional<string>& original_string = boost::none); }; } // namespace ledger @@ -205,11 +205,7 @@ public: mutable optional<xdata_t> xdata_; bool has_xdata() const { -#if BOOST_VERSION >= 105600 - return xdata_ != NULL; -#else - return xdata_; -#endif + return static_cast<bool>(xdata_); } void clear_xdata() { xdata_ = none; diff --git a/src/py_item.cc b/src/py_item.cc index 473bbef8..4dd104c9 100644 --- a/src/py_item.cc +++ b/src/py_item.cc @@ -32,6 +32,7 @@ #include <system.hh> #include "pyinterp.h" +#include "pyutils.h" #include "scope.h" #include "mask.h" #include "item.h" @@ -64,6 +65,13 @@ namespace { return item.get_tag(tag_mask, value_mask); } + std::string py_position_pathname(position_t const& pos) { + return pos.pathname.native(); + } + void py_position_set_pathname(position_t& pos, string const& s) { + pos.pathname = s; + } + } // unnamed namespace #if 0 @@ -79,8 +87,8 @@ void export_item() { class_< position_t > ("Position") .add_property("pathname", - make_getter(&position_t::pathname), - make_setter(&position_t::pathname)) + make_function(py_position_pathname), + make_function(py_position_set_pathname)) .add_property("beg_pos", make_getter(&position_t::beg_pos), make_setter(&position_t::beg_pos)) @@ -169,6 +177,8 @@ void export_item() .def("valid", &item_t::valid) ; + + register_optional_to_python<position_t>(); } } // namespace ledger diff --git a/src/times.h b/src/times.h index 421d1462..e1a9e847 100644 --- a/src/times.h +++ b/src/times.h @@ -500,11 +500,7 @@ public: void stabilize(const optional<date_t>& date = none); bool is_valid() const { -#if BOOST_VERSION >= 105600 - return start != NULL; -#else - return start; -#endif + return static_cast<bool>(start); } /** Find the current or next period containing date. Returns false if |