This is very odd.

I have my Emacs config in code blocks in an org-mode file that is called from my init file using (org-babel-load-file "~/.emacs.d/emacs-config.org").

I've tried to assign some new key-bindings:

#+begin_src emacs-lisp :tangle yes
  (global-set-key (kbd "C-c h") 'browse-url-emacs) ; plain text
  (global-set-key (kbd "C-c j") 'browse-url) ; default browser

For a reason that I don't understand, this breaks other key bindings. After restarting emacs, for example, C-x f is bound to the default set-fill-column instead of recentf-ido-find-file, to which I had it reassigned.

This is confusing, because there is no overlap between the key-bindings. But what's really weird is that the problem persists even when I comment out the new key-bindings in the code block:

#+begin_src emacs-lisp :tangle yes
; (global-set-key (kbd "C-c h") 'browse-url-emacs) ; plain text
; (global-set-key (kbd "C-c j") 'browse-url) ; default browser

The problem goes away if I instruct org-babel to ignore the code block (using the :tangle no property:

#+begin_src emacs-lisp :tangle no
; (global-set-key (kbd "C-c h") 'browse-url-emacs) ; plain text
; (global-set-key (kbd "C-c j") 'browse-url) ; default browser

Why do commands that are commented out seem to affect my config? (And in such a weird way?)

And why do these new key bindings mess up existing ones?

  • 2
    I think the file is tangled into ~/.emacs.d/emacs-config.el so you should take a look at this file and see what it contains in the various cases. That will probably help you understand what's going on. If you still have problems, you might want to add that file to your question if it's short enough - or better yet, you might be able to reproduce the problem with a much smaller emacs-config.org file and then post the resulting .el file in your question.
    – NickD
    Mar 4 at 15:11
  • Thanks, will do. @Drew thanks for the edits!
    – henning
    Mar 4 at 16:30

1 Answer 1


For an unknown reason, org-babel truncated the tangled file (emacs-config.el) above the problematic code snippet. All settings above the snippet were therefore lost. As NickD said in a comment, it is crucial to examine the tangled file for troubleshooting.

The full file was tangled once I removed (not changed) the :tangle yes property from the code snippet. I don't know why having the property caused the preceding (but not the subsequent) code blocks not to be tangled. (Perhaps either each block or no block must have the property set, but this seems like unexpected behavior, not like a feature.)

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.