From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [PATCH] Process hlines in imported tables Date: Fri, 29 Mar 2013 09:04:42 -0600 Message-ID: <87wqsq6yd1.fsf@gmail.com> References: <20130329014615.GA49671@BigDog.local> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:59184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULarY-0002Dy-6D for emacs-orgmode@gnu.org; Fri, 29 Mar 2013 11:05:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ULarU-0003eG-6g for emacs-orgmode@gnu.org; Fri, 29 Mar 2013 11:05:04 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:43795) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULarT-0003eA-Uz for emacs-orgmode@gnu.org; Fri, 29 Mar 2013 11:05:00 -0400 Received: by mail-pd0-f170.google.com with SMTP id 4so289675pdd.15 for ; Fri, 29 Mar 2013 08:04:59 -0700 (PDT) In-Reply-To: <20130329014615.GA49671@BigDog.local> (Rick Frankel's message of "Thu, 28 Mar 2013 21:46:15 -0400") 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 Rick Frankel writes: > 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, Oh, thanks for pointing this out, I've just pushed up a fix. The single "-" was tricking the number checker because it looks like a minus sign about to be followed by numbers. These characters are no longer converted to 0s. > 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 ("-"). > Users may want to insert a "-" in their tables, and I think it would be surprising to magically replace floating "-" characters with hlines. There are numerous existing options for inserting hlines into tables, e.g., the :colnames header argument, using the raw, wrap and org result types and printing literal Org-mode syntax from your block, additionally any result could be passed through an elisp code block which may insert hline symbols at will. Is there a specific use case which isn't addressed by the existing functionality? Thanks, > > rick > > 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))) -- Eric Schulte http://cs.unm.edu/~eschulte