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

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

[nongnu] elpa/csv2ledger 466a098d2b 034/190: Extract new function `c2l-g


From: ELPA Syncer
Subject: [nongnu] elpa/csv2ledger 466a098d2b 034/190: Extract new function `c2l-get-current-row` from `c2l-csv-entry-as-kill`.
Date: Sun, 2 Jun 2024 15:59:43 -0400 (EDT)

branch: elpa/csv2ledger
commit 466a098d2b845c99a1aba8947d708e09c52b0013
Author: Joost Kremers <joost.kremers@ipsoft.com>
Commit: Joost Kremers <joost.kremers@ipsoft.com>

    Extract new function `c2l-get-current-row` from `c2l-csv-entry-as-kill`.
---
 csv2ledger.el | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/csv2ledger.el b/csv2ledger.el
index 9ce636e67f..c0c150562a 100644
--- a/csv2ledger.el
+++ b/csv2ledger.el
@@ -270,6 +270,14 @@ strings are interpreted according to the template in
                                        c2l--accounts))))
     (c2l-compose-entry fields account)))
 
+(defun c2l-get-current-row ()
+  "Read the current line as a CSV row.
+Return value is a list of values as strings."
+  (let ((separator (car csv-separator-chars))
+        (quote-char (string-to-char (or (car csv-field-quotes) "")))
+        (line (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
+    (parse-csv-string line separator quote-char)))
+
 ;;;###autoload
 (defun c2l-set-base-account ()
   "Set `c2l-base-account'."
@@ -285,10 +293,7 @@ in `c2l-csv-columns'."
   (interactive)
   (unless c2l--accounts
     (setq c2l--accounts (c2l-read-accounts c2l-accounts-file)))
-  (let* ((separator (car csv-separator-chars))
-         (quote-char (string-to-char (or (car csv-field-quotes) "")))
-         (line (buffer-substring-no-properties (point-at-bol) (point-at-eol)))
-         (row (parse-csv-string line separator quote-char))
+  (let* ((row (c2l-get-current-row))
          (entry (c2l-csv-line-to-ledger row)))
     (kill-new entry)
     (message entry)))



reply via email to

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