diff options
author | Moritz Ulrich <moritz@tarn-vedra.de> | 2013-12-30 00:22:43 +0100 |
---|---|---|
committer | Moritz Ulrich <moritz@tarn-vedra.de> | 2013-12-30 00:22:43 +0100 |
commit | 6dbb36f525d1d5d35784e4f79b89d90ca1a3db93 (patch) | |
tree | 45fff749f18abc7048ca289bd98f3fbd42140c56 /lisp | |
parent | 15b94e8f4443311723e0f88c4af1c5c417184ba5 (diff) | |
download | fork-ledger-6dbb36f525d1d5d35784e4f79b89d90ca1a3db93.tar.gz fork-ledger-6dbb36f525d1d5d35784e4f79b89d90ca1a3db93.tar.bz2 fork-ledger-6dbb36f525d1d5d35784e4f79b89d90ca1a3db93.zip |
ledger-mode: Add `ledger-remove-effective-date'.
Signed-off-by: Moritz Ulrich <moritz@tarn-vedra.de>
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ledger-mode.el | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el index 8ae04934..79b6f0ec 100644 --- a/lisp/ledger-mode.el +++ b/lisp/ledger-mode.el @@ -145,6 +145,29 @@ Can indent, complete or align depending on context." (defvar ledger-mode-abbrev-table) +(defun ledger-remove-effective-date () + "Removes the effective date from a transaction or posting." + (interactive) + (let ((context (car (ledger-context-at-point)))) + (save-excursion + (save-restriction + (narrow-to-region (point-at-bol) (point-at-eol)) + (beginning-of-line) + (cond ((eq 'xact context) + (re-search-forward ledger-iso-date-regexp) + (when (= (char-after) ?=) + (let ((eq-pos (point))) + (delete-region + eq-pos + (re-search-forward ledger-iso-date-regexp))))) + ((eq 'acct-transaction context) + ;; Match "; [=date]" & delete string + (when (re-search-forward + (concat ledger-comment-regex + "\\[=" ledger-iso-date-regexp "\\]") + nil 'noerr) + (replace-match "")))))))) + (defun ledger-insert-effective-date () (interactive) (let ((context (car (ledger-context-at-point))) |