From 6dbb36f525d1d5d35784e4f79b89d90ca1a3db93 Mon Sep 17 00:00:00 2001 From: Moritz Ulrich Date: Mon, 30 Dec 2013 00:22:43 +0100 Subject: ledger-mode: Add `ledger-remove-effective-date'. Signed-off-by: Moritz Ulrich --- lisp/ledger-mode.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'lisp/ledger-mode.el') 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))) -- cgit v1.2.3