* table export to same buffer
@ 2013-08-02 17:23 Rustom Mody
2013-08-02 19:22 ` Sebastien Vauban
2013-08-03 4:52 ` Rustom Mody
0 siblings, 2 replies; 8+ messages in thread
From: Rustom Mody @ 2013-08-02 17:23 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 369 bytes --]
Is it possible to export an orgmode table not to a new file but overwriting
the org table in the same buffer?
Context is editing source code which contains a largeish table of (say)
constants.
Editing is done with orgtbl minor mode.
When done it should become back the table in the natural format of the
programming language
[For simplicity lets just say csv will do]
[-- Attachment #2: Type: text/html, Size: 398 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: table export to same buffer
2013-08-02 17:23 table export to same buffer Rustom Mody
@ 2013-08-02 19:22 ` Sebastien Vauban
2013-08-03 4:52 ` Rustom Mody
1 sibling, 0 replies; 8+ messages in thread
From: Sebastien Vauban @ 2013-08-02 19:22 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Rustom Mody wrote:
> Is it possible to export an orgmode table not to a new file but overwriting
> the org table in the same buffer?
>
> Context is editing source code which contains a largeish table of (say)
> constants.
> Editing is done with orgtbl minor mode.
> When done it should become back the table in the natural format of the
> programming language
> [For simplicity lets just say csv will do]
Using an Org Babel code block (which you have to write, of course) taking as
input your table, and outputting your constants in the wished format should do
what you're looking for, right?
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: table export to same buffer
2013-08-02 17:23 table export to same buffer Rustom Mody
2013-08-02 19:22 ` Sebastien Vauban
@ 2013-08-03 4:52 ` Rustom Mody
2013-08-03 7:25 ` Nicolas Goaziou
` (2 more replies)
1 sibling, 3 replies; 8+ messages in thread
From: Rustom Mody @ 2013-08-03 4:52 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1422 bytes --]
Sebastien Vauban wrote
> On Fri, Aug 2, 2013 at 10:53 PM, Rustom Mody <rustompmody@gmail.com>wrote:
>
>> Is it possible to export an orgmode table not to a new file but
>> overwriting the org table in the same buffer?
>>
>> Context is editing source code which contains a largeish table of (say)
>> constants.
>> Editing is done with orgtbl minor mode.
>> When done it should become back the table in the natural format of the
>> programming language
>> [For simplicity lets just say csv will do]
>>
>>
>>
> Using an Org Babel code block (which you have to write, of course) taking as
> input your table, and outputting your constants in the wished format should do
> what you're looking for, right?
>
>
I dont think so.
The context is writing C with C mode (or haskell with haskell-mode python
with python-mode etc) ie the user is not using orgmode. That is why I
mentioned orgtbl, ie org table editing facilities are needed but the major
mode is something else.
However here some pre and postprocessing is also probably required.
Something like an automation of the following:
1. Editing a large struct spec in C -- major mode is C-mode
2. Select the region (may even be a rectangle)
3. Paste into an org-mode buffer
4. Run C-c | on region
5. Edit table as required
6. org-table-export in desired format to a file F
7. Visit F
8. Copy/Cut F (if necessary as rectangle)
9. Go back to original C-mode buffer and paste
[-- Attachment #2: Type: text/html, Size: 1901 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: table export to same buffer
2013-08-03 4:52 ` Rustom Mody
@ 2013-08-03 7:25 ` Nicolas Goaziou
2013-08-03 8:06 ` Thorsten Jolitz
2013-08-03 23:34 ` William Henney
2 siblings, 0 replies; 8+ messages in thread
From: Nicolas Goaziou @ 2013-08-03 7:25 UTC (permalink / raw)
To: Rustom Mody; +Cc: emacs-orgmode
Hello,
Rustom Mody <rustompmody@gmail.com> writes:
> The context is writing C with C mode (or haskell with haskell-mode python
> with python-mode etc) ie the user is not using orgmode. That is why I
> mentioned orgtbl, ie org table editing facilities are needed but the major
> mode is something else.
>
> However here some pre and postprocessing is also probably required.
> Something like an automation of the following:
>
> 1. Editing a large struct spec in C -- major mode is C-mode
> 2. Select the region (may even be a rectangle)
> 3. Paste into an org-mode buffer
> 4. Run C-c | on region
> 5. Edit table as required
> 6. org-table-export in desired format to a file F
> 7. Visit F
> 8. Copy/Cut F (if necessary as rectangle)
> 9. Go back to original C-mode buffer and paste
There's also `org-export-replace-region-by'.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: table export to same buffer
2013-08-03 4:52 ` Rustom Mody
2013-08-03 7:25 ` Nicolas Goaziou
@ 2013-08-03 8:06 ` Thorsten Jolitz
2013-08-03 23:34 ` William Henney
2 siblings, 0 replies; 8+ messages in thread
From: Thorsten Jolitz @ 2013-08-03 8:06 UTC (permalink / raw)
To: emacs-orgmode
Rustom Mody <rustompmody@gmail.com> writes:
> Sebastien Vauban wrote
>
> On Fri, Aug 2, 2013 at 10:53 PM, Rustom Mody <rustompmody@gmail.com>
> wrote:
>
> Is it possible to export an orgmode table not to a new file but
> overwriting the org table in the same buffer?
>
> Context is editing source code which contains a largeish table
> of (say) constants. Editing is done with orgtbl minor mode.
> When done it should become back the table in the natural
> format of the programming language
> [For simplicity lets just say csv will do]
> Using an Org Babel code block (which you have to write, of course)
> taking as input your table, and outputting your constants in the
> wished format should do what you're looking for, right?
>
> I dont think so. The context is writing C with C mode (or haskell with
> haskell-mode python with python-mode etc) ie the user is not using
> orgmode. That is why I mentioned orgtbl, ie org table editing
> facilities are needed but the major mode is something else.
>
> However here some pre and postprocessing is also probably required.
> Something like an automation of the following:
>
> 1. Editing a large struct spec in C -- major mode is C-mode
> 2. Select the region (may even be a rectangle)
> 3. Paste into an org-mode buffer
> 4. Run C-c | on region
> 5. Edit table as required
> 6. org-table-export in desired format to a file F
> 7. Visit F
> 8. Copy/Cut F (if necessary as rectangle)
> 9. Go back to original C-mode buffer and paste
Another possibility is to make your source code file an 'outshine' file
(activate outline-minor-mode with outshine.el extensions and structure
it with outcommented Org-mode headlines), because then you get many of
these steps for free (see
[[http://orgmode.org/worg/org-tutorials/org-outside-org.html][Org-mode
outside Org-mode]] on Worg for more info about outshine.el and
outorg.el).
This way, your source code file really _is_ an Org-mode file too, you
switch between the two views on the same file with 'M-# M-#' and 'M-#'.
I can give you an example without changing buffer while writing this
email, since 'outorg' works with message-mode too, i.e. doing 'M-# M-#'
in a message-mode buffer lets me write my email in full Org-mode.
Lets insert a table with constants:
#+tblname: consts
| constant | value |
|----------+---------|
| conway | 1.30357 |
| pi | 3.14159 |
| e | 2.71828 |
#+name: tbl2lst
#+header: :var table=consts
#+header: :results value list verbatim :wrap "SRC picolisp"
#+begin_src emacs-lisp
`(prog (scl 5) (setq lst (car ',table)))
#+end_src
#+results: tbl2lst
#+BEGIN_SRC picolisp
(prog (scl 5) (setq lst (car (quote (("constant" "value") hline ("conway"
1.30357) ("pi" 3.14159) ("e" 2.71828))))))
#+END_SRC
So the steps are:
1. Make your source file an outshine file
2. Edit it as Org-file (with 'M-# M-#' outorg-edit-as-org)
3. Go back to the source view (with 'M-#' outorg-copy-edits-and-exit)
Assume I'm editing a PicoLisp source file and want to introduce
constants the easy way (in an Org-mode table). Then in step (2) I would
add the table 'consts' and the Emacs Lisp source-block 'tbl2lst'. When
going back to the source view, the table and the source block will be
converted to PicoLisp comments.
No so the results block, because outorg recognizes its a PicoLisp block
and will convert it back to source code. Thus in the Emacs Lisp block I
use the table as variable that holds a nested list structure and
transform this nested list into a structure of my target programming
language, let it be PicoLisp or C or whatever. This should be much
easier than parsing the table itself.
Then everytime you want to edit the constants, you simply switch to
Org-mode view, edit the Org table, eval the Emacs Lisp source-block, and
switch back to PicoLisp source view.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: table export to same buffer
2013-08-03 4:52 ` Rustom Mody
2013-08-03 7:25 ` Nicolas Goaziou
2013-08-03 8:06 ` Thorsten Jolitz
@ 2013-08-03 23:34 ` William Henney
2013-08-04 11:13 ` Rustom Mody
2 siblings, 1 reply; 8+ messages in thread
From: William Henney @ 2013-08-03 23:34 UTC (permalink / raw)
To: Rustom Mody; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1336 bytes --]
On Fri, Aug 2, 2013 at 11:52 PM, Rustom Mody <rustompmody@gmail.com> wrote:
> Sebastien Vauban wrote
>
>> On Fri, Aug 2, 2013 at 10:53 PM, Rustom Mody <rustompmody@gmail.com>wrote:
>>
>>> Is it possible to export an orgmode table not to a new file but
>>> overwriting the org table in the same buffer?
>>>
>>> Context is editing source code which contains a largeish table of (say)
>>> constants.
>>> Editing is done with orgtbl minor mode.
>>> When done it should become back the table in the natural format of the
>>> programming language
>>> [For simplicity lets just say csv will do]
>>>
>>>
>>>
>> Using an Org Babel code block (which you have to write, of course) taking as
>> input your table, and outputting your constants in the wished format should do
>> what you're looking for, right?
>>
>>
> I dont think so.
> The context is writing C with C mode (or haskell with haskell-mode python
> with python-mode etc) ie the user is not using orgmode. That is why I
> mentioned orgtbl, ie org table editing facilities are needed but the major
> mode is something else.
>
What about a radio table using orgtbl-to-generic?
See Appendix 6 of the Org manual
Will
--
Dr William Henney, Centro de Radioastronomía y Astrofísica,
Universidad Nacional Autónoma de México, Campus Morelia
[-- Attachment #2: Type: text/html, Size: 2198 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: table export to same buffer
2013-08-03 23:34 ` William Henney
@ 2013-08-04 11:13 ` Rustom Mody
2013-08-12 18:20 ` William Henney
0 siblings, 1 reply; 8+ messages in thread
From: Rustom Mody @ 2013-08-04 11:13 UTC (permalink / raw)
To: William Henney, Nicolas Goaziou; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1715 bytes --]
On Sun, Aug 4, 2013 at 5:04 AM, William Henney <whenney@gmail.com> wrote:
>
> On Fri, Aug 2, 2013 at 11:52 PM, Rustom Mody <rustompmody@gmail.com>wrote:
>
>> Sebastien Vauban wrote
>>
>>> On Fri, Aug 2, 2013 at 10:53 PM, Rustom Mody <rustompmody@gmail.com>wrote:
>>>
>>>> Is it possible to export an orgmode table not to a new file but
>>>> overwriting the org table in the same buffer?
>>>>
>>>> Context is editing source code which contains a largeish table of (say)
>>>> constants.
>>>> Editing is done with orgtbl minor mode.
>>>> When done it should become back the table in the natural format of the
>>>> programming language
>>>> [For simplicity lets just say csv will do]
>>>>
>>>>
>>>>
>>> Using an Org Babel code block (which you have to write, of course) taking as
>>> input your table, and outputting your constants in the wished format should do
>>> what you're looking for, right?
>>>
>>>
>> I dont think so.
>> The context is writing C with C mode (or haskell with haskell-mode python
>> with python-mode etc) ie the user is not using orgmode. That is why I
>> mentioned orgtbl, ie org table editing facilities are needed but the major
>> mode is something else.
>>
>
> What about a radio table using orgtbl-to-generic?
>
> See Appendix 6 of the Org manual
>
> Will
>
This looks like a useful approach
The variable names dont seem to match:
Appendix 6.2 talks of orgtbl-radio-tables
However org (8.0.7) seems to have orgtbl-radio-table-templates
Assuming they are the same, anywhere I can read about the documentation of
the template format?
Specifically I find that the name of the receiving function
(orgtbl-to-latex) seems to have a significance. The same in the template
seems to have none
[-- Attachment #2: Type: text/html, Size: 2906 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: table export to same buffer
2013-08-04 11:13 ` Rustom Mody
@ 2013-08-12 18:20 ` William Henney
0 siblings, 0 replies; 8+ messages in thread
From: William Henney @ 2013-08-12 18:20 UTC (permalink / raw)
To: Rustom Mody; +Cc: emacs-orgmode, Nicolas Goaziou
[-- Attachment #1.1: Type: text/plain, Size: 2013 bytes --]
Hi Rustom
Sorry for the delay - I only check the list sporadically…
On Sun, Aug 4, 2013 at 6:13 AM, Rustom Mody <rustompmody@gmail.com> wrote:
>
>
> On Sun, Aug 4, 2013 at 5:04 AM, William Henney <whenney@gmail.com> wrote:
>
>>
>> On Fri, Aug 2, 2013 at 11:52 PM, Rustom Mody <rustompmody@gmail.com>wrote:
>>
>>>
>>>
[Snip]
> I dont think so.
>>> The context is writing C with C mode (or haskell with haskell-mode
>>> python with python-mode etc) ie the user is not using orgmode. That is why
>>> I mentioned orgtbl, ie org table editing facilities are needed but the
>>> major mode is something else.
>>>
>>
>> What about a radio table using orgtbl-to-generic?
>>
>> See Appendix 6 of the Org manual
>>
>> Will
>>
>
> This looks like a useful approach
>
> The variable names dont seem to match:
> Appendix 6.2 talks of orgtbl-radio-tables
> However org (8.0.7) seems to have orgtbl-radio-table-templates
>
>
> Assuming they are the same, anywhere I can read about the documentation of
> the template format?
> Specifically I find that the name of the receiving function
> (orgtbl-to-latex) seems to have a significance. The same in the template
> seems to have none
>
>
The template is not strictly necessary - you can just add the required
lines by hand to your C source file.
I think that orgtbl-to-generic should be able to do what you want out of
the box. Maybe the attached example (orgtbl-test.c) might help you. The
idea is that you edit the org table at the top, then "C-u C-u C-c C-c" will
update all the formulae in the table and install the results in your C
source code at the bottom. This is not quite what you originally asked
for, since you have two copies of the data in the file and you have to
remember to only edit the version in the org table. But it is pretty
close.
Cheers
Will
--
Dr William Henney, Centro de Radioastronomía y Astrofísica,
Universidad Nacional Autónoma de México, Campus Morelia
[-- Attachment #1.2: Type: text/html, Size: 4141 bytes --]
[-- Attachment #2: orgtbl-test.c --]
[-- Type: text/x-csrc, Size: 693 bytes --]
/* -*- eval: (orgtbl-mode); -*- */
/*
#+ORGTBL: SEND mytable orgtbl-to-generic :lstart " const float " :sep " = " :skip 1 :lend ";" :skipcols (2 3)
| parameter | numerator | denominator | value |
|-----------+-----------+-------------+----------|
| a | 3.0 | 3.0 | 1.00000 |
| b | 14.0 | 7.0 | 2.00000 |
| c | -2.0 | 15.0 | -0.13333 |
#+TBLFM: $4=$2/$3;f5
With point in above table, "C-u C-u C-c C-c" will update formulae and install into C source
*/
void main() {
// BEGIN RECEIVE ORGTBL mytable
const float a = 1.00000;
const float b = 2.00000;
const float c = -0.13333;
// END RECEIVE ORGTBL mytable
}
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-08-12 18:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-02 17:23 table export to same buffer Rustom Mody
2013-08-02 19:22 ` Sebastien Vauban
2013-08-03 4:52 ` Rustom Mody
2013-08-03 7:25 ` Nicolas Goaziou
2013-08-03 8:06 ` Thorsten Jolitz
2013-08-03 23:34 ` William Henney
2013-08-04 11:13 ` Rustom Mody
2013-08-12 18:20 ` William Henney
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).