From a22ae041365a8bb6798429f444470072a99129c8 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Tue, 14 May 2013 16:23:00 -0700 Subject: Prevent failure if ledger sort buffer is called with point before the ledger start marker. --- lisp/ldg-sort.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lisp') diff --git a/lisp/ldg-sort.el b/lisp/ldg-sort.el index 06efd348..42b49648 100644 --- a/lisp/ldg-sort.el +++ b/lisp/ldg-sort.el @@ -22,7 +22,7 @@ ;;; Commentary: -;; +;; ;;; Code: @@ -45,7 +45,7 @@ (match-end 0))) (defun ledger-sort-insert-start-mark () - (interactive) + (interactive) (save-excursion (goto-char (point-min)) (if (ledger-sort-find-start) @@ -54,7 +54,7 @@ (insert "\n; Ledger-mode: Start sort\n\n")) (defun ledger-sort-insert-end-mark () - (interactive) + (interactive) (save-excursion (goto-char (point-min)) (if (ledger-sort-find-end) @@ -79,7 +79,7 @@ (setq point-delta (- (point) (car bounds))) (setq target-xact (buffer-substring (car bounds) (cadr bounds))) (setq inhibit-modification-hooks t) - (save-excursion + (save-excursion (save-restriction (goto-char beg) (ledger-next-record-function) ;; make sure point is at the @@ -100,7 +100,7 @@ 'ledger-end-record-function 'ledger-sort-startkey)))) - (goto-char beg) + (goto-char (point-min)) (re-search-forward (regexp-quote target-xact)) (goto-char (+ (match-beginning 0) point-delta)) (setq inhibit-modification-hooks nil))) @@ -108,7 +108,7 @@ (defun ledger-sort-buffer () "Sort the entire buffer." (interactive) - (let (sort-start + (let (sort-start sort-end) (save-excursion (goto-char (point-min)) @@ -116,7 +116,7 @@ sort-end (ledger-sort-find-end))) (ledger-sort-region (if sort-start sort-start - (point-min)) + (point-min)) (if sort-end sort-end (point-max))))) -- cgit v1.2.3