From mboxrd@z Thu Jan 1 00:00:00 1970 From: Benjamin Andresen Subject: Babel: a way to get the org-heading into source block Date: Sun, 18 Sep 2016 19:16:58 +0200 Message-ID: <87k2e9yvt1.fsf@in-ulm.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blfid-0003C7-71 for emacs-orgmode@gnu.org; Sun, 18 Sep 2016 13:17:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1blfiZ-0003cr-Et for emacs-orgmode@gnu.org; Sun, 18 Sep 2016 13:17:30 -0400 Received: from smtp.in-ulm.de ([217.10.8.16]:35557) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blfiZ-0003c0-4z for emacs-orgmode@gnu.org; Sun, 18 Sep 2016 13:17:27 -0400 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: Org Mode List Hello, small intro in case there is a better way than I thought up: I've just started using Ledger and wanted to use Babel to tangle the ledger file. Every entry is its own heading: * <2016-07-01 Fri> * Hollywood | Monthly rent #+begin_src ledger :tangle yes 07-01 * Hollywood | Monthly rent Expenses:Rent 500.00 USD Expenses:Rent:Parking spot 50.00 USD Assets:BOA:Checking #+end_src I've written a function to basically do what I want: (defun org-header-to-ledger (&optional point) (save-excursion (re-search-backward org-ts-regexp) (let* ((context (org-element-context)) (year (org-element-property :year-start context)) (month (org-element-property :month-start context)) (day (org-element-property :day-start context)) (title (cadr (split-string (org-element-property :title (org-element-property :parent context)) (rx (or "]" ">")))))) (format "%04d-%02d-%02d%s" year month day title)))) ;; (There are known bugs but for illustraton purposes this is suitable) Now in babel I would basically want to not have repeated data, so my entry should look like this: * <2016-07-01 Fri> * Hollywood | Monthly rent #+begin_src ledger :tangle yes <> Expenses:Rent 500.00 USD Expenses:Rent:Parking spot 50.00 USD Assets:BOA:Checking #+end_src The actual syntax is not that important, but something to that effect so I only have to keep one headline up to date is what I'm looking for. Is there a way to accomplish this right now? If there isn't, can you point me to where I would add such functionality? AFAIK named src block can already be inserted, I just don't know where in the source that is found. Thanks in advance and best regards, Benny