diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ldg-new.el | 26 | ||||
-rw-r--r-- | lisp/ledger.el | 24 |
2 files changed, 42 insertions, 8 deletions
diff --git a/lisp/ldg-new.el b/lisp/ldg-new.el index 84863c95..64377bb9 100644 --- a/lisp/ldg-new.el +++ b/lisp/ldg-new.el @@ -53,4 +53,30 @@ (provide 'ledger) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun ledger-create-test () + (interactive) + (save-restriction + (org-narrow-to-subtree) + (save-excursion + (let (text beg) + (goto-char (point-min)) + (forward-line 1) + (setq beg (point)) + (search-forward ":PROPERTIES:") + (goto-char (line-beginning-position)) + (setq text (buffer-substring-no-properties beg (point))) + (goto-char (point-min)) + (re-search-forward ":ID:\\s-+\\([^-]+\\)") + (find-file-other-window + (format "~/src/ledger/test/regress/%s.test" (match-string 1))) + (sit-for 0) + (insert text) + (goto-char (point-min)) + (while (not (eobp)) + (goto-char (line-beginning-position)) + (delete-char 3) + (forward-line 1)))))) + ;;; ledger.el ends here diff --git a/lisp/ledger.el b/lisp/ledger.el index 25bb485b..2d15f090 100644 --- a/lisp/ledger.el +++ b/lisp/ledger.el @@ -433,7 +433,9 @@ dropped." ;;;###autoload (define-derived-mode ledger-mode text-mode "Ledger" - "A mode for editing ledger data files." + "A mode for editing ledger data files. + +\\{ledger-mode-map}" (set (make-local-variable 'comment-start) " ; ") (set (make-local-variable 'comment-end) "") (set (make-local-variable 'indent-tabs-mode) nil) @@ -632,8 +634,7 @@ dropped." (defvar ledger-reconcile-mode-abbrev-table) -(define-derived-mode ledger-reconcile-mode text-mode "Reconcile" - "A mode for reconciling ledger entries." +(defvar ledger-reconcile-mode-map (let ((map (make-sparse-keymap))) (define-key map [(control ?m)] 'ledger-reconcile-visit) (define-key map [return] 'ledger-reconcile-visit) @@ -647,7 +648,12 @@ dropped." (define-key map [?p] 'previous-line) (define-key map [?s] 'ledger-reconcile-save) (define-key map [?q] 'ledger-reconcile-quit) - (use-local-map map))) + map)) + +(define-derived-mode ledger-reconcile-mode text-mode "Reconcile" + "A mode for reconciling ledger entries. + +\\{ledger-reconcile-mode-map}") ;; Context sensitivity @@ -807,8 +813,7 @@ specified line, returns nil." (defvar ledger-report-mode-abbrev-table) -(define-derived-mode ledger-report-mode text-mode "Ledger-Report" - "A mode for viewing ledger reports." +(defvar ledger-report-mode-map (let ((map (make-sparse-keymap))) (define-key map [? ] 'scroll-up) (define-key map [backspace] 'scroll-down) @@ -825,7 +830,10 @@ specified line, returns nil." 'ledger-report-kill) (define-key map [(control ?c) (control ?l) (control ?e)] 'ledger-report-edit) - (use-local-map map))) + map)) + +(define-derived-mode ledger-report-mode text-mode "Ledger-Report" + "A mode for viewing ledger reports.") (defun ledger-report-read-name () "Read the name of a ledger report to use, with completion. @@ -1201,7 +1209,7 @@ the default." ;; A sample function for $ users (defun ledger-next-amount (&optional end) - (when (re-search-forward "\\( \\|\t\\| \t\\)[ \t]*-?\\([A-Z$]+ *\\)?\\(-?[0-9,]+?\\)\\(.[0-9]+\\)?\\( *[A-Z$]+\\)?\\([ \t]*@@?[^\n;]+?\\)?\\([ \t]+;.+?\\)?$" (marker-position end) t) + (when (re-search-forward "\\( \\|\t\\| \t\\)[ \t]*-?\\([A-Z$€£]+ *\\)?\\(-?[0-9,]+?\\)\\(.[0-9]+\\)?\\( *[A-Z$€£]+\\)?\\([ \t]*@@?[^\n;]+?\\)?\\([ \t]+;.+?\\)?$" (marker-position end) t) (goto-char (match-beginning 0)) (skip-syntax-forward " ") (- (or (match-end 4) |