From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Huchler Subject: Multi-step ledger org-capture template Date: Tue, 21 Aug 2018 13:45:08 +0200 Message-ID: <876004kkor.fsf@mail.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fs56C-0005fu-W0 for emacs-orgmode@gnu.org; Tue, 21 Aug 2018 07:45:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fs568-0002aU-Ki for emacs-orgmode@gnu.org; Tue, 21 Aug 2018 07:45:24 -0400 Received: from [195.159.176.226] (port=48230 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fs567-0002Tg-73 for emacs-orgmode@gnu.org; Tue, 21 Aug 2018 07:45:20 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fs53v-0003bh-Vs for emacs-orgmode@gnu.org; Tue, 21 Aug 2018 13:43:03 +0200 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: emacs-orgmode@gnu.org I want to insert a table from a email (gnus) into org-mode but before it gets saved it should first be converted. I can do it manually, copy the ascii table to a org-file: mark it then use that command: #+begin_src emacs-lisp (defun my-make-table () "docstring" (interactive) (org-table-convert-region (region-beginning) (region-end) 2)) #+end_src to convert it to a org-table (2 spaces or more is a seperator) then use the following to create ledger style transaction: #+begin_src emacs-lisp :var mapping=food-name-mapping data=import-table (let* ((rev-mapping (mapcar (lambda (x) (list (nth 1 x) (car x))) mapping))) (mapconcat (lambda (line) (format "%s \t\t%s St {=€%s}" (car (assoc-default (nth 1 line) rev-mapping)) (nth 0 line) (nth 4 line))) data "\n")) #+end_src it uses this mapping table: #+NAME: food-name-mapping | expenses:food:vegetable:bananas | Bananas 125g | | | | To map the names of the items of the shop to the ones I use in ledger. First step would be to create a capture that at least imports it as org-table something like that: #+begin_src emacs-lisp ("K" "import Transaction" plain (file+function "~/notes/finanzen.org" (lambda () "" (progn (org-babel-goto-named-src-block "balance") (org-babel-goto-src-block-head)(forward-line)))) "%(copy-region-as-kill) %(switch-buffer \"temp-ledger-import\") %(yank) %(mark-buffer) %(org-table-create-or-convert-from-region) %(buffer-string)" :jump-to-captured t :empty-lines-after 1 :immediate-finish nil) #+end_src But I would want to do both convertions before I want to capture it in the end. Can I do that or do I need to work with org-capture-hooks? Any suggestions?