From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric S Fraga Subject: Re: controlling how htmlize fontifies code Date: Tue, 4 Aug 2015 17:03:16 +0100 Message-ID: <87r3njhwhn.fsf@ucl.ac.uk> References: <874mkihwl2.fsf@ucl.ac.uk> <20150802131919.GA98482@eyeBook.home> <87a8u8jxb0.fsf@ucl.ac.uk> <20150803210802.GA2327@eyeBook.home> <87a8u7faou.fsf@ucl.ac.uk> <87wpxbrw5v.fsf@gmx.us> <87h9ofgkej.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMega-0003Ly-TR for emacs-orgmode@gnu.org; Tue, 04 Aug 2015 12:03:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZMegU-0000G3-Q8 for emacs-orgmode@gnu.org; Tue, 04 Aug 2015 12:03:28 -0400 Received: from mail-am1on0139.outbound.protection.outlook.com ([157.56.112.139]:9600 helo=emea01-am1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMegU-0000Am-FD for emacs-orgmode@gnu.org; Tue, 04 Aug 2015 12:03:22 -0400 In-Reply-To: <87h9ofgkej.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Tue, 4 Aug 2015 17:09:40 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Rasmus Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain On Tuesday, 4 Aug 2015 at 17:09, Nicolas Goaziou wrote: [...] > Not really, although I would write it like the following instead: > > (let ((output-type org-html-htmlize-output-type) > (font-prefix org-html-htmlize-font-prefix)) > (with-temp-buffer > ... > ;; Htmlize region. > (let ((org-html-htmlize-output-type output-type) > (org-html-htmlize-font-prefix font-prefix)) > (org-html-htmlize-region-for-paste > (point-min) (point-max))))) Thanks Nicolas. This works! (diffs attached) At least with the output type set as a local variable but not with #+bind which is perfectly fine as local variable use is what I would prefer. And thank you to Rasmus as well as I would imagine the suggested code changes would work as well. -- : Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3beta-1315-ga3b2b7 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename="t.patch" diff --git a/lisp/ox-html.el b/lisp/ox-html.el index d454fab..82e3b76 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2041,25 +2041,29 @@ is the language used for CODE, as a string, or nil." ;; Case 2: Default. Fontify code. (t ;; htmlize - (setq code (with-temp-buffer - ;; Switch to language-specific mode. - (funcall lang-mode) - (insert code) - ;; Fontify buffer. - (font-lock-ensure) - ;; Remove formatting on newline characters. - (save-excursion - (let ((beg (point-min)) - (end (point-max))) - (goto-char beg) - (while (progn (end-of-line) (< (point) end)) - (put-text-property (point) (1+ (point)) 'face nil) - (forward-char 1)))) - (org-src-mode) - (set-buffer-modified-p nil) - ;; Htmlize region. - (org-html-htmlize-region-for-paste - (point-min) (point-max)))) + (let ((output-type org-html-htmlize-output-type) + (font-prefix org-html-htmlize-font-prefix)) + (setq code (with-temp-buffer + ;; Switch to language-specific mode. + (funcall lang-mode) + (insert code) + ;; Fontify buffer. + (font-lock-ensure) + ;; Remove formatting on newline characters. + (save-excursion + (let ((beg (point-min)) + (end (point-max))) + (goto-char beg) + (while (progn (end-of-line) (< (point) end)) + (put-text-property (point) (1+ (point)) 'face nil) + (forward-char 1)))) + (org-src-mode) + (set-buffer-modified-p nil) + ;; Htmlize region. + (let ((org-html-htmlize-output-type output-type) + (org-html-htmlize-font-prefix font-prefix)) + (org-html-htmlize-region-for-paste + (point-min) (point-max)))))) ;; Strip any enclosing
 tags.
 	  (let* ((beg (and (string-match "\\`]*>\n*" code) (match-end 0)))
 		 (end (and beg (string-match "\\'" code))))

--=-=-=--