I have this in my init.el to enable block code syntax highlighting in org-mode:

(setq org-src-fontify-natively t)

I have also this for org-babel:

 '((emacs-lisp . t)
   (ditaa . t)))

when I insert source code < s followed by TAB to draw something using ditaa (same problem with emacs-lisp code, it seems to be a general SRC code block problem), the syntax highlighting breaks when I write this line:

#+BEGIN_SRC ditaa :file "./foo.png" :cmdline -r

No syntax highlighting but code can be evaluated

enter image description here

However, when I leave only #+BEGIN_SRC sitting alone in the first line I get the highlighting right, but code will not be evaluated in this case when I hit C-c C-c. Even one space after SRC is enough to break that syntax highlighting. What is going on? Can anyone help me fix it?

Syntax highlighting is right but code cannot be evaluated

enter image description here


  • GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2016-04-17 on lgw01-04, modified by Debian)
  • GNU Emacs 25.1.2 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2016-09-29; nothing changed.
  • Org mode version 9.0.4 (release_9.0.4-248-gdef8a8)
  • Org mode version 9.0.5 (release_9.0.5-288-g4caad0) problem presists
  • theme used is moe-dark


When I run emacs --vanilla from the terminal, the problem disappears. So what is going on? What to do next to find the cause from here?

  • I can't reproduce this with Emacs, so upgrading might help if possible – Tyler Feb 17 '17 at 19:16
  • same problem after upgrading to emacs 25.1.2 – doctorate Feb 18 '17 at 9:00
  • I am experiencing a similar issue in org-mode v 9.3.8. I don't have anything similar to your polymode package though... – Ajned Sep 12 at 8:36

By commenting out this line in my init.el problem was removed, the line was related to polymode package.

(add-to-list 'auto-mode-alist '("\\.org" . poly-org-mode))

That's it. This post was very helpful.

| improve this answer | |

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.