emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* how to copy a column of a table (with content)
@ 2022-01-20  8:06 Uwe Brauer
  2022-01-20 10:28 ` Marco Wahl
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Brauer @ 2022-01-20  8:06 UTC (permalink / raw)
  To: emacs-orgmode


Hi 

I sometime have to deal with table that contains large columns and I
want to copy that columns and modify them a bit.

So I usually just insert an empty column and use kill-rectangle and yank-rectangle.

I am wondering, there seems no 
org-table-kill-this-column and org-table-yank-this-column.

I found 

https://emacs.stackexchange.com/questions/28270/how-to-select-and-copy-a-column-of-an-org-table-without-rectangle-selection#:~:text=Just%20mark%20the%20beginning%20of,table%2Dpaste%2Drectangle%20).

But it did not work for me.

Any ideas?

Regards

Uwe Brauer 



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

* Re: how to copy a column of a table (with content)
  2022-01-20  8:06 how to copy a column of a table (with content) Uwe Brauer
@ 2022-01-20 10:28 ` Marco Wahl
  2022-01-20 16:22   ` Uwe Brauer
  0 siblings, 1 reply; 3+ messages in thread
From: Marco Wahl @ 2022-01-20 10:28 UTC (permalink / raw)
  To: emacs-orgmode, oub

Uwe Brauer <oub@mat.ucm.es> writes:

> I sometime have to deal with table that contains large columns and I
> want to copy that columns and modify them a bit.
>
> So I usually just insert an empty column and use kill-rectangle and yank-rectangle.
>
> I am wondering, there seems no 
> org-table-kill-this-column and org-table-yank-this-column.
>
> I found 
>
> https://emacs.stackexchange.com/questions/28270/how-to-select-and-copy-a-column-of-an-org-table-without-rectangle-selection#:~:text=Just%20mark%20the%20beginning%20of,table%2Dpaste%2Drectangle%20).
>
> But it did not work for me.
>
> Any ideas?

I use the following function occasionally.  Possibly it helps in your case.

(defun mw-org-table-mark-column ()
  "Mark the column containing point."
  (interactive)
  (unless (org-at-table-p) (user-error "Not at a table"))
  (org-table-find-dataline)
  (org-table-check-inside-data-field)
  (let* ((col (org-table-current-column))
         (beg (org-table-begin))
	 (end (org-table-end)))
    (goto-char beg)
    (org-table-goto-column col)
    (re-search-backward "|" nil t)
    (push-mark)
    (goto-char (1- end))
    (org-table-goto-column (1+ col))
    (re-search-backward "|" nil t)
    (exchange-point-and-mark)
    (forward-char)))

Copy a column would be:

1. Put the cursor into that column.
2. M-x mw-org-table-mark-column
3. Move the cursor onto the |.  E.g. { C-b }.
4. M-x copy-rectangle-as-kill
5. Move the cursor to a suitable position in the first line of the table.
6. M-x yank-rectangle

BTW rectangle-mark-mode -- possibly activated with { C-x SPC } -- can
help with the copy and yank in this case.


HTH,
-- 
Marco


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

* Re: how to copy a column of a table (with content)
  2022-01-20 10:28 ` Marco Wahl
@ 2022-01-20 16:22   ` Uwe Brauer
  0 siblings, 0 replies; 3+ messages in thread
From: Uwe Brauer @ 2022-01-20 16:22 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi Marco
> Uwe Brauer <oub@mat.ucm.es> writes:

> I use the following function occasionally.  Possibly it helps in your case.

> (defun mw-org-table-mark-column ()
>   "Mark the column containing point."
>   (interactive)
>   (unless (org-at-table-p) (user-error "Not at a table"))
>   (org-table-find-dataline)
>   (org-table-check-inside-data-field)
>   (let* ((col (org-table-current-column))
>          (beg (org-table-begin))
> 	 (end (org-table-end)))
>     (goto-char beg)
>     (org-table-goto-column col)
>     (re-search-backward "|" nil t)
>     (push-mark)
>     (goto-char (1- end))
>     (org-table-goto-column (1+ col))
>     (re-search-backward "|" nil t)
>     (exchange-point-and-mark)
>     (forward-char)))
very nice, !!!

> Copy a column would be:

> 1. Put the cursor into that column.
> 2. M-x mw-org-table-mark-column
> 3. Move the cursor onto the |.  E.g. { C-b }.
> 4. M-x copy-rectangle-as-kill
> 5. Move the cursor to a suitable position in the first line of the table.
> 6. M-x yank-rectangle

> BTW rectangle-mark-mode -- possibly activated with { C-x SPC } -- can
> help with the copy and yank in this case.
Right, I completely forgot that mode! Thanks



> HTH,
very much so. Why not include the code into master?

Uwe 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

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

end of thread, other threads:[~2022-01-20 21:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-20  8:06 how to copy a column of a table (with content) Uwe Brauer
2022-01-20 10:28 ` Marco Wahl
2022-01-20 16:22   ` Uwe Brauer

Code repositories for project(s) associated with this 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).