From: Stefan Huchler <stefan.huchler@mail.de>
To: emacs-orgmode@gnu.org
Subject: Multi-step ledger org-capture template
Date: Tue, 21 Aug 2018 13:45:08 +0200 [thread overview]
Message-ID: <876004kkor.fsf@mail.de> (raw)
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?
next reply other threads:[~2018-08-21 11:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-21 11:45 Stefan Huchler [this message]
2018-08-22 22:48 ` Multi-step ledger org-capture template Stefan Huchler
2018-08-23 11:37 ` Stefan Huchler
2018-08-26 21:53 ` Stefan Huchler
2018-08-27 8:05 ` ST
2018-08-28 8:24 ` Neil Jerram
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=876004kkor.fsf@mail.de \
--to=stefan.huchler@mail.de \
--cc=emacs-orgmode@gnu.org \
/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).