emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Process hlines in imported tables
@ 2013-03-29  1:46 Rick Frankel
  2013-03-29 15:04 ` Eric Schulte
  0 siblings, 1 reply; 29+ messages in thread
From: Rick Frankel @ 2013-03-29  1:46 UTC (permalink / raw)
  To: emacs-orgmode

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

Currently, there is no way to include an hline in an imported or
converted table. The `org-babel-import-elisp-from-file converts lines
starting with '-' (or '|-') to an integer 0, because, even though
`org-table-to-lisp' will correctly convert lines starting with "|-",
because `org-table-convert-region' always puts "| " at the begining of
each line.

This patch solves that by not putting a space after the pipe symbol if
the first character of the line is a dash ("-").

rick

[-- Attachment #2: 0001-When-importing-or-converting-table-convert-rows-star.patch --]
[-- Type: text/plain, Size: 1779 bytes --]

From 86ee5bfcaa7513769cc3e2939c5e0b1a1f3c7706 Mon Sep 17 00:00:00 2001
From: Rick Frankel <rick@rickster.com>
Date: Thu, 28 Mar 2013 21:34:06 -0400
Subject: [PATCH] When importing or converting table, convert rows starting
 with "-" to horizontal (hlines).

* lisp/ob-core.el (org-babel-import-elisp-from-file): Check if row in
  an array or 'hline.
* lisp/org-table.el (org-table-convert-region): Don't put space after
  pipe symbol if line starts with '-', so `org-table-to-lisp' will
  match the row against `org-table-hline-regexp'.
---
 lisp/ob-core.el   | 3 ++-
 lisp/org-table.el | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index a63f77e..93b12b2 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2537,7 +2537,8 @@ If the table is trivial, then return it as a scalar."
 	      (org-table-import file-name separator)
 	      (delete-file file-name)
 	      (setq result (mapcar (lambda (row)
-				     (mapcar #'org-babel-string-read row))
+				     (if (eq row 'hline) 'hline
+				       (mapcar #'org-babel-string-read row)))
 				   (org-table-to-lisp))))
 	  (error (message "Error reading results: %s" err) nil)))
       (if (null (cdr result)) ;; if result is trivial vector, then scalarize it
diff --git a/lisp/org-table.el b/lisp/org-table.el
index f087cf7..da923cc 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -605,7 +605,8 @@ nil      When nil, the command tries to be smart and figure out the
 		   (format "^ *\\| *\t *\\| \\{%d,\\}" separator)))
 		(t (error "This should not happen"))))
       (while (re-search-forward re end t)
-	(replace-match "| " t t)))
+	(replace-match
+	 (if (= (char-after) ?-) "|" "| ") t t)))
     (goto-char beg)
     (org-table-align)))
 
-- 
1.8.2


^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2013-04-15 19:27 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-29  1:46 [PATCH] Process hlines in imported tables Rick Frankel
2013-03-29 15:04 ` Eric Schulte
2013-03-29 21:42   ` Rick Frankel
2013-03-30  0:01     ` Eric Schulte
2013-03-30 23:41       ` Rick Frankel
2013-03-31  0:43         ` Eric Schulte
2013-03-31 12:29           ` Rick Frankel
2013-03-31 13:37             ` Eric Schulte
2013-04-01 16:22               ` babel results handling (was: Process hlines in imported tables) Rick Frankel
2013-04-03 14:18                 ` babel results handling Eric Schulte
2013-04-03 18:02                   ` Achim Gratz
2013-04-04 18:20                   ` Rick Frankel
2013-04-03 18:21             ` [PATCH] Process hlines in imported tables Achim Gratz
2013-04-04 13:59               ` Sebastien Vauban
2013-04-04 15:02                 ` Eric Schulte
2013-04-04 21:01                   ` Sebastien Vauban
2013-04-06 16:30                     ` Eric Schulte
2013-04-15 13:06                     ` Sebastien Vauban
2013-04-15 15:25                       ` Eric Schulte
2013-04-15 19:27                         ` Sebastien Vauban
2013-04-04 18:35                 ` Rick Frankel
2013-04-04 21:05                   ` Sebastien Vauban
2013-04-04 19:29                 ` Achim Gratz
2013-04-06 16:29                   ` Eric Schulte
2013-04-06 17:07                     ` Eric Schulte
2013-04-06 17:24                     ` Bastien
2013-04-06 17:39                       ` Eric Schulte
2013-04-04 18:30               ` Rick Frankel
2013-04-04 20:27                 ` Sebastien Vauban

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).