0

When exporting an org file to Latex / HTML / etc. I want to replace every occurrence of "Hello" with "World"

(add-hook 'org-export-preprocess-final-hook
      (lambda () (replace-string "Hello" "World")))

Setting the hook doesn't seem to do anything, nothing gets replaced in the exported file. Do I use the wrong hook?

2
  • Which version of org-mode are you using? (Perhaps an older version doesn't provide that hook?)
    – phils
    Dec 21, 2015 at 22:15
  • Apparently version 8.2
    – Arne
    Dec 24, 2015 at 19:40

1 Answer 1

2

I tried and it worked for me.

Typed your exact line and executed it (using C-x e in my scratch buffer)

Confirmation, using C-h v org-export-preprocess-final-hook

org-export-preprocess-final-hook's value is ((lambda nil
     (replace-string "Hello" "World")))

Tested from a buffer containing

* Task
Hello
Bouh
Hello

Using M-x org-export then H (temporary buffer), I got (snippet)

<p>World
Bouh
World
</p></div>

Are you sure you executed your registration ?

3
  • Tried by using C-c C-e L (for latex in temp buffer), seemed to have work as well. I used M-x org-export cause I did not remember the shortcut. Have you tried looking at the content of the 'org-export-preprocess-final-hookvariable using C-h v to be sure your hook was properly registered ?
    – Bruce
    Dec 21, 2015 at 14:12
  • Yep, C-h v org-export-preprocess-final-hook gives me the same result you got.
    – Arne
    Dec 21, 2015 at 14:20
  • No clue except that it works for me, sorry, I can't reproduce the problem hence can't help :-/
    – Bruce
    Dec 21, 2015 at 14:24

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.