Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 ledger (3.1+dfsg1-7) unstable; urgency=medium
 .
   * Bug fix: "FTBFS when built with dpkg-buildpackage -A (no binary
 	  artifacts)", thanks to Santiago Vila (Closes: #805945).
Author: David Bremner <bremner@debian.org>
Bug-Debian: https://bugs.debian.org/805945

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- ledger-3.1+dfsg1.orig/doc/CMakeLists.txt
+++ ledger-3.1+dfsg1/doc/CMakeLists.txt
@@ -70,7 +70,7 @@ foreach(file ${ledger_info_files})
       set(papersize --texinfo=@afourpaper)
     endif()
     add_custom_command(OUTPUT ${file_base}.pdf
-      COMMAND texi2pdf ${papersize} -b -q -o ${file_base}.pdf ${CMAKE_CURRENT_SOURCE_DIR}/${file}
+      COMMAND texi2pdf --tidy ${papersize} -b -q -o ${file_base}.pdf ${CMAKE_CURRENT_SOURCE_DIR}/${file}
       DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
       VERBATIM)
     list(APPEND ledger_doc_files ${file_base}.pdf)
--- ledger-3.1+dfsg1.orig/doc/ledger3.texi
+++ ledger-3.1+dfsg1/doc/ledger3.texi
@@ -7875,11 +7875,10 @@ A regular expression that matches agains
 @itemx tag(REGEX)
 A regular expression that matches against a transaction's tags.
 
-@itemx expr date =~ /REGEX/
+@item expr date =~ /REGEX/
 Useful for specifying a date in plain terms.  For example, you could say
 @samp{expr date =~ /2014/}.
 
-
 @item expr comment =~ /REGEX/
 A regular expression that matches against a posting's comment field. This
 searches only a posting's field, not the transaction's note or comment field.
@@ -7935,13 +7934,12 @@ A sub-expression is nested in parenthesi
 more complicated arguments to functions, or for overriding the natural
 precedence order of operators.
 
-
-@itemx expr base =~ /REGEX/
+@item expr base =~ /REGEX/
 A regular expression that matches against an account's base name.  If
 a posting, this will match against the account affected by the
 posting.
 
-@itemx expr code =~ /REGEX/
+@item expr code =~ /REGEX/
 A regular expression that matches against the transaction code (the
 text that occurs between parentheses before the payee).
 
--- ledger-3.1+dfsg1.orig/lisp/ledger-fontify.el
+++ ledger-3.1+dfsg1/lisp/ledger-fontify.el
@@ -52,7 +52,7 @@
   (interactive "d")
 	(save-excursion
 		(goto-char position)
-		(let ((extents (ledger-navigate-find-xact-extents position))
+		(let ((extents (ledger-navigate-find-element-extents position))
 					(state (ledger-transaction-state)))
 			(if (and ledger-fontify-xact-state-overrides state)
 					(cond ((eq state 'cleared)
@@ -63,6 +63,7 @@
 
 (defun ledger-fontify-xact-by-line (extents)
 	"do line-by-line detailed fontification of xact"
+	(interactive)
 	(save-excursion
 		(ledger-fontify-xact-start (car extents))
 		(while (< (point) (cadr extents))
@@ -92,30 +93,58 @@ Fontify the first line of an xact"
 		(ledger-fontify-set-face (list (match-beginning 8)
 																	 (match-end 8)) 'ledger-font-comment-face)))
 
+
 (defun ledger-fontify-posting (pos)
-	(let ((state nil))
-		(re-search-forward ledger-posting-regex)
-		(if (match-string 1)
-				(save-match-data (setq state (ledger-state-from-string (s-trim (match-string 1))))))
-		(ledger-fontify-set-face (list (match-beginning 0) (match-end 2))
-														 (cond ((eq state 'cleared)
-																		'ledger-font-posting-account-cleared-face)
-																	 ((eq state 'pending)
-																		'ledger-font-posting-account-pending-face)
-																	 (t
-																		'ledger-font-posting-account-face)))
-		(ledger-fontify-set-face (list (match-beginning 4) (match-end 4))
-														 (cond ((eq state 'cleared)
-																		'ledger-font-posting-amount-cleared-face)
-																	 ((eq state 'pending)
-																		'ledger-font-posting-amount-pending-face)
-																	 (t
-																		'ledger-font-posting-amount-face)))
-		(ledger-fontify-set-face (list (match-beginning 5) (match-end 5))
-														 'ledger-font-comment-face)))
+	(let* ((state nil)
+				 (end-of-line-comment nil)
+				(end (progn (end-of-line)
+										(point)))
+				(start (progn (beginning-of-line)
+											(point))))
+
+		;; Look for a posting status flag
+		(save-match-data ;; must use save-match-data to shadow the search
+										 ;; results.  If there is no status flag then the
+										 ;; search below will fail and NOT clear the match
+										 ;; data.  So if the previous line did have a
+										 ;; status flag it is still sitting in the match
+										 ;; data, causing the current line to be fontified
+										 ;; like the previous line.  Don't ask how long
+										 ;; that took to figure out
+			(re-search-forward " \\([*!]\\) " end t)
+			(if (match-string 1)
+					(setq state (ledger-state-from-string (s-trim (match-string 1))))))
+		(beginning-of-line)
+		(re-search-forward "[[:graph:]]\\([ \t][ \t]\\)" end 'end)  ;; find the end of the account, or end of line
+
+		(when (<= (point) end)  ;; we are still on the line
+		  (ledger-fontify-set-face (list start (point))
+															 (cond ((eq state 'cleared)
+																			'ledger-font-posting-account-cleared-face)
+																		 ((eq state 'pending)
+																			'ledger-font-posting-account-pending-face)
+																		 (t
+																			'ledger-font-posting-account-face)))
+
+
+			(when (< (point) end)  ;; there is still more to fontify
+				(setq start (point))  ;; update start of next font region
+				(setq end-of-line-comment (re-search-forward ";" end 'end))  ;; find the end of the line, or start of a comment
+				(ledger-fontify-set-face (list start (point) )
+																 (cond ((eq state 'cleared)
+																				'ledger-font-posting-amount-cleared-face)
+																			 ((eq state 'pending)
+																				'ledger-font-posting-amount-pending-face)
+																			 (t
+																				'ledger-font-posting-amount-face)))
+				(when end-of-line-comment
+					(setq start (point))
+					(end-of-line)
+					(ledger-fontify-set-face (list (- start 1) (point)) ;; subtract 1 from start because we passed the semi-colon
+																	 'ledger-font-comment-face))))))
 
 (defun ledger-fontify-directive-at (position)
-	(let ((extents (ledger-navigate-find-xact-extents position))
+	(let ((extents (ledger-navigate-find-element-extents position))
 				(face 'ledger-font-default-face))
 		(cond ((looking-at "=")
 					 (setq face 'ledger-font-auto-xact-face))
@@ -153,6 +182,8 @@ Fontify the first line of an xact"
 					 (setq face 'ledger-font-include-directive-face))
 					((looking-at "payee")
 					 (setq face 'ledger-font-payee-directive-face))
+					((looking-at "P")
+					 (setq face 'ledger-font-price-directive-face))
 					((looking-at "tag")
 					 (setq face 'ledger-font-tag-directive-face)))
 		(ledger-fontify-set-face extents face)))
--- ledger-3.1+dfsg1.orig/lisp/ledger-fonts.el
+++ ledger-3.1+dfsg1/lisp/ledger-fonts.el
@@ -70,6 +70,8 @@
   "Default face for pending (!) payees"
   :group 'ledger-faces)
 
+
+
 (defface ledger-font-xact-highlight-face
   `((t :inherit ledger-occur-xact-face))
   "Default face for transaction under point"
@@ -94,6 +96,11 @@
   `((t :inherit ledger-font-directive-face))
   "Default face for other transactions"
   :group 'ledger-faces)
+
+(defface ledger-font-price-directive-face
+  `((t :inherit ledger-font-directive-face))
+  "Default face for other transactions"
+  :group 'ledger-faces)
 
 (defface ledger-font-apply-directive-face
   `((t :inherit ledger-font-directive-face))
--- ledger-3.1+dfsg1.orig/lisp/ledger-mode.el
+++ ledger-3.1+dfsg1/lisp/ledger-mode.el
@@ -96,11 +96,11 @@
   "Start a ledger session with the current month, but make it customizable to ease retro-entry.")
 
 (defun ledger-read-account-with-prompt (prompt)
-  (let* ((context (ledger-context-at-point))
-         (default (if (eq (ledger-context-line-type context) 'acct-transaction)
-                      (regexp-quote (ledger-context-field-value context 'account))
-                    nil)))
-    (ledger-read-string-with-default prompt default)))
+  (let ((context (ledger-context-at-point)))
+    (ledger-read-string-with-default prompt
+																		 (if (eq (ledger-context-line-type context) 'acct-transaction)
+																				 (regexp-quote (ledger-context-field-value context 'account))
+																			 nil))))
 
 (defun ledger-read-date (prompt)
   "Returns user-supplied date after `PROMPT', defaults to today."
@@ -262,7 +262,7 @@ With a prefix argument, remove the effec
     (define-key map [(control ?c) (control ?o) (control ?r)] 'ledger-report)
     (define-key map [(control ?c) (control ?o) (control ?s)] 'ledger-report-save)
 
-    (define-key map [(meta ?p)] 'ledger-navigate-prev-xact)
+    (define-key map [(meta ?p)] 'ledger-navigate-prev-xact-or-directive)
     (define-key map [(meta ?n)] 'ledger-navigate-next-xact-or-directive)
     map)
   "Keymap for `ledger-mode'.")
--- ledger-3.1+dfsg1.orig/lisp/ledger-navigate.el
+++ ledger-3.1+dfsg1/lisp/ledger-navigate.el
@@ -54,26 +54,31 @@ beginning with whitespace"
 										(ledger-navigate-start-xact-or-directive-p)))
 			(forward-line))))
 
-(defun ledger-navigate-prev-xact ()
+(defun ledger-navigate-prev-xact-or-directive ()
   "Move point to beginning of previous xact."
-	(ledger-navigate-beginning-of-xact)
-	(re-search-backward ledger-xact-start-regex nil t))
+	(interactive)
+	(let ((context (car (ledger-context-at-point))))
+		(when (equal context 'acct-transaction)
+			(ledger-navigate-beginning-of-xact))
+		(beginning-of-line)
+		(re-search-backward "^[[:graph:]]" nil t)))
 
 (defun ledger-navigate-beginning-of-xact ()
 	"Move point to the beginning of the current xact"
 	(interactive)
 	;; need to start at the beginning of a line incase we are in the first line of an xact already.
 	(beginning-of-line)
-	(unless (looking-at ledger-xact-start-regex)
-		(re-search-backward ledger-xact-start-regex nil t)
-		(beginning-of-line))
+	(let ((sreg (concat "^\\(=\\|~\\|" ledger-iso-date-regexp "\\)")))
+		(unless (looking-at sreg)
+			(re-search-backward sreg nil t)
+			(beginning-of-line)))
 	(point))
 
 (defun ledger-navigate-end-of-xact ()
   "Move point to end of xact."
 	(interactive)
   (ledger-navigate-next-xact-or-directive)
-	(backward-char)
+	(re-search-backward "^[ \t]")
 	(end-of-line)
 	(point))
 
@@ -91,4 +96,66 @@ Requires empty line separating xacts."
     (list (ledger-navigate-beginning-of-xact)
 					(ledger-navigate-end-of-xact))))
 
+(defun ledger-navigate-find-directive-extents (pos)
+	(goto-char pos)
+	(let ((begin (progn (beginning-of-line)
+											(point)))
+				(end (progn (end-of-line)
+										(+ 1 (point)))))
+		;; handle block comments here
+		(beginning-of-line)
+		(if (looking-at " *;")
+				(progn
+					(while (and (looking-at " *;")
+											(> (point) (point-min)))
+						(forward-line -1))
+					;; We are either at the beginning of the buffer, or we found
+					;; a line outside the comment.  If we are not at the
+					;; beginning of the buffer then we need to move forward a
+					;; line.
+					(if (> (point) (point-min))
+							(progn (forward-line 1)
+										 (beginning-of-line)))
+					(setq begin (point))
+					(goto-char pos)
+					(beginning-of-line)
+					(while (and (looking-at " *;")
+											(< (point) (point-max)))
+						(forward-line 1))
+					(setq end (point))))
+		(list begin end)))
+
+(defun ledger-navigate-block-comment (pos)
+	(interactive "d")
+	(goto-char pos)
+	(let ((begin (progn (beginning-of-line)
+											(point)))
+				(end (progn (end-of-line)
+										(point))))
+		;; handle block comments here
+		(beginning-of-line)
+		(if (looking-at " *;")
+				(progn
+					(while (and (looking-at " *;")
+											(> (point) (point-min)))
+						(forward-line -1))
+					(setq begin (point))
+					(goto-char pos)
+					(beginning-of-line)
+					(while (and (looking-at " *;")
+											(< (point) (point-max)))
+						(forward-line 1))
+					(setq end (point))))
+		(list begin end)))
+
+
+(defun ledger-navigate-find-element-extents (pos)
+	"return list containing beginning and end of the entity surrounding point"
+	(interactive "d")
+	(save-excursion
+		(goto-char pos)
+		(beginning-of-line)
+		(if (looking-at "[ =~0-9]")
+				(ledger-navigate-find-xact-extents pos)
+			(ledger-navigate-find-directive-extents pos))))
 ;;; ledger-navigate.el ends here
--- ledger-3.1+dfsg1.orig/lisp/ledger-occur.el
+++ ledger-3.1+dfsg1/lisp/ledger-occur.el
@@ -160,7 +160,7 @@ Used for coordinating `ledger-occur' wit
       (while (not (eobp))
         ;; if something found
         (when (setq endpoint (re-search-forward regex nil 'end))
-					(setq bounds (ledger-navigate-find-xact-extents endpoint))
+					(setq bounds (ledger-navigate-find-element-extents endpoint))
 					(push bounds lines)
 					;; move to the end of the xact, no need to search inside it more
           (goto-char (cadr bounds))))
--- ledger-3.1+dfsg1.orig/lisp/ledger-regex.el
+++ ledger-3.1+dfsg1/lisp/ledger-regex.el
@@ -333,7 +333,8 @@
           "\\)"))
 
 (defconst ledger-xact-start-regex
-	(concat ledger-iso-date-regexp  ;; subexp 1
+	(concat "^" ledger-iso-date-regexp  ;; subexp 1
+				;;	"\\(=" ledger-iso-date-regexp "\\)?"
           " ?\\([ *!]\\)"  ;; mark, subexp 5
           " ?\\((.*)\\)?"  ;; code, subexp 6
           " ?\\([^;\n]+\\)"   ;; desc, subexp 7
@@ -343,7 +344,7 @@
 (defconst ledger-posting-regex
 	(concat "^[ \t]+ ?"  ;; initial white space
 					"\\([*!]\\)? ?" ;; state, subexpr 1
-					"\\(.+?\\(\n\\|[ \t][ \t]\\)\\)"  ;; account, subexpr 2
+					"\\([[:print:]]+\\([ \t][ \t]\\)\\)"  ;; account, subexpr 2
 					"\\([^;\n]*\\)"  ;; amount, subexpr 4
 					"\\(.*\\)" ;; comment, subexpr 5
 					))
--- ledger-3.1+dfsg1.orig/lisp/ledger-xact.el
+++ ledger-3.1+dfsg1/lisp/ledger-xact.el
@@ -42,7 +42,7 @@
 (defun ledger-highlight-xact-under-point ()
   "Move the highlight overlay to the current transaction."
   (if ledger-highlight-xact-under-point
-      (let ((exts (ledger-navigate-find-xact-extents (point)))
+      (let ((exts (ledger-navigate-find-element-extents (point)))
             (ovl ledger-xact-highlight-overlay))
         (if (not ledger-xact-highlight-overlay)
             (setq ovl
--- ledger-3.1+dfsg1.orig/src/CMakeLists.txt
+++ ledger-3.1+dfsg1/src/CMakeLists.txt
@@ -254,7 +254,6 @@ add_pch_rule(${PROJECT_BINARY_DIR}/syste
 include(GNUInstallDirs)
 
 if (BUILD_LIBRARY)
-  set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
   add_library(libledger SHARED ${LEDGER_SOURCES})
   add_ledger_library_dependencies(libledger)
   set_target_properties(libledger PROPERTIES
@@ -264,6 +263,9 @@ if (BUILD_LIBRARY)
     SOVERSION ${Ledger_VERSION_MAJOR})
 
   add_executable(ledger main.cc global.cc)
+	set_target_properties(ledger PROPERTIES
+	                           INSTALL_RPATH "/usr/lib/ledger")
+
   target_link_libraries(ledger libledger)
 
   install(TARGETS libledger DESTINATION ${CMAKE_INSTALL_LIBDIR})
--- ledger-3.1+dfsg1.orig/src/account.h
+++ ledger-3.1+dfsg1/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() {
--- ledger-3.1+dfsg1.orig/src/filters.cc
+++ ledger-3.1+dfsg1/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));
     }
   };
--- ledger-3.1+dfsg1.orig/src/item.h
+++ ledger-3.1+dfsg1/src/item.h
@@ -191,11 +191,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 {
--- ledger-3.1+dfsg1.orig/src/iterators.cc
+++ ledger-3.1+dfsg1/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();
 
--- ledger-3.1+dfsg1.orig/src/parser.h
+++ ledger-3.1+dfsg1/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
--- ledger-3.1+dfsg1.orig/src/post.h
+++ ledger-3.1+dfsg1/src/post.h
@@ -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;
--- ledger-3.1+dfsg1.orig/src/times.h
+++ ledger-3.1+dfsg1/src/times.h
@@ -568,11 +568,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
