I organize my init.el in a single org-file as many do. Often times I remove code from my config to test things out. I typically do this by changing the src-block to have a :tangle no setting. In many cases, I forget about it and eventually realize large portions of my config are not tangled.

I'm not quite sure if I need to craft some type of watcher or hook function.

* This is a heading

    #+BEGIN_SRC emacs-lisp

would become

* TODO This is a heading

    #+BEGIN_SRC emacs-lisp :tangle no

I was thinking about adding something like this to an on-save hook and then modifying the code blocks section header if :tangle no.

(org-element-map (org-element-parse-buffer) 'src-block #'identity nil nil 'src-block)

But it takes a really long time just to run this function.

  • Not sure what you are asking for. E.g. why isn't a global search-and-replace of :tangle no to nothing enough?
    – NickD
    Commented Jun 2, 2020 at 4:43
  • @NickD Good point, another added benefit would be when knitting my init.el file to html, non-tangled blocks can be differentiated from tangled blocks.
    – dylanjm
    Commented Jun 2, 2020 at 4:47

1 Answer 1


On my computer, sections with todo keyword COMMENT are not tangled. That is, change your TODO example to * COMMENT This is a heading. It is also fairly easy to toggle the COMMENT keyword, with C-; keystroke anywhere on or within a heading.

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.