From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeremie Juste Subject: wrap long text in org table Date: Thu, 06 Sep 2018 10:33:38 +0200 Message-ID: <87tvn381p9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fxpjU-0004Uk-Pz for emacs-orgmode@gnu.org; Thu, 06 Sep 2018 04:33:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fxpjR-0008BX-Jn for emacs-orgmode@gnu.org; Thu, 06 Sep 2018 04:33:44 -0400 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:54123) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fxpjR-00089v-B0 for emacs-orgmode@gnu.org; Thu, 06 Sep 2018 04:33:41 -0400 Received: by mail-wm0-x229.google.com with SMTP id b19-v6so10529897wme.3 for ; Thu, 06 Sep 2018 01:33:41 -0700 (PDT) Received: from freegnu ([194.167.235.219]) by smtp.gmail.com with ESMTPSA id j44-v6sm4542080wre.40.2018.09.06.01.33.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 01:33:38 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org 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