emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* TABLES: Remove/add cell
@ 2011-09-30 17:38 Gustav Wikström
  2011-09-30 18:22 ` Michael Brand
  0 siblings, 1 reply; 13+ messages in thread
From: Gustav Wikström @ 2011-09-30 17:38 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 450 bytes --]

Hello!

How do I add or remove a single cell in a table?

Example:
I have the following table:
|        1 |        1 |
|        2 |        3 |
|        3 |        4 |
|        4 |          |

Now I want to add an empty cell in @2$2 (below the heading) and thus move
the following cells in column 2 down one step.

After:
|        1 |        1 |
|        2 |          |
|        3 |        3 |
|        4 |        4 |

Is this doable?

Regards
Gustav

[-- Attachment #2: Type: text/html, Size: 1654 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: TABLES: Remove/add cell
  2011-09-30 17:38 TABLES: Remove/add cell Gustav Wikström
@ 2011-09-30 18:22 ` Michael Brand
  2011-09-30 18:50   ` brian powell
                     ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Michael Brand @ 2011-09-30 18:22 UTC (permalink / raw)
  To: Gustav Wikström; +Cc: emacs-orgmode

Hi Gustav

Ehm - it is doable, but not by editing commands from Org table. Only
with several rectangular edits or an Org table formula with a few
tricks and a temporary column to be removed afterward. Probably not as
comfortable as you have expected:

- insert row in only one column
  start with:
  | a | 1 |   |
  | b | 3 |   |
  | c | 4 |   |
  | d |   |   |

  | a | 1 | 1 |
  | b | 3 |   |
  | c | 4 | 3 |
  | d |   | 4 |
  #+TBLFM: @1$3=$-1::@3$3..@>$3=subscr(@2$2..@>>$2, @# - 2)

- remove again
  start with:
  | a | 1 |   |
  | b |   |   |
  | c | 3 |   |
  | d | 4 |   |

  | a | 1 | 1 |
  | b |   | 3 |
  | c | 3 | 4 |
  | d | 4 |   |
  #+TBLFM: @1$3=$-1::@2$3..@>>$3=subscr(@3$2..@>$2, @# - 1)

See the Calc manual for "subscr" and the Org manual for "@#" and the rest.

If it does not work (e. g. org-version 6.33) then upgrade.

Michael

2011/9/30 Gustav Wikström <gustav.erik@gmail.com>:
> How do I add or remove a single cell in a table?
> Example:
> I have the following table:
> |        1 |        1 |
> |        2 |        3 |
> |        3 |        4 |
> |        4 |          |
> Now I want to add an empty cell in @2$2 (below the heading) and thus move
> the following cells in column 2 down one step.
> After:
> |        1 |        1 |
> |        2 |          |
> |        3 |        3 |
> |        4 |        4 |
> Is this doable?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: TABLES: Remove/add cell
  2011-09-30 18:22 ` Michael Brand
@ 2011-09-30 18:50   ` brian powell
  2011-09-30 19:27     ` Gustav Wikström
  2011-09-30 19:06   ` Michael Brand
  2011-10-01  9:40   ` suvayu ali
  2 siblings, 1 reply; 13+ messages in thread
From: brian powell @ 2011-09-30 18:50 UTC (permalink / raw)
  To: Michael Brand; +Cc: Gustav Wikström, emacs-orgmode

* May want to turn org-mode/table off temporarily (or maybe it will
just make it easier) then you can do the "rectangle edits" michael was
referring to:
** Go to the point just to the right of the 4.
** C@ ---marks the point.
** Go to the 3.
** Cxrk
** Go to "@2$2"--i.e. where the "4" used to be.
** Cxry
* Emacs OrgMode makes all of this easier since it lines everything up
for you by "covering down" the columns (org-table-align)---making all
the cells easily edited by the usual "rectangle-killing" and
"rectangle-yanking" methods.
** The method above can be generalized for editing OrgMode tables
regardless of the number of symbols in the cells--since OrgMode aligns
them for you; and, EMACS is restricted only by the amount of RAM in
your computer.
*** Also, if you want to edit gygabyte size files, using similar
methods, I highly recommend QEMACS.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: TABLES: Remove/add cell
  2011-09-30 18:22 ` Michael Brand
  2011-09-30 18:50   ` brian powell
@ 2011-09-30 19:06   ` Michael Brand
  2011-11-23 19:13     ` Michael Brand
  2011-10-01  9:40   ` suvayu ali
  2 siblings, 1 reply; 13+ messages in thread
From: Michael Brand @ 2011-09-30 19:06 UTC (permalink / raw)
  To: Gustav Wikström; +Cc: emacs-orgmode

Oh, and there is a much easier solution, probably the easiest:

Transpose the table with this
http://orgmode.org/worg/org-hacks.html#sec-1-3-1
If the section numbering changed in the meantime: look for "Transpose
tables (Juan Pechiar)"

and split it into two (or three) tables:

| a | b | c | d |

| 1 | 3 | 4 |   |

(| e | f | g | h |)

Then you can use the very convenient editing functions of Org table on
the second part of the table, join the parts together and transpose
again.

Michael

2011/9/30 Michael Brand <michael.ch.brand@gmail.com>:
> Ehm - it is doable, but not by editing commands from Org table. Only
> with several rectangular edits or an Org table formula with a few
> tricks and a temporary column to be removed afterward. Probably not as
> comfortable as you have expected:
>
> - insert row in only one column
>  start with:
>  | a | 1 |   |
>  | b | 3 |   |
>  | c | 4 |   |
>  | d |   |   |
>
>  | a | 1 | 1 |
>  | b | 3 |   |
>  | c | 4 | 3 |
>  | d |   | 4 |
>  #+TBLFM: @1$3=$-1::@3$3..@>$3=subscr(@2$2..@>>$2, @# - 2)
>
> - remove again
>  start with:
>  | a | 1 |   |
>  | b |   |   |
>  | c | 3 |   |
>  | d | 4 |   |
>
>  | a | 1 | 1 |
>  | b |   | 3 |
>  | c | 3 | 4 |
>  | d | 4 |   |
>  #+TBLFM: @1$3=$-1::@2$3..@>>$3=subscr(@3$2..@>$2, @# - 1)
>
> See the Calc manual for "subscr" and the Org manual for "@#" and the rest.
>
> If it does not work (e. g. org-version 6.33) then upgrade.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: TABLES: Remove/add cell
  2011-09-30 18:50   ` brian powell
@ 2011-09-30 19:27     ` Gustav Wikström
  0 siblings, 0 replies; 13+ messages in thread
From: Gustav Wikström @ 2011-09-30 19:27 UTC (permalink / raw)
  To: brian powell; +Cc: Michael Brand, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1321 bytes --]

This is similar to the way I've done it before. It makes it cumbersome if
there are many lines below the cell that is to be inserted though..

It would be nice to have as a function that inserts or deletes a cell in the
same way as one can insert and delete rows and columns. Maybe as a prefix
to M-S-<left/right> and M-S-<up/down> ?

/Gustav

On Fri, Sep 30, 2011 at 8:50 PM, brian powell <briangpowellms@gmail.com>wrote:

> * May want to turn org-mode/table off temporarily (or maybe it will
> just make it easier) then you can do the "rectangle edits" michael was
> referring to:
> ** Go to the point just to the right of the 4.
> ** C@ ---marks the point.
> ** Go to the 3.
> ** Cxrk
> ** Go to "@2$2"--i.e. where the "4" used to be.
> ** Cxry
> * Emacs OrgMode makes all of this easier since it lines everything up
> for you by "covering down" the columns (org-table-align)---making all
> the cells easily edited by the usual "rectangle-killing" and
> "rectangle-yanking" methods.
> ** The method above can be generalized for editing OrgMode tables
> regardless of the number of symbols in the cells--since OrgMode aligns
> them for you; and, EMACS is restricted only by the amount of RAM in
> your computer.
> *** Also, if you want to edit gygabyte size files, using similar
> methods, I highly recommend QEMACS.
>

[-- Attachment #2: Type: text/html, Size: 1748 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: TABLES: Remove/add cell
  2011-09-30 18:22 ` Michael Brand
  2011-09-30 18:50   ` brian powell
  2011-09-30 19:06   ` Michael Brand
@ 2011-10-01  9:40   ` suvayu ali
  2 siblings, 0 replies; 13+ messages in thread
From: suvayu ali @ 2011-10-01  9:40 UTC (permalink / raw)
  To: Michael Brand; +Cc: Gustav Wikström, emacs-orgmode

2011/9/30 Michael Brand <michael.ch.brand@gmail.com>:
> Ehm - it is doable, but not by editing commands from Org table. Only
> with several rectangular edits or an Org table formula with a few
> tricks and a temporary column to be removed afterward.

There are some org-table specific rectangle edit commands that should
make it easier. Cut the cells with org-table-cut-region, and paste by
org-table-paste-rectangle.

Hope this helps.

-- 
Suvayu

Open source is the future. It sets us free.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: TABLES: Remove/add cell
  2011-09-30 19:06   ` Michael Brand
@ 2011-11-23 19:13     ` Michael Brand
  2011-11-24 12:57       ` Daniel Martins
  2011-12-11 16:42       ` Bastien
  0 siblings, 2 replies; 13+ messages in thread
From: Michael Brand @ 2011-11-23 19:13 UTC (permalink / raw)
  To: Gustav Wikström, Daniel Martins; +Cc: emacs-orgmode

Hi Gustav and Daniel

2011/9/30 Gustav Wikström <gustav.erik@gmail.com>:
> How do I add or remove a single cell in a table?
> Example:
> I have the following table:
> |        1 |        1 |
> |        2 |        3 |
> |        3 |        4 |
> |        4 |          |
> Now I want to add an empty cell in @2$2 (below the heading) and thus move
> the following cells in column 2 down one step.
> After:
> |        1 |        1 |
> |        2 |          |
> |        3 |        3 |
> |        4 |        4 |

2011/9/30 Michael Brand <michael.ch.brand@gmail.com>:
> [...] transpose [...]
> and split it into two (or three) tables:
>
> | a | b | c | d |
>
> | 1 | 3 | 4 |   |
>
> (| e | f | g | h |)
>
> Then you can use the very convenient editing functions of Org table on
> the second part of the table,

to move the empty field in front of "3"

| a | b | c | d |

| 1 |  | 3 | 4 |

| e | f | g | h |

> join the parts together

| a | b | c | d |
| 1 |   | 3 | 4 |
| e | f | g | h |

> and transpose again.

By coincidence just today I had the same need to move or rotate
columns left/right, without affecting the other rows above and below.
Because I need this repeatedly I wrote two in-row functions derived
from org-table-move-column, without the need anymore of splitting and
joining the table like above.

It supports only the direction left/right. The direction up/down
Gustav asked for would be harder to implement but as a workaround you
can still transpose
http://orgmode.org/worg/org-hacks.html#transpose-table
and use the in-row left/right.

from another thread:
On Mon, Nov 21, 2011 at 14:31, Daniel Martins <danielemc@gmail.com> wrote:
> The feature of remove/add cell is quite important. Should be a feature
> request.

If I understand right and only for left/right, the in-row functions
cover that too:
- remove: first blank the field with "C-c Space"
  (org-table-blank-field) and then rotate in-row left
- add: rotate in-row right and replace the field content, before this
  step append new columns if required

For more see
"Change the column sequence in one row only" on Worg hacks:
http://orgmode.org/worg/org-hacks.html#column-sequence-in-row

Michael

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: TABLES: Remove/add cell
  2011-11-23 19:13     ` Michael Brand
@ 2011-11-24 12:57       ` Daniel Martins
  2011-12-11 16:41         ` Bastien
  2011-12-11 16:42       ` Bastien
  1 sibling, 1 reply; 13+ messages in thread
From: Daniel Martins @ 2011-11-24 12:57 UTC (permalink / raw)
  To: Michael Brand; +Cc: Gustav Wikström, emacs-orgmode

Great Michael!!!

One vote for being part of the core of org-mode!!! (with org-table
rtanspose as well)

Daniel

2011/11/23 Michael Brand <michael.ch.brand@gmail.com>:
> Hi Gustav and Daniel
>
> 2011/9/30 Gustav Wikström <gustav.erik@gmail.com>:
>> How do I add or remove a single cell in a table?
>> Example:
>> I have the following table:
>> |        1 |        1 |
>> |        2 |        3 |
>> |        3 |        4 |
>> |        4 |          |
>> Now I want to add an empty cell in @2$2 (below the heading) and thus move
>> the following cells in column 2 down one step.
>> After:
>> |        1 |        1 |
>> |        2 |          |
>> |        3 |        3 |
>> |        4 |        4 |
>
> 2011/9/30 Michael Brand <michael.ch.brand@gmail.com>:
>> [...] transpose [...]
>> and split it into two (or three) tables:
>>
>> | a | b | c | d |
>>
>> | 1 | 3 | 4 |   |
>>
>> (| e | f | g | h |)
>>
>> Then you can use the very convenient editing functions of Org table on
>> the second part of the table,
>
> to move the empty field in front of "3"
>
> | a | b | c | d |
>
> | 1 |  | 3 | 4 |
>
> | e | f | g | h |
>
>> join the parts together
>
> | a | b | c | d |
> | 1 |   | 3 | 4 |
> | e | f | g | h |
>
>> and transpose again.
>
> By coincidence just today I had the same need to move or rotate
> columns left/right, without affecting the other rows above and below.
> Because I need this repeatedly I wrote two in-row functions derived
> from org-table-move-column, without the need anymore of splitting and
> joining the table like above.
>
> It supports only the direction left/right. The direction up/down
> Gustav asked for would be harder to implement but as a workaround you
> can still transpose
> http://orgmode.org/worg/org-hacks.html#transpose-table
> and use the in-row left/right.
>
> from another thread:
> On Mon, Nov 21, 2011 at 14:31, Daniel Martins <danielemc@gmail.com> wrote:
>> The feature of remove/add cell is quite important. Should be a feature
>> request.
>
> If I understand right and only for left/right, the in-row functions
> cover that too:
> - remove: first blank the field with "C-c Space"
>  (org-table-blank-field) and then rotate in-row left
> - add: rotate in-row right and replace the field content, before this
>  step append new columns if required
>
> For more see
> "Change the column sequence in one row only" on Worg hacks:
> http://orgmode.org/worg/org-hacks.html#column-sequence-in-row
>
> Michael
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: TABLES: Remove/add cell
  2011-11-24 12:57       ` Daniel Martins
@ 2011-12-11 16:41         ` Bastien
  2011-12-11 17:21           ` Achim Gratz
  0 siblings, 1 reply; 13+ messages in thread
From: Bastien @ 2011-12-11 16:41 UTC (permalink / raw)
  To: Daniel Martins; +Cc: Gustav Wikström, Michael Brand, emacs-orgmode

Hi Michael and Daniel,

Daniel Martins <danielemc@gmail.com> writes:

> One vote for being part of the core of org-mode!!! (with org-table
> rtanspose as well)

Yes.  `org-table-transpose-table-at-point' is now part of Org's core.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: TABLES: Remove/add cell
  2011-11-23 19:13     ` Michael Brand
  2011-11-24 12:57       ` Daniel Martins
@ 2011-12-11 16:42       ` Bastien
  2011-12-18 16:18         ` Michael Brand
  1 sibling, 1 reply; 13+ messages in thread
From: Bastien @ 2011-12-11 16:42 UTC (permalink / raw)
  To: Michael Brand; +Cc: Gustav Wikström, emacs-orgmode

Hi Michael,

Michael Brand <michael.ch.brand@gmail.com> writes:

> If I understand right and only for left/right, the in-row functions
> cover that too:
> - remove: first blank the field with "C-c Space"
>   (org-table-blank-field) and then rotate in-row left
> - add: rotate in-row right and replace the field content, before this
>   step append new columns if required
>
> For more see
> "Change the column sequence in one row only" on Worg hacks:
> http://orgmode.org/worg/org-hacks.html#column-sequence-in-row

This is great -- would you like to prepare a patch to org-table.el 
adding these feature?  If you can come up with compatible keybindings,
that would be even better.

Thanks a lot in advance!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: TABLES: Remove/add cell
  2011-12-11 16:41         ` Bastien
@ 2011-12-11 17:21           ` Achim Gratz
  2011-12-11 17:39             ` Bastien
  0 siblings, 1 reply; 13+ messages in thread
From: Achim Gratz @ 2011-12-11 17:21 UTC (permalink / raw)
  To: emacs-orgmode

Bastien <bzg@altern.org> writes:
> Yes.  `org-table-transpose-table-at-point' is now part of Org's core.

There's one thing to take care of, though:

In org-table-transpose-table-at-point:
org-table.el:1774:33:Warning: function `remove-if-not' from cl package called
    at runtime


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptations for Waldorf Q V3.00R3 and Q+ V3.54R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: TABLES: Remove/add cell
  2011-12-11 17:21           ` Achim Gratz
@ 2011-12-11 17:39             ` Bastien
  0 siblings, 0 replies; 13+ messages in thread
From: Bastien @ 2011-12-11 17:39 UTC (permalink / raw)
  To: Achim Gratz; +Cc: emacs-orgmode

Achim Gratz <Stromeko@nexgo.de> writes:

> There's one thing to take care of, though:
>
> In org-table-transpose-table-at-point:
> org-table.el:1774:33:Warning: function `remove-if-not' from cl package called
>     at runtime

Done.  Thanks for spotting this!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: TABLES: Remove/add cell
  2011-12-11 16:42       ` Bastien
@ 2011-12-18 16:18         ` Michael Brand
  0 siblings, 0 replies; 13+ messages in thread
From: Michael Brand @ 2011-12-18 16:18 UTC (permalink / raw)
  To: Bastien; +Cc: Gustav Wikström, emacs-orgmode

Hi Bastien

On Sun, Dec 11, 2011 at 17:42, Bastien <bzg@altern.org> wrote:
> This is great -- would you like to prepare a patch to org-table.el
> adding these feature?  If you can come up with compatible keybindings,
> that would be even better.

Lack of repetitive key binding possibilities was only one of several
reasons (now all listed at the end of the article on Worg) why I
decided to put this only to Worg hacks and not into the Org core.

Michael

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-12-18 16:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-30 17:38 TABLES: Remove/add cell Gustav Wikström
2011-09-30 18:22 ` Michael Brand
2011-09-30 18:50   ` brian powell
2011-09-30 19:27     ` Gustav Wikström
2011-09-30 19:06   ` Michael Brand
2011-11-23 19:13     ` Michael Brand
2011-11-24 12:57       ` Daniel Martins
2011-12-11 16:41         ` Bastien
2011-12-11 17:21           ` Achim Gratz
2011-12-11 17:39             ` Bastien
2011-12-11 16:42       ` Bastien
2011-12-18 16:18         ` Michael Brand
2011-10-01  9:40   ` suvayu ali

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).