2

The code below is an org-mode file that will not load by-backend. But if I put the org code block setup anywhere else besides under * COMMENT it does run and (fbound 'by-backend) gives t. What is it about COMMENT that blocks local variable from doing setup upon loading the org file? I'm in org-mode 9.0.2 from elpa and Emacs 25.1.1.

* COMMENT
  #+name: setup
  #+begin_src emacs-lisp :results silent :exports none
  ;; (setq org-babel-latex-htlatex "htlatex")
  (defmacro by-backend (&rest body)
    `(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@body))
  #+end_src

  # Local variables:
  # eval: (org-sbe "setup")
  # End:
4

A section with a COMMENT keyword is just that, a comment, not to be evaluated. So speaks the manual

Finally, a ‘COMMENT’ keyword at the beginning of an entry, but after any other keyword or priority cookie, comments out the entire subtree. In this case, the subtree is not exported and no code block within it is executed either. [emphasis mine]

If what you want is to have the setup code evaluated, but not exported you can use the noexport tag, thusly:

* Setup                         :noexport:
  #+name: setup
  #+begin_src emacs-lisp :results silent :exports none
  ;; (setq org-babel-latex-htlatex "htlatex")
  (defmacro by-backend (&rest body)
    `(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@body))
  #+end_src

  # Local variables:
  # eval: (org-sbe "setup")
  # End:

org-sbe is still able to find the setup block, but the entire section, including the source block and its results, will be excluded from export.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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