From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [PATCH] Fix error prone babel table output format detection Date: Sun, 04 May 2014 09:51:02 -0600 Message-ID: <87bnvda5sx.fsf@gmail.com> References: <20140501065231.5AE63181A42@treetowl.lan> <8761lqrn5p.fsf@Rainer.invalid> <87eh0dnbot.fsf@treetowl.lan> <87d2fxlv4u.fsf@treetowl.lan> <87eh0dkfno.fsf@treetowl.lan> <87bnvhhlhn.fsf@treetowl.lan> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wgz1l-0001aX-Mv for emacs-orgmode@gnu.org; Sun, 04 May 2014 12:12:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wgz1h-0001mg-4P for emacs-orgmode@gnu.org; Sun, 04 May 2014 12:12:33 -0400 Received: from mail-ig0-x229.google.com ([2607:f8b0:4001:c05::229]:51038) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wgz1g-0001mc-V0 for emacs-orgmode@gnu.org; Sun, 04 May 2014 12:12:29 -0400 Received: by mail-ig0-f169.google.com with SMTP id hl10so489405igb.4 for ; Sun, 04 May 2014 09:12:28 -0700 (PDT) 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: Ian Kelling Cc: Achim Gratz , emacs-orgmode@gnu.org Ian Kelling writes: > Ian Kelling writes: >> It's a bit late. here is the same patch with correct indentation. > > That patch went out of it's way not to check more of the list than was > necessary, but after sending it, I kept thinking that it does extra > things which possibly negate any performance benefit of not checking the > whole list. So here is a simpler patch does the same thing, but goes > over the whole list. I'd love to hear a more experienced emacs lisper > weigh in on which is better. > Hi Ian, You should use the `org-every' function here. Look at the source of that function to see code to efficiently perform this sort of check. Best, > > -- >8 -- > Subject: [PATCH] Fix error prone babel table output format detection > > * lisp/ob-core.el: Test that all elements are in a list are lists or > 'hline instead of just the first. > > org-babel table output uses different formatting for a list of lists, > but detects it incorrectly causing an error. An example of a block > causing an error is an emacs lisp source block containing just 1 line: > '((1) 2) > --- > lisp/ob-core.el | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/lisp/ob-core.el b/lisp/ob-core.el > index 1348f04..05ccb00 100644 > --- a/lisp/ob-core.el > +++ b/lisp/ob-core.el > @@ -2184,9 +2184,10 @@ code ---- the results are extracted in the syntax of the source > ((funcall proper-list-p result) > (goto-char beg) > (insert (concat (orgtbl-to-orgtbl > - (if (or (eq 'hline (car result)) > - (and (listp (car result)) > - (listp (cdr (car result))))) > + (if (let ((proper t)) > + (dolist (elem result proper) > + (unless (or (listp elem) (eq elem 'hline)) > + (setq proper nil)))) > result (list result)) > '(:fmt (lambda (cell) (format "%s" cell)))) "\n")) > (goto-char beg) (when (org-at-table-p) (org-table-align))) -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D