mirror of
https://github.com/pestctrl/emacs-config.git
synced 2026-02-16 16:24:18 +00:00
Improvements to ledger account default
This commit is contained in:
parent
c46992c30e
commit
0782cfb325
1 changed files with 31 additions and 1 deletions
|
|
@ -225,7 +225,37 @@
|
||||||
|
|
||||||
(advice-add #'ledger-mode-clean-buffer
|
(advice-add #'ledger-mode-clean-buffer
|
||||||
:after
|
:after
|
||||||
#'my/ledger-clean-commodity))
|
#'my/ledger-clean-commodity)
|
||||||
|
|
||||||
|
(defun my/ledger-convert-alias (account)
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
|
(let ((regexp
|
||||||
|
(rx line-start
|
||||||
|
"alias " (literal account) "="
|
||||||
|
(group (+ (or alphanumeric ":" "_")))
|
||||||
|
(* space)
|
||||||
|
line-end)))
|
||||||
|
(or (and (re-search-forward regexp nil t)
|
||||||
|
(aprog1 (match-string 1)
|
||||||
|
(set-text-properties 0 (length it) nil it)))
|
||||||
|
account))))
|
||||||
|
|
||||||
|
(advice-add #'ledger-read-account-with-prompt
|
||||||
|
:filter-return
|
||||||
|
#'my/ledger-convert-alias)
|
||||||
|
|
||||||
|
(defun my/ledger-field (orig context field)
|
||||||
|
(let ((res (funcall orig context field)))
|
||||||
|
(if (or (not (eq field 'account))
|
||||||
|
(null res)
|
||||||
|
(not (string-match (rx (group (separated-list ":" (separated-list " " (+ alphanumeric)))) " ") res)) )
|
||||||
|
res
|
||||||
|
(match-string 1 res))))
|
||||||
|
|
||||||
|
(advice-add #'ledger-context-field-value
|
||||||
|
:around
|
||||||
|
#'my/ledger-field))
|
||||||
#+end_src
|
#+end_src
|
||||||
** Credit Card Statement Macro
|
** Credit Card Statement Macro
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue