summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2009-04-22 06:37:00 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2009-04-22 06:37:00 +0200
commitec773949d138265fbc496e620340141d557f68a0 (patch)
tree407c1682d83c2b443922fd45539ac834c8db3c49
parent7596db2d78ebb25eb85a1cdf68744124a78a94d8 (diff)
downloadorg-mode-ec773949d138265fbc496e620340141d557f68a0.tar.gz
Export: Handle empty drawers, and drawers that are missing the :END:
Export could loose large parts of a document if an empty drawer was present.
-rwxr-xr-xlisp/ChangeLog5
-rw-r--r--lisp/org-exp.el14
2 files changed, 17 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b9190ed..3e4e7c5 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2009-04-22 Carsten Dominik <carsten.dominik@gmail.com>
+
+ * org-exp.el (org-export-remove-or-extract-drawers): Handle empty
+ drawers, and drawers that are missing the :END: line.
+
2009-04-21 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-clock-goto): Go to recently clocked task if no
diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 382187f..187cd79 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -1447,10 +1447,20 @@ whose content to keep."
(org-delete-all exp-drawers
(copy-sequence all-drawers))
"\\|")
- "\\):[ \t]*\n\\([^\000]*?\n\\)?[ \t]*:END:[ \t]*\n")))
+ "\\):[ \t]*$"))
+ beg eol)
(while (re-search-forward re nil t)
(org-if-unprotected
- (replace-match ""))))))
+ (setq beg (match-beginning 0)
+ eol (match-end 0))
+ (if (re-search-forward "^\\([ \t]*:END:[ \t]*\n?\\)\\|^\\*+[ \t]"
+ nil t)
+ (if (match-end 1)
+ ;; terminated in this entry
+ (progn
+ (delete-region beg (match-end 1))
+ (goto-char beg))
+ (goto-char eol))))))))
(defun org-export-handle-export-tags (select-tags exclude-tags)
"Modify the buffer, honoring SELECT-TAGS and EXCLUDE-TAGS.