org-table-transpose-table-at-point: Preserve indentation and point
* lisp/org-table.el (org-table-transpose-table-at-point): Preserve indentatinon of first row. Restore point to transposed field in transposed table.
This commit is contained in:
parent
2eef1b4549
commit
fb5003ea63
|
@ -1834,7 +1834,7 @@ blindly applies a recipe that works for simple tables."
|
||||||
(goto-char beg)))))
|
(goto-char beg)))))
|
||||||
|
|
||||||
(defun org-table-transpose-table-at-point ()
|
(defun org-table-transpose-table-at-point ()
|
||||||
"Transpose orgmode table at point and eliminate hlines.
|
"Transpose Org table at point and eliminate hlines.
|
||||||
So a table like
|
So a table like
|
||||||
|
|
||||||
| 1 | 2 | 4 | 5 |
|
| 1 | 2 | 4 | 5 |
|
||||||
|
@ -1849,9 +1849,11 @@ will be transposed as
|
||||||
| 4 | c | g |
|
| 4 | c | g |
|
||||||
| 5 | d | h |
|
| 5 | d | h |
|
||||||
|
|
||||||
Note that horizontal lines disappeared."
|
Note that horizontal lines disappear."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((table (delete 'hline (org-table-to-lisp)))
|
(let* ((table (delete 'hline (org-table-to-lisp)))
|
||||||
|
(dline_old (org-table-current-line))
|
||||||
|
(col_old (org-table-current-column))
|
||||||
(contents (mapcar (lambda (p)
|
(contents (mapcar (lambda (p)
|
||||||
(let ((tp table))
|
(let ((tp table))
|
||||||
(mapcar
|
(mapcar
|
||||||
|
@ -1861,10 +1863,17 @@ Note that horizontal lines disappeared."
|
||||||
(setq tp (cdr tp))))
|
(setq tp (cdr tp))))
|
||||||
table)))
|
table)))
|
||||||
(car table))))
|
(car table))))
|
||||||
(delete-region (org-table-begin) (org-table-end))
|
(goto-char (org-table-begin))
|
||||||
(insert (mapconcat (lambda(x) (concat "| " (mapconcat 'identity x " | " ) " |\n" ))
|
(re-search-forward "|")
|
||||||
contents ""))
|
(backward-char)
|
||||||
(org-table-align)))
|
(delete-region (point) (org-table-end))
|
||||||
|
(insert (mapconcat
|
||||||
|
(lambda(x)
|
||||||
|
(concat "| " (mapconcat 'identity x " | " ) " |\n" ))
|
||||||
|
contents ""))
|
||||||
|
(org-table-goto-line col_old)
|
||||||
|
(org-table-goto-column dline_old))
|
||||||
|
(org-table-align))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun org-table-wrap-region (arg)
|
(defun org-table-wrap-region (arg)
|
||||||
|
|
Loading…
Reference in New Issue