Package: release.debian.org
Severity: normal
User: release.debian....@packages.debian.org
Usertags: unblock

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Please unblock package ledger

(explain the reason for the unblock here)

Upstream 3.1 contained several usability regressions for the
emacs-mode in binary package ledger-el. These regressions are
reported in bug #769454

Shortly after the release of 3.1 upstream committed several patches to
the emacs support, which I have cherry-picked.

(include/attach the debdiff against the package in testing)

I will attach the debdiff.  Unfortunately the patch export is a bit
sub-optimimal, so I'll also attach a git log, in case that helps.

unblock ledger/3.1+dfsg1-2

- -- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (900, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQGcBAEBCAAGBQJUf5SbAAoJEPIClx2kp54sYPoL/jDUXIBgzd1cKGajStjA1Bto
86hcuplnZUenLY/wFupXYfSvpH+AMUYFJ2og9Z4F7W/lHbdNK8chwWzkl1eWUmNi
qhge/gk9qK0JRxlE3t1Ia+Q9DgKDPwrhA9GGGLAGpkr/cdVOu33+zBuvZkGATDjS
9e0XoAPO2V/ntY9bC2PRp0vpazEiRYWR4dfm3Sr3yUAzKVJRK/pPeV2e1Xb0ewZU
wVERza3cbXAyGYCNlToA82FE0umCjADiRNJaG6iVNjJU44KGw4NRG6RTGm6LTBp2
KsG9JqyaQDIlGfggmj71HUszs1hSWryx0w65O10EykyH4CoUonBbqP6QSLhVngT0
GU0w/yLcQrG9L9ge4ecP7bdlETmihMg9owJuqKcYmIhK3VylzNqntxpax0i8k749
2XPBrb5dSwBJivHdD2LfhQyDIfXPAh/D1Hf5qImPbAVZNcJh9m0UhZ/nHCERG4DU
jRp/wr9MC6dsk1dj3GDkGl7faAtU5BTi0dTf7i1X6Q==
=siMe
-----END PGP SIGNATURE-----
diff -Nru ledger-3.1+dfsg1/debian/changelog ledger-3.1+dfsg1/debian/changelog
--- ledger-3.1+dfsg1/debian/changelog	2014-10-13 11:04:40.000000000 +0200
+++ ledger-3.1+dfsg1/debian/changelog	2014-12-03 22:29:20.000000000 +0100
@@ -1,3 +1,12 @@
+ledger (3.1+dfsg1-2) unstable; urgency=medium
+
+  * Cherry pick patches for Emacs ledger-mode (ledger-el) from
+    upstream (Closes: #769454).
+    - fix for completely broken M-p in Emacs ledger-mode
+    - fixes for syntax highlightling in ledger-mode
+
+ -- David Bremner <brem...@debian.org>  Wed, 03 Dec 2014 22:25:08 +0100
+
 ledger (3.1+dfsg1-1) unstable; urgency=medium
 
   * New upstream release
diff -Nru ledger-3.1+dfsg1/debian/patches/0001-debcherry-fixup-patch.patch ledger-3.1+dfsg1/debian/patches/0001-debcherry-fixup-patch.patch
--- ledger-3.1+dfsg1/debian/patches/0001-debcherry-fixup-patch.patch	2014-10-13 11:04:57.000000000 +0200
+++ ledger-3.1+dfsg1/debian/patches/0001-debcherry-fixup-patch.patch	2014-12-03 23:24:40.000000000 +0100
@@ -1,8 +1,24 @@
-From 6bf5613f5adff590fe25f22583c5e09625debcf3 Mon Sep 17 00:00:00 2001
+From 95ad158c8d7fa773dadbaf49d5ce4174bb110e4b Mon Sep 17 00:00:00 2001
 From: David Bremner <da...@tethera.net>
-Date: Mon, 13 Oct 2014 11:04:57 +0200
+Date: Wed, 3 Dec 2014 23:24:40 +0100
 Subject: [PATCH 1/2] debcherry fixup patch
 
+6f83309 Fix minor navigation bugs.  Prev and next act now properly handle directives and empty lines
+	 - no changes against upstream or conflicts
+aabb590 Fix a bug the caused reconciliation to lock up in an automatic transaction was followed immediately with a virtual transaction on the same account.
+	 - no changes against upstream or conflicts
+2950adb Smash a bug that cause the status on a posting with no amount to bleed into the next line.
+	 - extra changes or conflicts
+66c1721 Add 1 to the end of region for single line directives.  This will force the layout to show across the entire buffer.
+	 - no changes against upstream or conflicts
+0b47567 Handle block comments as blocks rather than individual lines.
+	 - extra changes or conflicts
+2f7d166 Fix navigate bug keeping prev-xact key binding from working.
+	 - extra changes or conflicts
+839f618 Detect the beginning of periodic transactions properly.
+	 - extra changes or conflicts
+7857f98 Improve finding boundaries of elements for fontification.  Also added P for price directives.
+	 - extra changes or conflicts
 88dbf49 disable RPATH for libledger
 	 - extra changes or conflicts
 a5315c6 Don't install files deleted by Debian
@@ -12,9 +28,16 @@
 b55f44e enable "tidy mode" for texi2pdf
 	 - extra changes or conflicts
 ---
- doc/CMakeLists.txt | 2 +-
- src/CMakeLists.txt | 4 +++-
- 2 files changed, 4 insertions(+), 2 deletions(-)
+ doc/CMakeLists.txt      |  2 +-
+ lisp/ledger-fontify.el  | 75 +++++++++++++++++++++++++++++++--------------
+ lisp/ledger-fonts.el    |  7 +++++
+ lisp/ledger-mode.el     | 12 ++++----
+ lisp/ledger-navigate.el | 81 ++++++++++++++++++++++++++++++++++++++++++++-----
+ lisp/ledger-occur.el    |  2 +-
+ lisp/ledger-regex.el    |  5 +--
+ lisp/ledger-xact.el     |  2 +-
+ src/CMakeLists.txt      |  4 ++-
+ 9 files changed, 149 insertions(+), 41 deletions(-)
 
 diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
 index 96c6d51..d810078 100644
@@ -29,6 +52,330 @@
        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
        VERBATIM)
      list(APPEND ledger_doc_files ${file_base}.pdf)
+diff --git a/lisp/ledger-fontify.el b/lisp/ledger-fontify.el
+index 45baa43..309cbc3 100644
+--- a/lisp/ledger-fontify.el
++++ b/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)))
+diff --git a/lisp/ledger-fonts.el b/lisp/ledger-fonts.el
+index f8ca3fa..9992731 100644
+--- a/lisp/ledger-fonts.el
++++ b/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"
+@@ -95,6 +97,11 @@
+   "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))
+   "Default face for other transactions"
+diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el
+index 3b00bb9..1eab0f3 100644
+--- a/lisp/ledger-mode.el
++++ b/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 effective date. "
+     (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'.")
+diff --git a/lisp/ledger-navigate.el b/lisp/ledger-navigate.el
+index 1e66dde..d954222 100644
+--- a/lisp/ledger-navigate.el
++++ b/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
+diff --git a/lisp/ledger-occur.el b/lisp/ledger-occur.el
+index cd7a267..400967f 100644
+--- a/lisp/ledger-occur.el
++++ b/lisp/ledger-occur.el
+@@ -160,7 +160,7 @@ Used for coordinating `ledger-occur' with other buffers, like reconcile."
+       (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))))
+diff --git a/lisp/ledger-regex.el b/lisp/ledger-regex.el
+index 238cfc6..b13647b 100644
+--- a/lisp/ledger-regex.el
++++ b/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
+ 					))
+diff --git a/lisp/ledger-xact.el b/lisp/ledger-xact.el
+index 522f8d9..3ef6738 100644
+--- a/lisp/ledger-xact.el
++++ b/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
 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
 index aec75c0..688cd9e 100644
 --- a/src/CMakeLists.txt
@@ -52,5 +399,5 @@
  
    install(TARGETS libledger DESTINATION ${CMAKE_INSTALL_LIBDIR})
 -- 
-2.1.1
+2.1.3
 
diff -Nru ledger-3.1+dfsg1/debian/patches/0002-Fix-texinfo-syntax-errors.patch ledger-3.1+dfsg1/debian/patches/0002-Fix-texinfo-syntax-errors.patch
--- ledger-3.1+dfsg1/debian/patches/0002-Fix-texinfo-syntax-errors.patch	2014-10-13 11:04:57.000000000 +0200
+++ ledger-3.1+dfsg1/debian/patches/0002-Fix-texinfo-syntax-errors.patch	2014-12-03 23:24:40.000000000 +0100
@@ -1,4 +1,4 @@
-From 6893d283b07ab11e17c700b8e5e0918c41ec4e19 Mon Sep 17 00:00:00 2001
+From 99144a6a7ff6f11c2574b5c90837fe8f543e6a9e Mon Sep 17 00:00:00 2001
 From: Martin Michlmayr <t...@cyrius.com>
 Date: Sun, 12 Oct 2014 16:52:43 -0400
 Subject: [PATCH 2/2] Fix texinfo syntax errors
@@ -48,5 +48,5 @@
  text that occurs between parentheses before the payee).
  
 -- 
-2.1.1
+2.1.3
 
commit a194a99c20991760936f2538f68d40d7f7c5661e
Author: David Bremner <brem...@debian.org>
Date:   Wed Dec 3 22:25:37 2014 +0100

    changelog stanza for 3.1+dfsg1-2

diff --git a/debian/changelog b/debian/changelog
index 9322708..b0371ac 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+ledger (3.1+dfsg1-2) unstable; urgency=medium
+
+  * Cherry pick patches for Emacs ledger-mode (ledger-el) from
+    upstream (Closes: #769454).
+    - fix for completely broken M-p in Emacs ledger-mode
+    - fixes for syntax highlightling in ledger-mode
+
+ -- David Bremner <brem...@debian.org>  Wed, 03 Dec 2014 22:25:08 +0100
+
 ledger (3.1+dfsg1-1) unstable; urgency=medium
 
   * New upstream release

commit ef3a1ab0a948d8250eb5309141551a01ed94d727
Author: Craig Earls <ender...@gmail.com>
Date:   Sat Nov 15 21:36:34 2014 -0700

    Fix minor navigation bugs.  Prev and next act now properly handle directives and empty lines
    
    (cherry picked from commit db7e4fd741021bec72121f915414679d30144735)

diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el
index 9376e2e..1eab0f3 100644
--- a/lisp/ledger-mode.el
+++ b/lisp/ledger-mode.el
@@ -262,7 +262,7 @@ With a prefix argument, remove the effective date. "
     (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'.")
diff --git a/lisp/ledger-navigate.el b/lisp/ledger-navigate.el
index 5da5cf8..d954222 100644
--- a/lisp/ledger-navigate.el
+++ b/lisp/ledger-navigate.el
@@ -54,11 +54,14 @@ 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."
 	(interactive)
-	(ledger-navigate-beginning-of-xact)
-	(re-search-backward ledger-xact-start-regex nil t))
+	(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"
@@ -75,7 +78,7 @@ beginning with whitespace"
   "Move point to end of xact."
 	(interactive)
   (ledger-navigate-next-xact-or-directive)
-	(backward-char)
+	(re-search-backward "^[ \t]")
 	(end-of-line)
 	(point))
 

commit 09833b86fb7d8fba96e3151192c7570c81228b1f
Author: Craig Earls <ender...@gmail.com>
Date:   Fri Nov 14 17:22:04 2014 -0700

    Fix a bug the caused reconciliation to lock up in an automatic transaction was followed immediately with a virtual transaction on the same account.
    
    This was related to the navigation changes push a while back.
    
    (cherry picked from commit 312b7ffa72787762de630bd750efd35f65d11c8d)

diff --git a/lisp/ledger-navigate.el b/lisp/ledger-navigate.el
index d4e7098..5da5cf8 100644
--- a/lisp/ledger-navigate.el
+++ b/lisp/ledger-navigate.el
@@ -65,7 +65,7 @@ beginning with whitespace"
 	(interactive)
 	;; need to start at the beginning of a line incase we are in the first line of an xact already.
 	(beginning-of-line)
-	(let ((sreg (concat "^\\(~\\|" ledger-iso-date-regexp "\\)")))
+	(let ((sreg (concat "^\\(=\\|~\\|" ledger-iso-date-regexp "\\)")))
 		(unless (looking-at sreg)
 			(re-search-backward sreg nil t)
 			(beginning-of-line)))
@@ -152,7 +152,7 @@ Requires empty line separating xacts."
 	(save-excursion
 		(goto-char pos)
 		(beginning-of-line)
-		(if (looking-at "[ ~0-9]")
+		(if (looking-at "[ =~0-9]")
 				(ledger-navigate-find-xact-extents pos)
 			(ledger-navigate-find-directive-extents pos))))
 ;;; ledger-navigate.el ends here
diff --git a/lisp/ledger-occur.el b/lisp/ledger-occur.el
index cd7a267..400967f 100644
--- a/lisp/ledger-occur.el
+++ b/lisp/ledger-occur.el
@@ -160,7 +160,7 @@ Used for coordinating `ledger-occur' with other buffers, like reconcile."
       (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))))

commit 2780eb2f1a5b487514226ef2b41bb69a02062d43
Author: Craig Earls <ender...@gmail.com>
Date:   Tue Nov 11 19:54:43 2014 -0700

    Smash a bug that cause the status on a posting with no amount to bleed into the next line.
    
    (cherry picked from commit a3f3aa304fcfb19fc716c5eaf33a6e152bb3aa71)

diff --git a/lisp/ledger-fontify.el b/lisp/ledger-fontify.el
index d876e5e..309cbc3 100644
--- a/lisp/ledger-fontify.el
+++ b/lisp/ledger-fontify.el
@@ -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,27 +93,55 @@ 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-element-extents position))
diff --git a/lisp/ledger-navigate.el b/lisp/ledger-navigate.el
index 97a545b..d4e7098 100644
--- a/lisp/ledger-navigate.el
+++ b/lisp/ledger-navigate.el
@@ -65,7 +65,7 @@ beginning with whitespace"
 	(interactive)
 	;; need to start at the beginning of a line incase we are in the first line of an xact already.
 	(beginning-of-line)
-	(let ((sreg (concat "\\(~\\|" ledger-iso-date-regexp "\\)")))
+	(let ((sreg (concat "^\\(~\\|" ledger-iso-date-regexp "\\)")))
 		(unless (looking-at sreg)
 			(re-search-backward sreg nil t)
 			(beginning-of-line)))
diff --git a/lisp/ledger-regex.el b/lisp/ledger-regex.el
index 238cfc6..b13647b 100644
--- a/lisp/ledger-regex.el
+++ b/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
 					))

commit 544dd9a8f95f1678de38c01a8a537e5250e35241
Author: Craig Earls <ender...@gmail.com>
Date:   Sun Nov 9 10:02:03 2014 -0700

    Add 1 to the end of region for single line directives.  This will force the layout to show across the entire buffer.
    
    (cherry picked from commit e54d7392bfafa51e657f92ee1a1feb68f7f2b123)

diff --git a/lisp/ledger-navigate.el b/lisp/ledger-navigate.el
index 5bc1837..97a545b 100644
--- a/lisp/ledger-navigate.el
+++ b/lisp/ledger-navigate.el
@@ -98,7 +98,7 @@ Requires empty line separating xacts."
 	(let ((begin (progn (beginning-of-line)
 											(point)))
 				(end (progn (end-of-line)
-										(point))))
+										(+ 1 (point)))))
 		;; handle block comments here
 		(beginning-of-line)
 		(if (looking-at " *;")

commit 76bd06ec0c7b8ab5a96b6245b941e2a1338c275f
Author: Craig Earls <ender...@gmail.com>
Date:   Sun Nov 9 09:50:22 2014 -0700

    Handle block comments as blocks rather than individual lines.
    
    (cherry picked from commit 2ef1c092100d53ad2882a59b9668cd183226c28f)

diff --git a/lisp/ledger-navigate.el b/lisp/ledger-navigate.el
index 5c89480..5bc1837 100644
--- a/lisp/ledger-navigate.el
+++ b/lisp/ledger-navigate.el
@@ -95,10 +95,56 @@ Requires empty line separating xacts."
 
 (defun ledger-navigate-find-directive-extents (pos)
 	(goto-char pos)
-	(list (progn (beginning-of-line)
-							 (point))
-				(progn (end-of-line)
-							 (point))))
+	(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))
+					;; 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"

commit fcaa5d313146fb18f77148cc76415f267b116abe
Author: Craig Earls <ender...@gmail.com>
Date:   Sun Nov 9 09:05:13 2014 -0700

    Fix navigate bug keeping prev-xact key binding from working.
    
    (cherry picked from commit 8a87fd1310c69133506d4e428abd02de07d29ac9)

diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el
index 3b00bb9..9376e2e 100644
--- a/lisp/ledger-mode.el
+++ b/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."
diff --git a/lisp/ledger-navigate.el b/lisp/ledger-navigate.el
index 2759d2d..5c89480 100644
--- a/lisp/ledger-navigate.el
+++ b/lisp/ledger-navigate.el
@@ -56,6 +56,7 @@ beginning with whitespace"
 
 (defun ledger-navigate-prev-xact ()
   "Move point to beginning of previous xact."
+	(interactive)
 	(ledger-navigate-beginning-of-xact)
 	(re-search-backward ledger-xact-start-regex nil t))
 
diff --git a/lisp/ledger-xact.el b/lisp/ledger-xact.el
index 522f8d9..3ef6738 100644
--- a/lisp/ledger-xact.el
+++ b/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

commit 1762af6098820ca9149d3f2ed3b5f7c6bbc21562
Author: Craig Earls <ender...@gmail.com>
Date:   Fri Nov 7 18:56:11 2014 -0700

    Detect the beginning of periodic transactions properly.
    
    (cherry picked from commit 6f3dad2024bb33c13dbb029b2127e2a23da86e35)

diff --git a/lisp/ledger-navigate.el b/lisp/ledger-navigate.el
index 1843430..2759d2d 100644
--- a/lisp/ledger-navigate.el
+++ b/lisp/ledger-navigate.el
@@ -64,9 +64,10 @@ beginning with whitespace"
 	(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 ()
@@ -104,7 +105,7 @@ Requires empty line separating xacts."
 	(save-excursion
 		(goto-char pos)
 		(beginning-of-line)
-		(if (looking-at "[ 0-9]")
+		(if (looking-at "[ ~0-9]")
 				(ledger-navigate-find-xact-extents pos)
 			(ledger-navigate-find-directive-extents pos))))
 ;;; ledger-navigate.el ends here

commit f2fcc9bd535eba2a89e4aa5aa5b748b37f0b35de
Author: Craig Earls <ender...@gmail.com>
Date:   Fri Nov 7 18:19:57 2014 -0700

    Improve finding boundaries of elements for fontification.  Also added P for price directives.
    
    (cherry picked from commit 1bd67755fa3127d80b7534d15f1f9de1b477c19a)

diff --git a/lisp/ledger-fontify.el b/lisp/ledger-fontify.el
index 45baa43..d876e5e 100644
--- a/lisp/ledger-fontify.el
+++ b/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)
@@ -115,7 +115,7 @@ Fontify the first line of an xact"
 														 '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 +153,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)))
diff --git a/lisp/ledger-fonts.el b/lisp/ledger-fonts.el
index f8ca3fa..9992731 100644
--- a/lisp/ledger-fonts.el
+++ b/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"
@@ -95,6 +97,11 @@
   "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))
   "Default face for other transactions"
diff --git a/lisp/ledger-navigate.el b/lisp/ledger-navigate.el
index 1e66dde..1843430 100644
--- a/lisp/ledger-navigate.el
+++ b/lisp/ledger-navigate.el
@@ -91,4 +91,20 @@ 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)
+	(list (progn (beginning-of-line)
+							 (point))
+				(progn (end-of-line)
+							 (point))))
+
+(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

Reply via email to