rg-html-fontify-code: Wrong number of arguments: #[(_beg _end) "À ‡" [font-lock-fontify-buffer] 1], 0

Solution

Redefine function org-font-lock-ensure. Add the following code snippet to init.el and execute it to solve the problem:

(defun org-font-lock-ensure ()
  (font-lock-fontify-buffer))

Hack log

I find that if there is no source code blocks in the content, then org-html-export-as-html works properly. So I guess the problem occurred during exporting source code blocks to HTML. M-x toggle-debug-on-error (to prints a backtrace when an error happens in Emacs). Then create a very simple org-mode file which only contains a python code block:

def hello():
   print "hello world"

M-x org-html-export-as-html, here is the Backtrace (unimportant parts are omitted):

Debugger entered--Lisp error: (wrong-number-of-arguments #[(_beg _end) "\300 \207" [font-lock-fontify-buffer] 1] 0)
  org-font-lock-ensure()
  org-html-fontify-code("def hello():\n   print \"hello world\"\n" "python")
  org-html-do-format-code("def hello():\n   print \"hello world\"\n" "python" nil t nil)

The problem was in org-font-lock-ensure

(defalias 'org-font-lock-ensure
  (if (fboundp 'org-font-lock-ensure)
      #'font-lock-ensure
    (lambda (_beg _end) (font-lock-fontify-buffer))))

Stop exploration here (it might just be a bug of org-mode), just redefine org-font-lock-ensure:

(defun org-font-lock-ensure ()
  (font-lock-fontify-buffer))

My site is free of ads and trackers. Was this post helpful to you? Why not BuyMeACoffee