From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Carsten Dominik Newsgroups: gmane.emacs.help Subject: Re: colored fonts in batch mode Date: Fri, 09 May 2008 15:45:15 +0200 Organization: Faculty of Science, University of Amsterdam Message-ID: References: <3eae7850-9fe0-413f-8e42-169ebf129ec6@k13g2000hse.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1210344060 18825 80.91.229.12 (9 May 2008 14:41:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 9 May 2008 14:41:00 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri May 09 16:41:37 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JuTmn-0002oy-3g for geh-help-gnu-emacs@m.gmane.org; Fri, 09 May 2008 16:41:25 +0200 Original-Received: from localhost ([127.0.0.1]:47425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JuTm4-0006HR-NE for geh-help-gnu-emacs@m.gmane.org; Fri, 09 May 2008 10:40:40 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!goblin1!goblin.stu.neva.ru!txtfeed2.tudelft.nl!tudelft.nl!binfeed1.tudelft.nl!usenet.uva.nl!news.science.uva.nl!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 68 Original-Distribution: world Original-NNTP-Posting-Host: nb-dominik2.science.uva.nl Original-X-Trace: info.science.uva.nl 1210340715 19945 146.50.22.167 (9 May 2008 13:45:15 GMT) Original-X-Complaints-To: usenet@science.uva.nl Original-NNTP-Posting-Date: Fri, 9 May 2008 13:45:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (darwin) Cancel-Lock: sha1:vOp5ySZr8HQc/JTsZU9FZTiGKlo= Original-Xref: shelby.stanford.edu gnu.emacs.help:158484 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:53849 Archived-At: Dan Espen writes: > > I'm more familiar with XEmacs than emacs, but I think > the concept applies. > > Rather using batch invocation wouldn't using the emacs > equivalent of "gnudoit" be a solution? > (gnudoit sends lisp commands to a running XEmacs.) No, I don't think that would help. This is an emacs progress on a webserver that is updating our pages at orgmode.org. OK, here is what I ended up doing: - I created a CSS file that contains many emacs face definitions. I grabbed these definitions during an interactive Emacs session, by creating a buffer that contained one letter with each available Emacs face. Then I applied htmlize-region to this buffer, and copied the class definitions from the css file. Pretty long list, but ok, I can clean it up if I need to. (with-temp-buffer (let ((fl (face-list)) (htmlize-css-name-prefix "org-") (htmlize-output-type 'css) f i) (while (setq f (pop fl) i (and f (face-attribute f :inherit))) (when (and (symbolp f) (or (not i) (not (listp i)))) (insert (org-add-props (copy-sequence "1") nil 'face f)))) (htmlize-region (point-min) (point-max)))) (switch-to-buffer "*html*") - The batch process now runs htmlize not with inline-css as its method, but the css. I can do this in any display, and even in batch mode, font-lock will still assign the correct face names to keywords in the buffer, and htmlize will pick up those font names rather than the display dependent specifications. (defun org-export-htmlize-region-for-paste (beg end) "Convert the region to HTML, using htmlize.el. This is much like `htmlize-region-for-paste', only that it uses the settings define in the org-... variables." (let* ((htmlize-output-type 'css) (htmlize-css-name-prefix org-export-htmlize-css-font-prefix) (htmlbuf (htmlize-region beg end))) (unwind-protect (with-current-buffer htmlbuf (buffer-substring (plist-get htmlize-buffer-places 'content-start) (plist-get htmlize-buffer-places 'content-end))) (kill-buffer htmlbuf)))) - Now I can publish pages with source code with classes on all keywords, and because of the css file I have control over how things get displayed. Pretty happy with that! Thanks to everyone who replied, I did try a couple of the ideas, but in the end the dependence in the current display is too deeply engraved in the emacs internals, so this system is not easy to fool in a stable way. - Carsten