ledger-mode: Introduce `ledger-default-date-format'.
Some elisp functions depend on a date-format supplied in ~/.ledgerrc. Change these by introducing a default ("%Y/%m/%d").
Signed-off-by: Moritz Ulrich <moritz@tarn-vedra.de>
This commit is contained in:
parent
7dd82f8bac
commit
9f694169a8
4 changed files with 16 additions and 9 deletions
|
|
@ -30,6 +30,8 @@
|
||||||
|
|
||||||
(defvar ledger-environment-alist nil)
|
(defvar ledger-environment-alist nil)
|
||||||
|
|
||||||
|
(defvar ledger-default-date-format "%Y/%m/%d")
|
||||||
|
|
||||||
(defun ledger-init-parse-initialization (buffer)
|
(defun ledger-init-parse-initialization (buffer)
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
(let (environment-alist)
|
(let (environment-alist)
|
||||||
|
|
|
||||||
|
|
@ -179,9 +179,11 @@ With a prefix argument, remove the effective date. "
|
||||||
(if (and (listp arg)
|
(if (and (listp arg)
|
||||||
(= 4 (prefix-numeric-value arg)))
|
(= 4 (prefix-numeric-value arg)))
|
||||||
(ledger-remove-effective-date)
|
(ledger-remove-effective-date)
|
||||||
(let ((context (car (ledger-context-at-point)))
|
(let* ((context (car (ledger-context-at-point)))
|
||||||
(date-string (format-time-string
|
(date-format (or
|
||||||
(cdr (assoc "date-format" ledger-environment-alist)))))
|
(cdr (assoc "date-format" ledger-environment-alist))
|
||||||
|
ledger-default-date-format))
|
||||||
|
(date-string (format-time-string date-format)))
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(narrow-to-region (point-at-bol) (point-at-eol))
|
(narrow-to-region (point-at-bol) (point-at-eol))
|
||||||
(cond
|
(cond
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(require 'easymenu)
|
(require 'easymenu)
|
||||||
|
(require 'ledger-init)
|
||||||
|
|
||||||
(defvar ledger-buf nil)
|
(defvar ledger-buf nil)
|
||||||
(defvar ledger-bufs nil)
|
(defvar ledger-bufs nil)
|
||||||
|
|
@ -64,7 +65,7 @@ reconcile-finish will mark all pending posting cleared."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:group 'ledger-reconcile)
|
:group 'ledger-reconcile)
|
||||||
|
|
||||||
(defcustom ledger-reconcile-default-date-format "%Y/%m/%d"
|
(defcustom ledger-reconcile-default-date-format ledger-default-date-format
|
||||||
"Default date format for the reconcile buffer"
|
"Default date format for the reconcile buffer"
|
||||||
:type 'string
|
:type 'string
|
||||||
:group 'ledger-reconcile)
|
:group 'ledger-reconcile)
|
||||||
|
|
@ -306,15 +307,14 @@ POSTING is used in `ledger-clear-whole-transactions' is nil."
|
||||||
(if (looking-at "(")
|
(if (looking-at "(")
|
||||||
(read (current-buffer)))))))) ;current-buffer is the *temp* created above
|
(read (current-buffer)))))))) ;current-buffer is the *temp* created above
|
||||||
(if (and ledger-success (> (length xacts) 0))
|
(if (and ledger-success (> (length xacts) 0))
|
||||||
(let ((date-format (cdr (assoc "date-format" ledger-environment-alist))))
|
(let ((date-format (or (cdr (assoc "date-format" ledger-environment-alist))
|
||||||
|
ledger-default-date-format)))
|
||||||
(dolist (xact xacts)
|
(dolist (xact xacts)
|
||||||
(dolist (posting (nthcdr 5 xact))
|
(dolist (posting (nthcdr 5 xact))
|
||||||
(let ((beg (point))
|
(let ((beg (point))
|
||||||
(where (ledger-marker-where-xact-is xact posting)))
|
(where (ledger-marker-where-xact-is xact posting)))
|
||||||
(insert (format "%s %-4s %-30s %-30s %15s\n"
|
(insert (format "%s %-4s %-30s %-30s %15s\n"
|
||||||
(format-time-string (if date-format
|
(format-time-string date-format (nth 2 xact))
|
||||||
date-format
|
|
||||||
ledger-reconcile-default-date-format) (nth 2 xact))
|
|
||||||
(if (nth 3 xact)
|
(if (nth 3 xact)
|
||||||
(nth 3 xact)
|
(nth 3 xact)
|
||||||
"")
|
"")
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@
|
||||||
;; function slot of the symbol VARNAME. Then use VARNAME as the
|
;; function slot of the symbol VARNAME. Then use VARNAME as the
|
||||||
;; function without have to use funcall.
|
;; function without have to use funcall.
|
||||||
|
|
||||||
|
(require 'ledger-init)
|
||||||
|
|
||||||
(defgroup ledger-schedule nil
|
(defgroup ledger-schedule nil
|
||||||
"Support for automatically recommendation transactions."
|
"Support for automatically recommendation transactions."
|
||||||
:group 'ledger)
|
:group 'ledger)
|
||||||
|
|
@ -288,7 +290,8 @@ returns true if the date meets the requirements"
|
||||||
"Format CANDIDATE-ITEMS for display."
|
"Format CANDIDATE-ITEMS for display."
|
||||||
(let ((candidates (ledger-schedule-list-upcoming-xacts candidate-items early horizon))
|
(let ((candidates (ledger-schedule-list-upcoming-xacts candidate-items early horizon))
|
||||||
(schedule-buf (get-buffer-create ledger-schedule-buffer-name))
|
(schedule-buf (get-buffer-create ledger-schedule-buffer-name))
|
||||||
(date-format (cdr (assoc "date-format" ledger-environment-alist))))
|
(date-format (or (cdr (assoc "date-format" ledger-environment-alist))
|
||||||
|
ledger-default-date-format)))
|
||||||
(with-current-buffer schedule-buf
|
(with-current-buffer schedule-buf
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(dolist (candidate candidates)
|
(dolist (candidate candidates)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue