From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rick Frankel Subject: [PATCH] Process hlines in imported tables Date: Thu, 28 Mar 2013 21:46:15 -0400 Message-ID: <20130329014615.GA49671@BigDog.local> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="2fHTh5uZTiUOsy+g" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:44178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULOOa-0002sX-Og for emacs-orgmode@gnu.org; Thu, 28 Mar 2013 21:46:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ULOOY-0004yF-0E for emacs-orgmode@gnu.org; Thu, 28 Mar 2013 21:46:20 -0400 Received: from [204.62.15.78] (port=37048 helo=mail.rickster.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULOOX-0004y9-Sc for emacs-orgmode@gnu.org; Thu, 28 Mar 2013 21:46:17 -0400 Received: from BigDog.local (pool-72-89-40-63.nycmny.fios.verizon.net [72.89.40.63]) by mail.rickster.com (Postfix) with ESMTPS id D61372000A for ; Thu, 28 Mar 2013 21:46:17 -0400 (EDT) Content-Disposition: inline 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --2fHTh5uZTiUOsy+g Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --2fHTh5uZTiUOsy+g Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-When-importing-or-converting-table-convert-rows-star.patch" >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 --2fHTh5uZTiUOsy+g--