Browse Source

org-exp: check for protection before removing comments

* lisp/org-exp.el (org-export-handle-comments): check for protection
  before removing comments
Eric Schulte 14 years ago
parent
commit
0e636dc2ed
1 changed files with 11 additions and 8 deletions
  1. 11 8
      lisp/org-exp.el

+ 11 - 8
lisp/org-exp.el

@@ -1644,14 +1644,17 @@ When it is nil, all comments will be removed."
     (while (or (looking-at re)
 	       (re-search-forward re nil t))
       (setq pos (match-beginning 0))
-      (if (and commentsp
-	       (not (equal (char-before (match-end 1)) ?+)))
-	  (progn (add-text-properties
-		  (match-beginning 0) (match-end 0) '(org-protected t))
-		 (replace-match (format commentsp (match-string 2)) t t))
-	(goto-char (1+ pos))
-	(replace-match "")
-	(goto-char (max (point-min) (1- pos)))))))
+      (if (get-text-property (point) 'org-protected)
+	  (goto-char (1+ pos))
+	(if (and commentsp
+		 (not (equal (char-before (match-end 1)) ?+)))
+	    (progn (add-text-properties
+		    (match-beginning 0) (match-end 0) '(org-protected t))
+		   (replace-match (format commentsp (match-string 2)) t t))
+	  (goto-char (1+ pos))
+	  (replace-match "")
+	  (goto-char (max (point-min) (1- pos))))))))
+
 
 (defun org-export-mark-radio-links ()
   "Find all matches for radio targets and turn them into internal links."