emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Achim Gratz <Stromeko@nexgo.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: [RFC] Replace some HTML related keywords with OPTIONS items
Date: Fri, 21 Jun 2013 20:55:26 +0200	[thread overview]
Message-ID: <87a9mjfg4h.fsf@gmail.com> (raw)
In-Reply-To: <87sj0b8i10.fsf@Rainer.invalid> (Achim Gratz's message of "Fri, 21 Jun 2013 19:56:11 +0200")

[-- Attachment #1: Type: text/plain, Size: 691 bytes --]

Hello,

Achim Gratz <Stromeko@nexgo.de> 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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-Change-OPTIONS-syntax-from-key-value-to-key-value.patch --]
[-- Type: text/x-diff, Size: 4291 bytes --]

From df3934522fc922d4c1b1a88c4cfa9a6d06370720 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
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	other threads:[~2013-06-21 18:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-20 19:20 [RFC] Replace some HTML related keywords with OPTIONS items Nicolas Goaziou
2013-06-20 19:36 ` Nicolas Goaziou
2013-06-20 21:29 ` Samuel Wales
2013-06-21  4:51   ` Achim Gratz
2013-06-21  7:41 ` Sebastien Vauban
2013-06-21  9:17 ` Eric Abrahamsen
2013-06-21  9:26 ` Carsten Dominik
2013-06-21 17:28   ` Nicolas Goaziou
2013-06-21 17:32     ` Rick Frankel
2013-06-21 17:56     ` Achim Gratz
2013-06-21 18:55       ` Nicolas Goaziou [this message]
2013-06-21 19:36         ` Samuel Wales
2013-06-21 20:05         ` Thorsten Jolitz
2013-06-21 20:16         ` Eric Schulte
2013-06-21 20:41         ` Achim Gratz
2013-06-23 21:55           ` Carsten Dominik
2013-06-24 17:19             ` Achim Gratz
2013-06-27 14:26     ` Bastien
2013-06-27 14:33 ` Bastien
2013-06-27 16:00   ` Nicolas Goaziou
2013-06-27 16:19     ` Bastien
2013-06-27 19:18       ` Nicolas Goaziou
2013-06-28  7:14         ` Bastien

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=87a9mjfg4h.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=Stromeko@nexgo.de \
    --cc=emacs-orgmode@gnu.org \
    /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).