unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Carsten Dominik <dominik@science.uva.nl>
To: help-gnu-emacs@gnu.org
Subject: Re: colored fonts in batch mode
Date: Fri, 09 May 2008 15:45:15 +0200	[thread overview]
Message-ID: <m2ve1noal0.fsf@nb-dominik2.science.uva.nl> (raw)
In-Reply-To: ichcd8zts8.fsf@verizon.net

Dan Espen <daneNO@MORE.mk.SPAMtelcordia.com> 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



  reply	other threads:[~2008-05-09 13:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-08  9:15 colored fonts in batch mode Carsten Dominik
2008-05-08 11:22 ` Jason Rumney
2008-05-08 12:23   ` Carsten Dominik
2008-05-08 14:18     ` Eli Zaretskii
     [not found]     ` <mailman.11327.1210256313.18990.help-gnu-emacs@gnu.org>
2008-05-08 15:42       ` Dan Espen
2008-05-09 13:45         ` Carsten Dominik [this message]
2008-05-08 15:45     ` Jason Rumney
2008-05-08 16:02 ` Johan Bockgård
2008-05-09 13:46   ` Carsten Dominik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2ve1noal0.fsf@nb-dominik2.science.uva.nl \
    --to=dominik@science.uva.nl \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).