Update copyright/commentary
[emoney] / emoney.el
index 3788fdf..6cbadd3 100644 (file)
--- a/emoney.el
+++ b/emoney.el
@@ -1,6 +1,6 @@
 ;; emoney.el --- A home finance package.
 
-;; Copyright (C) 2003 - 2011 Steve Youngs
+;; Copyright (C) 2003 - 2017 Steve Youngs
 
 ;; Author:        Steve Youngs <steve@sxemacs.org>
 ;; Maintainer:    Steve Youngs <steve@sxemacs.org>
 ;;  <bnewell@alum.mit.edu>.
 ;;
 ;;  eMoney tries to give the user a reasonably self-contained finance
-;;  solution.  The target audience is the home user and possibly the
-;;  small (very small) business operator.  It probably will never be
-;;  compatible with any commercial finance packages available.
+;;  solution.  The target audience is the home user.  It probably
+;;  will never be compatible with any commercial finance packages
+;;  available.
 ;;
 ;;  Right now, eMoney is nothing more than a very simple cash book
-;;  program.  Use it to balance your cheque book.  See the "Todo:"
-;;  section for a partial list of possible upcoming features.
+;;  program.  Use it to balance your cheque book.  See the TODO file
+;;  for a partial list of possible upcoming features.
 ;;
 ;;  Installation (from source):
 ;;
@@ -71,7 +71,7 @@
 ;;  `.emy' extension.
 ;;
 ;; Please note that I use SXEmacs exclusively, I have no idea whether
-;; or not this will run or even byte-compile with GNU/Emacs (it _will_
+;; or not this will run or even byte-compile with GNU/Emacs (it _should_
 ;; work fine with XEmacs).  Also, I have no desire or intentions of
 ;; making this package portable between XEmacs and GNU/Emacs.  Harsh
 ;; words?  No, not really, I simply don't have the time or resources to
 ;;
 ;; Another note: This package uses correct English spelling wherever
 ;; possible.  For example, "cheque" instead of "check", "summarise"
-;; instead of "summarize".  Although I welcome and encourage _ALL_
-;; contributions, patches that s/que/ch/ or s/ise/ize/ will go straight
-;; to /dev/null.
+;; instead of "summarize".
 
 ;;; ChangeLog:
 ;;
 ;;  This is just a place holder so `emoney-commentary' will work
-;;  properly.  See the ChangeLog file for changes.
+;;  properly.  See the ChangeLog files in ChangeLog.d and git log for
+;;  changes.
 
 ;;; Code:
 
@@ -564,6 +563,43 @@ in the current buffer."
                  (concat emoney-current-account-name ".emy")))
   (run-hooks 'emoney-switch-account-hook))
 
+(defun emoney-goto-default-account ()
+  "Switch to `emoney-default-account'."
+  (interactive)
+  (emoney-switch-to-account emoney-default-account))
+
+;:*=======================
+;:* Walk accounts
+(defun emoney-walk-accounts (direction)
+  "Move to account in direction, DIRECTION."
+  (let ((dl-acc-list (mapfam #'identity
+                            emoney-chart-of-accounts
+                            :result-type 'dllist)))
+    ;; Line up the dllist's car with the current account
+    (while (not (equal (dllist-car dl-acc-list) 
+                      (concat emoney-current-account-name ".emy")))
+      (dllist-rrotate dl-acc-list))
+    (cond
+     ((eq direction 'next)
+      (progn
+       (dllist-lrotate dl-acc-list)
+       (emoney-switch-to-account (dllist-car dl-acc-list))))
+     ((eq direction 'previous)
+      (progn
+       (dllist-rrotate dl-acc-list)
+       (emoney-switch-to-account (dllist-car dl-acc-list))))
+     (t (error 'invalid-argument)))))
+
+(defun emoney-walk-accounts-next ()
+  "Switch to the 'next' account in the chart of accounts."
+  (interactive)
+  (emoney-walk-accounts 'next))
+
+(defun emoney-walk-accounts-previous ()
+  "Switch to the 'previous' account in the chart of accounts."
+  (interactive)
+  (emoney-walk-accounts 'previous))
+
 (defconst emoney-accounts-buffer-map
   (let* ((map (make-sparse-keymap 'emoney-accounts-buffer-map)))
     (define-key map [button2] #'emoney-mouse-switch-to-account)
@@ -715,8 +751,11 @@ transactions.")
     (define-key map [(control c) b]           #'emoney-go-to-bank)
     (define-key map [(control c) c]           #'emoney-calc)
     (define-key map [(control c) s]           #'emoney-switch-to-account)
+    (define-key map [(control c) d]           #'emoney-goto-default-account)
     (define-key map [(control c) q]           #'emoney-quit)
     (define-key map [(control c) (control q)] #'emoney-recalc-and-exit)
+    (define-key map [(meta n)]                #'emoney-walk-accounts-next)
+    (define-key map [(meta p)]                #'emoney-walk-accounts-previous)
     map)
   "Keymap for emoney buffer.")