* wrap long text in org table
@ 2018-09-06 8:33 Jeremie Juste
0 siblings, 0 replies; only message in thread
From: Jeremie Juste @ 2018-09-06 8:33 UTC (permalink / raw)
To: emacs-orgmode
Hello,
Is there a way to wrap long text in org-table?
For instance I would like to wrap this text to 80.
| | <80> |
| 1 | Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum |
| 2 | Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum |
| 3 | Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum |
I found some code in on emacs.stackexchange
(https://emacs.stackexchange.com/questions/30837/org-tables-wrap-all-fields-in-column-to-a-given-size)
but it works only for the first line of my example. I'll try to improve
it and post it back on the mailing list but if you have any
clue feel free to help :-)
(defun org-table-wrap-to-width (width)
"Wrap current column to WIDTH."
(interactive (list (read-number "Enter column width: ")))
(org-table-check-inside-data-field)
(org-table-align)
(let (cline (ccol (org-table-current-column)) new-row-count (more t))
(org-table-goto-line 1)
(org-table-goto-column ccol)
(while more
(setq cline (org-table-current-line))
;; Cut current field
(org-table-copy-region (point) (point) 'cut)
;; Justify for width
(setq org-table-clip
(mapcar 'list (org-wrap (caar org-table-clip) width nil)))
;; Add new lines and fill
(setq new-row-count (1- (length org-table-clip)))
(if (> new-row-count 0)
(org-table-insert-n-row-below new-row-count))
(org-table-goto-line cline)
(org-table-goto-column ccol)
(org-table-paste-rectangle)
(org-table-goto-line (+ cline new-row-count))
;; Move to next line
(setq more (org-table-goto-line (+ cline new-row-count 1)))
(org-table-goto-column ccol))
(org-table-goto-line 1)
(org-table-goto-column ccol)))
Best regards,
Jeremie
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-09-06 8:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-06 8:33 wrap long text in org table Jeremie Juste
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).