Trouble with Emacs ledger-mode

436 views
Skip to first unread message

Scerj

unread,
Mar 30, 2011, 1:58:54 AM3/30/11
to Ledger
When I try to reconcile my checking account with Emacs and the ledger-
mode I get an error at the bottom of emacs which reads:

save-excursion: Wrong type argument: number-or-marker-p, nil

The ledger binary runs over my journal just fine, reporting balances
for all accounts. Also, other features of the ledger-mode work fine
like syntax highlighting and the Ctrl-C Ctrl-C clearing of accounts in
the transactions.

Reconcile use to work. I recently rebuilt my ledger package and re-
installed it because, after I performed a software upgrade, it linked
to some out dated boost libraries.

I'm running Arch Linux. The ledger package I installed is found in the
Arch User Repository. It looks like it clones John's git repo, goes to
town building the master branch, and creates a package. I built the
package again a couple of weeks ago so it should have any recent
commits.

I tried removing all recent transactions and my budget entries,
thinking there was a subtle parsing error somewhere. The error
persists.

Any ideas on what could be causing this?

Thanks!

Janne

unread,
Mar 30, 2011, 2:38:55 AM3/30/11
to Ledger
Hi,

I had a similar problem with an older version of ledger. By using the
elisp debugger I found that my main ledger included other files by
relative pathnames, which didn't work when emacs called the ledger
binary, so the call returned nothing and the error message was lost.
Changing to absolute pathnames fixed this for me.

Hope it helps,
J

Scerj

unread,
Apr 4, 2011, 12:16:27 AM4/4/11
to Ledger
Well, my journal contains no include directives. Any other ideas? Does
the ledger.el emacs mode include other ".el" files that could be
missing?

Jake

Philip Rooke

unread,
Apr 22, 2011, 7:16:04 AM4/22/11
to public-ledger-cli-/J...@plane.gmane.org


Scerj <jnickoloff-Re5JQ...@public.gmane.org> writes:

> When I try to reconcile my checking account with Emacs and the ledger-
> mode I get an error at the bottom of emacs which reads:
>
> save-excursion: Wrong type argument: number-or-marker-p, nil

I too have recently rebuilt Ledger and am seeing a similar problem with
reconcile mode.

> Any ideas on what could be causing this?

Maybe a possible partial explanation but no fix.

In my case it errors out in the function ledger-do-reconcile at the point
it is trying to goto the line number in the ledger file for a particular
transaction. The uncleared transactions are in a list structure that I
think _should_ look something like:

((/dev/stdin 1890 (19667 18688 0) nil "John Lewis"
(1897 "Liabilities:premier" "£-159.00" nil))...

The file line numbers are the second item in the detail of each
transction which are dug out with an (nth 1 call and passed to
goto-line. What I see being passed through to goto-line is actually
/dev/stdin, which, not being a file position causes the error.

The transaction list is built by a call out to ledger with the emacs
option that returns a stream suitable for the lisp reader to swallow up.
In my case that stream looks like:

((""/dev/stdin"" 1890 (19667 18688 0) nil "John Lewis"
(1897 "Liabilities:premier" "£-159.00" nil))...

with those odd looking doubled quotes. I am guessing but it looks
like the reader is seeing an empty string as the first item in the list
and therefore /dev/stdin, rather than the line number, as the second.

This isn't a lisp issue. I am getting those doubled quotes on the
command line as well. If they are the source of the problem then I'm
sorry but I have no idea where they are coming from.

For what it is worth I am building with boost 1.46.1

Phil


Matt Lundin

unread,
May 2, 2011, 6:17:03 PM5/2/11
to ledge...@googlegroups.com
Philip Rooke <ph...@yax.org.uk> writes:

> In my case it errors out in the function ledger-do-reconcile at the point
> it is trying to goto the line number in the ledger file for a particular
> transaction. The uncleared transactions are in a list structure that I
> think _should_ look something like:
>
> ((/dev/stdin 1890 (19667 18688 0) nil "John Lewis"
> (1897 "Liabilities:premier" "£-159.00" nil))...
>
> The file line numbers are the second item in the detail of each
> transction which are dug out with an (nth 1 call and passed to
> goto-line. What I see being passed through to goto-line is actually
> /dev/stdin, which, not being a file position causes the error.
>
> The transaction list is built by a call out to ledger with the emacs
> option that returns a stream suitable for the lisp reader to swallow up.
> In my case that stream looks like:
>
> ((""/dev/stdin"" 1890 (19667 18688 0) nil "John Lewis"
> (1897 "Liabilities:premier" "£-159.00" nil))...
>
> with those odd looking doubled quotes. I am guessing but it looks
> like the reader is seeing an empty string as the first item in the list
> and therefore /dev/stdin, rather than the line number, as the second.
>

I can confirm this issue.

> This isn't a lisp issue. I am getting those doubled quotes on the
> command line as well. If they are the source of the problem then I'm
> sorry but I have no idea where they are coming from.

My emergency workaround (for the past several weeks) has been to use
some elisp to remove the double quotes:

--8<---------------cut here---------------start------------->8---
diff --git a/ledger/ledger.el b/ledger/ledger.el
index 8e4de27..20a4370 100644
--- a/ledger/ledger.el
+++ b/ledger/ledger.el
@@ -583,6 +583,9 @@ dropped."
(ledger-run-ledger buf "--uncleared" "emacs" account)))
(when (= 0 exit-code)
(goto-char (point-min))
+ (while (re-search-forward "\"\"" nil t)
+ (replace-match "\""))
+ (goto-char (point-min))
(unless (eobp)
(unless (looking-at "(")
(error (buffer-string)))
--8<---------------cut here---------------end--------------->8---

Obviously, this is not a long-term solution. :)

Best,
Matt

Scerj

unread,
May 3, 2011, 1:36:57 AM5/3/11
to Ledger
Woot! That patch worked for me. Although I had trouble applying it.

patch -p2 < ledger.patch

Right? I must be missing something obvious. I do not work with patches
often. Looks like it might be a git only patch? I applied the patch
manually.

Thank you Matt and Philip! Reconcile is going to be so much easier
now.

~Scerj


On May 2, 3:17 pm, Matt Lundin <m...@imapmail.org> wrote:
Reply all
Reply to author
Forward
0 new messages