From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: Re: [RFC] Simplify attributes syntax Date: Sat, 09 Mar 2013 14:55:49 -0500 Message-ID: <87hakkcpq2.fsf@gmail.com> References: <87ppz9zar8.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:52505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEPs2-00056D-5l for emacs-orgmode@gnu.org; Sat, 09 Mar 2013 14:55:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UEPrz-0003Fs-UC for emacs-orgmode@gnu.org; Sat, 09 Mar 2013 14:55:54 -0500 Received: from mail-qc0-x236.google.com ([2607:f8b0:400d:c01::236]:51478) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEPrz-0003FB-QB for emacs-orgmode@gnu.org; Sat, 09 Mar 2013 14:55:51 -0500 Received: by mail-qc0-f182.google.com with SMTP id k19so979033qcs.41 for ; Sat, 09 Mar 2013 11:55:51 -0800 (PST) In-Reply-To: <87ppz9zar8.fsf@gmail.com> 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: Nicolas Goaziou Cc: Org Mode List Hi Nicolas, I think this patch is a welcome simplification. Would it be possible to merge the code that is used for reading babel header args (things like =E2=80=9C:results output :file foo.txt=E2=80=9D) with the code from the exp= orter? Unless they are parsed by the same code, the two syntaxes will differ in subtle and headache-inducing ways (for users and developers). Both methods as it stands have their pros and cons. org-export-read-attribute seems* to give the wrong result for the case of #+ATTR_FOO: :key "one :two three" -> (:key "\"one" :two "three\"") Whereas org-babel-parse-header-arguments (returning an alist, not a plist) gives correctly ((:key . "one :two three")) OTOH ":key (one :two)" makes o-b-parse-header-arguments give an error because it tries to read (one :two) as elisp, and =E2=80=9Cone=E2=80=9D isn= =E2=80=99t an elisp function. For o-x-read-attribute we correctly(?) get (:key "(one :two)"). o-b-parse-header-arguments can cope with ":key '(one :two three)" (note the single quote to not barf on the lisp-like syntax) giving ((:key one :two three)) =E2=80=93 which is a notational variant of ((:key . (one :two three))) =E2=80=93 whereas o-x-read-attribute gives (:key "'(one" :two "three)") In this last case I think that either value is arguably correct =E2=80=93 b= ut it should be consistently one and not the other. * For testing, I extracted the following function from org-export-read-attribute. =20=20 #+begin_src emacs-lisp (defun o-test (value) (let ((s value) result) (while (string-match "\\(?:^\\|[ \t]+\\)\\(:[-a-zA-Z0-9_]+\\)\\([ \t]+\\|$\\)" s) (let ((value (substring s 0 (match-beginning 0)))) (push (and (not (member value '("nil" ""))) value) result)) (push (intern (match-string 1 s)) result) (setq s (substring s (match-end 0)))) ;; Ignore any string before the first property with `cdr'. (cdr (nreverse (cons (and (org-string-nw-p s) (not (equal s "nil")) s) result)))) ) #+end_src --=20 Aaron Ecay