emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Simon Michael <simon@joyful.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Add org-babel support for hledger
Date: Mon, 20 Feb 2017 19:12:12 +0100	[thread overview]
Message-ID: <87d1ecybnn.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <A818499F-B1FD-44EC-8C40-7EBEC579E414@joyful.com> (Simon Michael's message of "Sat, 18 Feb 2017 18:44:55 +0000")

Hello,

Simon Michael <simon@joyful.com> 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	other threads:[~2017-02-20 18:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-18 18:44 [PATCH] Add org-babel support for hledger Simon Michael
2017-02-20 18:12 ` Nicolas Goaziou [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d1ecybnn.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=simon@joyful.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).