summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorMoritz Ulrich <moritz@tarn-vedra.de>2013-12-29 22:56:45 +0100
committerMoritz Ulrich <moritz@tarn-vedra.de>2013-12-29 22:56:45 +0100
commit15b94e8f4443311723e0f88c4af1c5c417184ba5 (patch)
treed7818c5b3e7f0d3654d1c8252a0bb1aa672fb329 /lisp
parentc0812b91bf7e0f2b913dd679cf5c55524fd8bbd5 (diff)
downloadfork-ledger-15b94e8f4443311723e0f88c4af1c5c417184ba5.tar.gz
fork-ledger-15b94e8f4443311723e0f88c4af1c5c417184ba5.tar.bz2
fork-ledger-15b94e8f4443311723e0f88c4af1c5c417184ba5.zip
emacs-mode: Prefix every function/variable/macro with ledger-.
This is the common convention in Emacs Lisp. Not following it might cause problems with other packages as functions/variables/macros are always visible to other modules. Signed-off-by: Moritz Ulrich <moritz@tarn-vedra.de>
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ledger-context.el61
-rw-r--r--lisp/ledger-reconcile.el4
2 files changed, 33 insertions, 32 deletions
diff --git a/lisp/ledger-context.el b/lisp/ledger-context.el
index eb3d4353..44ad3a30 100644
--- a/lisp/ledger-context.el
+++ b/lisp/ledger-context.el
@@ -28,29 +28,30 @@
(eval-when-compile
(require 'cl))
-;; *-string constants are assembled in the single-line-config macro to
-;; form the regex and list of elements
-(defconst indent-string "\\(^[ \t]+\\)")
-(defconst status-string "\\([*! ]?\\)")
-(defconst account-string "[\\[(]?\\(.*?\\)[])]?")
-(defconst amount-string "[ \t]?\\(-?[0-9]+\\.[0-9]*\\)")
-(defconst comment-string "[ \t]*;[ \t]*\\(.*?\\)")
-(defconst nil-string "\\([ \t]+\\)")
-(defconst commodity-string "\\(.+?\\)")
-(defconst date-string "^\\([0-9]\\{4\\}[/-][01]?[0-9][/-][0123]?[0-9]\\)")
-(defconst code-string "\\((.*)\\)?")
-(defconst payee-string "\\(.*\\)")
-
-(defmacro line-regex (&rest elements)
+;; ledger-*-string constants are assembled in the
+;; `ledger-single-line-config' macro to form the regex and list of
+;; elements
+(defconst ledger-indent-string "\\(^[ \t]+\\)")
+(defconst ledger-status-string "\\([*! ]?\\)")
+(defconst ledger-account-string "[\\[(]?\\(.*?\\)[])]?")
+(defconst ledger-amount-string "[ \t]?\\(-?[0-9]+\\.[0-9]*\\)")
+(defconst ledger-comment-string "[ \t]*;[ \t]*\\(.*?\\)")
+(defconst ledger-nil-string "\\([ \t]+\\)")
+(defconst ledger-commodity-string "\\(.+?\\)")
+(defconst ledger-date-string "^\\([0-9]\\{4\\}[/-][01]?[0-9][/-][0123]?[0-9]\\)")
+(defconst ledger-code-string "\\((.*)\\)?")
+(defconst ledger-payee-string "\\(.*\\)")
+
+(defmacro ledger-line-regex (&rest elements)
(let (regex-string)
(concat (dolist (e elements regex-string)
(setq regex-string
(concat regex-string
(eval
(intern
- (concat (symbol-name e) "-string")))))) "[ \t]*$")))
+ (concat "ledger-" (symbol-name e) "-string")))))) "[ \t]*$")))
-(defmacro single-line-config2 (&rest elements)
+(defmacro ledger-single-line-config2 (&rest elements)
"Take list of ELEMENTS and return regex and element list for use in context-at-point"
(let (regex-string)
`'(,(concat (dolist (e elements regex-string)
@@ -58,26 +59,26 @@
(concat regex-string
(eval
(intern
- (concat (symbol-name e) "-string")))))) "[ \t]*$")
+ (concat "ledger-" (symbol-name e) "-string")))))) "[ \t]*$")
,elements)))
-(defmacro single-line-config (&rest elements)
+(defmacro ledger-single-line-config (&rest elements)
"Take list of ELEMENTS and return regex and element list for use in context-at-point"
- `'(,(eval `(line-regex ,@elements))
+ `'(,(eval `(ledger-line-regex ,@elements))
,elements))
(defconst ledger-line-config
- (list (list 'xact (list (single-line-config date nil status nil code nil payee nil comment)
- (single-line-config date nil status nil code nil payee)
- (single-line-config date nil status nil payee)))
- (list 'acct-transaction (list (single-line-config indent comment)
- (single-line-config2 indent status account nil commodity amount nil comment)
- (single-line-config2 indent status account nil commodity amount)
- (single-line-config2 indent status account nil amount nil commodity comment)
- (single-line-config2 indent status account nil amount nil commodity)
- (single-line-config2 indent status account nil amount)
- (single-line-config2 indent status account nil comment)
- (single-line-config2 indent status account)))))
+ (list (list 'xact (list (ledger-single-line-config date nil status nil code nil payee nil comment)
+ (ledger-single-line-config date nil status nil code nil payee)
+ (ledger-single-line-config date nil status nil payee)))
+ (list 'acct-transaction (list (ledger-single-line-config indent comment)
+ (ledger-single-line-config2 indent status account nil commodity amount nil comment)
+ (ledger-single-line-config2 indent status account nil commodity amount)
+ (ledger-single-line-config2 indent status account nil amount nil commodity comment)
+ (ledger-single-line-config2 indent status account nil amount nil commodity)
+ (ledger-single-line-config2 indent status account nil amount)
+ (ledger-single-line-config2 indent status account nil comment)
+ (ledger-single-line-config2 indent status account)))))
(defun ledger-extract-context-info (line-type pos)
"Get context info for current line with LINE-TYPE.
diff --git a/lisp/ledger-reconcile.el b/lisp/ledger-reconcile.el
index 126b7083..2e8e1ef9 100644
--- a/lisp/ledger-reconcile.el
+++ b/lisp/ledger-reconcile.el
@@ -109,7 +109,7 @@ And calculate the target-delta of the account being reconciled."
(message "Pending balance: %s"
(ledger-commodity-to-string pending))))))
-(defun is-stdin (file)
+(defun ledger-is-stdin (file)
"True if ledger FILE is standard input."
(or
(equal file "")
@@ -279,7 +279,7 @@ and exit reconcile mode"
(defun ledger-marker-where-xact-is (emacs-xact posting)
"Find the position of the EMACS-XACT in the `ledger-buf'.
POSTING is used in `ledger-clear-whole-transactions' is nil."
- (let ((buf (if (is-stdin (nth 0 emacs-xact))
+ (let ((buf (if (ledger-is-stdin (nth 0 emacs-xact))
ledger-buf
(find-file-noselect (nth 0 emacs-xact)))))
(cons