emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/csv2ledger 98ab50c9a7 185/190: New command c2l-read-accoun


From: ELPA Syncer
Subject: [nongnu] elpa/csv2ledger 98ab50c9a7 185/190: New command c2l-read-account-matchers
Date: Sun, 2 Jun 2024 16:00:01 -0400 (EDT)

branch: elpa/csv2ledger
commit 98ab50c9a76fdd0b384b23dd8e27f9393c28a335
Author: Joost Kremers <joostkremers@fastmail.com>
Commit: Joost Kremers <joostkremers@fastmail.com>

    New command c2l-read-account-matchers
    
    After manually updating the account matchers file, this command can be used 
to
    reread it.
---
 csv2ledger.el | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/csv2ledger.el b/csv2ledger.el
index 5cc915d8ef..122b1eeab5 100644
--- a/csv2ledger.el
+++ b/csv2ledger.el
@@ -214,7 +214,7 @@ used as the target account.
 This variable is normally given a value based on the matchers in
 `c2l-account-matchers-file', but it can also be set directly.")
 
-(defun c2l--read-account-matchers (file)
+(defun c2l--read-account-matchers-file (file)
   "Read account matchers from FILE.
 See the documentation for the variable
 `c2l-account-matchers-file' for details on the matcher file."
@@ -244,15 +244,18 @@ for that account."
                   (car e)))
           (seq-group-by #'cdr accounts)))
 
-(defun c2l-set-matcher-regexps ()
+(defun c2l-set-matcher-regexps (&optional force)
   "Set `c2l-matcher-regexps' based on the file in `c2l-account-matchers-file'.
-If `c2l-matcher-regexps' already has a value, do not change it.
-Return the (new) value of `c2l-matcher-regexps'."
-  (or c2l-matcher-regexps
-      (setq-local c2l-matcher-regexps
-                  (thread-first c2l-account-matchers-file
-                                (c2l--read-account-matchers)
-                                (c2l--compile-matcher-regexps)))))
+If `c2l-matcher-regexps' already has a value, do not change it,
+unless FORCE is non-nil.  Return the (new) value of
+`c2l-matcher-regexps'."
+  (when (or force
+            c2l-matcher-regexps)
+    (setq-local c2l-matcher-regexps
+                (thread-first c2l-account-matchers-file
+                              (c2l--read-account-matchers-file)
+                              (c2l--compile-matcher-regexps))))
+  c2l-matcher-regexps)
 
 ;;;###autoload (put 'c2l-target-match-fields 'safe-local-variable '(lambda (v) 
(seq-every-p #'stringp v)))
 (defcustom c2l-target-match-fields '(payee description)
@@ -497,6 +500,10 @@ new buffer is created."
     (setq c2l--accounts (c2l--read-accounts c2l-accounts-file)))
   (setq c2l-base-account (completing-read "Base account for current buffer: " 
c2l--accounts)))
 
+(defun c2l-read-account-matchers ()
+  "(Re)read the account matchers file."
+  (c2l-set-matcher-regexps 'force))
+
 ;;;###autoload
 (defun c2l-csv-entry-as-kill ()
   "Convert the current CSV row to a Ledger entry and place it in the kill ring.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]