emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [RFC] Replace some HTML related keywords with OPTIONS items


From: Nicolas Goaziou
Subject: Re: [O] [RFC] Replace some HTML related keywords with OPTIONS items
Date: Fri, 21 Jun 2013 20:55:26 +0200

Hello,

Achim Gratz <address@hidden> 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
>From df3934522fc922d4c1b1a88c4cfa9a6d06370720 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <address@hidden>
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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]