emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-sbe recent changes?
@ 2022-10-30 18:07 alan.schmitt
  2022-10-30 19:26 ` Alan Schmitt
  2022-10-31  1:24 ` Ihor Radchenko
  0 siblings, 2 replies; 6+ messages in thread
From: alan.schmitt @ 2022-10-30 18:07 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1730 bytes --]

Hello,

I’ve been using ledger and an org-mode table to track my finances for a
long time, and today it broke: when I evaluate a table macro, I get an
#ERROR instead of the computed value.

The code I’m using is still the one from here:
https://alan.petitepomme.net/tips/ledger_and_org.html

Basically I define a function like this (I added the message part for debugging):

#+name: call_ledger
#+begin_src emacs-lisp :var lcmd="bal" :var bucket="Quotidien" :var prefix="Expenses:" :var period=()
  (let* ((name (org-trim bucket))
         (bname (concat "'^" prefix name "'"))
         (ledger "ledger -f ~/Documents/Org/mescomptes.ledger")
         (parg (when period (concat " -p '" period "'")))
         (cutcmd "tail -1 | cut -d ' ' -f 2")
         (cmd
          (concat ledger " -J " parg " " lcmd " " bname " | " cutcmd))
         (res (org-trim (shell-command-to-string cmd))))
    (message res)
    (if (equal res "") 0 res))
#+end_src

Then I call it in a table that looks like this (removing a lot of stuff
for privacy reasons):

| Bucket                         | Planned | Remaining |
|--------------------------------+---------+-----------+
| Achat Maison                   |    1000 | #ERROR    |
|--------------------------------+---------+-----------+
| Total                          |    1000 | #ERROR    |
#+TBLFM: @2$3..@>>$3='(org-sbe call_ledger (bucket $$1) (prefix "\"Bucket:Expenses:\""))

It used to work, but now I get an #ERROR. The strange thing is that the
correct value is printed with the message call. Did something change
recently regarding org-sbe and table? How can I find out what the
value is causing the #ERROR to be printed?

Thanks,

Alan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-01  8:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-30 18:07 org-sbe recent changes? alan.schmitt
2022-10-30 19:26 ` Alan Schmitt
2022-10-31  1:24 ` Ihor Radchenko
2022-10-31  8:07   ` Alan Schmitt
2022-11-01  2:16     ` Ihor Radchenko
2022-11-01  8:40       ` Alan Schmitt

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).