From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: SUMMARY: [Feature Request] Make property-drawers exportable Date: Thu, 26 Sep 2013 13:28:15 +0200 Message-ID: <58B8BF7F-E4B4-405F-8EC1-E73821BE7B18@gmail.com> References: <8738shvzaj.fsf@gmail.com> <87ppvkiz8b.fsf@gmail.com> <87vc5cviu6.fsf@gmail.com> <871u80imo6.fsf@gmail.com> <33429FE3-CAA5-4F58-8536-135F96CA9C11@gmail.com> <406B4BB5-5A38-44EB-AC97-DEA17644164C@gmail.com> <3EAEACD0-1B99-40B7-8A5D-AE491C9F8528@gmail.com> <87a9j115m0.fsf@gmail.com> <39CF3890-4884-4894-8670-627AC5B4E935@gmail.com> <874n9914ld.fsf@gmail.com> <87pprwzkjx.fsf@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Content-Type: multipart/signed; boundary="Apple-Mail=_7C2F6380-C18C-4165-862D-33DFDD0D37BE"; protocol="application/pgp-signature"; micalg=pgp-sha1 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VP9kB-0007w8-JQ for emacs-orgmode@gnu.org; Thu, 26 Sep 2013 07:28:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VP9k4-0000P0-Ad for emacs-orgmode@gnu.org; Thu, 26 Sep 2013 07:28:27 -0400 Received: from mail-ee0-x235.google.com ([2a00:1450:4013:c00::235]:39388) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VP9k3-0000Or-Rg for emacs-orgmode@gnu.org; Thu, 26 Sep 2013 07:28:20 -0400 Received: by mail-ee0-f53.google.com with SMTP id b15so466596eek.26 for ; Thu, 26 Sep 2013 04:28:19 -0700 (PDT) In-Reply-To: <87pprwzkjx.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: Thorsten Jolitz , emacs-orgmode@gnu.org --Apple-Mail=_7C2F6380-C18C-4165-862D-33DFDD0D37BE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi, this does look good to me, except that the customize type of org-export-with-properties needs to be extended to allow for the list of strings. Please just go ahead and apply it to master, then I and hopefully others = will test it further. - Carsten On 25.9.2013, at 22:57, Nicolas Goaziou wrote: > Carsten Dominik writes: >=20 >> Not really. It would simplify processing to have the list instead >> of a string, but indeed, a filter can accomplish all of it. >=20 > Here is a first patch. It doesn't handle export back-ends in contrib. >=20 >=20 > Regards, >=20 > --=20 > Nicolas Goaziou > =46rom c48974d10e0d57b6332fcfed384a49ee530ea04a Mon Sep 17 00:00:00 = 2001 > From: Nicolas Goaziou > Date: Wed, 25 Sep 2013 21:27:29 +0200 > Subject: [PATCH] ox: Add a defcustom to export properties drawers >=20 > * lisp/ox.el (org-export-with-drawers): Improve docstring. > (org-export-with-properties): New variable > (org-export--skip-p): Handle new variable. > (org-export-options-alist): Install new variable. > * lisp/ox-ascii.el (org-ascii-node-property, > org-ascii-property-drawer): New functions. > * lisp/ox-html.el (org-html-node-property): New function. > (org-html-property-drawer): Export property drawers as "pre" blocks. > * lisp/ox-latex.el (org-latex-property-drawer, > org-latex-node-property): New functions. > * lisp/ox-man.el (org-man-node-property, org-man-property-drawer): New > functions. > * lisp/ox-md.el (org-md-node-property, org-md-property-drawer): New > functions. > * lisp/ox-odt.el (org-odt-node-property): New function. > (org-odt-property-drawer): Export property drawers as fixed width > blocks. > * lisp/ox-texinfo.el (org-texinfo-node-property): New function. > (org-texinfo-property-drawer): Export property drawers as verbatim > blocks. > * testing/lisp/test-ox.el: Add tests. > --- > lisp/ox-ascii.el | 23 +++++++++++++++++++++++ > lisp/ox-html.el | 21 ++++++++++++++++----- > lisp/ox-latex.el | 25 ++++++++++++++++++++++++- > lisp/ox-man.el | 19 ++++++++++++++++++- > lisp/ox-md.el | 24 ++++++++++++++++++++++++ > lisp/ox-odt.el | 23 ++++++++++++++++++----- > lisp/ox-texinfo.el | 21 ++++++++++++++++----- > lisp/ox.el | 28 +++++++++++++++++++++++++--- > testing/lisp/test-ox.el | 19 +++++++++++++++++++ > 9 files changed, 183 insertions(+), 20 deletions(-) >=20 > diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el > index 74a7c64..e0a3fa9 100644 > --- a/lisp/ox-ascii.el > +++ b/lisp/ox-ascii.el > @@ -81,10 +81,12 @@ > (latex-fragment . org-ascii-latex-fragment) > (line-break . org-ascii-line-break) > (link . org-ascii-link) > + (node-property . org-ascii-node-property) > (paragraph . org-ascii-paragraph) > (plain-list . org-ascii-plain-list) > (plain-text . org-ascii-plain-text) > (planning . org-ascii-planning) > + (property-drawer . org-ascii-property-drawer) > (quote-block . org-ascii-quote-block) > (quote-section . org-ascii-quote-section) > (radio-target . org-ascii-radio-target) > @@ -1440,6 +1442,18 @@ INFO is a plist holding contextual = information." > (unless org-ascii-links-to-notes (format " (%s)" = raw-link)))))))) >=20 >=20 > +;;;; Node Properties > + > +(defun org-ascii-node-property (node-property contents info) > + "Transcode a NODE-PROPERTY element from Org to ASCII. > +CONTENTS is nil. INFO is a plist holding contextual > +information." > + (format "%s:%s" > + (org-element-property :key node-property) > + (let ((value (org-element-property :value node-property))) > + (if value (concat " " value) "")))) > + > + > ;;;; Paragraph >=20 > (defun org-ascii-paragraph (paragraph contents info) > @@ -1509,6 +1523,15 @@ channel." > " ")) >=20 >=20 > +;;;; Property Drawer > + > +(defun org-ascii-property-drawer (property-drawer contents info) > + "Transcode a PROPERTY-DRAWER element from Org to ASCII. > +CONTENTS holds the contents of the drawer. INFO is a plist > +holding contextual information." > + (org-string-nw-p contents)) > + > + > ;;;; Quote Block >=20 > (defun org-ascii-quote-block (quote-block contents info) > diff --git a/lisp/ox-html.el b/lisp/ox-html.el > index 14b31b2..66862bc 100644 > --- a/lisp/ox-html.el > +++ b/lisp/ox-html.el > @@ -76,6 +76,7 @@ > (latex-fragment . org-html-latex-fragment) > (line-break . org-html-line-break) > (link . org-html-link) > + (node-property . org-html-node-property) > (paragraph . org-html-paragraph) > (plain-list . org-html-plain-list) > (plain-text . org-html-plain-text) > @@ -2782,6 +2783,17 @@ INFO is a plist holding contextual information. = See > ;; No path, only description. Try to do something useful. > (t (format "%s" desc))))) >=20 > +;;;; Node Property > + > +(defun org-html-node-property (node-property contents info) > + "Transcode a NODE-PROPERTY element from Org to HTML. > +CONTENTS is nil. INFO is a plist holding contextual > +information." > + (format "%s:%s" > + (org-element-property :key node-property) > + (let ((value (org-element-property :value node-property))) > + (if value (concat " " value) "")))) > + > ;;;; Paragraph >=20 > (defun org-html-paragraph (paragraph contents info) > @@ -2930,11 +2942,10 @@ channel." >=20 > (defun org-html-property-drawer (property-drawer contents info) > "Transcode a PROPERTY-DRAWER element from Org to HTML. > -CONTENTS is nil. INFO is a plist holding contextual > -information." > - ;; The property drawer isn't exported but we want separating blank > - ;; lines nonetheless. > - "") > +CONTENTS holds the contents of the drawer. INFO is a plist > +holding contextual information." > + (and (org-string-nw-p contents) > + (format "
\n%s
" contents))) >=20 > ;;;; Quote Block >=20 > diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el > index e1173ef..196e50f 100644 > --- a/lisp/ox-latex.el > +++ b/lisp/ox-latex.el > @@ -63,11 +63,12 @@ > (latex-fragment . org-latex-latex-fragment) > (line-break . org-latex-line-break) > (link . org-latex-link) > + (node-property . org-latex-node-property) > (paragraph . org-latex-paragraph) > (plain-list . org-latex-plain-list) > (plain-text . org-latex-plain-text) > (planning . org-latex-planning) > - (property-drawer . (lambda (&rest args) "")) > + (property-drawer . org-latex-property-drawer) > (quote-block . org-latex-quote-block) > (quote-section . org-latex-quote-section) > (radio-target . org-latex-radio-target) > @@ -1837,6 +1838,18 @@ INFO is a plist holding contextual information. = See > (t (format org-latex-link-with-unknown-path-format desc))))) >=20 >=20 > +;;;; Node Property > + > +(defun org-latex-node-property (node-property contents info) > + "Transcode a NODE-PROPERTY element from Org to LaTeX. > +CONTENTS is nil. INFO is a plist holding contextual > +information." > + (format "%s:%s" > + (org-element-property :key node-property) > + (let ((value (org-element-property :value node-property))) > + (if value (concat " " value) "")))) > + > + > ;;;; Paragraph >=20 > (defun org-latex-paragraph (paragraph contents info) > @@ -1961,6 +1974,16 @@ information." > "\\\\")) >=20 >=20 > +;;;; Property Drawer > + > +(defun org-latex-property-drawer (property-drawer contents info) > + "Transcode a PROPERTY-DRAWER element from Org to LaTeX. > +CONTENTS holds the contents of the drawer. INFO is a plist > +holding contextual information." > + (and (org-string-nw-p contents) > + (format "\\begin{verbatim}\n%s\\end{verbatim}" contents))) > + > + > ;;;; Quote Block >=20 > (defun org-latex-quote-block (quote-block contents info) > diff --git a/lisp/ox-man.el b/lisp/ox-man.el > index a160e4c..760e264 100644 > --- a/lisp/ox-man.el > +++ b/lisp/ox-man.el > @@ -76,11 +76,12 @@ > (keyword . org-man-keyword) > (line-break . org-man-line-break) > (link . org-man-link) > + (node-property . org-man-node-property) > (paragraph . org-man-paragraph) > (plain-list . org-man-plain-list) > (plain-text . org-man-plain-text) > (planning . org-man-planning) > - (property-drawer . (lambda (&rest args) "")) > + (property-drawer . org-man-property-drawer) > (quote-block . org-man-quote-block) > (quote-section . org-man-quote-section) > (radio-target . org-man-radio-target) > @@ -663,6 +664,16 @@ INFO is a plist holding contextual information. = See > ;; No path, only description. Try to do something useful. > (t (format "\\fI%s\\fP" desc))))) >=20 > +;;;; Node Property > + > +(defun org-man-node-property (node-property contents info) > + "Transcode a NODE-PROPERTY element from Org to Man. > +CONTENTS is nil. INFO is a plist holding contextual > +information." > + (format "%s:%s" > + (org-element-property :key node-property) > + (let ((value (org-element-property :value node-property))) > + (if value (concat " " value) "")))) >=20 > ;;; Paragraph >=20 > @@ -722,6 +733,12 @@ contextual information." >=20 > ;;; Property Drawer >=20 > +(defun org-man-property-drawer (property-drawer contents info) > + "Transcode a PROPERTY-DRAWER element from Org to Man. > +CONTENTS holds the contents of the drawer. INFO is a plist > +holding contextual information." > + (and (org-string-nw-p contents) > + (format ".RS\n.nf\n%s\n.fi\n.RE" contents))) >=20 > ;;; Quote Block >=20 > diff --git a/lisp/ox-md.el b/lisp/ox-md.el > index feb611c..1114c50 100644 > --- a/lisp/ox-md.el > +++ b/lisp/ox-md.el > @@ -82,9 +82,11 @@ This variable can be set to either `atx' or = `setext'." > (item . org-md-item) > (line-break . org-md-line-break) > (link . org-md-link) > + (node-property . org-md-node-property) > (paragraph . org-md-paragraph) > (plain-list . org-md-plain-list) > (plain-text . org-md-plain-text) > + (property-drawer . org-md-property-drawer) > (quote-block . org-md-quote-block) > (quote-section . org-md-example-block) > (section . org-md-section) > @@ -334,6 +336,18 @@ a communication channel." > (format "[%s](%s)" contents path))))))) >=20 >=20 > +;;;; Node Property > + > +(defun org-md-node-property (node-property contents info) > + "Transcode a NODE-PROPERTY element into Markdown syntax. > +CONTENTS is nil. INFO is a plist holding contextual > +information." > + (format "%s:%s" > + (org-element-property :key node-property) > + (let ((value (org-element-property :value node-property))) > + (if value (concat " " value) "")))) > + > + > ;;;; Paragraph >=20 > (defun org-md-paragraph (paragraph contents info) > @@ -382,6 +396,16 @@ contextual information." > text) >=20 >=20 > +;;;; Property Drawer > + > +(defun org-md-property-drawer (property-drawer contents info) > + "Transcode a PROPERTY-DRAWER element into Markdown format. > +CONTENTS holds the contents of the drawer. INFO is a plist > +holding contextual information." > + (and (org-string-nw-p contents) > + (replace-regexp-in-string "^" " " contents))) > + > + > ;;;; Quote Block >=20 > (defun org-md-quote-block (quote-block contents info) > diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el > index ae9e473..57a9b6e 100644 > --- a/lisp/ox-odt.el > +++ b/lisp/ox-odt.el > @@ -59,6 +59,7 @@ > (latex-fragment . org-odt-latex-fragment) > (line-break . org-odt-line-break) > (link . org-odt-link) > + (node-property . org-odt-node-property) > (paragraph . org-odt-paragraph) > (plain-list . org-odt-plain-list) > (plain-text . org-odt-plain-text) > @@ -2868,6 +2869,18 @@ INFO is a plist holding contextual information. = See > "Emphasis" desc))))) >=20 >=20 > +;;;; Node Property > + > +(defun org-odt-node-property (node-property contents info) > + "Transcode a NODE-PROPERTY element from Org to ODT. > +CONTENTS is nil. INFO is a plist holding contextual > +information." > + (org-odt--encode-plain-text > + (format "%s:%s" > + (org-element-property :key node-property) > + (let ((value (org-element-property :value node-property))) > + (if value (concat " " value) ""))))) > + > ;;;; Paragraph >=20 > (defun org-odt--format-paragraph (paragraph contents default center = quote) > @@ -3005,11 +3018,11 @@ channel." >=20 > (defun org-odt-property-drawer (property-drawer contents info) > "Transcode a PROPERTY-DRAWER element from Org to ODT. > -CONTENTS is nil. INFO is a plist holding contextual > -information." > - ;; The property drawer isn't exported but we want separating blank > - ;; lines nonetheless. > - "") > +CONTENTS holds the contents of the drawer. INFO is a plist > +holding contextual information." > + (and (org-string-nw-p contents) > + (format "%s" > + contents))) >=20 >=20 > ;;;; Quote Block > diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el > index d289e60..c834087 100644 > --- a/lisp/ox-texinfo.el > +++ b/lisp/ox-texinfo.el > @@ -89,6 +89,7 @@ > (keyword . org-texinfo-keyword) > (line-break . org-texinfo-line-break) > (link . org-texinfo-link) > + (node-property . org-texinfo-node-property) > (paragraph . org-texinfo-paragraph) > (plain-list . org-texinfo-plain-list) > (plain-text . org-texinfo-plain-text) > @@ -1294,6 +1295,17 @@ are generated directly." > ;;(org-texinfo--build-detailed-menu parse top info) > (org-texinfo--build-menu parse 1 info 'detailed))))) >=20 > +;;;; Node Property > + > +(defun org-texinfo-node-property (node-property contents info) > + "Transcode a NODE-PROPERTY element from Org to Texinfo. > +CONTENTS is nil. INFO is a plist holding contextual > +information." > + (format "%s:%s" > + (org-element-property :key node-property) > + (let ((value (org-element-property :value node-property))) > + (if value (concat " " value) "")))) > + > ;;; Paragraph >=20 > (defun org-texinfo-paragraph (paragraph contents info) > @@ -1398,11 +1410,10 @@ information." >=20 > (defun org-texinfo-property-drawer (property-drawer contents info) > "Transcode a PROPERTY-DRAWER element from Org to Texinfo. > -CONTENTS is nil. INFO is a plist holding contextual > -information." > - ;; The property drawer isn't exported but we want separating blank > - ;; lines nonetheless. > - "") > +CONTENTS holds the contents of the drawer. INFO is a plist > +holding contextual information." > + (and (org-string-nw-p contents) > + (format "@verbatim\n%s@end verbatim" contents))) >=20 > ;;; Quote Block >=20 > diff --git a/lisp/ox.el b/lisp/ox.el > index 6c59368..7e1d932 100644 > --- a/lisp/ox.el > +++ b/lisp/ox.el > @@ -128,6 +128,7 @@ > (:with-latex nil "tex" org-export-with-latex) > (:with-planning nil "p" org-export-with-planning) > (:with-priority nil "pri" org-export-with-priority) > + (:with-properties nil "prop" org-export-with-properties) > (:with-smart-quotes nil "'" org-export-with-smart-quotes) > (:with-special-strings nil "-" org-export-with-special-strings) > (:with-statistics-cookies nil "stat" = org-export-with-statistics-cookies) > @@ -396,10 +397,11 @@ This option can also be set on with the CREATOR = keyword." > "Non-nil means export contents of standard drawers. >=20 > When t, all drawers are exported. This may also be a list of > -drawer names to export. If that list starts with `not', only > -drawers with such names will be ignored. > +drawer names to export, as strings. If that list starts with > +`not', only drawers with such names will be ignored. >=20 > -This variable doesn't apply to properties drawers. > +This variable doesn't apply to properties drawers. See > +`org-export-with-properties' instead. >=20 > This option can also be set with the OPTIONS keyword, > e.g. \"d:nil\"." > @@ -557,6 +559,19 @@ e.g. \"pri:t\"." > :group 'org-export-general > :type 'boolean) >=20 > +(defcustom org-export-with-properties nil > + "Non-nil means export contents of properties drawers. > + > +When t, all properties are exported. This may also be a list of > +properties to export, as strings. > + > +This option can also be set with the OPTIONS keyword, > +e.g. \"prop:t\"." > + :group 'org-export-general > + :version "24.4" > + :package-version '(Org . "8.2") > + :type 'boolean) > + > (defcustom org-export-with-section-numbers t > "Non-nil means add section numbers to headlines when exporting. >=20 > @@ -2072,7 +2087,14 @@ a tree with a select tag." > (not (eq todo-type with-tasks))) > (and (consp with-tasks) (not (member todo = with-tasks)))))))) > ((latex-environment latex-fragment) (not (plist-get options = :with-latex))) > + (node-property > + (let ((properties-set (plist-get options :with-properties))) > + (cond ((null properties-set) t) > + ((consp properties-set) > + (not (member-ignore-case (org-element-property :key blob) > + properties-set)))))) > (planning (not (plist-get options :with-planning))) > + (property-drawer (not (plist-get options :with-properties))) > (statistics-cookie (not (plist-get options = :with-statistics-cookies))) > (table-cell > (and (org-export-table-has-special-column-p > diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el > index 54248cb..47c68d7 100644 > --- a/testing/lisp/test-ox.el > +++ b/testing/lisp/test-ox.el > @@ -479,6 +479,25 @@ Paragraph" > (org-test-with-temp-text "CLOSED: [2012-04-29 sun. 10:45]" > (org-export-as (org-test-default-backend) > nil nil nil '(:with-planning nil)))))) > + ;; Property Drawers. > + (should > + (equal "* H1\n" > + (org-test-with-temp-text > + "* H1\n :PROPERTIES:\n :PROP: value\n :END:" > + (org-export-as (org-test-default-backend) > + nil nil nil '(:with-properties nil))))) > + (should > + (equal "* H1\n:PROPERTIES:\n:PROP: value\n:END:\n" > + (org-test-with-temp-text > + "* H1\n :PROPERTIES:\n :PROP: value\n :END:" > + (org-export-as (org-test-default-backend) > + nil nil nil '(:with-properties t))))) > + (should > + (equal "* H1\n:PROPERTIES:\n:B: 2\n:END:\n" > + (org-test-with-temp-text > + "* H1\n :PROPERTIES:\n :A: 1\n :B: 2\n:END:" > + (org-export-as (org-test-default-backend) > + nil nil nil '(:with-properties ("B")))))) > ;; Statistics cookies. > (should > (equal "" > --=20 > 1.8.4 >=20 --Apple-Mail=_7C2F6380-C18C-4165-862D-33DFDD0D37BE Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJSRBpPAAoJEO+gg/nAZuwMt2UH/AiB5uaYzgVYcWb59fpTJ3Xd hmC9ReaxtGMkmQLanPHZZRu2CzNF8V4NYsGLKbN9+VDeiQbak+wVPC4xW3M3vzCB joIy6uyCavL0HCWfLLM28whii2OYPrlO0DsFlE3f+LWb6Pst1tTYv7kGEYLzemGW 5JUTIqCy0oBbX9vKkV0LxnOkg0A7clpJBNpKl4PMRErjDzroPZud58Tb8oZTb8BN qclPt+GOSuj/lPBnfCIhf+jkh8riyoH80NBcZwv3/fqDeCDWprN1jKDGUDJzsQoL Jkibg2sQDRrXKx7gp5CqUBNdk3xSOpEGHpZJOpQx9ioRH74HrOrrPn6T/6aMfUc= =whH2 -----END PGP SIGNATURE----- --Apple-Mail=_7C2F6380-C18C-4165-862D-33DFDD0D37BE--