Check README.

This commit is contained in:
David Keegan 2013-10-28 10:25:41 +00:00
parent 638fbf4c7d
commit db568429e2
5 changed files with 44 additions and 33 deletions

View file

@ -1,4 +1,6 @@
An add-on to ledger-mode which inserts recurring transactions to An add-on to ledger-mode which appends recurring transactions to
the current file. the current ledger file. Recurring transactions are configured in a
separate file which conforms to ledger file format and resides in
the same directory as the ledger file.

View file

@ -19,7 +19,7 @@ class Transaction:
self._Dis = None # Date in Seconds (since epoch). self._Dis = None # Date in Seconds (since epoch).
self._Ds = None # Actual Date Separator. self._Ds = None # Actual Date Separator.
self._Period = None # Period String. self._Period = None # Period String.
self._Al = [] # Additional Lines (after date). self._Al = [] # Additional Lines (after date).
if not Line is None: self._Set(Line) if not Line is None: self._Set(Line)
def __repr__(self): def __repr__(self):

View file

@ -1,4 +1,4 @@
; Generated by usMelpaBuild(dk.sh). Do not edit! ; Generated by usMelpaBuild(dk.sh). Do not edit!
(define-package "dklrt" "0.1" (define-package "dklrt" "1.0"
"Ledger Recurring Transactions." "Ledger Recurring Transactions."
'((ldg-mode "20130908.1357") (emacs "24.1"))) '((dkmisc "0.5") (ldg-mode "20130908.1357") (emacs "24.1")))

View file

@ -3,28 +3,31 @@
;; Copyright: (c) David Keegan 2011-2013. ;; Copyright: (c) David Keegan 2011-2013.
;; Licence: FSF GPLv3. ;; Licence: FSF GPLv3.
;; Author: David Keegan <dksw@eircom.net> ;; Author: David Keegan <dksw@eircom.net>
;; Version: 0.1 ;; Version: 1.0
;; Package-Requires: ((ldg-mode "20130908.1357") (emacs "24.1")) ;; Package-Requires: ((dkmisc "0.5") (ldg-mode "20130908.1357") (emacs "24.1"))
;; Keywords: ledger ledger-cli recurring periodic automatic ;; Keywords: ledger ledger-cli recurring periodic automatic
;; URL: https://github.com/davidkeegan/dklrt ;; URL: https://github.com/davidkeegan/dklrt
;;; Commentary: ;;; Commentary:
;; An add-on to ledger-mode which inserts recurring transactions to ;; An add-on to ledger-mode which appends recurring transactions to
;; the current file. ;; the current ledger file. Recurring transactions are configured in a
;; separate file which conforms to ledger file format and resides in
;; the same directory as the ledger file.
;;; Code: ;;; Code:
(require 'dkmisc) (require 'dkmisc)
(require 'ledger "ledger-mode")
;;;###autoload ;;;###autoload
(defgroup dklrt nil (defgroup dklrt nil
"Customisation of dklrt package (Ledger Recurring Transactions)." "Customisation of dklrt package (Ledger Recurring Transactions)."
:tag "dklrt" :tag "dklrt"
:group 'dk) :group 'dk)
(defcustom dklrt-SortAfterAppend nil (defcustom dklrt-SortAfterAppend nil
"Controls positioning of appended recurring transactions. "Controls positioning of appended recurring transactions.
If non-nil, sort the ledger buffer after recurring transactions If non-nil, sort the ledger buffer after recurring transactions
have been appended. This ensures the recurring transactions are have been appended. This ensures the recurring transactions are
positioned by date. Note: the positions of non-recurring positioned by date. Note: the positions of non-recurring
@ -33,13 +36,13 @@ transactions will probably be affected."
:type '(boolean)) :type '(boolean))
(defcustom dklrt-PythonProgram "python" (defcustom dklrt-PythonProgram "python"
"The Python interpreter to be run. "The Python interpreter to be run.
The default assumes python is on the PATH." The default assumes python is on the PATH."
:tag "dklrt-PythonProgram" :tag "dklrt-PythonProgram"
:type '(string)) :type '(string))
(defcustom dklrt-AppendBefore "1w" (defcustom dklrt-AppendBefore "1w"
"Controls when a recurring transaction is actually appended. "Controls when a recurring transaction is actually appended.
The value is a period do list format: <integer><y|m|d|w|h>. A The value is a period do list format: <integer><y|m|d|w|h>. A
recurring transaction is appended when the current date/time is recurring transaction is appended when the current date/time is
greater than or equal to the configured transaction date minus greater than or equal to the configured transaction date minus
@ -50,12 +53,12 @@ transaction date."
:type '(string)) :type '(string))
(defcustom dklrt-LedgerFileSuffix "ldg" (defcustom dklrt-LedgerFileSuffix "ldg"
"Suffix of Ledger File (excluding period)." "Suffix of Ledger File (excluding period)."
:tag "dklrt-LedgerFileSuffix" :tag "dklrt-LedgerFileSuffix"
:type '(string)) :type '(string))
(defcustom dklrt-RecurringConfigFileSuffix "rec" (defcustom dklrt-RecurringConfigFileSuffix "rec"
"Suffix of Recurring Transactions Config File (excluding period)." "Suffix of Recurring Transactions Config File (excluding period)."
:tag "dklrt-RecurringConfigFileSuffix" :tag "dklrt-RecurringConfigFileSuffix"
:type '(string)) :type '(string))
@ -66,23 +69,23 @@ transaction date."
; Hard-coded alternative value for debug only. ; Hard-coded alternative value for debug only.
(or dklrt-PackageDirectory (or dklrt-PackageDirectory
(setq dklrt-PackageDirectory "/opt/dk/emacs/dklrt-20131028.838/")) (setq dklrt-PackageDirectory "/opt/dk/emacs/dklrt-20131028.954/"))
;;;###autoload ;;;###autoload
(defun dklrt-SetCcKeys() (defun dklrt-SetCcKeys()
"Bind \C-cr to dklrt-AppendRecurring. "Bind \C-cr to `dklrt-AppendRecurring'.
To invoke, add this function to ledger-mode-hook." To invoke, add this function to `ledger-mode-hook'."
(define-key (current-local-map) "\C-cr" 'dklrt-AppendRecurring)) (define-key (current-local-map) "\C-cr" 'dklrt-AppendRecurring))
;;;###autoload ;;;###autoload
(defun dklrt-AppendRecurringMaybe() (defun dklrt-AppendRecurringMaybe()
"Call dklrt_AppendRecurring(), but only if appropriate." "Call `dklrt_AppendRecurring', but only if appropriate."
(interactive) (interactive)
(if (dklrt-AppendRecurringOk) (dklrt-AppendRecurring))) (if (dklrt-AppendRecurringOk) (dklrt-AppendRecurring)))
;;;###autoload ;;;###autoload
(defun dklrt-AppendRecurring() (defun dklrt-AppendRecurring()
"Appends recurring transactions to the current ledger buffer/file." "Append recurring transactions to the current ledger buffer/file."
(interactive) (interactive)
(dklrt-AppendRecurringOk t) (dklrt-AppendRecurringOk t)
@ -120,10 +123,10 @@ To invoke, add this function to ledger-mode-hook."
;;;###autoload ;;;###autoload
(defun dklrt-AppendRecurringOk(&optional Throw) (defun dklrt-AppendRecurringOk(&optional Throw)
"Return non nil if ok to append recurring transactions. "Return non nil if ok to append recurring transactions.
The current buffer must be unmodified, in ledger-mode, and a The current buffer must be unmodified, in `ledger-mode', and a
Recurring Transactions Config File must exist for the current Recurring Transactions Config File must exist for the current
file." ledger file. If THROW, call error() instead of returning nil."
(and (and
(dklrt-IsLedgerMode Throw) (dklrt-IsLedgerMode Throw)
(dklrt-NotRecurringConfigFile Throw) (dklrt-NotRecurringConfigFile Throw)
@ -133,7 +136,8 @@ file."
;;;###autoload ;;;###autoload
(defun dklrt-IsLedgerMode(&optional Throw) (defun dklrt-IsLedgerMode(&optional Throw)
"True if current buffer is a ledger buffer." "Return t if current buffer is a ledger buffer.
If THROW, call `error' instead of returning nil."
(let* (let*
((Rv (equal mode-name "Ledger"))) ((Rv (equal mode-name "Ledger")))
(and (not Rv) Throw (and (not Rv) Throw
@ -141,7 +145,8 @@ file."
Rv)) Rv))
(defun dklrt-NotRecurringConfigFile(&optional Throw) (defun dklrt-NotRecurringConfigFile(&optional Throw)
"True if current buffer is not a Recurring Config File." "Return t if current buffer is not a Recurring Config File.
If THROW, call `error' instead of returning nil."
(let* (let*
((Fne (file-name-extension (buffer-file-name))) ((Fne (file-name-extension (buffer-file-name)))
(Rv (not (string= Fne dklrt-RecurringConfigFileSuffix)))) (Rv (not (string= Fne dklrt-RecurringConfigFileSuffix))))
@ -151,7 +156,8 @@ file."
Rv)) Rv))
(defun dklrt-Unmodified(&optional Throw) (defun dklrt-Unmodified(&optional Throw)
"True if current buffer is unmodified." "Return t if current buffer is unmodified.
If THROW, call `error' instead of returning nil."
(let* (let*
((Rv (not (buffer-modified-p)))) ((Rv (not (buffer-modified-p))))
(and (not Rv) Throw (and (not Rv) Throw
@ -159,7 +165,8 @@ file."
Rv)) Rv))
(defun dklrt-LedgerFileExists(&optional Throw) (defun dklrt-LedgerFileExists(&optional Throw)
"Return t if the ledger file exists otherwise nil." "Return t if the ledger file exists.
If THROW, call `error' instead of returning nil."
(let* (let*
((Lfn (buffer-file-name)) ((Lfn (buffer-file-name))
(Rv (and Lfn (file-exists-p Lfn)))) (Rv (and Lfn (file-exists-p Lfn))))
@ -168,7 +175,8 @@ file."
Rv)) Rv))
(defun dklrt-RecurringConfigFileExists(&optional Throw) (defun dklrt-RecurringConfigFileExists(&optional Throw)
"Return t if the Recurring Config File exists, otherwise nil." "Return t if the Recurring Config File exists.
If THROW, call `error' instead of returning nil."
(let* (let*
((Lfn (buffer-file-name)) ((Lfn (buffer-file-name))
(Cfn (dklrt-RecurringConfigFileName Lfn)) (Cfn (dklrt-RecurringConfigFileName Lfn))
@ -178,9 +186,10 @@ file."
Rv)) Rv))
(defun dklrt-RecurringConfigFileName(LedgerFileName) (defun dklrt-RecurringConfigFileName(LedgerFileName)
"Returns the corresponding recurring configuration file name. "Return the corresponding recurring configuration file name.
Removes the suffix (if any) and then appends the recurring Remove the suffix (if any) from LEDGERFILENAME and then append
suffix as per 'dklrt-RecurringConfigFileSuffix'." the recurring suffix as configured via
`dklrt-RecurringConfigFileSuffix'."
(concat (file-name-sans-extension LedgerFileName) "." (concat (file-name-sans-extension LedgerFileName) "."
dklrt-RecurringConfigFileSuffix)) dklrt-RecurringConfigFileSuffix))

View file

@ -2,7 +2,7 @@
@c %**start of header @c %**start of header
@setfilename dklrt.info @setfilename dklrt.info
@settitle Do List Mode 1.0 @settitle Ledger Recurring Transactions 1.0
@c %**end of header @c %**end of header
@syncodeindex fn cp @syncodeindex fn cp
@ -53,7 +53,7 @@ Foundation GNU Free Documentation Licence.
@end macro @end macro
@titlepage @titlepage
@title Ledger Recurring Transactions 0.1 @title Ledger Recurring Transactions 1.0
@author David Keegan @author David Keegan
@page @page
@vskip 0pt plus 1filll @vskip 0pt plus 1filll