emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] [BUG] Inconsistency in src block hiding


From: Nicolas Goaziou
Subject: Re: [O] [BUG] Inconsistency in src block hiding
Date: Wed, 18 Jan 2012 18:36:46 +0100

Hello,

Eric Schulte <address@hidden> writes:

> Well maybe we should roll back this change.

Please don't.  _That_ would be a regression.

> I'll wait to see if Nicolas has a solution which is both functional and
> conforms to the Org-mode wide syntax norms.

The problem comes from the current exporter, which isn't neutral about
drawers, by default.

I think that a temporary fix should be to:

  1. Change default drawer formatting function to the following
     (neutral):

     #+begin_src emacs-lisp
     (defun org-export-format-drawer (name contents)
       "Export contents of a drawer as-is.
     Property drawers are ignored."
       (if (string= "PROPERTIES" name) "" contents))
     #+end_src

  2. Handle drawers earlier in org-export-preprocess-string function,
     i.e. just before footnote handling, so its contents can benefit
     from further modifications.

  3. Allow drawers in export by default (excepted PROPERTIES
     drawers). That is change `org-export-with-drawers' default value to
     t.

I'm packaging this in the following quick patch, highly untested.


Regards,

-- 
Nicolas Goaziou
>From 0c15bf694f8051eb58fd131868059460f28f2e0d Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <address@hidden>
Date: Wed, 18 Jan 2012 18:34:11 +0100
Subject: [PATCH] org-exp: Set neutral behaviour towards drawers

* lisp/org-exp.el (org-export-with-drawers): Change default value so
  all drawers are exportable as a default.
(org-export-preprocess-string): Handle drawers earlier in the
  preprocess, so their contents can be modified further.
(org-export-format-drawer): Change default behaviour contents of
  drawers are exported as Org code.  As a special case, property
  drawers are still ignored.
---
 lisp/org-exp.el |   26 ++++++++------------------
 1 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index c7e1a94..d9b0a3e 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -406,7 +406,7 @@ This option can also be set with the +OPTIONS line, e.g. 
\"tags:nil\"."
          (const :tag "Not in TOC" not-in-toc)
          (const :tag "On" t)))
 
-(defcustom org-export-with-drawers nil
+(defcustom org-export-with-drawers t
   "Non-nil means export with drawers like the property drawer.
 When t, all drawers are exported.  This may also be a list of
 drawer names to export."
@@ -1156,6 +1156,10 @@ on this string to produce the exported version."
       ;; Get rid of tasks, depending on configuration
       (org-export-remove-tasks (plist-get parameters :tasks))
 
+      ;; Get rid of drawers
+      (org-export-remove-or-extract-drawers
+       drawers (plist-get parameters :drawers))
+
       ;; Prepare footnotes for export.  During that process, footnotes
       ;; actually included in the exported part of the buffer go
       ;; though some transformations:
@@ -1209,10 +1213,6 @@ on this string to produce the exported version."
       ;; Find HTML special classes for headlines
       (org-export-remember-html-container-classes)
 
-      ;; Get rid of drawers
-      (org-export-remove-or-extract-drawers
-       drawers (plist-get parameters :drawers))
-
       ;; Get the correct stuff before the first headline
       (when (plist-get parameters :skip-before-1st-heading)
        (goto-char (point-min))
@@ -1500,19 +1500,9 @@ EXP-DRAWERS will be removed."
                                  name content))
           (insert content)))))))
 
-(defun org-export-format-drawer (name content)
-  "Format the content of a drawer as a colon example."
-  (if (string-match "[ \t]+\\'" content)
-      (setq content (substring content (match-beginning 0))))
-  (while (string-match "\\`[ \t]*\n" content)
-    (setq content (substring content (match-end 0))))
-  (setq content (org-remove-indentation content))
-  (setq content (concat ": " (mapconcat 'identity
-                                       (org-split-string content "\n")
-                                       "\n: ")
-                       "\n"))
-  (setq content (concat " : " (upcase name) "\n" content))
-  (org-add-props content nil 'org-protected t))
+(defun org-export-format-drawer (name contents)
+  "Export contents of a drawer as-is."
+  (if (string= "PROPERTIES" name) "" contents))
 
 (defun org-export-handle-export-tags (select-tags exclude-tags)
   "Modify the buffer, honoring SELECT-TAGS and EXCLUDE-TAGS.
-- 
1.7.8.3


reply via email to

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