1

I'm preparing a presentation in org-mode and I'd like to demonstrate live the execution of code. So I'd like to start the presentation without any result block.

How can I remove (strip) the results on save?

I realize there's M-x org-babel-remove-result. And maybe there's a way to hook this one into C-x C-s somehow. But I don't know.

1 Answer 1

2

Add this snippet of code to your init file.

(defun my-results-remove-hook ()
  (when (eq major-mode 'org-mode)
      (org-babel-remove-result)))
(add-hook 'before-save-hook 'my-results-remove-hook)

And rest assured, the result blocks will not get persisted.

1
  • 1
    I realize that org-babel-remove-result removes the result of the source block at point, but not all results. I use your snippet, but adapt it to call (org-babel-remove-result-one-or-many "#+RESULT") - and it works. Thanks!
    – hintze
    Mar 22 at 8:08

Your Answer

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

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