Hello Org's developpers, Some time ago I tried to export in html form an org file containing many src blocks and ended with the following message :
org-html-do-format-code: Buffer is read-only: #<killed buffer> After narrowing down my file here are the steps to reproduce : emacs -q (require 'htmlize) ;; this is important else `org-html-fontify-code` ;; will keep the wrong branch ;; open the ecm-org-src-ro.org ([1]) ;; try to export as html I've also attached a patch ([2]) to fix this. I've also opened the bug 41641 with the sames informations. Pierre
#+title: ECM - src block read-only #+begin_src compilation -*- mode: compilation; default-directory: "~/Travail/VCS/Emacs/emacs-org-mode/" -*- Compilation started at Fri May 29 20:05:37 make -k targets Getting Help ============ make help - show brief help make targets - ditto make helpall - show extended help Build and Check =============== make - build Org ELisp and all documentation make all - ditto make compile - build Org ELisp files make single - build Org ELisp files, single Emacs per source make autoloads - create org-loaddefs.el to load Org in-place make test - build Org ELisp files and run test suite make vanilla - run Emacs with this Org-mode and no personal config make config - check main configuration make doc - build all documentation make info - build Info documentation Installation ============ make install - build and install Org Full documentation on Worg ========================== https://orgmode.org/worg/dev/org-build-system.html Compilation finished at Fri May 29 20:05:37 #+end_src
>From c292c6bc638b6ae94bfe1fa8636b819b1d655d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20T=C3=A9choueyres?= <pierre.techouey...@free.fr> Date: Mon, 1 Jun 2020 12:30:04 +0200 Subject: [PATCH] ox-html.el: Fix read-only error when export src bloc When the type of src block involve an read-only buffer (ex: compilation mode) avoid to setup the temp buffer as read-only and error when processing it * lisp/ox-html.el (org-html-fontify-code): set `inhibit-read-only' to avoid read-only temp buffer. --- lisp/ox-html.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index fe0a315c9..32996c2c2 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2156,7 +2156,8 @@ org-html-fontify-code ;; htmlize (setq code (let ((output-type org-html-htmlize-output-type) - (font-prefix org-html-htmlize-font-prefix)) + (font-prefix org-html-htmlize-font-prefix) + (inhibit-read-only t)) (with-temp-buffer ;; Switch to language-specific mode. (funcall lang-mode) -- 2.26.2