all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Eric Schulte" <schulte.eric@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: [PATCH] remove newline characters from the contents of table cells
Date: Fri, 18 Jun 2010 12:41:52 -0700	[thread overview]
Message-ID: <87eig4dt6n.fsf@gmail.com> (raw)

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

This patch changes the functionality of orgtbl-to-orgtbl so that it will
remove newline characters from the text of table cells and replace them
with "\n".  This protects the final table from such newlines.

This patch will probably only have any noticeable effect for tables
imported form external files, or from the results of code blocks.

Best -- Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-table-will-now-strip-newlines-from-the-text-of-t.patch --]
[-- Type: text/x-diff, Size: 1987 bytes --]

From 34aacc9aa037e8f17c8d32ed61a25f0a350713a0 Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Fri, 18 Jun 2010 12:38:26 -0700
Subject: [PATCH] org-table: will now strip newlines from the text of table cells

* lisp/org-table.el (orgtbl-to-generic): added the :remove-newlines
  option which will strip newline characters from the text of table
  cells and replace then with "\n"

  (orgtbl-to-orgtbl): now using the new :remove-newlines option to
  orgtbl-to-generic
---
 lisp/org-table.el |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index 46efc28..e81a855 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -4119,6 +4119,7 @@ directly by `orgtbl-send-table'.  See manual."
   (let* ((splicep (plist-get params :splice))
 	 (hline (plist-get params :hline))
 	 (remove-nil-linesp (plist-get params :remove-nil-lines))
+	 (remove-newlines (plist-get params :remove-newlines))
 	 (*orgtbl-hline* hline)
 	 (*orgtbl-table* table)
 	 (*orgtbl-sep* (plist-get params :sep))
@@ -4173,9 +4174,13 @@ directly by `orgtbl-send-table'.  See manual."
 	(let ((tend (orgtbl-eval-str (plist-get params :tend))))
 	  (if tend (push tend *orgtbl-rtn*)))))
 
-    (mapconcat 'identity (nreverse (if remove-nil-linesp
-				       (remq nil *orgtbl-rtn*)
-				     *orgtbl-rtn*)) "\n")))
+    (mapconcat (if remove-newlines
+		   (lambda (tend)
+		     (replace-regexp-in-string "[\n\r\t\f]" "\\\\n" tend))
+		 'identity)
+	       (nreverse (if remove-nil-linesp
+			     (remq nil *orgtbl-rtn*)
+			   *orgtbl-rtn*)) "\n")))
 
 (defun orgtbl-to-tsv (table params)
   "Convert the orgtbl-mode table to TAB separated material."
@@ -4301,6 +4306,7 @@ and :tend suppress strings without splicing; they can be set to
 provide ORGTBL directives for the generated table."
   (let* ((params2
 	  (list
+	   :remove-newlines t
 	   :tstart nil :tend nil
 	   :hline "|---"
 	   :sep " | "
-- 
1.7.0.4


[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

                 reply	other threads:[~2010-06-18 19:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eig4dt6n.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.