From: Thorsten Jolitz <tjolitz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Bug: Revert orgtbl-create-or-convert-from-region [6.33x]
Date: Mon, 05 Aug 2013 16:07:49 +0200 [thread overview]
Message-ID: <87wqo06xje.fsf@gmail.com> (raw)
In-Reply-To: 8738qo8e1f.fsf@gmail.com
Thorsten Jolitz <tjolitz@gmail.com> writes:
> Or use something like this:
>
> #+begin_src emacs-lisp
> (defun tj/insert-exported-table (&optional insertion-point file)
> (let ((tmp-file (or file (make-temp-file "foo")))
> (insert-point (or insertion-point (1+ (org-table-end)))))
> (org-table-export tmp-file "orgtbl-to-csv")
> (goto-char insert-point)
> (insert-file-contents tmp-file)))
> #+end_src
actually, to make it more useful, it should be expanded to something like:
#+begin_src emacs-lisp
(defun tj/insert-exported-table (&optional insertion-point format file)
"Insert table exportet to FILE with function FORMAT.
Insertion position is either below the exportet table or INSERTION-POINT."
(interactive
(cond
((equal current-prefix-arg nil) nil)
((equal current-prefix-arg '(4))
(list
(read-number "Insertion Point: ")))
((equal current-prefix-arg '(16))
(list
(read-number "Insertion Point: ")
;; enter without double quotes
(read-string "Format: ")))
(t
(list
(read-number "Insertion Point: ")
(read-string "Format: ")
(ido-read-file-name "File: ")))))
(let ((tmp-file (or file (make-temp-file "foo")))
(insert-point (or insertion-point (1+ (org-table-end))))
(fmt (or format "orgtbl-to-csv")))
(org-table-export tmp-file fmt)
(save-excursion
(goto-char insert-point)
(insert-file-contents tmp-file))))
#+end_src
#+results:
: tj/insert-exported-table
do 'M-x tj/insert-exported-table' on this table:
| header 1 | header 2 | header 3 |
|----------+----------+----------|
| label1 | 3 | 99 |
| label2 | 2 | 66 |
| label3 | 7 | 231 |
header 1,header 2,header 3
label1,3,99
label2,2,66
label3,7,231
--
cheers,
Thorsten
next prev parent reply other threads:[~2013-08-05 14:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-05 7:49 Bug: Revert orgtbl-create-or-convert-from-region [6.33x] Daniel Hornung
2013-08-05 9:16 ` Thorsten Jolitz
2013-08-05 9:49 ` Daniel Hornung
2013-08-05 13:26 ` Thorsten Jolitz
2013-08-05 14:07 ` Thorsten Jolitz [this message]
2013-08-05 14:19 ` Nick Dokos
2013-08-07 8:49 ` Daniel Hornung
-- strict thread matches above, loose matches on Subject: below --
2013-08-06 5:28 Rustom Mody
2013-08-06 5:31 ` Rustom Mody
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=87wqo06xje.fsf@gmail.com \
--to=tjolitz@gmail.com \
--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).