diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-23 18:39:54 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-23 18:45:41 -0400 |
commit | 057506ab6dddbfb75d1bb29289602f375ca57df5 (patch) | |
tree | 359075596eb231f462d3decb8f5cd7cf1e5e2ec2 | |
parent | 310e339464d972bba9a66caa55f6409248a0f419 (diff) | |
download | fork-ledger-057506ab6dddbfb75d1bb29289602f375ca57df5.tar.gz fork-ledger-057506ab6dddbfb75d1bb29289602f375ca57df5.tar.bz2 fork-ledger-057506ab6dddbfb75d1bb29289602f375ca57df5.zip |
The Great Renaming
To better follow naming standards used in the accounting community --
particularly those relating to double-entry accounting -- the following
technical terms in Ledger have been changed:
- what was "entry" is now "transaction"
- what was "transaction" is now "posting"
Correspondingly, the shorthand names "entry" and "xact" have been
changed to "xact" and "post", respectively.
-rw-r--r-- | lisp/ledger.el | 190 | ||||
-rwxr-xr-x | tools/rename.sh | 67 |
2 files changed, 162 insertions, 95 deletions
diff --git a/lisp/ledger.el b/lisp/ledger.el index 33d77926..61a9cd12 100644 --- a/lisp/ledger.el +++ b/lisp/ledger.el @@ -35,11 +35,11 @@ ;; To use this module: Load this file, open a ledger data file, and ;; type M-x ledger-mode. Once this is done, you can type: ;; -;; C-c C-a add a new entry, based on previous entries -;; C-c C-e toggle cleared status of an entry -;; C-c C-y set default year for entry mode -;; C-c C-m set default month for entry mode -;; C-c C-r reconcile uncleared entries related to an account +;; C-c C-a add a new transaction, based on previous transactions +;; C-c C-e toggle cleared status of an transaction +;; C-c C-y set default year for transaction mode +;; C-c C-m set default month for transaction mode +;; C-c C-r reconcile uncleared transactions related to an account ;; C-c C-o C-r run a ledger report ;; C-C C-o C-g goto the ledger report buffer ;; C-c C-o C-e edit the defined ledger reports @@ -48,7 +48,7 @@ ;; C-c C-o C-k kill the ledger report buffer ;; ;; In the reconcile buffer, use SPACE to toggle the cleared status of -;; a transaction, C-x C-s to save changes (to the ledger file as +;; a posting, C-x C-s to save changes (to the ledger file as ;; well). ;; ;; The ledger reports command asks the user to select a report to run @@ -85,8 +85,8 @@ :type 'file :group 'ledger) -(defcustom ledger-clear-whole-entries nil - "If non-nil, clear whole entries, not individual transactions." +(defcustom ledger-clear-whole-transactions nil + "If non-nil, clear whole transactions, not individual postings." :type 'boolean :group 'ledger) @@ -121,8 +121,8 @@ text that should replace the format specifier." :type 'alist :group 'ledger) -(defcustom ledger-default-acct-transaction-indent " " - "Default indentation for account transactions in an entry." +(defcustom ledger-default-acct-posting-indent " " + "Default indentation for account postings in an transaction." :type 'string :group 'ledger) @@ -147,12 +147,12 @@ text that should replace the format specifier." (defvar ledger-year (ledger-current-year) "Start a ledger session with the current year, but make it -customizable to ease retro-entry.") +customizable to ease retro-transaction.") (defvar ledger-month (ledger-current-month) "Start a ledger session with the current month, but make it -customizable to ease retro-entry.") +customizable to ease retro-transaction.") -(defun ledger-iterate-entries (callback) +(defun ledger-iterate-transactions (callback) (goto-char (point-min)) (let* ((now (current-time)) (current-year (nth 5 (decode-time now)))) @@ -194,18 +194,18 @@ Return the difference in the format of a time value." (defun ledger-find-slot (moment) (catch 'found - (ledger-iterate-entries + (ledger-iterate-transactions (function (lambda (start date mark desc) (if (ledger-time-less-p moment date) (throw 'found t))))))) -(defun ledger-add-entry (entry-text &optional insert-at-point) +(defun ledger-add-transaction (transaction-text &optional insert-at-point) (interactive (list - (read-string "Entry: " (concat ledger-year "/" ledger-month "/")))) + (read-string "Transaction: " (concat ledger-year "/" ledger-month "/")))) (let* ((args (with-temp-buffer - (insert entry-text) + (insert transaction-text) (eshell-parse-arguments (point-min) (point-max)))) (ledger-buf (current-buffer)) exit-code) @@ -221,7 +221,7 @@ Return the difference in the format of a time value." (insert (with-temp-buffer (setq exit-code - (apply #'ledger-run-ledger ledger-buf "entry" + (apply #'ledger-run-ledger ledger-buf "xact" (mapcar 'eval args))) (goto-char (point-min)) (if (looking-at "Error: ") @@ -231,7 +231,7 @@ Return the difference in the format of a time value." (buffer-string))) "\n")))) -(defun ledger-current-entry-bounds () +(defun ledger-current-transaction-bounds () (save-excursion (when (or (looking-at "^[0-9]") (re-search-backward "^[0-9]" nil t)) @@ -240,12 +240,12 @@ Return the difference in the format of a time value." (forward-line)) (cons (copy-marker beg) (point-marker)))))) -(defun ledger-delete-current-entry () +(defun ledger-delete-current-transaction () (interactive) - (let ((bounds (ledger-current-entry-bounds))) + (let ((bounds (ledger-current-transaction-bounds))) (delete-region (car bounds) (cdr bounds)))) -(defun ledger-toggle-current-entry (&optional style) +(defun ledger-toggle-current-transaction (&optional style) (interactive) (let (clear) (save-excursion @@ -275,7 +275,7 @@ Return the difference in the format of a time value." 'pending 'cleared))) -(defun ledger-entry-state () +(defun ledger-transaction-state () (save-excursion (when (or (looking-at "^[0-9]") (re-search-backward "^[0-9]" nil t)) @@ -285,30 +285,30 @@ Return the difference in the format of a time value." ((looking-at "\\*\\s-*") 'cleared) (t nil))))) -(defun ledger-transaction-state () +(defun ledger-posting-state () (save-excursion (goto-char (line-beginning-position)) (skip-syntax-forward " ") (cond ((looking-at "!\\s-*") 'pending) ((looking-at "\\*\\s-*") 'cleared) - (t (ledger-entry-state))))) + (t (ledger-transaction-state))))) -(defun ledger-toggle-current-transaction (&optional style) - "Toggle the cleared status of the transaction under point. +(defun ledger-toggle-current-posting (&optional style) + "Toggle the cleared status of the posting under point. Optional argument STYLE may be `pending' or `cleared', depending on which type of status the caller wishes to indicate (default is `cleared'). This function is rather complicated because it must preserve both -the overall formatting of the ledger entry, as well as ensuring +the overall formatting of the ledger transaction, as well as ensuring that the most minimal display format is used. This could be -achieved more certainly by passing the entry to ledger for +achieved more certainly by passing the transaction to ledger for formatting, but doing so causes inline math expressions to be dropped." (interactive) - (let ((bounds (ledger-current-entry-bounds)) + (let ((bounds (ledger-current-transaction-bounds)) clear cleared) - ;; Uncompact the entry, to make it easier to toggle the - ;; transaction + ;; Uncompact the transaction, to make it easier to toggle the + ;; posting (save-excursion (goto-char (car bounds)) (skip-chars-forward "0-9./= \t") @@ -329,7 +329,7 @@ dropped." (if (search-forward " " (line-end-position) t) (delete-char 2)) (forward-line)))) - ;; Toggle the individual transaction + ;; Toggle the individual posting (save-excursion (goto-char (line-beginning-position)) (when (looking-at "[ \t]") @@ -367,7 +367,7 @@ dropped." ((looking-at " ") (delete-char 1)))) (setq clear inserted))))) - ;; Clean up the entry so that it displays minimally + ;; Clean up the transaction so that it displays minimally (save-excursion (goto-char (car bounds)) (forward-line) @@ -415,9 +415,9 @@ dropped." (defun ledger-toggle-current (&optional style) (interactive) - (if ledger-clear-whole-entries - (ledger-toggle-current-entry style) - (ledger-toggle-current-transaction style))) + (if ledger-clear-whole-transactions + (ledger-toggle-current-transaction style) + (ledger-toggle-current-posting style))) (defvar ledger-mode-abbrev-table) @@ -439,18 +439,18 @@ dropped." (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 ?a)] 'ledger-add-transaction) + (define-key map [(control ?c) (control ?d)] 'ledger-delete-current-transaction) (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 ?e)] 'ledger-toggle-current-transaction) (define-key map [(control ?c) (control ?r)] 'ledger-reconcile) (define-key map [(control ?c) (control ?s)] 'ledger-sort) (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) tab] 'ledger-fully-complete-transaction) + (define-key map [(control ?c) (control ?i)] 'ledger-fully-complete-transaction) (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) @@ -516,7 +516,7 @@ dropped." (defun ledger-reconcile-add () (interactive) (with-current-buffer ledger-buf - (call-interactively #'ledger-add-entry)) + (call-interactively #'ledger-add-transaction)) (ledger-reconcile-refresh)) (defun ledger-reconcile-delete () @@ -525,7 +525,7 @@ dropped." (when (equal (car where) "<stdin>") (with-current-buffer ledger-buf (goto-char (cdr where)) - (ledger-delete-current-entry)) + (ledger-delete-current-transaction)) (let ((inhibit-read-only t)) (goto-char (line-beginning-position)) (delete-region (point) (1+ (line-end-position))) @@ -579,23 +579,23 @@ dropped." (read (current-buffer)))))))) (dolist (item items) (let ((index 1)) - (dolist (xact (nthcdr 5 item)) + (dolist (post (nthcdr 5 item)) (let ((beg (point)) (where (with-current-buffer buf (cons (nth 0 item) - (if ledger-clear-whole-entries + (if ledger-clear-whole-transactions (save-excursion (goto-line (nth 1 item)) (point-marker)) (save-excursion - (goto-line (nth 0 xact)) + (goto-line (nth 0 post)) (point-marker))))))) (insert (format "%s %-30s %-25s %15s\n" (format-time-string "%m/%d" (nth 2 item)) - (nth 4 item) (nth 1 xact) (nth 2 xact))) - (if (nth 3 xact) + (nth 4 item) (nth 1 post) (nth 2 post))) + (if (nth 3 post) (set-text-properties beg (1- (point)) (list 'face 'bold 'where where)) @@ -623,7 +623,7 @@ dropped." (defvar ledger-reconcile-mode-abbrev-table) (define-derived-mode ledger-reconcile-mode text-mode "Reconcile" - "A mode for reconciling ledger entries." + "A mode for reconciling ledger transactions." (let ((map (make-sparse-keymap))) (define-key map [(control ?m)] 'ledger-reconcile-visit) (define-key map [return] 'ledger-reconcile-visit) @@ -642,12 +642,12 @@ dropped." ;; Context sensitivity (defconst ledger-line-config - '((entry + '((transaction (("^\\(\\([0-9][0-9][0-9][0-9]/\\)?[01]?[0-9]/[0123]?[0-9]\\)[ \t]+\\(\\([!*]\\)[ \t]\\)?[ \t]*\\((\\(.*\\))\\)?[ \t]*\\(.*?\\)[ \t]*;\\(.*\\)[ \t]*$" (date nil status nil nil code payee comment)) ("^\\(\\([0-9][0-9][0-9][0-9]/\\)?[01]?[0-9]/[0123]?[0-9]\\)[ \t]+\\(\\([!*]\\)[ \t]\\)?[ \t]*\\((\\(.*\\))\\)?[ \t]*\\(.*\\)[ \t]*$" (date nil status nil nil code payee)))) - (acct-transaction + (acct-posting (("\\(^[ \t]+\\)\\(.*?\\)[ \t]+\\([$]\\)\\(-?[0-9]*\\(\\.[0-9]*\\)?\\)[ \t]*;[ \t]*\\(.*?\\)[ \t]*$" (indent account commodity amount nil comment)) ("\\(^[ \t]+\\)\\(.*?\\)[ \t]+\\([$]\\)\\(-?[0-9]*\\(\\.[0-9]*\\)?\\)[ \t]*$" @@ -704,13 +704,13 @@ the fields in the line in a association list." (cond ((equal (point) (line-end-position)) '(empty-line nil nil)) ((memq first-char '(?\ ?\t)) - (ledger-extract-context-info 'acct-transaction pos)) + (ledger-extract-context-info 'acct-posting pos)) ((memq first-char '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9)) - (ledger-extract-context-info 'entry pos)) + (ledger-extract-context-info 'transaction pos)) ((equal first-char ?\=) - '(automated-entry nil nil)) + '(automated-transaction nil nil)) ((equal first-char ?\~) - '(period-entry nil nil)) + '(period-transaction nil nil)) ((equal first-char ?\!) '(command-directive)) ((equal first-char ?\;) @@ -775,13 +775,13 @@ specified line, returns nil." (defun ledger-context-goto-field-end (context-info field-name) (goto-char (ledger-context-field-end-position context-info field-name))) -(defun ledger-entry-payee () - "Returns the payee of the entry containing point or nil." +(defun ledger-transaction-payee () + "Returns the payee of the transaction containing point or nil." (let ((i 0)) - (while (eq (ledger-context-line-type (ledger-context-other-line i)) 'acct-transaction) + (while (eq (ledger-context-line-type (ledger-context-other-line i)) 'acct-posting) (setq i (- i 1))) (let ((context-info (ledger-context-other-line i))) - (if (eq (ledger-context-line-type context-info) 'entry) + (if (eq (ledger-context-line-type context-info) 'transaction) (ledger-context-field-value context-info 'payee) nil)))) @@ -904,25 +904,25 @@ otherwise the current buffer file is used." "Substitute a payee name The user is prompted to enter a payee and that is substitued. If -point is in an entry, the payee for that entry is used as the +point is in an transaction, the payee for that transaction is used as the default." ;; It is intended copmletion should be available on existing ;; payees, but the list of possible completions needs to be ;; developed to allow this. - (ledger-read-string-with-default "Payee" (regexp-quote (ledger-entry-payee)))) + (ledger-read-string-with-default "Payee" (regexp-quote (ledger-transaction-payee)))) (defun ledger-report-account-format-specifier () "Substitute an account name The user is prompted to enter an account name, which can be any regular expression identifying an account. If point is on an account -transaction line for an entry, the full account name on that line is +posting line for an transaction, the full account name on that line is the default." ;; It is intended completion should be available on existing account ;; names, but it remains to be implemented. (let* ((context (ledger-context-at-point)) (default - (if (eq (ledger-context-line-type context) 'acct-transaction) + (if (eq (ledger-context-line-type context) 'acct-posting) (regexp-quote (ledger-context-field-value context 'account)) nil))) (ledger-read-string-with-default "Account" default))) @@ -1037,13 +1037,13 @@ the default." (goto-char (line-beginning-position)) (cond ((looking-at "^[0-9/.=-]+\\(\\s-+\\*\\)?\\(\\s-+(.+?)\\)?\\s-+") (goto-char (match-end 0)) - 'entry) + 'transaction) ((looking-at "^\\s-+\\([*!]\\s-+\\)?[[(]?\\(.\\)") (goto-char (match-beginning 2)) - 'transaction) + 'posting) ((looking-at "^\\(sun\\|mon\\|tue\\|wed\\|thu\\|fri\\|sat\\)\\s-+") (goto-char (match-end 0)) - 'entry) + 'transaction) (t (ignore (goto-char here)))))) @@ -1064,9 +1064,9 @@ the default." args))) (cons (reverse args) (reverse begins))))) -(defun ledger-entries () +(defun ledger-transactions () (let ((origin (point)) - entries-list) + transactions-list) (save-excursion (goto-char (point-min)) (while (re-search-forward @@ -1074,9 +1074,9 @@ the default." "\\(.+?\\)\\(\t\\|\n\\| [ \t]\\)") nil t) (unless (and (>= origin (match-beginning 0)) (< origin (match-end 0))) - (setq entries-list (cons (match-string-no-properties 3) - entries-list))))) - (pcomplete-uniqify-list (nreverse entries-list)))) + (setq transactions-list (cons (match-string-no-properties 3) + transactions-list))))) + (pcomplete-uniqify-list (nreverse transactions-list)))) (defvar ledger-account-tree nil) @@ -1093,12 +1093,12 @@ the default." (setq elements (split-string account-path ":")) (let ((root ledger-account-tree)) (while elements - (let ((entry (assoc (car elements) root))) - (if entry - (setq root (cdr entry)) - (setq entry (cons (car elements) (list t))) - (nconc root (list entry)) - (setq root (cdr entry)))) + (let ((transaction (assoc (car elements) root))) + (if transaction + (setq root (cdr transaction)) + (setq transaction (cons (car elements) (list t))) + (nconc root (list transaction)) + (setq root (cdr transaction)))) (setq elements (cdr elements))))))))) (defun ledger-accounts () @@ -1108,11 +1108,11 @@ the default." (root ledger-account-tree) (prefix nil)) (while (cdr elements) - (let ((entry (assoc (car elements) root))) - (if entry + (let ((transaction (assoc (car elements) root))) + (if transaction (setq prefix (concat prefix (and prefix ":") (car elements)) - root (cdr entry)) + root (cdr transaction)) (setq root nil elements nil))) (setq elements (cdr elements))) (and root @@ -1133,16 +1133,16 @@ the default." (interactive) (while (pcomplete-here (if (eq (save-excursion - (ledger-thing-at-point)) 'entry) + (ledger-thing-at-point)) 'transaction) (if (null current-prefix-arg) - (ledger-entries) ; this completes against entry names + (ledger-transactions) ; this completes against transaction names (progn (let ((text (buffer-substring (line-beginning-position) (line-end-position)))) (delete-region (line-beginning-position) (line-end-position)) (condition-case err - (ledger-add-entry text t) + (ledger-add-transaction text t) ((error) (insert text)))) (forward-line) @@ -1152,30 +1152,30 @@ the default." (throw 'pcompleted t))) (ledger-accounts))))) -(defun ledger-fully-complete-entry () +(defun ledger-fully-complete-transaction () "Do appropriate completion for the thing at point" (interactive) (let ((name (caar (ledger-parse-arguments))) - xacts) + posts) (save-excursion - (when (eq 'entry (ledger-thing-at-point)) + (when (eq 'transaction (ledger-thing-at-point)) (when (re-search-backward (concat "^[0-9/.=-]+\\(\\s-+\\*\\)?\\(\\s-+(.*?)\\)?\\s-+" (regexp-quote name) "\\(\t\\|\n\\| [ \t]\\)") nil t) (forward-line) (while (looking-at "^\\s-+") - (setq xacts (cons (buffer-substring-no-properties + (setq posts (cons (buffer-substring-no-properties (line-beginning-position) (line-end-position)) - xacts)) + posts)) (forward-line)) - (setq xacts (nreverse xacts))))) - (when xacts + (setq posts (nreverse posts))))) + (when posts (save-excursion (insert ?\n) - (while xacts - (insert (car xacts) ?\n) - (setq xacts (cdr xacts)))) + (while posts + (insert (car posts) ?\n) + (setq posts (cdr posts)))) (forward-line) (goto-char (line-end-position)) (if (re-search-backward "\\(\t\\| [ \t]\\)" nil t) @@ -1219,7 +1219,7 @@ This is done so that the last digit falls in COLUMN, which defaults to 52." (defalias 'ledger-align-dollars 'ledger-align-amounts) -;; A sample entry sorting function, which works if entry dates are of +;; A sample transaction sorting function, which works if transaction dates are of ;; the form YYYY/mm/dd. (defun ledger-sort () diff --git a/tools/rename.sh b/tools/rename.sh new file mode 100755 index 00000000..7d27d8f8 --- /dev/null +++ b/tools/rename.sh @@ -0,0 +1,67 @@ +#!/bin/zsh + +git reset --hard + +rm -f src/system.hh.gch ledger + +for file in *(.) contrib/*(.) doc/*(.) plan/*(.) python/*(.) src/*(.) test/*(.) test/*/*(.) tools/*(.) +do + echo Renaming items in $file ... + + perl -i -pe 's/xact/fazole/g;' $file 2> /dev/null + perl -i -pe 's/XACT/FAZOLE/g;' $file 2> /dev/null + perl -i -pe 's/Xact/Fazole/g;' $file 2> /dev/null + perl -i -pe 's/xacts/fazoles/g;' $file 2> /dev/null + perl -i -pe 's/XACTS/FAZOLES/g;' $file 2> /dev/null + perl -i -pe 's/Xacts/Fazoles/g;' $file 2> /dev/null + + perl -i -pe 's/transaction/brazole/g;' $file 2> /dev/null + perl -i -pe 's/TRANSACTION/BRAZOLE/g;' $file 2> /dev/null + perl -i -pe 's/Transaction/Brazole/g;' $file 2> /dev/null + perl -i -pe 's/transactions/brazoles/g;' $file 2> /dev/null + perl -i -pe 's/TRANSACTIONS/BRAZOLES/g;' $file 2> /dev/null + perl -i -pe 's/Transactions/Brazoles/g;' $file 2> /dev/null + + perl -i -pe 's/entry/xact/g;' $file 2> /dev/null + perl -i -pe 's/ENTRY/XACT/g;' $file 2> /dev/null + perl -i -pe 's/Entry/Xact/g;' $file 2> /dev/null + perl -i -pe 's/entries/xacts/g;' $file 2> /dev/null + perl -i -pe 's/ENTRIES/XACTS/g;' $file 2> /dev/null + perl -i -pe 's/Entries/Xacts/g;' $file 2> /dev/null + perl -i -pe 's/entrys/xacts/g;' $file 2> /dev/null + perl -i -pe 's/ENTRYS/XACTS/g;' $file 2> /dev/null + perl -i -pe 's/Entrys/Xacts/g;' $file 2> /dev/null + + perl -i -pe 's/fazoles/posts/g;' $file 2> /dev/null + perl -i -pe 's/FAZOLES/POSTS/g;' $file 2> /dev/null + perl -i -pe 's/Fazoles/Posts/g;' $file 2> /dev/null + perl -i -pe 's/fazole/post/g;' $file 2> /dev/null + perl -i -pe 's/FAZOLE/POST/g;' $file 2> /dev/null + perl -i -pe 's/Fazole/Post/g;' $file 2> /dev/null + + perl -i -pe 's/brazoles/postings/g;' $file 2> /dev/null + perl -i -pe 's/BRAZOLES/POSTINGS/g;' $file 2> /dev/null + perl -i -pe 's/Brazoles/Postings/g;' $file 2> /dev/null + perl -i -pe 's/brazole/posting/g;' $file 2> /dev/null + perl -i -pe 's/BRAZOLE/POSTING/g;' $file 2> /dev/null + perl -i -pe 's/Brazole/Posting/g;' $file 2> /dev/null + + perl -i -pe 's/\@dirxact/\@direntry/g;' $file 2> /dev/null + perl -i -pe 's/\@end dirxact/\@end direntry/g;' $file 2> /dev/null +done + +mv src/xact.h src/fazole.h +mv src/xact.cc src/fazole.cc +mv src/entry.h src/xact.h +mv src/entry.cc src/xact.cc +mv src/fazole.h src/post.h +mv src/fazole.cc src/post.cc + +mv src/py_xact.py src/fazole.py +mv src/py_entry.py src/py_xact.py +mv src/fazole.py src/py_post.py + +ln -sf ~/Products/ledger/ledger . + +tools/myacprep + |