0

When using literate configuration, is there a way to exclude code blocks?

Maybe tag the babel blocks to include or exclude?

Any great ideas?;)

10
  • 2
    A :tangle no header prevents the code block from being tangled - in fact, that's the default: you have to take explicit action to include the block in the tangled file. Is that what you want? If not, can you explain what you mean by literate configuration?
    – NickD
    Apr 26, 2022 at 19:22
  • Hmm, I've based my config on this way to do it and it includes all code blocks: github.com/mrvdb/emacs-config Apr 26, 2022 at 19:36
  • ok, :tangle no works great;) , but what if I want to just type :tangle yes when I want something included? Where is it set that it's default everything included?;) Apr 26, 2022 at 19:46
  • Why don't you add a small example in the question that does not work the way you expect it to?
    – NickD
    Apr 26, 2022 at 19:50
  • 1
    Let me repeat: Why don't you add a small example in the question that does not work the way you expect it to? An example of 4000 lines does not qualify as "small".
    – NickD
    Apr 27, 2022 at 11:55

2 Answers 2

1

This block won't be excluded:

*** CUA mode
#+begin_src emacs-lisp
  (cua-mode t)
#+end_src

This block will be excluded because it has the COMMENT state, which has been added with C-c ; (C-c ; runs the command org-toggle-comment):

*** COMMENT Highlighting syntax in code blocks
#+begin_src emacs-lisp
  (setq org-src-fontify-natively t)
#+end_src
0

[Not an answer, but we are talking at cross purposes in the comments, so maybe this will help]

Here's a small example (in a file called foo500.org):

* foo

#+begin_src elisp
  (princ "Hello world")
#+end_src

Trying to tangle this with C-c C-v C-t produces the message Tangled 0 code blocks from foo500.org.

If I change the code block to this:

* foo

#+begin_src elisp :tangle yes
  (princ "Hello world")
#+end_src

then tangling with C-c C-v C-t produces the message Tangled 1 code block from foo500.org and there is now a file foo500.el containing this:

(princ "Hello world")

That's what I said in the comments and that's what I've shown above.

If this works the same way for you, then what happens with your 4000-line file is irrelevant: you have made a wrong diagnosis of the problem and me looking at it is not going to help unless I try it out - something which I'm not going to do, since I don't have the time.

If it does not work the same way for you, then I'm willing to look a little further, but you have to do the work to narrow it down.

I hope that helps.

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.