emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Aaron Ecay <aaronecay@gmail.com>
To: Nicolas Goaziou <n.goaziou@gmail.com>
Cc: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: [RFC] Simplify attributes syntax
Date: Sat, 09 Mar 2013 14:55:49 -0500	[thread overview]
Message-ID: <87hakkcpq2.fsf@gmail.com> (raw)
In-Reply-To: <87ppz9zar8.fsf@gmail.com>

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
“:results output :file foo.txt”) with the code from the exporter?
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 “one” isn’t 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)) – which is a notational variant of
((:key . (one :two three))) – whereas o-x-read-attribute gives
(:key "'(one" :two "three)")

In this last case I think that either value is arguably correct – but it
should be consistently one and not the other.

* For testing, I extracted the following function from
org-export-read-attribute.
  
#+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

-- 
Aaron Ecay

  parent reply	other threads:[~2013-03-09 19:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-09  0:18 [RFC] Simplify attributes syntax Nicolas Goaziou
2013-03-09  0:44 ` Thomas S. Dye
2013-03-09 13:55 ` Bastien
2013-03-09 14:45   ` Nicolas Goaziou
2013-03-09 19:55 ` Aaron Ecay [this message]
2013-03-09 21:19   ` Nicolas Goaziou
2013-03-11  7:40 ` Nicolas Goaziou
2013-03-13  8:47 ` Christian Egli
2013-03-13 15:28   ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87hakkcpq2.fsf@gmail.com \
    --to=aaronecay@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=n.goaziou@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).