emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] [PATCH] Add org-babel support for hledger


From: Nicolas Goaziou
Subject: Re: [O] [PATCH] Add org-babel support for hledger
Date: Mon, 20 Feb 2017 19:12:12 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Hello,

Simon Michael <address@hidden> writes:

> I'd like org-babel to support hledger for generating financial
> reports, similar to the existing support for Ledger.

Thank you. I'll happily merge it with the code base after some details
are sorted out.

> I don't know the exact process to follow (instructions in the git
> repo, on the website and in irc are different) and have not yet signed
> FSF copyright assignment - any help appreciated.

The first step is to sign the FSF copyright assignment since the patch
is non-trivial. Then we can apply the patch.

An entry in ORG-NEWS file would be great. It can be sent separately from
the patch, or with it, as you see fit. Unit tests are more than welcome,
too.

> Below is the output of git format-patch.

Some comments follow.

> +;;; ob-hledger.el --- org-babel functions for hledger

It is a common mistake across code base, but it should be: Org Babel ...
or simply Babel ...

Also, you should activate lexical binding:

  ob-ledger.el --- Babel Functions for hledger      -*- lexical-binding: t; -*- 
 

> +;; Org-Babel support for evaluating hledger entries.

See above.

> +(defun org-babel-execute:hledger (body params)
> +  "Execute a block of hledger entries with org-babel.  This function is
> +called by `org-babel-execute-src-block'."

The first line of a docstring needs to be a sentence on its own. So,

      Execute a block of hledger entries with Babel.  
   This function is   called by `org-babel-execute-src-block'."

> +  (message "executing hledger source code block")
> +  (let ((result-params (split-string (or (cdr (assoc :results params)) "")))

assoc -> assq

> +     (cmdline (cdr (assoc :cmdline params)))

Ditto.

> +        (in-file (org-babel-temp-file "hledger-"))
> +     (out-file (org-babel-temp-file "hledger-output-")))
> +    (with-temp-file in-file (insert body))
> +    (message "%s" (concat "hledger"
> +                          (if (> (length body) 0)
> +                              (concat " -f " (org-babel-process-file-name 
> in-file))
> +                            "")
> +                          " " cmdline))
> +    (with-output-to-string
> +      (shell-command (concat "hledger"
> +                             (if (> (length body) 0)
> +                                 (concat " -f " (org-babel-process-file-name 
> in-file))
> +                               "")
> +                             " " cmdline
> +                             " > " (org-babel-process-file-name out-file))))

This is calling for some refactoring:

  (concat "hledger" (if ...) " " cmdline)

could be built only once and bound to a symbol.


Regards,

-- 
Nicolas Goaziou



reply via email to

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