Ad ledger-mode flags to limit sort region for sort buffer
This commit is contained in:
parent
9a86fe022c
commit
c85a91b030
2 changed files with 25 additions and 3 deletions
|
|
@ -303,6 +303,21 @@ transactions like automated transaction, will be moved in the sorting
|
|||
process and may not function correctly afterwards. For this reason
|
||||
there is no key sequence.
|
||||
|
||||
You can limit the allowed sort region by using embedded Ledger-mode
|
||||
markup within your ledger. For exmaple
|
||||
@smallexample
|
||||
<<< infomration to not sort >>>
|
||||
|
||||
; Ledger-mode: Start sort
|
||||
|
||||
<<< xacts to sort >>>
|
||||
|
||||
;Ledger-mode: End sort
|
||||
|
||||
<<< information to not sort >>>
|
||||
@end smallexample
|
||||
|
||||
|
||||
@node Hiding Transactions, , Sorting Transactions, The Ledger Buffer
|
||||
@section Hiding Transactions
|
||||
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@
|
|||
;; the beginning of next record
|
||||
;; after the region
|
||||
(setq new-end (point))
|
||||
(narrow-to-region beg end)
|
||||
(goto-char (point-min))
|
||||
(narrow-to-region new-beg new-end)
|
||||
(goto-char new-beg)
|
||||
|
||||
(let ((inhibit-field-text-motion t))
|
||||
(sort-subr
|
||||
|
|
@ -66,7 +66,14 @@
|
|||
(defun ledger-sort-buffer ()
|
||||
"Sort the entire buffer."
|
||||
(interactive)
|
||||
(ledger-sort-region (point-min) (point-max)))
|
||||
(let ((sort-start (point-min))
|
||||
(sort-end (point-max)))
|
||||
(goto-char (point-min))
|
||||
(if (re-search-forward ";.*Ledger-mode:.*Start sort" nil t)
|
||||
(set 'sort-start (match-end 0)))
|
||||
(if (re-search-forward ";.*Ledger-mode:.*End sort" nil t)
|
||||
(set 'sort-end (match-end 0)))
|
||||
(ledger-sort-region sort-start sort-end)))
|
||||
|
||||
(provide 'ldg-sort)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue