From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [RFC] Replace some HTML related keywords with OPTIONS items Date: Fri, 21 Jun 2013 20:55:26 +0200 Message-ID: <87a9mjfg4h.fsf@gmail.com> References: <87vc58fv2x.fsf@gmail.com> <04A18E4E-0428-4B06-ACC9-4A73DAF25258@gmail.com> <87mwqjfk5d.fsf@gmail.com> <87sj0b8i10.fsf@Rainer.invalid> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq6UQ-0002CJ-OD for emacs-orgmode@gnu.org; Fri, 21 Jun 2013 14:55:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uq6UP-0008EP-F1 for emacs-orgmode@gnu.org; Fri, 21 Jun 2013 14:55:18 -0400 Received: from mail-we0-x232.google.com ([2a00:1450:400c:c03::232]:39931) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq6UP-0008EI-5i for emacs-orgmode@gnu.org; Fri, 21 Jun 2013 14:55:17 -0400 Received: by mail-we0-f178.google.com with SMTP id u53so6781843wes.9 for ; Fri, 21 Jun 2013 11:55:16 -0700 (PDT) In-Reply-To: <87sj0b8i10.fsf@Rainer.invalid> (Achim Gratz's message of "Fri, 21 Jun 2013 19:56:11 +0200") 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: Achim Gratz Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hello, Achim Gratz writes: > Nicolas Goaziou writes: >> As for the move from #+OPTIONS: key:value to #+OPTIONS: :key value, >> I can provide a patch, but it will break export in many documents. >> A workaround would be to support both versions and document only the >> newest one. > > I didn't know supporting both styles was in the cards. If it isn't > overly complicated, that would be welcome of course. Here is a preliminary patch. It doesn't update org.texi yet. I find the new syntax weird for one character keys: #+OPTIONS: :* t :e t :: t :f t :- t :^ t :| t Maybe we should expand them in order to make them less cryptic. Regards, -- Nicolas Goaziou --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ox-Change-OPTIONS-syntax-from-key-value-to-key-value.patch >From df3934522fc922d4c1b1a88c4cfa9a6d06370720 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Fri, 21 Jun 2013 20:49:05 +0200 Subject: [PATCH] ox: Change OPTIONS syntax from key:value to :key value * lisp/ox.el (org-export--parse-option-keyword): Change OPTIONS syntax from key:value to :key value. Still recognize old syntax for compatibility. (org-export-insert-default-template): Use new syntax. * testing/lisp/test-ox.el: Update tests. --- lisp/ox.el | 26 +++++++++++++++++--------- testing/lisp/test-ox.el | 24 ++++++++++++------------ 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/lisp/ox.el b/lisp/ox.el index e49de22..8a29908 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -1524,20 +1524,29 @@ specific items to read, if any." (append (and backend (org-export-backend-options backend)) org-export-options-alist)) plist) - (dolist (option all) + (dolist (option all plist) (let ((property (car option)) (item (nth 2 option))) (when (and item (not (plist-member plist property)) - (string-match (concat "\\(\\`\\|[ \t]\\)" - (regexp-quote item) - ":\\(([^)\n]+)\\|[^ \t\n\r;,.]*\\)") - options)) + (let ((item (regexp-quote item))) + (or (string-match + (concat "\\(?:\\`\\|[ \t]\\):" + item + "[ \t]+\\(([^)\n]+)\\|[^ \t\n\r;,.]*\\)") + options) + ;; Compatibility code for deprecated + ;; item:value syntax. It can be removed in + ;; Org 9.0+. + (string-match + (concat "\\(?:\\`\\|[ \t]\\)" + item + ":\\(([^)\n]+)\\|[^ \t\n\r;,.]*\\)") + options)))) (setq plist (plist-put plist property (car (read-from-string - (match-string 2 options)))))))) - plist)) + (match-string 1 options)))))))))) (defun org-export--get-subtree-options (&optional backend) "Get export options in subtree at point. @@ -3171,8 +3180,7 @@ locally for the subtree through node properties." (when options (let ((items (mapcar - (lambda (opt) - (format "%s:%s" (car opt) (format "%s" (cdr opt)))) + (lambda (opt) (format ":%s %s" (car opt) (cdr opt))) (sort options (lambda (k1 k2) (string< (car k1) (car k2))))))) (if subtreep (org-entry-put diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index cbae08a..1a9c241 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -120,9 +120,9 @@ already filled in `info'." (should (equal (org-export--parse-option-keyword - "H:1 num:t \\n:t timestamp:t arch:t author:t creator:t d:t email:t - *:t e:t ::t f:t pri:t -:t ^:t toc:t |:t tags:t tasks:t <:t todo:t inline:nil - stat:t") + ":H 1 :num t :\\n t :timestamp t :arch t :author t :creator t :d t :email t + :* t :e t :: t :f t :pri t :- t :^ t :toc t :| t :tags t :tasks t :< t :todo t + :inline nil :stat t") '(:headline-levels 1 :preserve-breaks t :section-numbers t :time-stamp-file t :with-archived-trees t :with-author t :with-creator t :with-drawers t @@ -135,13 +135,13 @@ already filled in `info'." (should (equal (org-export--parse-option-keyword - "arch:headline creator:comment d:(\"TEST\") - ^:{} toc:1 tags:not-in-toc tasks:todo num:2 <:active") - '( :section-numbers - 2 - :with-archived-trees headline :with-creator comment - :with-drawers ("TEST") :with-sub-superscript {} :with-toc 1 - :with-tags not-in-toc :with-tasks todo :with-timestamps active)))) + ":arch headline :creator comment :d (\"TEST\") :^ {} :toc 1 + :tags not-in-toc :tasks todo :num 2 :< active") + '(:section-numbers + 2 + :with-archived-trees headline :with-creator comment + :with-drawers ("TEST") :with-sub-superscript {} :with-toc 1 + :with-tags not-in-toc :with-tasks todo :with-timestamps active)))) (ert-deftest test-org-export/get-inbuffer-options () "Test reading all standard export keywords." @@ -208,10 +208,10 @@ Paragraph" :title '("subtree-title") ;; EXPORT_OPTIONS. - (org-test-with-temp-text "#+OPTIONS: H:1 + (org-test-with-temp-text "#+OPTIONS: :H 1 * Headline :PROPERTIES: - :EXPORT_OPTIONS: H:2 + :EXPORT_OPTIONS: :H 2 :END: Paragraph" (forward-line) -- 1.8.3.1 --=-=-=--