help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: htmlize from shell


From: Johan Bockgård
Subject: Re: htmlize from shell
Date: Wed, 23 Jun 2004 22:26:02 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.2 (usg-unix-v)

nick <nobody@nowhere.non> writes:

> Using --load instead, I tried 
>
>       emacs -q --no-site-file --batch --load htmlit.el
>
> with htmlit.el containing the following:
>
>      (setq debug-on-error t)
>      (load-library "font-lock")
>      (load-library "htmlize")
>      (font-lock-mode t)
>      (htmlize-many-files  (list "/home/nick/tmp/297.txt" ))
>
> I get the following backtrace: [...]

You can use something like this:

-------- my-htmlize.el ----------------------------------
;; USAGE:
;;     emacs -batch -l my-htmlize.el <file> 

;; Note: Writes to stdout

;; Explicitly set the faces. Example:
(custom-set-faces 
 '(default                      ((t (:foreground "#ffffff" :background 
"black"))))
 '(font-lock-builtin-face       ((t (:foreground "#ff0000"))))
 '(font-lock-comment-face       ((t (:bold t :foreground "#333300"))))
 '(font-lock-constant-face      ((t (:foreground "magenta"))))
 '(font-lock-function-name-face ((t (:bold t :foreground "Blue"))))
 '(font-lock-keyword-face       ((t (:foreground "yellow3"))))
 '(font-lock-string-face        ((t (:foreground "light blue"))))
 '(font-lock-type-face          ((t (:foreground "green"))))
 '(font-lock-variable-name-face ((t (:foreground "cyan" :bold t))))
 '(font-lock-warning-face       ((t (:foreground "red" :weight bold)))))

(setq htmlize-use-rgb-map 'force)
(require 'htmlize)

(find-file (pop command-line-args-left))
(font-lock-fontify-buffer)
(with-current-buffer (htmlize-buffer)
  (princ (buffer-string)))
---------------------------------------------------------

You could easily adapt this to htmlize several files etc.

-- 
Johan Bockgård


reply via email to

[Prev in Thread] Current Thread [Next in Thread]