From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] Add org-babel support for hledger Date: Mon, 20 Feb 2017 19:12:12 +0100 Message-ID: <87d1ecybnn.fsf@nicolasgoaziou.fr> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cfsRg-00047v-H6 for emacs-orgmode@gnu.org; Mon, 20 Feb 2017 13:12:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cfsRc-00013D-HC for emacs-orgmode@gnu.org; Mon, 20 Feb 2017 13:12:20 -0500 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:43337) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cfsRc-00012y-9o for emacs-orgmode@gnu.org; Mon, 20 Feb 2017 13:12:16 -0500 In-Reply-To: (Simon Michael's message of "Sat, 18 Feb 2017 18:44:55 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Simon Michael Cc: emacs-orgmode@gnu.org Hello, Simon Michael 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