rewrote ledger-end-record in ledger-sort to get rid of next-paragraph

This commit is contained in:
Craig Earls 2014-09-13 12:38:40 -07:00
parent 8fc83e8148
commit 20dd0b706a

View file

@ -28,13 +28,17 @@
(defun ledger-next-record-function () (defun ledger-next-record-function ()
"Move point to next transaction." "Move point to next transaction."
(if (looking-at ledger-payee-any-status-regex)
(forward-line)) ;; make sure we actually move to the next xact,
;; even if we are the beginning of one now.
(if (re-search-forward ledger-payee-any-status-regex nil t) (if (re-search-forward ledger-payee-any-status-regex nil t)
(goto-char (match-beginning 0)) (goto-char (match-beginning 0))
(goto-char (point-max)))) (goto-char (point-max))))
(defun ledger-end-record-function () (defun ledger-end-record-function ()
"Move point to end of transaction." "Move point to end of transaction."
(forward-paragraph)) (ledger-next-record-function)
(backward-char))
(defun ledger-sort-find-start () (defun ledger-sort-find-start ()
(if (re-search-forward ";.*Ledger-mode:.*Start sort" nil t) (if (re-search-forward ";.*Ledger-mode:.*Start sort" nil t)
@ -69,7 +73,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
@ -82,12 +86,12 @@
(save-excursion (save-excursion
(save-restriction (save-restriction
(goto-char beg) (goto-char beg)
(ledger-next-record-function) ;; make sure point is at the ;; make sure point is at the beginning of a xact
;; beginning of a xact (ledger-next-record-function)
(setq new-beg (point)) (setq new-beg (point))
(goto-char end) (goto-char end)
(ledger-next-record-function) ;; make sure end of region is at (ledger-next-record-function)
;; 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)