In the function org-export--generate-copy-script, the buffer contents are
copied over with buffer-substring-no-properties, so it appears that all
text properties are lost in the temporary copy.

I wondered why that is done?

I came across this because I was using text properties to find pieces of
text to modify before exporting in a org-export-before hook, but it doesn't
work since the text properties are gone.

The text properties are put on by font-lock. Curiously, if I add these
three lines

  (switch-to-buffer (current-buffer))
  (sem-mode 1)  # refontifies buffer
  (message-box "")

then the text-properties are put back on and I can find them again. If
leave the first or last line off though, this does not work. The last line
is especially mystifying.

Here is a minimal example that shows the issue. When you run the src block,
the word red will be italicized, and when you export it red will be turned
into the word yellow. without the unintuitive switch-to-buffer and message
box lines though, you will get an error.

Any ideas on what is happening here?

# begin
This is red.


#+BEGIN_SRC emacs-lisp :results silent :exports none
(font-lock-add-keywords
 nil
 '(("red" 0 '(face italic changeme t))))


(defun preprocess (backend)
  (switch-to-buffer (current-buffer))
  (font-lock-add-keywords
   nil
   '(("red" 0 '(face italic changeme t))))
  (message-box "")
  (let* ((start (next-single-property-change (point) 'changeme))
(end (next-single-property-change start 'changeme)))
    (setf (buffer-substring start end) "yellow")))

(add-hook 'org-export-before-processing-hook 'preprocess nil t)
#+END_SRC

John

-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

Reply via email to