summaryrefslogtreecommitdiff
path: root/lisp/ldg-mode.el
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-02-05 12:33:42 -0700
committerCraig Earls <enderw88@gmail.com>2013-02-05 12:33:42 -0700
commit4d7c4929395421eb039f0d03afafaf55cffd686d (patch)
tree733c8c25741bd3777ab2503423dcc86dd8537247 /lisp/ldg-mode.el
parentd67c42207fa75b0b4715705b577a228eec05729a (diff)
downloadfork-ledger-4d7c4929395421eb039f0d03afafaf55cffd686d.tar.gz
fork-ledger-4d7c4929395421eb039f0d03afafaf55cffd686d.tar.bz2
fork-ledger-4d7c4929395421eb039f0d03afafaf55cffd686d.zip
Lisp code cleanup
Most of the files have been touched several times and the indentation structure was wrong. I ran all the files through the emacs indent region function to get back to a baseline
Diffstat (limited to 'lisp/ldg-mode.el')
-rw-r--r--lisp/ldg-mode.el176
1 files changed, 88 insertions, 88 deletions
diff --git a/lisp/ldg-mode.el b/lisp/ldg-mode.el
index 4c55cdc0..226009c6 100644
--- a/lisp/ldg-mode.el
+++ b/lisp/ldg-mode.el
@@ -43,77 +43,77 @@ customizable to ease retro-entry.")
;;;###autoload
(define-derived-mode ledger-mode text-mode "Ledger"
- "A mode for editing ledger data files."
- (ledger-check-version)
- (ledger-post-setup)
-
- (set (make-local-variable 'comment-start) " ; ")
- (set (make-local-variable 'comment-end) "")
- (set (make-local-variable 'indent-tabs-mode) nil)
-
- (if (boundp 'font-lock-defaults)
- (set (make-local-variable 'font-lock-defaults)
- '(ledger-font-lock-keywords nil t)))
-
- (set (make-local-variable 'pcomplete-parse-arguments-function)
- 'ledger-parse-arguments)
- (set (make-local-variable 'pcomplete-command-completion-function)
- 'ledger-complete-at-point)
- (set (make-local-variable 'pcomplete-termination-string) "")
-
- (let ((map (current-local-map)))
- (define-key map [(control ?c) (control ?a)] 'ledger-add-entry)
- (define-key map [(control ?c) (control ?d)] 'ledger-delete-current-entry)
- (define-key map [(control ?c) (control ?y)] 'ledger-set-year)
- (define-key map [(control ?c) (control ?m)] 'ledger-set-month)
- (define-key map [(control ?c) (control ?c)] 'ledger-toggle-current)
- (define-key map [(control ?c) (control ?e)] 'ledger-toggle-current-entry)
- (define-key map [(control ?c) (control ?r)] 'ledger-reconcile)
- (define-key map [(control ?c) (control ?s)] 'ledger-sort-region)
- (define-key map [(control ?c) (control ?t)] 'ledger-test-run)
- (define-key map [(control ?c) (control ?v)] 'ledger-post-edit-amount)
- (define-key map [(control ?c) (control ?f)] 'ledger-occur)
- (define-key map [tab] 'pcomplete)
- (define-key map [(control ?i)] 'pcomplete)
- (define-key map [(control ?c) tab] 'ledger-fully-complete-entry)
- (define-key map [(control ?c) (control ?i)] 'ledger-fully-complete-entry)
- (define-key map [(control ?c) (control ?o) (control ?r)] 'ledger-report)
- (define-key map [(control ?c) (control ?o) (control ?g)] 'ledger-report-goto)
- (define-key map [(control ?c) (control ?o) (control ?a)] 'ledger-report-redo)
- (define-key map [(control ?c) (control ?o) (control ?s)] 'ledger-report-save)
- (define-key map [(control ?c) (control ?o) (control ?e)] 'ledger-report-edit)
- (define-key map [(control ?c) (control ?o) (control ?k)] 'ledger-report-kill)
-
- (define-key map [(meta ?p)] 'ledger-post-prev-xact)
- (define-key map [(meta ?n)] 'ledger-post-next-xact)
-
- (define-key map [menu-bar] (make-sparse-keymap "ldg-menu"))
- (define-key map [menu-bar ldg-menu] (cons "Ledger" map))
-
- (define-key map [report-kill] '(menu-item "Kill Report" ledger-report-kill :enable ledger-works))
- (define-key map [report-edit] '(menu-item "Edit Report" ledger-report-edit :enable ledger-works))
- (define-key map [report-save] '(menu-item "Save Report" ledger-report-save :enable ledger-works))
- (define-key map [report-rrun] '(menu-item "Re-run Report" ledger-report-redo :enable ledger-works))
- (define-key map [report-goto] '(menu-item "Goto Report" ledger-report-goto :enable ledger-works))
- (define-key map [report-run] '(menu-item "Run Report" ledger-report :enable ledger-works))
- (define-key map [sep5] '(menu-item "--"))
- (define-key map [set-month] '(menu-item "Set Month" ledger-set-month :enable ledger-works))
- (define-key map [set-year] '(menu-item "Set Year" ledger-set-year :enable ledger-works))
- (define-key map [sep1] '("--"))
- (define-key map [sort-buff] '(menu-item "Sort Buffer" ledger-sort-buffer))
- (define-key map [sort-reg] '(menu-item "Sort Region" ledger-sort-region :enable mark-active))
- (define-key map [sep2] '(menu-item "--"))
- (define-key map [toggle-post] '(menu-item "Toggle Current Posting" ledger-toggle-current))
- (define-key map [toggle-xact] '(menu-item "Toggle Current Transaction" ledger-toggle-current-entry))
- (define-key map [sep4] '(menu-item "--"))
- (define-key map [edit-amount] '(menu-item "Calc on Amount" ledger-post-edit-amount))
- (define-key map [sep] '(menu-item "--"))
- (define-key map [delete-xact] '(menu-item "Delete Entry" ledger-delete-current-entry))
- (define-key map [add-xact] '(menu-item "Add Entry" ledger-add-entry :enable ledger-works))
- (define-key map [sep3] '(menu-item "--"))
- (define-key map [reconcile] '(menu-item "Reconcile Account" ledger-reconcile :enable ledger-works))
- (define-key map [reconcile] '(menu-item "Hide Xacts" ledger-occur))
- ))
+ "A mode for editing ledger data files."
+ (ledger-check-version)
+ (ledger-post-setup)
+
+ (set (make-local-variable 'comment-start) " ; ")
+ (set (make-local-variable 'comment-end) "")
+ (set (make-local-variable 'indent-tabs-mode) nil)
+
+ (if (boundp 'font-lock-defaults)
+ (set (make-local-variable 'font-lock-defaults)
+ '(ledger-font-lock-keywords nil t)))
+
+ (set (make-local-variable 'pcomplete-parse-arguments-function)
+ 'ledger-parse-arguments)
+ (set (make-local-variable 'pcomplete-command-completion-function)
+ 'ledger-complete-at-point)
+ (set (make-local-variable 'pcomplete-termination-string) "")
+
+ (let ((map (current-local-map)))
+ (define-key map [(control ?c) (control ?a)] 'ledger-add-entry)
+ (define-key map [(control ?c) (control ?d)] 'ledger-delete-current-entry)
+ (define-key map [(control ?c) (control ?y)] 'ledger-set-year)
+ (define-key map [(control ?c) (control ?m)] 'ledger-set-month)
+ (define-key map [(control ?c) (control ?c)] 'ledger-toggle-current)
+ (define-key map [(control ?c) (control ?e)] 'ledger-toggle-current-entry)
+ (define-key map [(control ?c) (control ?r)] 'ledger-reconcile)
+ (define-key map [(control ?c) (control ?s)] 'ledger-sort-region)
+ (define-key map [(control ?c) (control ?t)] 'ledger-test-run)
+ (define-key map [(control ?c) (control ?v)] 'ledger-post-edit-amount)
+ (define-key map [(control ?c) (control ?f)] 'ledger-occur)
+ (define-key map [tab] 'pcomplete)
+ (define-key map [(control ?i)] 'pcomplete)
+ (define-key map [(control ?c) tab] 'ledger-fully-complete-entry)
+ (define-key map [(control ?c) (control ?i)] 'ledger-fully-complete-entry)
+ (define-key map [(control ?c) (control ?o) (control ?r)] 'ledger-report)
+ (define-key map [(control ?c) (control ?o) (control ?g)] 'ledger-report-goto)
+ (define-key map [(control ?c) (control ?o) (control ?a)] 'ledger-report-redo)
+ (define-key map [(control ?c) (control ?o) (control ?s)] 'ledger-report-save)
+ (define-key map [(control ?c) (control ?o) (control ?e)] 'ledger-report-edit)
+ (define-key map [(control ?c) (control ?o) (control ?k)] 'ledger-report-kill)
+
+ (define-key map [(meta ?p)] 'ledger-post-prev-xact)
+ (define-key map [(meta ?n)] 'ledger-post-next-xact)
+
+ (define-key map [menu-bar] (make-sparse-keymap "ldg-menu"))
+ (define-key map [menu-bar ldg-menu] (cons "Ledger" map))
+
+ (define-key map [report-kill] '(menu-item "Kill Report" ledger-report-kill :enable ledger-works))
+ (define-key map [report-edit] '(menu-item "Edit Report" ledger-report-edit :enable ledger-works))
+ (define-key map [report-save] '(menu-item "Save Report" ledger-report-save :enable ledger-works))
+ (define-key map [report-rrun] '(menu-item "Re-run Report" ledger-report-redo :enable ledger-works))
+ (define-key map [report-goto] '(menu-item "Goto Report" ledger-report-goto :enable ledger-works))
+ (define-key map [report-run] '(menu-item "Run Report" ledger-report :enable ledger-works))
+ (define-key map [sep5] '(menu-item "--"))
+ (define-key map [set-month] '(menu-item "Set Month" ledger-set-month :enable ledger-works))
+ (define-key map [set-year] '(menu-item "Set Year" ledger-set-year :enable ledger-works))
+ (define-key map [sep1] '("--"))
+ (define-key map [sort-buff] '(menu-item "Sort Buffer" ledger-sort-buffer))
+ (define-key map [sort-reg] '(menu-item "Sort Region" ledger-sort-region :enable mark-active))
+ (define-key map [sep2] '(menu-item "--"))
+ (define-key map [toggle-post] '(menu-item "Toggle Current Posting" ledger-toggle-current))
+ (define-key map [toggle-xact] '(menu-item "Toggle Current Transaction" ledger-toggle-current-entry))
+ (define-key map [sep4] '(menu-item "--"))
+ (define-key map [edit-amount] '(menu-item "Calc on Amount" ledger-post-edit-amount))
+ (define-key map [sep] '(menu-item "--"))
+ (define-key map [delete-xact] '(menu-item "Delete Entry" ledger-delete-current-entry))
+ (define-key map [add-xact] '(menu-item "Add Entry" ledger-add-entry :enable ledger-works))
+ (define-key map [sep3] '(menu-item "--"))
+ (define-key map [reconcile] '(menu-item "Reconcile Account" ledger-reconcile :enable ledger-works))
+ (define-key map [reconcile] '(menu-item "Hide Xacts" ledger-occur))
+ ))
(defun ledger-time-less-p (t1 t2)
"Say whether time value T1 is less than time value T2."
@@ -133,8 +133,8 @@ Return the difference in the format of a time value."
(ledger-iterate-entries
(function
(lambda (start date mark desc)
- (if (ledger-time-less-p moment date)
- (throw 'found t)))))))
+ (if (ledger-time-less-p moment date)
+ (throw 'found t)))))))
(defun ledger-iterate-entries (callback)
(goto-char (point-min))
@@ -149,18 +149,18 @@ Return the difference in the format of a time value."
(let ((found (match-string 2)))
(if found
(setq current-year (string-to-number found))
- (let ((start (match-beginning 0))
- (year (match-string 3))
- (month (string-to-number (match-string 4)))
- (day (string-to-number (match-string 5)))
- (mark (match-string 6))
- (desc (match-string 7)))
- (if (and year (> (length year) 0))
- (setq year (string-to-number year)))
- (funcall callback start
- (encode-time 0 0 0 day month
- (or year current-year))
- mark desc)))))
+ (let ((start (match-beginning 0))
+ (year (match-string 3))
+ (month (string-to-number (match-string 4)))
+ (day (string-to-number (match-string 5)))
+ (mark (match-string 6))
+ (desc (match-string 7)))
+ (if (and year (> (length year) 0))
+ (setq year (string-to-number year)))
+ (funcall callback start
+ (encode-time 0 0 0 day month
+ (or year current-year))
+ mark desc)))))
(forward-line))))
(defun ledger-set-year (newyear)
@@ -168,14 +168,14 @@ Return the difference in the format of a time value."
(interactive "p")
(if (= newyear 1)
(setq ledger-year (read-string "Year: " (ledger-current-year)))
- (setq ledger-year (number-to-string newyear))))
+ (setq ledger-year (number-to-string newyear))))
(defun ledger-set-month (newmonth)
"Set ledger's idea of the current month to the prefix argument."
(interactive "p")
(if (= newmonth 1)
(setq ledger-month (read-string "Month: " (ledger-current-month)))
- (setq ledger-month (format "%02d" newmonth))))
+ (setq ledger-month (format "%02d" newmonth))))
(defun ledger-add-entry (entry-text &optional insert-at-point)
(interactive (list
@@ -202,7 +202,7 @@ Return the difference in the format of a time value."
(goto-char (point-min))
(if (looking-at "Error: ")
(error (buffer-string))
- (buffer-string)))
+ (buffer-string)))
"\n"))))
(defun ledger-current-entry-bounds ()