Function: hfy-copy-and-fontify-file

hfy-copy-and-fontify-file is a byte-compiled function defined in htmlfontify.el.gz.

Signature

(hfy-copy-and-fontify-file SRCDIR DSTDIR FILE)

Documentation

Open FILE in SRCDIR - if fontified, write a fontified copy to DSTDIR adding an extension of hfy-extn. Fontification is actually done by htmlfontify-buffer. If the buffer is not fontified, just copy it.

Source Code

;; Defined in /usr/src/emacs/lisp/htmlfontify.el.gz
;; open a file, check fontification, if fontified, write a fontified copy
;; to the destination directory, otherwise just copy the file:
(defun hfy-copy-and-fontify-file (srcdir dstdir file)
  "Open FILE in SRCDIR - if fontified, write a fontified copy to DSTDIR
adding an extension of `hfy-extn'.  Fontification is actually done by
`htmlfontify-buffer'.  If the buffer is not fontified, just copy it."
  ;;(message "hfy-copy-and-fontify-file");;DBUG
  (let (;;(window-system  (or window-system 'htmlfontify))
        (target nil)
        (source nil)
        (html   nil))
    (cd srcdir)
    (with-current-buffer (setq source (find-file-noselect file))
      ;; FIXME: Shouldn't this use expand-file-name?  --Stef
      (setq target (concat dstdir "/" file))
      (hfy-make-directory (hfy-dirname target))
      (if (not (hfy-opt 'skip-refontification)) (font-lock-ensure))
      (if (or (hfy-fontified-p) (hfy-text-p srcdir file))
          (progn (setq html  (hfy-fontify-buffer srcdir file))
                 (set-buffer  html)
                 (write-file (concat target hfy-extn))
                 (kill-buffer html))
	(let ((modes (file-modes target)))
	  (if (and modes (not (file-writable-p target)))
	      (set-file-modes target (logior modes #o0200))))
        (copy-file (buffer-file-name source) target 'overwrite))
      (kill-buffer source)) ))