summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorSteve Purcell <steve@sanityinc.com>2013-12-09 20:33:20 +0000
committerSteve Purcell <steve@sanityinc.com>2013-12-09 20:41:01 +0000
commitc85643b04e2274c35744142656c642e30b1d3708 (patch)
tree3c8f9ada25425d2ff437800842bcd0681f2534dd /lisp
parent123ada2f377c6bf20afebfcb65345b2c107723af (diff)
downloadfork-ledger-c85643b04e2274c35744142656c642e30b1d3708.tar.gz
fork-ledger-c85643b04e2274c35744142656c642e30b1d3708.tar.bz2
fork-ledger-c85643b04e2274c35744142656c642e30b1d3708.zip
ledger-mode: declare keymaps at the top level
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ledger-mode.el71
-rw-r--r--lisp/ledger-reconcile.el8
-rw-r--r--lisp/ledger-report.el78
3 files changed, 81 insertions, 76 deletions
diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el
index 2f860f2f..b9f77ba6 100644
--- a/lisp/ledger-mode.el
+++ b/lisp/ledger-mode.el
@@ -176,40 +176,8 @@ Can indent, complete or align depending on context."
table)
"Syntax table for `ledger-mode' buffers.")
-;;;###autoload
-(define-derived-mode ledger-mode text-mode "Ledger"
- "A mode for editing ledger data files."
- (ledger-check-version)
- (ledger-schedule-check-available)
- (ledger-post-setup)
-
- (set-syntax-table ledger-mode-syntax-table)
- (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)))
- (setq font-lock-extend-region-functions
- (list #'font-lock-extend-region-wholelines))
- (setq font-lock-multiline nil)
-
- (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) "")
-
- (add-hook 'post-command-hook 'ledger-highlight-xact-under-point nil t)
- (add-hook 'before-revert-hook 'ledger-occur-remove-all-overlays nil t)
- (make-variable-buffer-local 'highlight-overlay)
-
- (ledger-init-load-init-file)
-
- (set (make-local-variable 'indent-region-function) 'ledger-post-align-postings)
-
- (let ((map (current-local-map)))
+(defvar ledger-mode-map
+ (let ((map (make-sparse-keymap)))
(define-key map [(control ?c) (control ?a)] 'ledger-add-transaction)
(define-key map [(control ?c) (control ?b)] 'ledger-post-edit-amount)
(define-key map [(control ?c) (control ?c)] 'ledger-toggle-current)
@@ -283,9 +251,42 @@ Can indent, complete or align depending on context."
(define-key map [add-xact] '(menu-item "Show upcoming transactions" ledger-schedule-upcoming :enable ledger-schedule-available))
(define-key map [sep3] '(menu-item "--"))
(define-key map [stats] '(menu-item "Ledger Statistics" ledger-display-ledger-stats :enable ledger-works))
- (define-key map [fold-buffer] '(menu-item "Narrow to REGEX" ledger-occur))))
+ (define-key map [fold-buffer] '(menu-item "Narrow to REGEX" ledger-occur))
+ map)
+ "Keymap for `ledger-mode'.")
+
+;;;###autoload
+(define-derived-mode ledger-mode text-mode "Ledger"
+ "A mode for editing ledger data files."
+ (ledger-check-version)
+ (ledger-schedule-check-available)
+ (ledger-post-setup)
+ (set-syntax-table ledger-mode-syntax-table)
+ (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)))
+ (setq font-lock-extend-region-functions
+ (list #'font-lock-extend-region-wholelines))
+ (setq font-lock-multiline nil)
+
+ (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) "")
+
+ (add-hook 'post-command-hook 'ledger-highlight-xact-under-point nil t)
+ (add-hook 'before-revert-hook 'ledger-occur-remove-all-overlays nil t)
+ (make-variable-buffer-local 'highlight-overlay)
+
+ (ledger-init-load-init-file)
+ (set (make-local-variable 'indent-region-function) 'ledger-post-align-postings))
(defun ledger-set-year (newyear)
diff --git a/lisp/ledger-reconcile.el b/lisp/ledger-reconcile.el
index 4821a982..e15d0a67 100644
--- a/lisp/ledger-reconcile.el
+++ b/lisp/ledger-reconcile.el
@@ -431,8 +431,7 @@ moved and recentered. If they aren't strange things happen."
(setq ledger-reconcile-sort-key ,sort-by)
(ledger-reconcile-refresh)))
-(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)
@@ -482,8 +481,11 @@ moved and recentered. If they aren't strange things happen."
(define-key map [menu-bar ledger-recon-menu fin] '("Finish" . ledger-reconcile-finish))
(define-key map [menu-bar ledger-recon-menu ref] '("Refresh" . ledger-reconcile-refresh))
(define-key map [menu-bar ledger-recon-menu sav] '("Save" . ledger-reconcile-save))
+ map)
+ "Keymap for `ledger-reconcile-mode'.")
- (use-local-map map)))
+(define-derived-mode ledger-reconcile-mode text-mode "Reconcile"
+ "A mode for reconciling ledger entries.")
(provide 'ledger-reconcile)
diff --git a/lisp/ledger-report.el b/lisp/ledger-report.el
index e785bc1b..022cb6f6 100644
--- a/lisp/ledger-report.el
+++ b/lisp/ledger-report.el
@@ -84,45 +84,47 @@ text that should replace the format specifier."
(setq inhibit-read-only t)
(reverse-region (point) (point-max))))
+(defvar ledger-report-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map [? ] 'scroll-up)
+ (define-key map [backspace] 'scroll-down)
+ (define-key map [?r] 'ledger-report-redo)
+ (define-key map [(shift ?r)] 'ledger-report-reverse-lines)
+ (define-key map [?s] 'ledger-report-save)
+ (define-key map [?k] 'ledger-report-kill)
+ (define-key map [?e] 'ledger-report-edit)
+ (define-key map [?q] 'ledger-report-quit)
+ (define-key map [(control ?c) (control ?l) (control ?r)]
+ 'ledger-report-redo)
+ (define-key map [(control ?c) (control ?l) (control ?S)]
+ 'ledger-report-save)
+ (define-key map [(control ?c) (control ?l) (control ?k)]
+ 'ledger-report-kill)
+ (define-key map [(control ?c) (control ?l) (control ?e)]
+ 'ledger-report-edit)
+ (define-key map [return] 'ledger-report-visit-source)
+
+
+ (define-key map [menu-bar] (make-sparse-keymap "ledger-rep"))
+ (define-key map [menu-bar ledger-rep] (cons "Reports" map))
+
+ (define-key map [menu-bar ledger-rep lrq] '("Quit" . ledger-report-quit))
+ (define-key map [menu-bar ledger-rep s2] '("--"))
+ (define-key map [menu-bar ledger-rep lrd] '("Scroll Down" . scroll-down))
+ (define-key map [menu-bar ledger-rep vis] '("Visit Source" . ledger-report-visit-source))
+ (define-key map [menu-bar ledger-rep lru] '("Scroll Up" . scroll-up))
+ (define-key map [menu-bar ledger-rep s1] '("--"))
+ (define-key map [menu-bar ledger-rep rev] '("Reverse report order" . ledger-report-reverse-lines))
+ (define-key map [menu-bar ledger-rep s0] '("--"))
+ (define-key map [menu-bar ledger-rep lrk] '("Kill Report" . ledger-report-kill))
+ (define-key map [menu-bar ledger-rep lrr] '("Re-run Report" . ledger-report-redo))
+ (define-key map [menu-bar ledger-rep lre] '("Edit Report" . ledger-report-edit))
+ (define-key map [menu-bar ledger-rep lrs] '("Save Report" . ledger-report-save))
+ map)
+ "Keymap for `ledger-report-mode'.")
+
(define-derived-mode ledger-report-mode text-mode "Ledger-Report"
- "A mode for viewing ledger reports."
- (let ((map (make-sparse-keymap)))
- (define-key map [? ] 'scroll-up)
- (define-key map [backspace] 'scroll-down)
- (define-key map [?r] 'ledger-report-redo)
- (define-key map [(shift ?r)] 'ledger-report-reverse-lines)
- (define-key map [?s] 'ledger-report-save)
- (define-key map [?k] 'ledger-report-kill)
- (define-key map [?e] 'ledger-report-edit)
- (define-key map [?q] 'ledger-report-quit)
- (define-key map [(control ?c) (control ?l) (control ?r)]
- 'ledger-report-redo)
- (define-key map [(control ?c) (control ?l) (control ?S)]
- 'ledger-report-save)
- (define-key map [(control ?c) (control ?l) (control ?k)]
- 'ledger-report-kill)
- (define-key map [(control ?c) (control ?l) (control ?e)]
- 'ledger-report-edit)
- (define-key map [return] 'ledger-report-visit-source)
-
-
- (define-key map [menu-bar] (make-sparse-keymap "ledger-rep"))
- (define-key map [menu-bar ledger-rep] (cons "Reports" map))
-
- (define-key map [menu-bar ledger-rep lrq] '("Quit" . ledger-report-quit))
- (define-key map [menu-bar ledger-rep s2] '("--"))
- (define-key map [menu-bar ledger-rep lrd] '("Scroll Down" . scroll-down))
- (define-key map [menu-bar ledger-rep vis] '("Visit Source" . ledger-report-visit-source))
- (define-key map [menu-bar ledger-rep lru] '("Scroll Up" . scroll-up))
- (define-key map [menu-bar ledger-rep s1] '("--"))
- (define-key map [menu-bar ledger-rep rev] '("Reverse report order" . ledger-report-reverse-lines))
- (define-key map [menu-bar ledger-rep s0] '("--"))
- (define-key map [menu-bar ledger-rep lrk] '("Kill Report" . ledger-report-kill))
- (define-key map [menu-bar ledger-rep lrr] '("Re-run Report" . ledger-report-redo))
- (define-key map [menu-bar ledger-rep lre] '("Edit Report" . ledger-report-edit))
- (define-key map [menu-bar ledger-rep lrs] '("Save Report" . ledger-report-save))
-
- (use-local-map map)))
+ "A mode for viewing ledger reports.")
(defun ledger-report-value-format-specifier ()
"Return a valid meta-data tag name"