Re: [Orgmode] Sorting table columns (*not* content)

2010-11-01 Thread brian powell
Ah wow!  Thanks Christian!  I, at least, am very happy and content about
this subject-thread!

MLeft and MRight work great in TableMode of EmacsOrgMode!

Agree too: Rectangle editing is slower than Christian's method--EmacsOrgMode
has blown me away all over again!

Christian's method is a manual one though, Juan's and Dan's are program/app
based--there is more than one way to skin a cat.

All of the methods @do@ help one sort columns (in the way Gary described) in
OrgMode.

But still, playing devil's advocate here: There are those disappearing
hlines in Juan's method--maybe there is some code to write here.
___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Sorting table columns (*not* content)

2010-11-01 Thread Christian Moe
If you want to sort table columns manually (usually that's quick and 
easy), forget rectangle editing: M-left and M-right are your friends.


Cheers,
Christian


On 11/1/10 2:52 PM, Jeff Horn wrote:

From the manual: [1]

,
| C-c C-x M-w
| Copy a rectangular region from a table to a special clipboard. Point
and mark determine edge fields of the rectangle. If there is no active
region, copy just the current field. The process ignores horizontal
separator lines.
| C-c C-x C-w
| Copy a rectangular region from a table to a special clipboard, and
blank all fields in the rectangle. So this is the “cut” operation.
| C-c C-x C-y
| Paste a rectangular region into a table. The upper left corner ends
up in the current field. All involved fields will be overwritten. If
the rectangle does not fit into the present table, the table is
enlarged as needed. The process ignores horizontal separator lines.
`

Hope this helps,
Jeff

* Footnotes
[1] http://orgmode.org/org.html#Built_002din-table-editor




___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Sorting table columns (*not* content)

2010-11-01 Thread brian powell
Jeff Horn seems to be explaining specifics of how to do some nitty-gritty
manipulations--he mentions (quoting the manual) methods for yanking, Ccxy

The methods Jeff expressed are useful for the question posed.

I recommend rectangle-kill and rectangle-yank--Cxrk and Cxry to solve this
(in a very simple albeit possibly faster or slower way--depending on how
many columns you want to move/sort---moving column/rectangle 3 to the 3rd
position in this case--took a few seconds)

I tested Juan's method/defun---works great!!
Thanks Juan

P.S. I did lose the hlines like you reported; but, to put the line back was
3 key strokes: |-Tab

On Mon, Nov 1, 2010 at 10:43 AM, Juan Pechiar  wrote:

> If you don't mind losing h-lines, you can transpose the table, sort
> rows, and transpose back.
>
> This code (which I previously posted to the list) transposes a table:
>
> #+begin_src: emacs-lisp
>
> (defun org-transpose-table-at-point ()
>  "Transpose orgmode table at point, eliminate hlines"
>  (interactive)
>  (let ((contents (apply #'mapcar* #'list
> (remove-if-not 'listp  ;; remove 'hline from list
>(org-table-to-lisp  ;; signals
> error if not table
>)
>(delete-region (org-table-begin) (org-table-end))
>(insert (mapconcat (lambda(x) (concat "| " (mapconcat 'identity x " | "
> ) "  |\n" ))
>   contents
>   ""))
>(org-table-align)
>)
> )
>
> #+end_src
>
> Regards,
> .j.
>
> On Mon, Nov 01, 2010 at 02:42:55PM +0100, Gary wrote:
> > Is there any way to sort the columns of a table, such that for example
> >
> > | Col 3 | Col 1 | Col 2 |
> >
> > can be converted to
> >
> > | Col 1 | Col 2 | Col 3 |
> > |---+---+---|
> > | ...   | ...   | ...   |
> >
> > ?
>
> ___
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Sorting table columns (*not* content)

2010-11-01 Thread Juan Pechiar
If you don't mind losing h-lines, you can transpose the table, sort
rows, and transpose back.

This code (which I previously posted to the list) transposes a table:

#+begin_src: emacs-lisp

(defun org-transpose-table-at-point ()
  "Transpose orgmode table at point, eliminate hlines"
  (interactive)
  (let ((contents (apply #'mapcar* #'list
 (remove-if-not 'listp  ;; remove 'hline from list
(org-table-to-lisp  ;; signals 
error if not table
)
(delete-region (org-table-begin) (org-table-end))
(insert (mapconcat (lambda(x) (concat "| " (mapconcat 'identity x " | " ) " 
 |\n" ))
   contents
   ""))
(org-table-align)
)
)

#+end_src

Regards,
.j.

On Mon, Nov 01, 2010 at 02:42:55PM +0100, Gary wrote:
> Is there any way to sort the columns of a table, such that for example
>
> | Col 3 | Col 1 | Col 2 |
>
> can be converted to
>
> | Col 1 | Col 2 | Col 3 |
> |---+---+---|
> | ...   | ...   | ...   |
>
> ?

___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Sorting table columns (*not* content)

2010-11-01 Thread Jeff Horn
>From the manual: [1]
,
| C-c C-x M-w
| Copy a rectangular region from a table to a special clipboard. Point
and mark determine edge fields of the rectangle. If there is no active
region, copy just the current field. The process ignores horizontal
separator lines.
| C-c C-x C-w
| Copy a rectangular region from a table to a special clipboard, and
blank all fields in the rectangle. So this is the “cut” operation.
| C-c C-x C-y
| Paste a rectangular region into a table. The upper left corner ends
up in the current field. All involved fields will be overwritten. If
the rectangle does not fit into the present table, the table is
enlarged as needed. The process ignores horizontal separator lines.
`

Hope this helps,
Jeff

* Footnotes
[1] http://orgmode.org/org.html#Built_002din-table-editor

-- 
Jeffrey Horn
Graduate Lecturer and PhD Student in Economics
George Mason University

(704) 271-4797
jh...@gmu.edu
jrhorn...@gmail.com

http://www.failuretorefrain.com/jeff/

___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode