* lisp/org-exp.el (org-export-handle-comments): Add the org-protected property to the replacement string.
Although org-export-handle-comments adds the org-protected property to the matched string, the subsequent `replace-match' call to change the comment character does not add this property to the entire format string. Fix this by propertizing the entirety of the newtext argument to replace-match. --- I think this change makes the actual implementation match the intention of the code, we want the replacement comment character to be protected as well, however, I'm not sure if this breaks the usecases in ob-tangle and the like. lisp/org-exp.el | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 3e84314..da2475e 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -1853,7 +1853,10 @@ When it is nil, all comments will be removed." (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)) + (replace-match (propertize + (format commentsp (match-string 2)) + 'org-protected t) + t t)) (goto-char (1+ pos)) (replace-match "") (goto-char (max (point-min) (1- pos)))))))) -- 1.7.4.rc2.18.gb20e9