I have run into an error with latest version of org-mode and cannot seem to find how to track it down. I have reported the issue on the org mail list, but so far the only response indicates they could not reproduce the issue.
So far I have tried the following
Ensured it is not a mixed version issue. A common org problem occurs when you try to install a new version, but some of the old version has already been loaded. I used all the standard techniques to avoid this problem and even deleted the version of org which comes with emacs 25. So I'm pretty sure it is not a mixed version problem.
I have tried with both emacs 25.1 and emacs 25.2-rc2. Same issue
I have tried using different accounts (same desktop) - one of which was a completely fresh account.
I've check for load-file shadows, but all looks correct.
I get the same issue with both the org and org-plus-contgrib packages
I also tried the org package in elpa (which is same version as the one in the org archive).
I have downloaded and built the package from sources.
I have tried opening an org file without source blocks, which is fine, but then when I open the first one with a source block, I get the error.
I have tried org-reload with and without the arg to load from *.el before opening the org file with source blocks and it makes no difference.
The error only occurs when I am also loading the goto-address-prog-mode mode (part of goto-addr package in emacs).
When you first visit an org file with a src_block, you get the error org-mode fontificaiton error at line x. It doesn't seem to matter what the src-block type is i.e. emacs-lisp or sh both give the same error. The code in the sr block is not fontified.
If you then kill the buffer and then re-open the org file a second time, it loads fine - no errors and src blocks are fontified.
This makes me suspect that org is loading something, but is not loading it until after it has loaded the org file - possibly goto-address-prog-mode is holding things up. However, I cannot work out how to generate a stacktrace. Setting debug-on-error has no effect.
I have been using the goto-address-prog-mode with org for some time and only noticed this problem when updating most recent version from org repo.
Ideas? Suggestions? How can I dig into this to find out what the problem is? How can I get a debug backtrace? Can anyone else reproduce this issue?
The minimal init.el file I use to reproduce this problem is below. I ensure there is nothing in my .emacs.d/elpa directory (in fact, I delete it before starting).
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
(package-initialize)
(unless (package-installed-p 'org-plus-contrib)
(package-refresh-contents)
(package-install 'org-plus-contrib))
(require 'org)
(require 'goto-addr)
(add-hook 'prog-mode-hook 'goto-address-prog-mode)
and the test org file I use is
* Test
This is a test of fontification in org files which contain source blocks
First, we test an sh block
#+BEGIN_SRC sh
echo "Hello world"
#+END_SRC
Next, a simple emacs lisp source block
#+BEGIN_SRC emacs-lisp
;; A simple test
(message "A Test")
#+END_SRC
and I start emacs with
emacs -Q -l .emacs.d/init.el --debug-init