From 86ee5bfcaa7513769cc3e2939c5e0b1a1f3c7706 Mon Sep 17 00:00:00 2001 From: Rick Frankel 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