浏览代码

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.
Carsten Dominik 16 年之前
父节点
当前提交
ec773949d1
共有 2 个文件被更改,包括 17 次插入2 次删除
  1. 5 0
      lisp/ChangeLog
  2. 12 2
      lisp/org-exp.el

+ 5 - 0
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

+ 12 - 2
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.