RTFM
rtfm / Emacs / htmlfontify / again...
.etla.org
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                      "http://www.w3c.org/TR/html40/loose.dtd">
<html>
  <head>
    <title>rtfm.etla.org ( emacs / htmlfontify / src/htmlfontify.el )</title>
    <link rel="stylesheet" type="text/css" href="/css/red+black.css">

<style type="text/css"><!-- 
body { background: rgb(0, 0, 0);  color: rgb(255, 255, 255);  font-family: misc-fixed;  font-size: 100%;  text-decoration: none; }
span.default   { background: rgb(0, 0, 0);  color: rgb(255, 255, 255);  font-family: misc-fixed;  font-size: 100%;  text-decoration: none; }
span.default a { background: rgb(0, 0, 0);  color: rgb(255, 255, 255);  font-family: misc-fixed;  font-size: 100%;  text-decoration: underline; }
span.variable-name   { color: rgb(152, 251, 152);  font-size: 100%;  text-decoration: none; }
span.variable-name a { color: rgb(152, 251, 152);  font-size: 100%;  text-decoration: underline; }
span.string   { color: rgb(64, 224, 208);  font-size: 100%;  text-decoration: none; }
span.string a { color: rgb(64, 224, 208);  font-size: 100%;  text-decoration: underline; }
span.builtin   { color: rgb(176, 196, 222);  font-size: 100%;  text-decoration: none; }
span.builtin a { color: rgb(176, 196, 222);  font-size: 100%;  text-decoration: underline; }
span.type   { color: rgb(144, 238, 144);  font-size: 100%;  text-decoration: none; }
span.type a { color: rgb(144, 238, 144);  font-size: 100%;  text-decoration: underline; }
span.function-name   { text-decoration: underline;  color: rgb(160, 192, 255);  font-size: 100%; }
span.function-name a { text-decoration: underline;  color: rgb(160, 192, 255);  font-size: 100%; }
span.keyword   { color: rgb(112, 192, 255);  font-size: 100%;  text-decoration: none; }
span.keyword a { color: rgb(112, 192, 255);  font-size: 100%;  text-decoration: underline; }
span.constant   { color: rgb(127, 255, 212);  font-size: 100%;  text-decoration: none; }
span.constant a { color: rgb(127, 255, 212);  font-size: 100%;  text-decoration: underline; }
span.comment   { color: rgb(211, 211, 211);  font-size: 100%;  text-decoration: none; }
span.comment a { color: rgb(211, 211, 211);  font-size: 100%;  text-decoration: underline; }
 --></style>


  </head>

  <body  class="frame">
   <!-- leftmargin="0" rightmargin="0" bottommargin="0"
   topmargin="0"  marginwidth="0" marginheight="0" -->
   <table border="0" cellspacing="5" cellpadding="9" class="frame" width="100%">
    <tr>
     <td class="frame"> 
      <img src="/images/rtfm.png" alt="RTFM" title="RTFM"> 
     </td>
     <td class="frame" width="100%"> 
      <div class="mtitle">rtfm / emacs / htmlfontify / src/htmlfontify.el</div> 
     </td>
    </tr>

    <tr>
     <td class="frame" valign="top"> 
      <img src="/images/etla.png" alt=".etla.org" title=".etla.org"> 
<hr noshade>
<div class="menu">
<a href="../">&lt;&lt;</a> <br>
&nbsp;&nbsp;<a href="htmlfontify.el.html">htmlfontify.el</a><br>
&nbsp;&nbsp;<a href="hfy-cmap.el.html">hfy-cmap.el</a><br>
&nbsp;&nbsp;<a href="index.html">index</a><br>
&nbsp;&nbsp;<a href="LICENSE">LICENSE</a><br>
</div>

     </td>
     <td valign="top" class="body"> 

<pre>
<span class="comment">;; Here's some emacs code to html-pretty-print an emacs buffer, preserving
;; the emacs syntax/whatever highlighting. It also knows how to drive etags
;; (just exuberant-ctags, others later) and hyperlink the code according
;; to its (exuberant-ctags') output.

;;  This program is distributed in the hope that it will be useful,
;;  but WITHOUT ANY WARRANTY; without even the implied warranty of
;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;  GNU General Public License for more details.

;;  You should have received a copy of the GNU General Public License
;;  along with this program; if not, write to the Free Software
;;  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

;; Copyright (C) 2002 Vivek Dasmohapatra &lt;vivek@etla.org&gt;

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.

;; NOTE: Currently the hyperlinking code only knows how to drive GNU find
;; and the exuberant-ctags variant of etags (on platforms where the -R
;; (recursion) switch is implemented). I will probably adapt this code to
;; drive other variants of etags - I am much less likely to support other
;; variants of find, though, unless they support the -path test.

;; A sample of the htmlfontified / hyperlinked output of this module can be
;; found at http://rtfm.etla.org/sql/dbishell/src/ - it's not perfect, but
;; it's a hell of a lot faster and more thorough than I could hope to be
;; doing this by hand.

;; some user / horrified onlooker comments:
;; What? No! There's something deeply wrong here...   (R. Shufflebotham)
;; You're a freak.                                    (D. Silverstone)
;; Aren't we giving you enough to do?                 (J. Busuttil)
;; You're almost as messed up as Lexx is!             (N. Graves-Morris)

;; Changes:
;; 0.01
;; ----
;; first semi-clean version - debian package candidate

;; 0.02
;; ----
;; at proposed deb maintainers req, make it work on emacs20
;; ----
;; removed all references to [:xdigit:] and {N} in regexen, 
;; emacs20 doesn't seem to understand them.
;; ----
;; add fallback colour name -&gt; triplet code for when we aren't
;; running in X. (not useful yet, but if we can force the code
;; to use the X face specs even when on console, this will be handy)
;; ----
;; emacs20 version seems much slower than emacs21 version, not unexpected.

;; 0.03
;; ----
;; If there are multiple definitions of a tag within a file (eg proto and
;; decl, or multiple method impl's), they now all get marked with #tag
;; anchors (we had a last match wins case before)
;; ----
;; If a tag is both an anchor and a link, we now mark it as both -
;; didn't do this before because I was afraid of overlapping
;; start-0 start-1 stop-0 stop-1 effects, but the code seems to cope Ok.
;; ----
;; Ok, we should force fontification, and suppress saving of .flc files
;; (by default, customisable) now.

;; 0.04
;; ----
;; Add ability to fontify as if in a display class other than the one we are
;; connected to. Hopefully this will allow (for example) X-style fontification
;; when running in batch mode or on a tty, or light-background fontification
;; when we have a dark background emacs setup (for publishing to white bg web
;; pages)

;; 0.05
;; ----
;; add ability to split index page out alphabetically + defcustom to control
;; this behaviour. (off by default).
;; ----
;; Force fontification even more in batch
;; mode. (need to dummy up the marker 'font-lock-cache-position so it won't
;; blow up)

;; 0.06
;; ----
;; dummy up a bogus window-system to make cperl mode do a full fontification
;; run thingy (it doesn't call defface when if it thinks there's no x display)
;; ow, my sentences are starting to not be parseable, sleep may be advisable.
;; curse this frail body...

;; 0.07
;; ----
;; Added proper GPL friendly headers to the file(s)

;; 0.08
;; ----
;; were getting &lt;span&gt;&lt;a&gt;foo&lt;/span&gt;&lt;/a&gt; overlaps, should be fixed now...

;; 0.09
;; ----
;; Ok, nsgmls now validates the default output of htmlfontify with no
;; warnings now that a doctype + title have been added, and the stylesheet
;; has been moved into the header section.
;; ----
;; added optimisations customisation entry, plus first entry in same to
;; merge adjacent identical spans separated by nothing but whitespace

;; 0.10
;; ----
;; Fixed bug in harvesting of some face attributes, added code to
;; cope with harvesting attr's for 'default, which is a special case
;; if we have set `</span><span class="constant"><a href="htmlfontify.el.html#hfy-display-class.338">hfy-display-class</a></span><span class="comment">'.
;; ----
;; Added style entry for body element, with style values from the default
;; face. (Was using hardwired values that I like before).

;; 0.11
;; ----
;; Added ability to suppress hyperlinks in blocks highlighted as strings
;; and/or comments, cope when source file is copied verbatim (no
;; highlighting) and target is read-only. Tags beginning with non-alnum
;; characters are now hyperlinked properly (also stops C++ destructors
;; trampling the linking of constructors or _name's links stomping on
;; name's)

;; elisp-dep-block &gt;&gt;
</span>(<span class="keyword">require</span> '<span class="constant">faces</span>)
<span class="comment">;;  (facep face-attr-construct x-color-values color-values face-name)
</span>(<span class="keyword">require</span> '<span class="constant">fast-lock</span>)
<span class="comment">;;  (fast-lock-mode)
</span>(<span class="keyword">require</span> '<span class="constant">custom</span>)
<span class="comment">;;  (defgroup defcustom)
</span>(<span class="keyword">require</span> '<span class="constant">font-lock</span>)
<span class="comment">;;  (font-lock-fontify-region)
;; elisp-dep-block &lt;&lt;

;; emacs 20 compatibility:
</span>(<span class="keyword">eval-and-compile</span>
  (<span class="keyword">if</span> (&lt;= 21 emacs-major-version) nil <span class="comment">;; already post emacs21, NOOP

    ;; Weasels. emacs20 doesn't have built in hashes. Kludge it:
    ;; minimal hash table implementation:
</span>    (<span class="keyword">defun</span> <span class="function-name">hfy-asst</span> (key alist <span class="type">&amp;optional</span> test default)
      (<span class="keyword">let</span> (found (tail alist) value)
	(<span class="keyword">while</span> (and tail (not found))
	  (<span class="keyword">let</span> ((elt (car tail)))
	    (<span class="keyword">when</span> (funcall (or test 'equal) (<span class="keyword">if</span> (consp elt) (car elt) elt) key)
	      (setq found t value (<span class="keyword">if</span> (consp elt) elt default))))
	  (setq tail (cdr tail))) value))

    (<span class="keyword">if</span> (not (fboundp 'make-hash-table))
	(<span class="keyword">defun</span> <span class="function-name">make-hash-table</span> (<span class="type">&amp;rest</span> KEYWORD-ARGS)
	  (cons (or (cadr (memq <span class="builtin">:test</span> KEYWORD-ARGS)) 'eql) (list))) )

    (<span class="keyword">if</span> (not (fboundp 'puthash))
	(<span class="keyword">defun</span> <span class="function-name">puthash</span> (KEY VALUE TABLE)
	  (<span class="keyword">let</span> ((entry         nil)
		(test  (car TABLE))
		(alist (cdr TABLE)))
	    (<span class="keyword">if</span> (setq entry (hfy-asst KEY alist test))
		(setq alist (delq entry alist)))
	    (setcdr TABLE (cons (cons KEY VALUE) alist)))) )

    (<span class="keyword">if</span> (not (fboundp 'clrhash))
	(<span class="keyword">defun</span> <span class="function-name">clrhash</span> (TABLE) (setcdr TABLE nil)) )

    (<span class="keyword">if</span> (not (fboundp 'gethash))
	(<span class="keyword">defun</span> <span class="function-name">gethash</span> (KEY TABLE <span class="type">&amp;optional</span> DFLT)
	  (<span class="keyword">let</span> ((test  (car TABLE))
		(alist (cdr TABLE)))
	    (or (cdr (hfy-asst KEY alist test)) DFLT))) )

    (<span class="keyword">if</span> (not (fboundp 'remhash))
	(<span class="keyword">defun</span> <span class="function-name">remhash</span> (KEY TABLE)
	  (<span class="keyword">let</span> ((entry         nil)
		(test  (car TABLE))
		(alist (cdr TABLE)))
	    (<span class="keyword">if</span> (setq entry (hfy-asst KEY alist test))
		(setcdr TABLE (delq entry alist))))) )

    (<span class="keyword">if</span> (not (fboundp 'maphash))
	(<span class="keyword">defun</span> <span class="function-name">maphash</span> (FUN TABLE)
	  (mapcar (<span class="keyword">lambda</span> (CONS) (funcall FUN (car CONS) (cdr CONS)))
		  (cdr TABLE)) nil) )

    <span class="comment">;; non-x-windows emacs20 duct tape...
    ;; admittedly, we get no significant fontification here anyway
    ;; because emacs20 can't fontify on a tty
</span>    (<span class="keyword">if</span> window-system nil <span class="comment">;; NOOP
</span>      (<span class="keyword">defun</span> <span class="function-name">x-color-defined-p</span> (colour <span class="type">&amp;optional</span> frame)
	(<span class="keyword">let</span> ((window-system nil)) (<span class="keyword">if</span> (<a href="htmlfontify.el.html#hfy-colour-vals.474">hfy-colour-vals</a> colour) t nil))))
    )<span class="comment">;; done with emacs20 compatibility
</span>
  (<span class="keyword">if</span> (not (fboundp 'caddr))      
      (<span class="keyword">defun</span> <span class="function-name">caddr</span> (list)
	<span class="string">&quot;Return the `</span><span class="constant">car</span><span class="string">' of the `</span><span class="constant">cddr</span><span class="string">' of LIST.&quot;</span>
	(car (cddr list))))

  (<span class="keyword">if</span> (not (fboundp 'cadddr))      
      (<span class="keyword">defun</span> <span class="function-name">cadddr</span> (list)
	<span class="string">&quot;Return the `</span><span class="constant">cadr</span><span class="string">' of the `</span><span class="constant">cddr</span><span class="string">' of LIST.&quot;</span>
	(cadr (cddr list))))
  )

<a name="htmlfontify-version.208"></a>(<span class="keyword">defconst</span> <span class="variable-name"><a href="htmlfontify.el.html#htmlfontify-version.208">htmlfontify-version</a></span> 0.11)

<a name="htmlfontify.210"></a>(<span class="keyword">defgroup</span> <span class="type"><a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a></span> nil
  <span class="string">&quot;Copy and convert buffers and files to html, adding hyperlinks between
files \(driven by etags\) if requested.\n\n
See:
  `</span><span class="constant"><a href="htmlfontify.el.html#htmlfontify-buffer.1108">htmlfontify-buffer</a></span><span class="string">'
  `</span><span class="constant"><a href="htmlfontify.el.html#htmlfontify-run-etags.1456">htmlfontify-run-etags</a></span><span class="string">'
  `</span><span class="constant"><a href="htmlfontify.el.html#htmlfontify-copy-and-link-dir.1466">htmlfontify-copy-and-link-dir</a></span><span class="string">'&quot;</span>
  <span class="builtin">:group</span>  'applications
  <span class="builtin">:prefix</span> <span class="string">&quot;hfy-&quot;</span>)

<a name="hfy-page-header.220"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-page-header.220">hfy-page-header</a></span> '<a href="htmlfontify.el.html#hfy-default-header.504">hfy-default-header</a>
  <span class="string">&quot;*Function called with two arguments \(the filename relative to the top
level source directory being etag\'d and fontified), and a string containing
the &lt;style&gt;...&lt;/style&gt; text to embed in the document- the string returned will
be used as the header for the htmlfontified version of the source file.\n
See also: `</span><span class="constant"><a href="htmlfontify.el.html#hfy-page-footer.236">hfy-page-footer</a></span><span class="string">'&quot;</span>
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>  '(function))

<a name="hfy-split-index.229"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-split-index.229">hfy-split-index</a></span> nil
  <span class="string">&quot;*Whether or not to split the index `</span><span class="constant"><a href="htmlfontify.el.html#hfy-index-file.274">hfy-index-file</a></span><span class="string">' alphabetically
on the first letter of each tag. Useful when the index would otherwise
be large and take a long time to render or be difficult to navigate.&quot;</span>
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>  '(boolean))

<a name="hfy-page-footer.236"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-page-footer.236">hfy-page-footer</a></span> '<a href="htmlfontify.el.html#hfy-default-footer.509">hfy-default-footer</a>
  <span class="string">&quot;*As `</span><span class="constant"><a href="htmlfontify.el.html#hfy-page-header.220">hfy-page-header</a></span><span class="string">', but generates the output footer
\(and takes only 1 argument, the filename\).&quot;</span>
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>  '(function))

<a name="hfy-extn.242"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-extn.242">hfy-extn</a></span>        <span class="string">&quot;.html&quot;
  &quot;*File extension used for output files&quot;</span>
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>  '(string))

<a name="hfy-src-doc-link-style.247"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-src-doc-link-style.247">hfy-src-doc-link-style</a></span> <span class="string">&quot;text-decoration: underline;&quot;
  &quot;*String to add to the \'&lt;style&gt; a\' variant of an <a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a> css class.&quot;</span>
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>  '(string))

<a name="hfy-src-doc-link-unstyle.252"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-src-doc-link-unstyle.252">hfy-src-doc-link-unstyle</a></span> <span class="string">&quot; text-decoration: none;&quot;
  &quot;*Regex to remove from the &lt;style&gt; a variant of an <a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a> css class.&quot;</span>
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>  '(string))

<a name="hfy-link-extn.257"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-link-extn.257">hfy-link-extn</a></span> nil
  <span class="string">&quot;*File extension used for href links - Useful where the <a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
output files are going to be processed again, with a rersulting change
in file extension. If `</span><span class="constant">nil</span><span class="string">', then any code using this should fall back
to `</span><span class="constant"><a href="htmlfontify.el.html#hfy-extn.242">hfy-extn</a></span><span class="string">'.&quot;</span>
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>  '(string))

<a name="hfy-link-style-fun.265"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-link-style-fun.265">hfy-link-style-fun</a></span> '<a href="htmlfontify.el.html#hfy-link-style-string.513">hfy-link-style-string</a>
  <span class="string">&quot;*Set this to a function, which will be called with one argument
\(a \&quot;{ foo: bar; ...}\&quot; css style-string\) - it should return a copy of
its argument, altered so as to make any changes you want made for text which
is a hyperlink, in addition to being in the class to which that style would
normally be applied.&quot;</span>
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>  '(function))

<a name="hfy-index-file.274"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-index-file.274">hfy-index-file</a></span>  <span class="string">&quot;hfy-index&quot;
  &quot;*Name \(sans extension\) of the index file produced during
fontification-and-hyperlinking.&quot;</span>
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>  '(string))

<a name="hfy-html-quote-regex.280"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-html-quote-regex.280">hfy-html-quote-regex</a></span> <span class="string">&quot;\\(&lt;\\|\&quot;\\|&amp;\\|&gt;\\)&quot;
  &quot;*Regex to match \(with a single back-reference per match\) strings in HTML
which should be quoted with `</span><span class="constant"><a href="htmlfontify.el.html#hfy-html-quote.959">hfy-html-quote</a></span><span class="string">' \(and `</span><span class="constant"><a href="htmlfontify.el.html#hfy-html-quote-map.317">hfy-html-quote-map</a></span><span class="string">'\)
to make them safe.&quot;</span>
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>  '(regexp))

<a name="hfy-init-kludge-hooks.287"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-init-kludge-hooks.287">hfy-init-kludge-hooks</a></span> '(<a href="htmlfontify.el.html#hfy-kludge-cperl-mode.492">hfy-kludge-cperl-mode</a>)
  <span class="string">&quot;*List of functions to call when starting <a href="htmlfontify.el.html#htmlfontify-buffer.1108">htmlfontify-buffer</a> to do any
kludging necessary to get highlighting modes to bahave as you want, even
when not running under a window system.&quot;</span>
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>  '(hook))

<a name="hfy-default-face-def.294"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-default-face-def.294">hfy-default-face-def</a></span> nil
  <span class="string">&quot;*Fallback `</span><span class="constant">defface</span><span class="string">' specification for the face \'default, used when
`</span><span class="constant"><a href="htmlfontify.el.html#hfy-display-class.338">hfy-display-class</a></span><span class="string">' has been set \(the normal <a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a> way of extracting
potentially non-current face information doesn\'t necessarily work for
\'default\).\n
Example: I customise this to:\n
\(\(t :background \&quot;black\&quot; :foreground \&quot;white\&quot; :family \&quot;misc-fixed\&quot;\)\)&quot;</span>
  <span class="builtin">:group</span>   '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>    '(alist))

<a name="etags-tag-regex.304"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#etags-tag-regex.304">etags-tag-regex</a></span> (concat <span class="string">&quot;.*&quot; 
				   &quot;\x7f&quot; &quot;\\(.+\\)&quot;
				   &quot;\x01&quot; &quot;\\([0-9]+\\)&quot;
				   &quot;,&quot;    &quot;\\([0-9]+\\)$&quot;</span>)
  <span class="string">&quot;*Regex used to parse an etags entry: must have 3 subexps, corresponding,
in order, to:

   1 - The tag
   2 - The line
   3 - The char \(point\) at which the tag occurs.&quot;</span>
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>  '(regexp))

<a name="hfy-html-quote-map.317"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-html-quote-map.317">hfy-html-quote-map</a></span> '((<span class="string">&quot;\&quot;&quot; &quot;&amp;quot;&quot;</span>)
				(<span class="string">&quot;&lt;&quot;  &quot;&amp;lt;&quot;</span>  )
				(<span class="string">&quot;&amp;&quot;  &quot;&amp;amp;&quot;</span> )
				(<span class="string">&quot;&gt;&quot;  &quot;&amp;gt;&quot;</span>  ))
  <span class="string">&quot;*Alist of char -&gt; entity mappings used to make the text html-safe.&quot;</span>
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>  '(alist <span class="builtin">:key-type</span> (string)))

<a name="hfy-etags-cmd.325"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-etags-cmd.325">hfy-etags-cmd</a></span>   <span class="string">&quot;etags -R -f -&quot;
  &quot;*etags equivalent command to run in a source directory to generate a tags
file for the whole source tree from there on down. The command should emit
the etags output on stdout.&quot;</span>
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>  '(string))

<a name="hfy-find-cmd.332"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-find-cmd.332">hfy-find-cmd</a></span>
  <span class="string">&quot;find . -type f \\! -name \\*~ \\! -name \\*.flc \\! -path \\*/CVS/\\*&quot;
  &quot;*find command used to harvest a list of files to attempt to fontify.&quot;</span>
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:type</span>  '(string))

<a name="hfy-display-class.338"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-display-class.338">hfy-display-class</a></span> nil
  <span class="string">&quot;*Display class to use to determine which display class to use when
calculating a face\'s attributes. This is useful when, for example, you
are running emacs on a tty or in batch mode, and want <a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a> to have
access to the face spec you would use if you were connected to an X display.\n
Some valid class specification elements are:\n
  \'\(class      color\)
  \'\(class      grayscale\)
  \'\(background dark\)
  \'\(background light\)
  \'\(type       x-toolkit\)
  \'\(type       tty\)
  \'\(type       motif\)
  \'\(type       lucid\)
Multiple values for a tag may be combined, to indicate that any one or more
of these values in the specification key constitutes a match, eg:\n
\'\(\(class color grayscale\) \(type tty\)\) would match any of:\n
  \'\(\(class color\)\)
  \'\(\(class grayscale\)\)
  \'\(\(class color grayscale\)\)\)
  \'\(\(class color foo\)\)
  \'\(\(type  tty\)\)
  \'\(\(type  tty\) \(class color\)\)\n
and so on.&quot;</span>
  <span class="builtin">:type</span>    '(alist <span class="builtin">:key-type</span> (symbol) <span class="builtin">:value-type</span> (symbol))
  <span class="builtin">:group</span>   '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>
  <span class="builtin">:options</span> '((type       (choice (const <span class="builtin">:tag</span> <span class="string">&quot;X11&quot;</span>           x-toolkit)
				 (const <span class="builtin">:tag</span> <span class="string">&quot;Terminal&quot;</span>      tty      )
				 (const <span class="builtin">:tag</span> <span class="string">&quot;Lucid Toolkit&quot;</span> lucid    )
				 (const <span class="builtin">:tag</span> <span class="string">&quot;Motif Toolkit&quot;</span> motif    )))
	     
	     (class      (choice (const <span class="builtin">:tag</span> <span class="string">&quot;Colour&quot;</span>        color    )
				 (const <span class="builtin">:tag</span> <span class="string">&quot;Greyscale&quot;</span>     grayscale)))
	     
	     (background (choice (const <span class="builtin">:tag</span> <span class="string">&quot;Dark&quot;</span>          dark )
				 (const <span class="builtin">:tag</span> <span class="string">&quot;Bright&quot;</span>        light)))    ))

<a name="hfy-optimisations.375"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-optimisations.375">hfy-optimisations</a></span> (list)
  <span class="string">&quot;*Optimisations to turn on: So far, the following have been implemented:\n
  merge-adjacent-tags: If two (or more) span tags are adjacent, identical and
                       separated by nothing more than whitespace, they will
                       be merged into one span.
  zap-comment-links  : Suppress hyperlinking of tags found in comments.
  zap-string-links   : Suppress hyperlinking of tags found in strings.\n
  And the following are planned but not yet available:\n
  kill-context-leak  : Suppress hyperlinking between files highlighted by
                       different modes.\n
Note: like compiler optimisations, these optimise the _output_ of the code,
not the processing of the source itself, and are therefore likely to slow
<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a> down, at least a little.&quot;</span>
  <span class="builtin">:type</span>  '(set (const <span class="builtin">:tag</span> <span class="string">&quot;merge-adjacent-tags&quot;</span> merge-adjacent-tags)
	       (const <span class="builtin">:tag</span> <span class="string">&quot;zap-comment-links&quot;</span>   zap-comment-links  )
	       (const <span class="builtin">:tag</span> <span class="string">&quot;zap-string-links&quot;</span>    zap-string-links   )
	       (const <span class="builtin">:tag</span> <span class="string">&quot;kill-context-leak&quot;</span>   kill-context-leak  )
	       )
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>)

<a name="hfy-fast-lock-save.395"></a>(<span class="keyword">defcustom</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-fast-lock-save.395">hfy-fast-lock-save</a></span> nil
  <span class="string">&quot;*Minimum size of a buffer for cached fontification.
This value is temporarily assigned to `</span><span class="constant">fast-lock-minimum-size</span><span class="string">' during
html-fontification.\n
Only buffers more than this can have associated Font Lock cache files saved.\n
If nil, means cache files are never created.\n
If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE),
where MAJOR-MODE is a symbol or t (meaning the default).  For example:\n
 ((c-mode     . 25600  )\n  (c++-mode   . 25600  )\n  (rmail-mode . 1048576))\n
means that the minimum size is 25K for buffers in C or C++ modes, one megabyte
for buffers in Rmail mode, and size is irrelevant \(ie no saves\) otherwise.\n&quot;</span>
  <span class="builtin">:type</span> '(choice
	  (const   <span class="builtin">:tag</span> <span class="string">&quot;none&quot;</span> nil)
	  (integer <span class="builtin">:tag</span> <span class="string">&quot;size&quot;</span>)
	  (repeat  <span class="builtin">:menu-tag</span> <span class="string">&quot;mode specific&quot;</span>
		   <span class="builtin">:tag</span>      <span class="string">&quot;mode specific&quot;</span>
		   <span class="builtin">:value</span> ((t . nil))
		   (cons <span class="builtin">:tag</span> <span class="string">&quot;Instance&quot;</span>
			 (radio <span class="builtin">:tag</span> <span class="string">&quot;Mode&quot;</span>
				(const  <span class="builtin">:tag</span> <span class="string">&quot;all&quot;</span> t)
				(symbol <span class="builtin">:tag</span> <span class="string">&quot;name&quot;</span>))
			 (radio <span class="builtin">:tag</span> <span class="string">&quot;Size&quot;</span>
				(const   <span class="builtin">:tag</span> <span class="string">&quot;none&quot;</span> nil)
				(integer <span class="builtin">:tag</span> <span class="string">&quot;size&quot;</span>)))))
  <span class="builtin">:group</span> '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>)


<a name="hfy-tags-cache.422"></a>(<span class="keyword">defvar</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-tags-cache.422">hfy-tags-cache</a></span>  nil
  <span class="string">&quot;Alist of the form\n
\(\(\&quot;/src/dir/0\&quot; . tag-hash0\) \(\&quot;/src/dir/1\&quot; tag-hash1\) ...\)\n
Each  tag hash entry then contains entries of the form:\n
\&quot;tag_string\&quot; =&gt; ((\&quot;file/name.ext\&quot; line char) ... )\n
ie an alist mapping \(relative\) file paths to line and character offsets.\n
See `</span><span class="constant"><a href="htmlfontify.el.html#hfy-load-tags-cache.1342">hfy-load-tags-cache</a></span><span class="string">'.&quot;</span>)

<a name="hfy-tags-sortl.430"></a>(<span class="keyword">defvar</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-tags-sortl.430">hfy-tags-sortl</a></span>  nil
  <span class="string">&quot;Alist of the form \(\(\&quot;/src/dir\&quot; . (tag0 tag1 tag2)\) ... \)\n
Where the tags are stored in descending order of length.\n
See `</span><span class="constant"><a href="htmlfontify.el.html#hfy-load-tags-cache.1342">hfy-load-tags-cache</a></span><span class="string">'.&quot;</span>)

<a name="hfy-style-assoc.435"></a>(<span class="keyword">defvar</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-style-assoc.435">hfy-style-assoc</a></span> 'please-ignore-this-line
  <span class="string">&quot;An assoc representing/describing an emacs face. Properties may be repeated,
In which case later properties should be treated as if they were inherited
from a \'parent\' font. \(For some properties, only the first encountered value
is of any importance, for others the values might be cumulative, and for
others they might be cumulative in a complex way).\n
Some examples:\n
\(<a href="htmlfontify.el.html#hfy-face-to-style.745">hfy-face-to-style</a> 'default\) =&gt;
  \(\(\&quot;background\&quot;      . \&quot;rgb\(0, 0, 0\)\&quot;\)
   \(\&quot;color\&quot;           . \&quot;rgb\(255, 255, 255\)\&quot;\)
   \(\&quot;font-style\&quot;      . \&quot;normal\&quot;\)
   \(\&quot;font-weight\&quot;     . \&quot;500\&quot;\)
   \(\&quot;font-stretch\&quot;    . \&quot;normal\&quot;\)
   \(\&quot;font-family\&quot;     . \&quot;misc-fixed\&quot;\)
   \(\&quot;font-size\&quot;       . \&quot;13pt\&quot;\)
   \(\&quot;text-decoration\&quot; . \&quot;none\&quot;\)\)\n
\(<a href="htmlfontify.el.html#hfy-face-to-style.745">hfy-face-to-style</a> 'Info-title-3-face\) =&gt;
  \(\(\&quot;font-weight\&quot;     . \&quot;700\&quot;\)
   \(\&quot;font-family\&quot;     . \&quot;helv\&quot;\)
   \(\&quot;font-size\&quot;       . \&quot;120%\&quot;\)
   \(\&quot;text-decoration\&quot; . \&quot;none\&quot;\)\)\n&quot;</span>)

<a name="hfy-hex-regex.457"></a>(<span class="keyword">defconst</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-hex-regex.457">hfy-hex-regex</a></span> <span class="string">&quot;[0-9A-Fa-f]&quot;</span>)

<a name="hfy-triplet-regex.459"></a>(<span class="keyword">defconst</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-triplet-regex.459">hfy-triplet-regex</a></span>
  (concat 
   <span class="string">&quot;\\(&quot;</span> <a href="htmlfontify.el.html#hfy-hex-regex.457">hfy-hex-regex</a> <a href="htmlfontify.el.html#hfy-hex-regex.457">hfy-hex-regex</a> <span class="string">&quot;\\)&quot;
   &quot;\\(&quot;</span> <a href="htmlfontify.el.html#hfy-hex-regex.457">hfy-hex-regex</a> <a href="htmlfontify.el.html#hfy-hex-regex.457">hfy-hex-regex</a> <span class="string">&quot;\\)&quot;
   &quot;\\(&quot;</span> <a href="htmlfontify.el.html#hfy-hex-regex.457">hfy-hex-regex</a> <a href="htmlfontify.el.html#hfy-hex-regex.457">hfy-hex-regex</a> <span class="string">&quot;\\)&quot;</span>))

<a name="hfy-interq.465"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-interq.465">hfy-interq</a></span> (set-a set-b)
  <span class="string">&quot;Return the intersection \(using `</span><span class="constant">eq</span><span class="string">'\) of 2 lists.&quot;</span>
  (<span class="keyword">let</span> ((sa set-a) (interq nil))
    (<span class="keyword">while</span> sa
      (setq elt (car sa)
	    sa  (cdr sa))
      (<span class="keyword">if</span> (memq elt set-b) (setq interq (cons elt interq)))) interq))


<a name="hfy-colour-vals.474"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-colour-vals.474">hfy-colour-vals</a></span> (colour)
  <span class="comment">;;(message &quot;hfy-colour-vals&quot;);;DBUG
</span>  (<span class="keyword">if</span> (string-match <a href="htmlfontify.el.html#hfy-triplet-regex.459">hfy-triplet-regex</a> colour)
      (mapcar
       (<span class="keyword">lambda</span> (x)
	 (* (string-to-int (match-string x colour) 16) 257)) '(1 2 3))
    <span class="comment">;;(message &quot;&gt;&gt; %s&quot; colour)
</span>    (<span class="keyword">if</span> window-system
	(<span class="keyword">if</span> (fboundp 'color-values)
	    (color-values colour)
	  <span class="comment">;;(message &quot;[%S]&quot; window-system)
</span>	  (x-color-values colour))
      <span class="comment">;; blarg - tty colours are no good - go fetch some X colours:
</span>      (<span class="keyword">require</span> '<span class="constant">hfy-cmap</span>)
      (<a href="hfy-cmap.el.html#hfy-fallback-colour-values.771">hfy-fallback-colour-values</a> colour))))

<a name="hfy-cperl-mode-kludged-p.490"></a>(<span class="keyword">defvar</span> <span class="variable-name"><a href="htmlfontify.el.html#hfy-cperl-mode-kludged-p.490">hfy-cperl-mode-kludged-p</a></span> nil)

<a name="hfy-kludge-cperl-mode.492"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-kludge-cperl-mode.492">hfy-kludge-cperl-mode</a></span> ()
  <span class="string">&quot;cperl mode does its damndest not to do some of its fontification when not
in a windowing system - try to trick it...&quot;</span>
  (<span class="keyword">if</span> (not <a href="htmlfontify.el.html#hfy-cperl-mode-kludged-p.490">hfy-cperl-mode-kludged-p</a>)
      (<span class="keyword">progn</span> (<span class="keyword">if</span> (not window-system)
		 (<span class="keyword">let</span> ((window-system '<a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a>))
		   (load-library <span class="string">&quot;cperl-mode&quot;</span>)
		   (setq cperl-syntaxify-by-font-lock t)))
	     (setq <a href="htmlfontify.el.html#hfy-cperl-mode-kludged-p.490">hfy-cperl-mode-kludged-p</a> t))) )

<a name="hfy-opt.502"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-opt.502">hfy-opt</a></span> (symbol) (memq symbol <a href="htmlfontify.el.html#hfy-optimisations.375">hfy-optimisations</a>))

<a name="hfy-default-header.504"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-default-header.504">hfy-default-header</a></span> (file style)
  <span class="string">&quot;Default value for `</span><span class="constant"><a href="htmlfontify.el.html#hfy-page-header.220">hfy-page-header</a></span><span class="string">'&quot;</span>
  (format <span class="string">&quot;&lt;!DOCTYPE HTML PUBLIC \&quot;-//W3C//DTD HTML 4.01 Transitional//EN\&quot;&gt;
&lt;html&gt;\n &lt;head&gt;\n  &lt;title&gt;%s&lt;/title&gt;\n %s\n &lt;/head&gt;\n  &lt;body&gt;\n&quot;</span> file style))

<a name="hfy-default-footer.509"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-default-footer.509">hfy-default-footer</a></span> (file)
  <span class="string">&quot;Default value for `</span><span class="constant"><a href="htmlfontify.el.html#hfy-page-footer.236">hfy-page-footer</a></span><span class="string">'&quot;
  &quot;\n &lt;/body&gt;\n&lt;/html&gt;\n&quot;</span>)

<a name="hfy-link-style-string.513"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-link-style-string.513">hfy-link-style-string</a></span> (style-string)
  <span class="string">&quot;Replace the end of a css style declaration STYLE-STRING with the contents
of the variable `</span><span class="constant"><a href="htmlfontify.el.html#hfy-src-doc-link-style.247">hfy-src-doc-link-style</a></span><span class="string">', removing text matching the regex
`</span><span class="constant"><a href="htmlfontify.el.html#hfy-src-doc-link-unstyle.252">hfy-src-doc-link-unstyle</a></span><span class="string">' first, if necessary.&quot;</span>
  <span class="comment">;;(message &quot;hfy-colour-vals&quot;);;DBUG
</span>  (<span class="keyword">if</span> (string-match <a href="htmlfontify.el.html#hfy-src-doc-link-unstyle.252">hfy-src-doc-link-unstyle</a> style-string)
      (setq style-string (replace-match <span class="string">&quot;&quot;</span> 'fixed-case 'literal style-string)))
  (<span class="keyword">if</span> (and (not (string-match <a href="htmlfontify.el.html#hfy-src-doc-link-style.247">hfy-src-doc-link-style</a> style-string))
           (string-match <span class="string">&quot;} *$&quot;</span> style-string))
      (concat (replace-match <a href="htmlfontify.el.html#hfy-src-doc-link-style.247">hfy-src-doc-link-style</a>
			     'fixed-case
			     'literal
			     style-string) <span class="string">&quot; }&quot;</span>) style-string))

<span class="comment">;; utility functions - cast emacs style specification values into their
;; css2 equivalents:
</span><a name="hfy-triplet.529"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-triplet.529">hfy-triplet</a></span> (colour)
  <span class="string">&quot;Takes a colour name (string) and return a css rgb(R, G, B) triplet string.
Uses the definition of \&quot;white\&quot; to map the numbers to the 0-255 range, so
if you\'ve redefined white, (esp if you've redefined it to have a triplet
member lower than that of the colour you are processing, strange things
may happen)&quot;</span>
  <span class="comment">;;(message &quot;hfy-colour-vals&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((white (mapcar (<span class="keyword">lambda</span> (I) (float (1+ I))) (<a href="htmlfontify.el.html#hfy-colour-vals.474">hfy-colour-vals</a> <span class="string">&quot;white&quot;</span>)))
	(rgb16 (mapcar (<span class="keyword">lambda</span> (I) (float (1+ I))) (<a href="htmlfontify.el.html#hfy-colour-vals.474">hfy-colour-vals</a>  colour))))
    (<span class="keyword">if</span> rgb16
	(apply 'format <span class="string">&quot;rgb(%d, %d, %d)&quot;</span>
	       (mapcar (<span class="keyword">lambda</span> (X)
			 (* (/ (nth X rgb16)
			       (nth X white)) 255)) '(0 1 2))))) )

<a name="hfy-family.544"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-family.544">hfy-family</a></span> (family) (list (cons <span class="string">&quot;font-family&quot;</span>  family)))
<a name="hfy-bgcol.545"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-bgcol.545">hfy-bgcol</a></span>  (colour) (list (cons <span class="string">&quot;background&quot;</span>   (<a href="htmlfontify.el.html#hfy-triplet.529">hfy-triplet</a> colour))))
<a name="hfy-colour.546"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-colour.546">hfy-colour</a></span> (colour) (list (cons <span class="string">&quot;color&quot;</span>        (<a href="htmlfontify.el.html#hfy-triplet.529">hfy-triplet</a> colour))))
<a name="hfy-width.547"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-width.547">hfy-width</a></span>  (width)  (list (cons <span class="string">&quot;font-stretch&quot;</span> (symbol-name  width))))

<a name="hfy-size.549"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-size.549">hfy-size</a></span>   (height)
  <span class="string">&quot;Derive a css font-size specifier from an emacs font :height attribute.
Does not cope with the case where height is a function to be applied to
the height of the underlying font&quot;</span>
  (list 
   (<span class="keyword">cond</span>
    ((floatp   height) (cons <span class="string">&quot;font-size&quot;</span> (format <span class="string">&quot;%d%%&quot;</span> (* height 100))))
    ((integerp height) (cons <span class="string">&quot;font-size&quot;</span> (format <span class="string">&quot;%dpt&quot;</span> (/ height 10 )))) )) )

<a name="hfy-slant.558"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-slant.558">hfy-slant</a></span>  (slant)
  <span class="string">&quot;Derive a font-style css specifier from the emacs :slant attribute -
CSS does not define the reverse-* styles, so just maps those to the
regular specifiers.&quot;</span>
  (list (cons <span class="string">&quot;font-style&quot;</span> (<span class="keyword">cond</span> ((eq 'italic          slant) <span class="string">&quot;italic&quot;</span> )
				 ((eq 'reverse-italic  slant) <span class="string">&quot;italic&quot;</span> )
				 ((eq 'oblique         slant) <span class="string">&quot;oblique&quot;</span>)
				 ((eq 'reverse-oblique slant) <span class="string">&quot;oblique&quot;</span>)
				 (t                           <span class="string">&quot;normal&quot;</span> )))) )

<a name="hfy-weight.568"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-weight.568">hfy-weight</a></span> (weight)
  <span class="string">&quot;Derive a font-weight css specifier from an emacs weight spec symbol.&quot;</span>
  (list (cons <span class="string">&quot;font-weight&quot;</span> (<span class="keyword">cond</span> ((eq 'ultra-bold  weight) <span class="string">&quot;900&quot;</span>)
				  ((eq 'extra-bold  weight) <span class="string">&quot;800&quot;</span>)
				  ((eq 'bold        weight) <span class="string">&quot;700&quot;</span>)
				  ((eq 'semi-bold   weight) <span class="string">&quot;600&quot;</span>)
				  ((eq 'normal      weight) <span class="string">&quot;500&quot;</span>)
				  ((eq 'semi-light  weight) <span class="string">&quot;400&quot;</span>)
				  ((eq 'light       weight) <span class="string">&quot;300&quot;</span>)
				  ((eq 'extra-light weight) <span class="string">&quot;200&quot;</span>)
				  ((eq 'ultra-light weight) <span class="string">&quot;100&quot;</span>)))) )

<a name="hfy-box-to-border-assoc.580"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-box-to-border-assoc.580">hfy-box-to-border-assoc</a></span> (spec)
  (<span class="keyword">if</span> spec
      (<span class="keyword">let</span> ((tag (car  spec))
	    (val (cadr spec)))
	(cons (<span class="keyword">cond</span> ((eq tag <span class="builtin">:color</span>) (cons <span class="string">&quot;colour&quot;</span> val))
		    ((eq tag <span class="builtin">:width</span>) (cons <span class="string">&quot;width&quot;</span>  val))
		    ((eq tag <span class="builtin">:style</span>) (cons <span class="string">&quot;style&quot;</span>  val)))
	      (<a href="htmlfontify.el.html#hfy-box-to-border-assoc.580">hfy-box-to-border-assoc</a> (cddr spec))))) )

<a name="hfy-box-to-style.589"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-box-to-style.589">hfy-box-to-style</a></span> (spec)
  (<span class="keyword">let*</span> ((css (<a href="htmlfontify.el.html#hfy-box-to-border-assoc.580">hfy-box-to-border-assoc</a>  spec))
	 (col (cdr      (assoc <span class="string">&quot;colour&quot;</span> css)))
	 (s   (cdr      (assoc <span class="string">&quot;style&quot;</span>  css))))
    (list
     (<span class="keyword">if</span> col (cons <span class="string">&quot;border-color&quot;</span> (cdr (assoc <span class="string">&quot;colour&quot;</span> css))))
     (cons <span class="string">&quot;border-width&quot;</span> (format <span class="string">&quot;%dpx&quot;</span> (or (cdr (assoc <span class="string">&quot;width&quot;</span> css)) 1)))
     (cons <span class="string">&quot;border-style&quot;</span> (<span class="keyword">cond</span> ((eq s 'released-button) <span class="string">&quot;outset&quot;</span>)
				((eq s 'pressed-button ) <span class="string">&quot;inset&quot;</span> )
				(t                       <span class="string">&quot;solid&quot;</span> ))))) )

<a name="hfy-box.600"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-box.600">hfy-box</a></span> (box)
  <span class="string">&quot;Derive CSS border-* attributes from the emacs :box attribute.&quot;</span>
  (<span class="keyword">if</span> box
      (<span class="keyword">cond</span>
       ((integerp box) (list (cons <span class="string">&quot;border-width&quot;</span> (format <span class="string">&quot;%dpx&quot;</span>   box))))
       ((stringp  box) (list (cons <span class="string">&quot;border&quot;</span> (format <span class="string">&quot;solid %s 1px&quot;</span> box))))
       ((listp    box) (<a href="htmlfontify.el.html#hfy-box-to-style.589">hfy-box-to-style</a> box)                            ))) )

<a name="hfy-decor.608"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-decor.608">hfy-decor</a></span> (tag val)
  <span class="string">&quot;Derive CSS text-decoration specifiers from various emacs font attributes.&quot;</span>
  (list
   (<span class="keyword">cond</span> ((eq tag <span class="builtin">:underline</span>     ) (cons <span class="string">&quot;text-decoration&quot; &quot;underline&quot;</span>   ))
	 ((eq tag <span class="builtin">:overline</span>      ) (cons <span class="string">&quot;text-decoration&quot; &quot;overline&quot;</span>    ))
	 ((eq tag <span class="builtin">:strike-through</span>) (cons <span class="string">&quot;text-decoration&quot; &quot;line-through&quot;</span>)))))

<a name="hfy-combined-face-spec.615"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-combined-face-spec.615">hfy-combined-face-spec</a></span> (face)
  <span class="string">&quot;Return a `</span><span class="constant">defface</span><span class="string">' style alist of possible specifications for FACE,
with any entries resulting from user customisation \(`</span><span class="constant">custom-set-faces</span><span class="string">'\)
taking precedence.&quot;</span>
  (<span class="keyword">let</span> ((spec  nil))
    (setq spec (append (or (get face 'saved-face)        (list))
		       (or (get face 'face-defface-spec) (list))))
    (<span class="keyword">if</span> (and <a href="htmlfontify.el.html#hfy-display-class.338">hfy-display-class</a> <a href="htmlfontify.el.html#hfy-default-face-def.294">hfy-default-face-def</a> (eq face 'default))
	(setq spec (append <a href="htmlfontify.el.html#hfy-default-face-def.294">hfy-default-face-def</a> spec))) spec))
  
<a name="hfy-face-attr-for-class.625"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-face-attr-for-class.625">hfy-face-attr-for-class</a></span> (face <span class="type">&amp;optional</span> class)
  <span class="string">&quot;Return the face attributes for FACE. If CLASS is set, it must be a `</span><span class="constant">defface</span><span class="string">'
alist key \[see below\], in which case the first face specification returned
by `</span><span class="constant"><a href="htmlfontify.el.html#hfy-combined-face-spec.615">hfy-combined-face-spec</a></span><span class="string">' which *doesn\'t* clash with CLASS is returned.
\(A specification with a class of `t' is considered to match any class you
specify - this matches emacs\' behaviour when deciding on which face attributes
to use, to the best of my understanding\).\n
If CLASS is nil, then you just get get whatever `</span><span class="constant">face-attr-construct</span><span class="string">' returns,
ie the current specification in effect for FACE.\n
See `</span><span class="constant"><a href="htmlfontify.el.html#hfy-display-class.338">hfy-display-class</a></span><span class="string">' for details of valid values for CLASS.&quot;</span>
  (<span class="keyword">if</span> class 
      (<span class="keyword">let</span> ((face-props (<a href="htmlfontify.el.html#hfy-combined-face-spec.615">hfy-combined-face-spec</a> face))
	    (face-specn nil)
	    (face-class nil)
	    (face-attrs nil)
	    (face-match nil))                   <span class="comment">;; itern 0: not matched yet
</span>	(<span class="keyword">while</span> (and face-props (not face-match))<span class="comment">;; stop if matched on last iter
</span>	  (setq face-match t                    <span class="comment">;; assume will match this iter
</span>		face-specn (car face-props)
		face-class (car face-specn)
		face-attrs (cdr face-specn)
		face-props (cdr face-props))
	  <span class="comment">;;(message &quot;%s @ %S =~ %S&quot; face face-class class)
	  ;; if the current element CEL of CLASS is t we match
	  ;; if the current face-class is t, we match
	  ;; if the cdr of CEL has a non-nil
	  ;;   intersection with the cdr of the first member of
	  ;;   the current face-class with the same car as CEL, we match
	  ;; if none of these conditions is true, set the match flag back to
	  ;; nil, so the loop will continue on to the naxt face-specn:
</span>	  (setq cbuf class)
	  (<span class="keyword">let</span> ((cbuf class)
		(cel    nil))
	    (<span class="keyword">while</span> (and face-match cbuf)
	      (setq cel  (car cbuf)
		    cbuf (cdr cbuf)
		    key  (car  cel)
		    val  (cdr  cel))
	      (<span class="keyword">if</span> (not (or (memq t (list cel face-class))
			   (<a href="htmlfontify.el.html#hfy-interq.465">hfy-interq</a> (<span class="keyword">if</span> (listp val) val (list val))
				       (cdr     (assq key face-class)))))
		  (setq face-match nil))))) <span class="comment">;; nope, didn't match this iter
	;; matched ? last attrs : nil
</span>	(<span class="keyword">if</span> face-match  
	    (<span class="keyword">if</span> (listp (car face-attrs)) (car face-attrs) face-attrs) nil))
    (face-attr-construct face)) )

<span class="comment">;; construct an assoc of (css-tag-name . css-tag-value) pairs
;; from a face or assoc of face attributes:
</span><a name="hfy-face-to-style-i.674"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-face-to-style-i.674">hfy-face-to-style-i</a></span> (fn)
  <span class="string">&quot;The guts of `</span><span class="constant"><a href="htmlfontify.el.html#hfy-face-to-style.745">hfy-face-to-style</a></span><span class="string">': FN should be a `</span><span class="constant">defface</span><span class="string">'
font specification, as returned by `</span><span class="constant">face-attr-construct</span><span class="string">'. Note that
this function does not get font-sizes right if they are based on
inherited modifiers (via the :inherit) attribute, and any other modifiers
that are cumulative if they appear multiple times need to be merged by the
user - `</span><span class="constant"><a href="htmlfontify.el.html#hfy-flatten-style.725">hfy-flatten-style</a></span><span class="string">' should do this.&quot;</span>
  <span class="comment">;;(message &quot;hfy-face-to-style-i&quot;);;DBUG
</span>  (<span class="keyword">if</span> fn
      (<span class="keyword">let</span> ((key  (car  fn))
	    (val  (cadr fn))
	    (next (cddr fn))
	    (that       nil)
	    (this       nil)
	    (parent     nil))
	(setq this
	      (<span class="keyword">if</span> val (<span class="keyword">cond</span>
		       ((eq key <span class="builtin">:family</span>        ) (<a href="htmlfontify.el.html#hfy-family.544">hfy-family</a>    val))
		       ((eq key <span class="builtin">:width</span>         ) (<a href="htmlfontify.el.html#hfy-width.547">hfy-width</a>     val))
		       ((eq key <span class="builtin">:weight</span>        ) (<a href="htmlfontify.el.html#hfy-weight.568">hfy-weight</a>    val))
		       ((eq key <span class="builtin">:slant</span>         ) (<a href="htmlfontify.el.html#hfy-slant.558">hfy-slant</a>     val))
		       ((eq key <span class="builtin">:foreground</span>    ) (<a href="htmlfontify.el.html#hfy-colour.546">hfy-colour</a>    val))
		       ((eq key <span class="builtin">:background</span>    ) (<a href="htmlfontify.el.html#hfy-bgcol.545">hfy-bgcol</a>     val))
		       ((eq key <span class="builtin">:box</span>           ) (<a href="htmlfontify.el.html#hfy-box.600">hfy-box</a>       val))
		       ((eq key <span class="builtin">:height</span>        ) (<a href="htmlfontify.el.html#hfy-size.549">hfy-size</a>      val))
		       ((eq key <span class="builtin">:underline</span>     ) (<a href="htmlfontify.el.html#hfy-decor.608">hfy-decor</a> key val))
		       ((eq key <span class="builtin">:overline</span>      ) (<a href="htmlfontify.el.html#hfy-decor.608">hfy-decor</a> key val))
		       ((eq key <span class="builtin">:strike-through</span>) (<a href="htmlfontify.el.html#hfy-decor.608">hfy-decor</a> key val))
		       ((eq key <span class="builtin">:bold</span>          ) (<a href="htmlfontify.el.html#hfy-weight.568">hfy-weight</a>  'bold))
		       ((eq key <span class="builtin">:italic</span>        ) (<a href="htmlfontify.el.html#hfy-slant.558">hfy-slant</a> 'italic)))))
	(setq that (<a href="htmlfontify.el.html#hfy-face-to-style-i.674">hfy-face-to-style-i</a> next))
	(<span class="keyword">if</span> (eq key <span class="builtin">:inherit</span>)
	    (setq parent (<a href="htmlfontify.el.html#hfy-face-to-style-i.674">hfy-face-to-style-i</a>
			  (<a href="htmlfontify.el.html#hfy-face-attr-for-class.625">hfy-face-attr-for-class</a> val <a href="htmlfontify.el.html#hfy-display-class.338">hfy-display-class</a>))))
	(nconc this that parent))) )

<a name="hfy-size-to-int.710"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-size-to-int.710">hfy-size-to-int</a></span> (spec)
  <span class="string">&quot;Convert SPEC, a css font-size specifier, back to an emacs :height attribute
value. Used while merging multiple font-size attributes.&quot;</span>
  <span class="comment">;;(message &quot;hfy-size-to-int&quot;);;DBUG
</span>  (list
   (<span class="keyword">if</span> (string-match <span class="string">&quot;\\([0-9]+\\)\\(%\\|pt\\)&quot;</span> spec)
       (<span class="keyword">cond</span> ((string= <span class="string">&quot;%&quot;</span>  (match-string 2 spec))
	      (/ (string-to-int (match-string 1 spec)) 100.0))
	     ((string= <span class="string">&quot;pt&quot;</span> (match-string 2 spec))
	      (* (string-to-int (match-string 1 spec))    10)))
     (string-to-number spec))) )

<span class="comment">;; size is different, in that in order to get it right at all,
;; we have to trawl the inheritance path, accumulating modifiers,
;; _until_ we get to an absolute (pt) specifier, then combine the lot
</span><a name="hfy-flatten-style.725"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-flatten-style.725">hfy-flatten-style</a></span> (style)
  <span class="string">&quot;Take STYLE (see `</span><span class="constant"><a href="htmlfontify.el.html#hfy-face-to-style-i.674">hfy-face-to-style-i</a></span><span class="string">', `</span><span class="constant"><a href="htmlfontify.el.html#hfy-face-to-style.745">hfy-face-to-style</a></span><span class="string">') and merge
any multiple attributes appropriately. Currently only font-size is merged
down to a single occurrence - others may need special handling, but I
haven\'t encountered them yet. Returns a `</span><span class="constant"><a href="htmlfontify.el.html#hfy-style-assoc.435">hfy-style-assoc</a></span><span class="string">'.&quot;</span>
  <span class="comment">;;(message &quot;hfy-flatten-style&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((n        0)
	(m (list 1))
	(x      nil)
	(r      nil))
    (mapcar
     (<span class="keyword">lambda</span> (css)
       (<span class="keyword">if</span> (string= (car css) <span class="string">&quot;font-size&quot;</span>)
	   (<span class="keyword">progn</span>
	     (<span class="keyword">if</span> (not x) (setq m (nconc m (<a href="htmlfontify.el.html#hfy-size-to-int.710">hfy-size-to-int</a> (cdr css)))))
	     (<span class="keyword">if</span> (string-match <span class="string">&quot;pt&quot;</span> (cdr css)) (setq x t)))
	 (setq r (nconc r (list css))))) style)
    (setq  n (apply '* m))
    (nconc r (<a href="htmlfontify.el.html#hfy-size.549">hfy-size</a> (<span class="keyword">if</span> x (round n) (* n 1.0)))) r))

<a name="hfy-face-to-style.745"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-face-to-style.745">hfy-face-to-style</a></span> (fn)
  <span class="string">&quot;Take FN, a font or `</span><span class="constant">defface</span><span class="string">' style font specification,
\(as returned by `</span><span class="constant">face-attr-construct</span><span class="string">'\) and return a `</span><span class="constant"><a href="htmlfontify.el.html#hfy-style-assoc.435">hfy-style-assoc</a></span><span class="string">'.\n
See also: `</span><span class="constant"><a href="htmlfontify.el.html#hfy-face-to-style-i.674">hfy-face-to-style-i</a></span><span class="string">', `</span><span class="constant"><a href="htmlfontify.el.html#hfy-flatten-style.725">hfy-flatten-style</a></span><span class="string">'.&quot;</span>
  <span class="comment">;;(message &quot;hfy-face-to-style&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((face-def (<span class="keyword">if</span> (facep fn)
		      (<a href="htmlfontify.el.html#hfy-face-attr-for-class.625">hfy-face-attr-for-class</a> fn <a href="htmlfontify.el.html#hfy-display-class.338">hfy-display-class</a>) fn))
	(final-style nil))
    (setq final-style (<a href="htmlfontify.el.html#hfy-flatten-style.725">hfy-flatten-style</a> (<a href="htmlfontify.el.html#hfy-face-to-style-i.674">hfy-face-to-style-i</a> face-def)))
    <span class="comment">;;(message &quot;%S&quot; final-style)
</span>    (<span class="keyword">if</span> (not (assoc <span class="string">&quot;text-decoration&quot;</span> final-style))
	(<span class="keyword">progn</span> (setq final-style
		     (nconc final-style '((<span class="string">&quot;text-decoration&quot;</span>.<span class="string">&quot;none&quot;</span>))))))
    final-style))

<span class="comment">;; strip redundant bits from a name. Technically, this could result in
;; a collision, but it is pretty unlikely - will fix later...
</span><a name="hfy-css-name.762"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-css-name.762">hfy-css-name</a></span> (fn)
  <span class="string">&quot;Strip some of the boring bits from a font-name and return a css style name.&quot;</span>
  <span class="comment">;;(message &quot;hfy-css-name&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((face-name (format <span class="string">&quot;%s&quot;</span> fn)))
    (<span class="keyword">if</span> (or (string-match <span class="string">&quot;font-lock-\\(.*\\)&quot;</span> face-name)
	    (string-match <span class="string">&quot;cperl-\\(.*\\)&quot;</span>     face-name)
	    (string-match <span class="string">&quot;[Ii]nfo-\\(.*\\)&quot;</span>   face-name))
	(<span class="keyword">progn</span>
	  (setq face-name (match-string 1 face-name))
	  (<span class="keyword">if</span> (string-match <span class="string">&quot;\\(.*\\)-face&quot;</span> face-name)
	      (setq face-name (match-string 1 face-name))) face-name)
      face-name)) )

<span class="comment">;; construct an assoc of (stripped-name . &quot;{ css-stuff-here }&quot;) pairs
;; from a face:
</span><a name="hfy-face-to-css.777"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-face-to-css.777">hfy-face-to-css</a></span> (fn)
  <span class="string">&quot;Take FN, a font or `</span><span class="constant">defface</span><span class="string">' specification \(cf. `</span><span class="constant">face-attr-construct</span><span class="string">'\)
and return a CSS style specification.

See also: `</span><span class="constant"><a href="htmlfontify.el.html#hfy-face-to-style.745">hfy-face-to-style</a></span><span class="string">'&quot;</span>
  <span class="comment">;;(message &quot;hfy-face-to-css&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((css-list nil)
	(css-text nil)
	(style    nil)
	(seen     nil))
    (setq css-list (<a href="htmlfontify.el.html#hfy-face-to-style.745">hfy-face-to-style</a> fn))
    (setq css-text
	  (nconc
	   (mapcar
	    (<span class="keyword">lambda</span> (E)
	      (<span class="keyword">if</span> (car E)
		    (<span class="keyword">if</span> (not (member (car E) seen))
			(<span class="keyword">progn</span>
			  (setq seen (cons (car E) seen))
			  (format <span class="string">&quot; %s: %s; &quot;</span> (car E) (cdr E)))))) css-list)))
    (cons (<a href="htmlfontify.el.html#hfy-css-name.762">hfy-css-name</a> fn) (format <span class="string">&quot;{%s}&quot;</span> (apply 'concat css-text)))) )

<span class="comment">;; extract a face from a list of char properties, if there is one:
</span><a name="hfy-p-to-face.800"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-p-to-face.800">hfy-p-to-face</a></span> (props)
  <span class="string">&quot;Given PROPS, a list of text-properties, return the value of the face
property, or nil.&quot;</span>
  <span class="comment">;;(message &quot;hfy-p-to-face&quot;);;DBUG
</span>  (<span class="keyword">if</span> props
      (<span class="keyword">if</span> (string= (car props) <span class="string">&quot;face&quot;</span>)
	  (<span class="keyword">if</span> (listp (cadr props)) (car (cadr props)) (cadr props))
	(<a href="htmlfontify.el.html#hfy-p-to-face.800">hfy-p-to-face</a> (cddr props))) nil))

<a name="hfy-face-at.809"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-face-at.809">hfy-face-at</a></span> (p)
  <span class="string">&quot;Find face in effect at point P&quot;</span>
  <span class="comment">;;(message &quot;hfy-face-at&quot;);;DBUG
</span>  (<a href="htmlfontify.el.html#hfy-p-to-face.800">hfy-p-to-face</a> (text-properties-at p)))

<span class="comment">;; construct an assoc of (face-name . (css-name . &quot;{ css-style }&quot;)) elements:
</span><a name="hfy-compile-stylesheet.815"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-compile-stylesheet.815">hfy-compile-stylesheet</a></span> ()
  <span class="string">&quot;Trawl the current buffer, construct an return a `</span><span class="constant">hfy-sheet-assoc</span><span class="string">'.&quot;</span>
  <span class="comment">;;(message &quot;hfy-compile-stylesheet&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((pt (point-min))
	(fn         nil)
	(css        nil)
	(style      nil))
    (<span class="keyword">save-excursion</span>
      (goto-char pt)
      (<span class="keyword">while</span> (&lt; pt (point-max))
	(<span class="keyword">if</span> (and (setq fn (<a href="htmlfontify.el.html#hfy-face-at.809">hfy-face-at</a> pt)) (not (assoc fn style)))
	    (setq style (cons (cons fn (<a href="htmlfontify.el.html#hfy-face-to-css.777">hfy-face-to-css</a> fn)) style)))
	(setq pt (next-char-property-change pt))) )
    (setq style (cons (cons 'default (<a href="htmlfontify.el.html#hfy-face-to-css.777">hfy-face-to-css</a> 'default)) style))) )

<a name="hfy-fontified-p.830"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-fontified-p.830">hfy-fontified-p</a></span> ()
  <span class="string">&quot;`</span><span class="constant">font-lock</span><span class="string">' doesn't like to say it\'s been fontified when in batch
mode, but we want to know if we should fontify or raw copy, so in batch
mode we check for non-default face properties. Otherwise we test
`</span><span class="constant">font-lock-mode</span><span class="string">' and `</span><span class="constant">font-lock-fontified</span><span class="string">' for truth.&quot;</span>
  <span class="comment">;;(message &quot;font-lock-fontified: %S&quot; font-lock-fontified)
  ;;(message &quot;noninteractive     : %S&quot; noninteractive)
  ;;(message &quot;font-lock-mode     : %S&quot; font-lock-mode)
</span>  (and font-lock-fontified
       (<span class="keyword">if</span> noninteractive
	   (<span class="keyword">let</span> ((pt  (point-min))
		 (face-name   nil))
	     (<span class="keyword">save-excursion</span>
	       (goto-char pt)
	       (<span class="keyword">while</span> (and (&lt; pt (point-max)) (not face-name))
		 (setq face-name (<a href="htmlfontify.el.html#hfy-face-at.809">hfy-face-at</a> pt))
		 (setq pt (next-char-property-change pt)))) face-name)
	 font-lock-mode)))

<span class="comment">;; remember, the map is in reverse point order:
;; I wrote this while suffering the effects of a cold, and maybe a
;; mild fever - I think it's correct, but it might be a little warped
;; as my minfd keeps ... where was I? Oh yes, the bunnies...
</span><a name="hfy-merge-adjacent-spans.853"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-merge-adjacent-spans.853">hfy-merge-adjacent-spans</a></span> (face-map)
  (<span class="keyword">let</span> ((tmp-map face-map)
	(map-buf      nil)
	(first-start  nil)
	(first-stop   nil)
	(last-start   nil)
	(last-stop    nil)
	(span-stop    nil)
	(span-start   nil)
	(reduced-map  nil))
    <span class="comment">;;(setq reduced-map (cons (car  tmp-map) reduced-map))
    ;;(setq reduced-map (cons (cadr tmp-map) reduced-map))
</span>    (<span class="keyword">while</span> tmp-map
      (setq first-start (cadddr tmp-map)
	    first-stop  (caddr  tmp-map)
	    last-start  (cadr   tmp-map)
	    last-stop   (car    tmp-map)
	    map-buf      tmp-map
	    span-start   last-start
	    span-stop    last-stop      )
      (<span class="keyword">while</span> (and (eq (cdr first-start)
		      (cdr  last-start))
		  (<span class="keyword">save-excursion</span>
		    (goto-char (car first-stop))
		    (not (re-search-forward <span class="string">&quot;[^ \t\n\r]&quot;</span> (car last-start) t))))
	(setq map-buf     (cddr map-buf)
	      span-start  first-start
	      first-start (cadddr map-buf)
	      first-stop  (caddr  map-buf)
	      last-start  (cadr   map-buf)
	      last-stop   (car    map-buf)))
      (setq reduced-map (cons span-stop  reduced-map))
      (setq reduced-map (cons span-start reduced-map))
      (setq tmp-map (memq last-start tmp-map))
      (setq tmp-map (cdr tmp-map)))
    (setq reduced-map (nreverse reduced-map))))

<span class="comment">;; remember to generate 'synthetic' &lt;/span&gt; entries -
;; emacs copes by just having a stack of styles in effect
;; and only using the top one: html has a more simplistic approach -
;; we have to explicitly end a style, there's no way of temporarily
;; overriding it w. another one... (afaik)
</span><a name="hfy-compile-face-map.895"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-compile-face-map.895">hfy-compile-face-map</a></span> ()
  <span class="string">&quot;Compile and return a `</span><span class="constant">hfy-facemap-assoc</span><span class="string">' for the current buffer.&quot;</span>
  <span class="comment">;;(message &quot;hfy-compile-face-map&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((pt (point-min))
	(fn         nil)
	(map        nil)
	(prev-tag   nil)) <span class="comment">;; t   if the last tag-point was a span-start
                          ;; nil if it was a span-stop
</span>    (<span class="keyword">save-excursion</span>
      (goto-char pt)
      (<span class="keyword">while</span> (&lt; pt (point-max))
	(<span class="keyword">if</span> (setq fn (<a href="htmlfontify.el.html#hfy-face-at.809">hfy-face-at</a> pt))
	    (<span class="keyword">progn</span> (<span class="keyword">if</span> prev-tag (setq map (cons (cons pt 'end) map)))
	           (setq map (cons (cons pt fn) map))
		   (setq prev-tag t))
	  (<span class="keyword">if</span> prev-tag (setq map (cons (cons pt 'end) map)))
	  (setq prev-tag nil))
	(setq pt (next-char-property-change pt)))
      (<span class="keyword">if</span> (not (eq 'end (cdar map)))
	  (setq map (cons (cons (point-max) 'end) map))))
    (<span class="keyword">if</span> (<a href="htmlfontify.el.html#hfy-opt.502">hfy-opt</a> 'merge-adjacent-tags) (<a href="htmlfontify.el.html#hfy-merge-adjacent-spans.853">hfy-merge-adjacent-spans</a> map) map)))

<span class="comment">;; generate a buffer to hold the output. Should make this safer, really...
</span><a name="hfy-buffer.918"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-buffer.918">hfy-buffer</a></span> () (get-buffer-create (concat (buffer-name) <a href="htmlfontify.el.html#hfy-extn.242">hfy-extn</a>)))

<span class="comment">;; get a css style name for a face from the style:
</span><a name="hfy-lookup.921"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-lookup.921">hfy-lookup</a></span> (face style) (cadr (assoc face style)))

<a name="hfy-link-style.923"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-link-style.923">hfy-link-style</a></span> (style-string)
  <span class="comment">;;(message &quot;hfy-link-style&quot;);;DBUG
</span>  (<span class="keyword">if</span> (functionp <a href="htmlfontify.el.html#hfy-link-style-fun.265">hfy-link-style-fun</a>)
      (funcall <a href="htmlfontify.el.html#hfy-link-style-fun.265">hfy-link-style-fun</a> style-string)
    style-string))

<span class="comment">;; barf up the inline css stylesheet
</span><a name="hfy-sprintf-stylesheet.930"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-sprintf-stylesheet.930">hfy-sprintf-stylesheet</a></span> (css file)
  <span class="comment">;;(message &quot;hfy-sprintf-stylesheet&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((stylesheet nil))
    (setq stylesheet
	  (concat
	   <span class="string">&quot;&lt;style type=\&quot;text/css\&quot;&gt;&lt;!-- \n&quot;</span>
	   (format <span class="string">&quot;body %s\n&quot;</span> (cddr (assq 'default css)))
	   (apply 'concat
		  (mapcar
		   (<span class="keyword">lambda</span> (style)
		     (format
		      <span class="string">&quot;span.%s   %s\nspan.%s a %s\n&quot;</span>
		      (cadr style) (cddr style)
		      (cadr style) (<a href="htmlfontify.el.html#hfy-link-style.923">hfy-link-style</a> (cddr style)))) css))
	   <span class="string">&quot; --&gt;&lt;/style&gt;\n&quot;</span>))
    (funcall <a href="htmlfontify.el.html#hfy-page-header.220">hfy-page-header</a> file stylesheet)))

<span class="comment">;; tag all the dangerous characters we want to escape
;; (ie any &quot;&lt;&gt; chars we _didn't_ put there explicitly for css markup)
</span><a name="hfy-html-enkludge-buffer.949"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-html-enkludge-buffer.949">hfy-html-enkludge-buffer</a></span> ()
  <span class="string">&quot;Mark dangerous [\&quot;\&lt;\&gt;] characters with the \'hfy-quoteme property.\n
See also `</span><span class="constant"><a href="htmlfontify.el.html#hfy-html-dekludge-buffer.969">hfy-html-dekludge-buffer</a></span><span class="string">'.&quot;</span>
  <span class="comment">;;(message &quot;hfy-html-enkludge-buffer&quot;);;DBUG
</span>  (<span class="keyword">save-excursion</span>
    (goto-char (point-min))
    (<span class="keyword">while</span> (re-search-forward <a href="htmlfontify.el.html#hfy-html-quote-regex.280">hfy-html-quote-regex</a> nil t)
      (put-text-property (match-beginning 0) (point) 'hfy-quoteme t))) )

<span class="comment">;; dangerous char -&gt; &amp;entity;
</span><a name="hfy-html-quote.959"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-html-quote.959">hfy-html-quote</a></span> (char-string)
  <span class="string">&quot;Map a string (usu. 1 char long) to an html safe string (entity) if need be.&quot;</span>
  <span class="comment">;;(message &quot;hfy-html-quote&quot;);;DBUG
</span>  (or (cadr (assoc char-string <a href="htmlfontify.el.html#hfy-html-quote-map.317">hfy-html-quote-map</a>)) char-string) )

<span class="comment">;; actually entity-ise dangerous chars.
;; note that we can't do this until _after_ we have inserted the css
;; markup, since we use a position-based map to insert this, and if we
;; enter any other text before we do this, we'd have to track another
;; map of offsets, which would be tedious...
</span><a name="hfy-html-dekludge-buffer.969"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-html-dekludge-buffer.969">hfy-html-dekludge-buffer</a></span> ()
  <span class="string">&quot;Transform all dangerous characters marked with the \'hfy-quoteme property
using `</span><span class="constant"><a href="htmlfontify.el.html#hfy-html-quote.959">hfy-html-quote</a></span><span class="string">'\n
See also `</span><span class="constant"><a href="htmlfontify.el.html#hfy-html-enkludge-buffer.949">hfy-html-enkludge-buffer</a></span><span class="string">'.&quot;</span>
  <span class="comment">;;(message &quot;hfy-html-dekludge-buffer&quot;);;DBUG
</span>  (<span class="keyword">save-excursion</span>
    (goto-char (point-min))
    (<span class="keyword">while</span> (re-search-forward <a href="htmlfontify.el.html#hfy-html-quote-regex.280">hfy-html-quote-regex</a> nil t)
      (<span class="keyword">if</span> (get-text-property (match-beginning 0) 'hfy-quoteme)
	  (replace-match (<a href="htmlfontify.el.html#hfy-html-quote.959">hfy-html-quote</a> (match-string 1)))
	)
      )
    )
  )

<a name="hfy-fontify-buffer.984"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-fontify-buffer.984">hfy-fontify-buffer</a></span> (<span class="type">&amp;optional</span> srcdir file)
  <span class="string">&quot;Implement the guts of `</span><span class="constant"><a href="htmlfontify.el.html#htmlfontify-buffer.1108">htmlfontify-buffer</a></span><span class="string">'&quot;</span>
  (<span class="keyword">if</span> srcdir (setq srcdir (directory-file-name srcdir)))
  (<span class="keyword">let</span> ((in-style                                   nil)
	(fast-lock-minimum-size      <a href="htmlfontify.el.html#hfy-fast-lock-save.395">hfy-fast-lock-save</a>)
	(html-buffer           (<a href="htmlfontify.el.html#hfy-buffer.918">hfy-buffer</a>            ))
	(css-sheet             (<a href="htmlfontify.el.html#hfy-compile-stylesheet.815">hfy-compile-stylesheet</a>))
	(css-map               (<a href="htmlfontify.el.html#hfy-compile-face-map.895">hfy-compile-face-map</a>  )))
    <span class="comment">;; copy the buffer, including fontification, and switch to it:
</span>    (copy-to-buffer html-buffer (point-min) (point-max))
    (set-buffer     html-buffer)
    <span class="comment">;; at this point, html-buffer retains the fontification of the parent:
    ;; #####################################################################
    ;; if we are in etags mode, add properties to mark the anchors and links
</span>    (<span class="keyword">if</span> (and srcdir file)
	(<span class="keyword">progn</span>
	  (<a href="htmlfontify.el.html#hfy-mark-tags-this-file.1220">hfy-mark-tags-this-file</a>  srcdir file) <span class="comment">;; mark anchors
</span>	  (<a href="htmlfontify.el.html#hfy-mark-tags-other-file.1287">hfy-mark-tags-other-file</a> srcdir file))) <span class="comment">;; mark links
    ;; #####################################################################
    ;; mark the 'dangerous' characters
</span>    (<a href="htmlfontify.el.html#hfy-html-enkludge-buffer.949">hfy-html-enkludge-buffer</a>)
    <span class="comment">;; trawl the position-based face-map, inserting span tags as we go
    ;; note that we cannot change any character positions before this point
    ;; or we will invalidate the map:
    ;; NB: This also means we have to trawl the map in descending file-offset
    ;; order, obviously.
    ;; ---------------------------------------------------------------------
    ;; Remember, inserting pushes properties to the right, which we don't
    ;; actually want to happen for link properties, so we have to flag
    ;; them and move them by hand - if you don't, you end up with
    ;;
    ;; &lt;span class=&quot;foo&quot;&gt;&lt;a href=&quot;bar&quot;&gt;texta&lt;/span&gt;&lt;span class=&quot;bletch&quot;&gt;&lt;/a&gt;...
    ;;
    ;; instead of:
    ;;
    ;; &lt;span class=&quot;foo&quot;&gt;&lt;a href=&quot;bar&quot;&gt;texta&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;bletch&quot;&gt;...
    ;;
    ;; If my analysis of the problem is correct, we can detect link-ness by
    ;; either hfy-linkp or hfy-endl properties at the insertion point, but I
    ;; think we only need to relocate the hfy-endl property, as the hfy-linkp
    ;; property has already served its main purpose by this point.
</span>    (mapcar
     (<span class="keyword">lambda</span> (point-face)
       (<span class="keyword">let</span> ((pt (car point-face))
	     (fn (cdr point-face))
	     <span class="comment">;;(PROPS nil)
</span>	     (move-link       nil))
	 (goto-char pt)
	 (setq move-link
	       (or (get-text-property pt 'hfy-linkp)
		   (get-text-property pt 'hfy-endl )))
	 (<span class="keyword">if</span> (eq 'end fn)
	     (<span class="keyword">if</span> (not (and srcdir file)) (insert <span class="string">&quot;&lt;/span&gt;&quot;</span>)
	       <span class="comment">;;(setq PROPS (text-properties-at 6740))
</span>	       (insert <span class="string">&quot;&lt;/span&gt;&quot;</span>)
	       <span class="comment">;; (message &quot;move-link: %S, pt: %d, point: %d, PROPS: %S&quot;
	       ;; 	   move-link pt (point) PROPS )
</span>	       (<span class="keyword">if</span> (not move-link) nil
		 <span class="comment">;;(message &quot;removing props @ %d&quot; (point))
</span>		 (remove-text-properties (point) (1+ (point)) '(hfy-endl nil))
		 (put-text-property pt (1+ pt) 'hfy-endl t)
		 )
	       )	   
	   (insert (format <span class="string">&quot;&lt;span class=\&quot;%s\&quot;&gt;&quot;</span>
			   (<a href="htmlfontify.el.html#hfy-lookup.921">hfy-lookup</a> fn css-sheet)))
	   (<span class="keyword">if</span> (not move-link) nil
	     <span class="comment">;;(message &quot;removing prop2 @ %d&quot; (point))
</span>	     (<span class="keyword">if</span> (remove-text-properties (point) (1+ (point)) '(hfy-endl nil))
		 (put-text-property pt (1+ pt) 'hfy-endl t))) ))) css-map)
    <span class="comment">;; #####################################################################
</span>    (<span class="keyword">if</span> (and srcdir file)
	(<span class="keyword">let</span> ((pt nil)
	      (pr nil)
	      (x  nil))
	  (<span class="keyword">progn</span>
	    (setq pt (point-min))
	    (<span class="keyword">while</span> (setq pt (next-single-property-change pt 'hfy-anchor))
	      (<span class="keyword">if</span> (setq pr (get-text-property pt 'hfy-anchor))
		  (<span class="keyword">progn</span> (goto-char pt)
			 (remove-text-properties pt (1+ pt) '(hfy-anchor nil))
			 (insert (concat <span class="string">&quot;&lt;a name=\&quot;&quot;</span> pr <span class="string">&quot;\&quot;&gt;&lt;/a&gt;&quot;</span>)))))
 	    (setq pt (point-min))
 	    (<span class="keyword">while</span> (setq pt (next-single-property-change pt 'hfy-link))
	      (<span class="keyword">if</span> (setq pr (get-text-property pt 'hfy-link))
 		  (<span class="keyword">progn</span> (goto-char pt)
			 (remove-text-properties pt (1+ pt) '(hfy-link nil))
			 (insert (format <span class="string">&quot;&lt;a href=\&quot;%s\&quot;&gt;&quot;</span> pr)))))
 	    (setq pt (point-min))
 	    (<span class="keyword">while</span> (setq pt (next-single-property-change pt 'hfy-endl))
 	      (<span class="keyword">if</span> (get-text-property pt 'hfy-endl)
		  (<span class="keyword">progn</span> (goto-char pt)
			 (remove-text-properties pt (1+ pt) '(hfy-endl nil))
			 (insert <span class="string">&quot;&lt;/a&gt;&quot;</span>)))))))
    <span class="comment">;; #####################################################################
    ;; transform the dangerous chars. This changes character positions
    ;; since entities have &gt; char length.
    ;; note that this deletes the dangerous characters, and therefore
    ;; destroys any properties they may contain (such as 'hfy-endl),
    ;; so we have to do this after we use said properties:
</span>    (<a href="htmlfontify.el.html#hfy-html-dekludge-buffer.969">hfy-html-dekludge-buffer</a>)
    <span class="comment">;; insert the stylesheet at the top:
</span>    (goto-char (point-min))
    (insert (<a href="htmlfontify.el.html#hfy-sprintf-stylesheet.930">hfy-sprintf-stylesheet</a> css-sheet file))
    (insert <span class="string">&quot;\n&lt;pre&gt;\n&quot;</span>)
    (goto-char (point-max))
    (insert <span class="string">&quot;\n&lt;/pre&gt;\n&quot;</span>)
    (insert (funcall <a href="htmlfontify.el.html#hfy-page-footer.236">hfy-page-footer</a> file))
    <span class="comment">;; display the html buffer, if interactive:
</span>    html-buffer))

<a name="hfy-force-fontification.1094"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-force-fontification.1094">hfy-force-fontification</a></span> ()
  (mapcar (<span class="keyword">lambda</span> (fun) (funcall fun)) <a href="htmlfontify.el.html#hfy-init-kludge-hooks.287">hfy-init-kludge-hooks</a>)
  (or font-lock-cache-position (set 'font-lock-cache-position (make-marker)))
  (<span class="keyword">if</span> (not noninteractive)
      (<span class="keyword">progn</span>
	(message <span class="string">&quot;hfy interactive mode (%S %S)&quot;</span> window-system major-mode)
	(font-lock-fontify-region (point-min) (point-max) nil))
    (message <span class="string">&quot;hfy batch mode (%S)&quot;</span> major-mode)
    <span class="comment">;;(set 'font-lock-cache-position (make-marker))
</span>    (font-lock-fontify-buffer)
    <span class="comment">;;(font-lock-fontify-region (point-min) (point-max) nil)
</span>    )                           
  )

<a name="htmlfontify-buffer.1108"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#htmlfontify-buffer.1108">htmlfontify-buffer</a></span> (<span class="type">&amp;optional</span> srcdir file)
  <span class="string">&quot;Create a new buffer, named for the current buffer + a .html extension,
containing an inline css-stylesheet and formatted css-markup html that
reproduces the look of the current emacs buffer as closely as possible.

Dangerous characters in the existing buffer are turned into html entities,
so you should even be able to do html-within-html fontified display.

If the SRCDIR and FILE arguments are set, lookup etags derived entries
in the `</span><span class="constant"><a href="htmlfontify.el.html#hfy-tags-cache.422">hfy-tags-cache</a></span><span class="string">' and add html anchors and hyperlinks as appropriate.&quot;</span>
  (interactive)
  <span class="comment">;;(message &quot;htmlfontify-buffer&quot;)
  ;; pick up the file name in case we didn't receive it
</span>  (<span class="keyword">if</span> (not file)
      (<span class="keyword">progn</span> (setq file (buffer-file-name))
	     (<span class="keyword">if</span> (string-match <span class="string">&quot;/\\([^/]*\\)$&quot;</span> file)
		 (setq file (match-string 1 file)))))
  (<span class="keyword">let</span> ((fast-lock-minimum-size <a href="htmlfontify.el.html#hfy-fast-lock-save.395">hfy-fast-lock-save</a>)
	(font-lock-support-mode    'fast-lock-mode))
  (<a href="htmlfontify.el.html#hfy-force-fontification.1094">hfy-force-fontification</a>)
  (<span class="keyword">if</span> (interactive-p)
      (switch-to-buffer (<a href="htmlfontify.el.html#hfy-fontify-buffer.984">hfy-fontify-buffer</a> srcdir file))
    (<a href="htmlfontify.el.html#hfy-fontify-buffer.984">hfy-fontify-buffer</a> srcdir file))) )

<span class="comment">;; recursive file listing
</span><a name="hfy-list-files.1133"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-list-files.1133">hfy-list-files</a></span> (directory)
  <span class="string">&quot;Return a list of files under DIRECTORY.
Strips any leading \&quot;./\&quot; from each filename.&quot;</span>
  <span class="comment">;;(message &quot;hfy-list-files&quot;);;DBUG
</span>  (cd directory)
  (mapcar (<span class="keyword">lambda</span> (F) (<span class="keyword">if</span> (string-match <span class="string">&quot;^./\\(.*\\)&quot;</span> F) (match-string 1 F) F))
	  (split-string (shell-command-to-string <a href="htmlfontify.el.html#hfy-find-cmd.332">hfy-find-cmd</a>))) )

<span class="comment">;; strip the filename off, return a directiry name
;; not a particularly thorough implementaion, but it will be
;; fed pretty carefully, so it should be Ok:
</span><a name="hfy-dirname.1144"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-dirname.1144">hfy-dirname</a></span> (file)
  <span class="string">&quot;Return everything preceding the last \&quot;/\&quot; from a relative filename,
on the assumption that this will produce a relative directory name. Hardly
bombproof, but good enough in the context in which it is being used.&quot;</span>
  <span class="comment">;;(message &quot;hfy-dirname&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((f (directory-file-name file)))
    (and (string-match <span class="string">&quot;^\\(.*\\)/&quot;</span> f) (match-string 1 f))))

<span class="comment">;; create a directory, cf mkdir -p 
</span><a name="hfy-make-directory.1153"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-make-directory.1153">hfy-make-directory</a></span> (dir)
  <span class="string">&quot;Approx equivalent of mkdir -p DIR&quot;</span>
  <span class="comment">;;(message &quot;hfy-make-directory&quot;);;DBUG
</span>  (<span class="keyword">if</span> (file-exists-p dir)
      (<span class="keyword">if</span> (file-directory-p dir) t)
    (make-directory dir t)))

<span class="comment">;; open a file, check fontification, if fontified, write a fontified copy
;; to the destination directory, otherwise just copy the file:
</span><a name="hfy-copy-and-fontify-file.1162"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-copy-and-fontify-file.1162">hfy-copy-and-fontify-file</a></span> (srcdir dstdir file)
  <span class="string">&quot;open FILE in SRCDIR - if fontified, write a fontified copy to DSTDIR
adding an extension of `</span><span class="constant"><a href="htmlfontify.el.html#hfy-extn.242">hfy-extn</a></span><span class="string">'. Fontification is actually done by
`</span><span class="constant"><a href="htmlfontify.el.html#htmlfontify-buffer.1108">htmlfontify-buffer</a></span><span class="string">'. If the buffer is not fontified, just copy it.&quot;</span>
  <span class="comment">;;(message &quot;hfy-copy-and-fontify-file&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((fast-lock-minimum-size      <a href="htmlfontify.el.html#hfy-fast-lock-save.395">hfy-fast-lock-save</a>)
	(font-lock-support-mode         'fast-lock-mode)
	<span class="comment">;;(window-system  (or window-system 'htmlfontify))
</span>	(target nil)
	(source nil)
	(html   nil))
    (cd srcdir)
    (<span class="keyword">save-excursion</span>
      (setq source (find-file-noselect file))
      (set-buffer   source)
      (setq target (concat dstdir <span class="string">&quot;/&quot;</span> file))
      (<a href="htmlfontify.el.html#hfy-make-directory.1153">hfy-make-directory</a> (<a href="htmlfontify.el.html#hfy-dirname.1144">hfy-dirname</a> target))
      (<a href="htmlfontify.el.html#hfy-force-fontification.1094">hfy-force-fontification</a>)
      (<span class="keyword">if</span> (<a href="htmlfontify.el.html#hfy-fontified-p.830">hfy-fontified-p</a>)
	  (<span class="keyword">progn</span> (setq html  (<a href="htmlfontify.el.html#hfy-fontify-buffer.984">hfy-fontify-buffer</a> srcdir file))
		 (set-buffer  html)
		 (write-file  (concat target <a href="htmlfontify.el.html#hfy-extn.242">hfy-extn</a>))
		 (kill-buffer html))
	(<span class="keyword">if</span> (and (file-exists-p target) (not (file-writable-p target)))
	    (set-file-modes target (logior (file-modes target) #o0200)))
	(copy-file (buffer-file-name source) target 'overwrite))
      (kill-buffer source))
    )
  )

<span class="comment">;; what line are we on?
</span><a name="hfy-line-number.1193"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-line-number.1193">hfy-line-number</a></span> ()
  <span class="comment">;;(message &quot;hfy-line-number&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((opoint (point)) start)
    (<span class="keyword">save-excursion</span>
      (goto-char (point-min))
      (forward-line     0)
      (setq start (point))
      (goto-char   opoint)
      (forward-line 0)
      (1+ (count-lines 1 (point))))))

<span class="comment">;; list of tags in file in srcdir
</span><a name="hfy-tags-for-file.1205"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-tags-for-file.1205">hfy-tags-for-file</a></span> (srcdir file)
  <span class="string">&quot;List of etags tags that have definitions in this FILE. Looks up
the tags cache in `</span><span class="constant"><a href="htmlfontify.el.html#hfy-tags-cache.422">hfy-tags-cache</a></span><span class="string">' using SRCDIR as the key.&quot;</span>
  <span class="comment">;;(message &quot;hfy-tags-for-file&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((cache-entry (assoc srcdir <a href="htmlfontify.el.html#hfy-tags-cache.422">hfy-tags-cache</a>))
	(cache-hash   nil)
	(tag-list     nil))
    (<span class="keyword">if</span> (setq cache-hash (cadr cache-entry))
	(maphash
	 (<span class="keyword">lambda</span> (K V)
	   (<span class="keyword">if</span> (assoc file V)
	       (setq tag-list (cons K tag-list)))) cache-hash))
    tag-list))

<span class="comment">;; mark the tags native to this file for anchors
</span><a name="hfy-mark-tags-this-file.1220"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-mark-tags-this-file.1220">hfy-mark-tags-this-file</a></span> (srcdir file)
  <span class="string">&quot;Mark tags in FILE (lookup SRCDIR in `</span><span class="constant"><a href="htmlfontify.el.html#hfy-tags-cache.422">hfy-tags-cache</a></span><span class="string">') with the \'hfy-anchor
property, with a value of \&quot;tag.line-number\&quot;.&quot;</span>
  <span class="comment">;;(message &quot;hfy-mark-tags-this-file&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((cache-entry (assoc srcdir <a href="htmlfontify.el.html#hfy-tags-cache.422">hfy-tags-cache</a>))
	(cache-hash   nil))
    (<span class="keyword">if</span> (setq cache-hash (cadr cache-entry))
	(mapcar
	 (<span class="keyword">lambda</span> (TAG)
	   (mapcar
	    (<span class="keyword">lambda</span> (TLIST)
	      (<span class="keyword">if</span> (string= file (car TLIST))
		  (<span class="keyword">let*</span> ((line              (cadr TLIST) )
			 (chr              (caddr TLIST) )
			 (link (format <span class="string">&quot;%s.%d&quot;</span> TAG line) ))
		    (put-text-property (+ 1 chr)
				       (+ 2 chr)
				       'hfy-anchor link))))
	    (gethash TAG cache-hash)))
	 (<a href="htmlfontify.el.html#hfy-tags-for-file.1205">hfy-tags-for-file</a> srcdir file)))))

<a name="hfy-relstub.1241"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-relstub.1241">hfy-relstub</a></span> (file <span class="type">&amp;optional</span> start)
  <span class="string">&quot;Return a \&quot;../\&quot; stub of the appropriate length for the current source
tree depth \(as determined from FILE\). iyswim.&quot;</span>
  <span class="comment">;;(message &quot;hfy-relstub&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((c <span class="string">&quot;&quot;</span>))
    (<span class="keyword">while</span> (setq start (string-match <span class="string">&quot;/&quot;</span> file start))
      (setq start (1+ start)) (setq c (concat c <span class="string">&quot;../&quot;</span>))) c))

<a name="hfy-href-stub.1249"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-href-stub.1249">hfy-href-stub</a></span> (this-file def-files tag)
  <span class="string">&quot;Return an href stub for a tag href: if DEF-FILES \(list of files containing
definitions for the tag in question\) contains only one entry, the href should
link straight to that file. Otherwise, the link should be to the index file.\n
We are not yet concerned with the file extensions/ tag line number and so
on at this point.\n
If `</span><span class="constant"><a href="htmlfontify.el.html#hfy-split-index.229">hfy-split-index</a></span><span class="string">' is set, and the href wil be to an index file rather than
a source file, append a .X to `</span><span class="constant"><a href="htmlfontify.el.html#hfy-index-file.274">hfy-index-file</a></span><span class="string">', where X is the uppercased
first character of TAG.\n
See also: `</span><span class="constant"><a href="htmlfontify.el.html#hfy-relstub.1241">hfy-relstub</a></span><span class="string">', `</span><span class="constant"><a href="htmlfontify.el.html#hfy-index-file.274">hfy-index-file</a></span><span class="string">'`'.&quot;</span>
  <span class="comment">;;(message &quot;hfy-href-stub&quot;);;DBUG
</span>  (concat
   (<a href="htmlfontify.el.html#hfy-relstub.1241">hfy-relstub</a> this-file)
   (<span class="keyword">if</span> (= 1 (length def-files)) (car def-files)
     (<span class="keyword">if</span> (not <a href="htmlfontify.el.html#hfy-split-index.229">hfy-split-index</a>) <a href="htmlfontify.el.html#hfy-index-file.274">hfy-index-file</a>
       (concat <a href="htmlfontify.el.html#hfy-index-file.274">hfy-index-file</a> <span class="string">&quot;.&quot;</span> (upcase (substring tag 0 1)))))) )

<a name="hfy-href.1266"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-href.1266">hfy-href</a></span> (this-file def-files tag tag-map)
  <span class="string">&quot;Return a relative href to the tag in question, based on\n
THIS-FILE `</span><span class="constant"><a href="htmlfontify.el.html#hfy-link-extn.257">hfy-link-extn</a></span><span class="string">' `</span><span class="constant"><a href="htmlfontify.el.html#hfy-extn.242">hfy-extn</a></span><span class="string">' DEF-FILES TAG and TAG-MAP\n
THIS-FILE is the current source file
DEF-FILES is a list of file containing possible link endpoints for TAG
TAG is the TAG in question
TAG-MAP is the entry in `</span><span class="constant"><a href="htmlfontify.el.html#hfy-tags-cache.422">hfy-tags-cache</a></span><span class="string">'.&quot;</span>
  <span class="comment">;;(message &quot;hfy-href&quot;);;DBUG
</span>  (concat
   (<a href="htmlfontify.el.html#hfy-href-stub.1249">hfy-href-stub</a> this-file def-files tag)
   (or <a href="htmlfontify.el.html#hfy-link-extn.257">hfy-link-extn</a> <a href="htmlfontify.el.html#hfy-extn.242">hfy-extn</a>) <span class="string">&quot;#&quot;</span> tag <span class="comment">;;(.src -&gt; .html)
</span>   (<span class="keyword">if</span> (= 1 (length def-files))
       (concat <span class="string">&quot;.&quot;</span> (format <span class="string">&quot;%d&quot;</span> (cadr (assoc (car def-files) tag-map)))))) )

<a name="hfy-word-regex.1280"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-word-regex.1280">hfy-word-regex</a></span> (string)
  <span class="string">&quot;Return a regex that matches STRING as the first `</span><span class="constant">match-string</span><span class="string">', with non
word characters on either side \(vaguely emulating the perl \\b regex atom\).&quot;</span>
  (concat <span class="string">&quot;[^$A-Za-z_0-9]\\(&quot;</span> (regexp-quote string) <span class="string">&quot;\\)[^A-Za-z_0-9]&quot;</span>))

<span class="comment">;; mark all tags for hyperlinking, except the tags at
;; their own points of definition, iyswim:
</span><a name="hfy-mark-tags-other-file.1287"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-mark-tags-other-file.1287">hfy-mark-tags-other-file</a></span> (srcdir file)
  <span class="string">&quot;Mark href start points with the \'hfy-link prop \(value: href string\)\n
Mark href end points with the \'hfy-endl prop \(value t\)\n
Avoid overlapping links, and mark links in descending length of
tag name in order to prevent subtags from usurping supertags,
\(eg \&quot;term\&quot; for \&quot;terminal\&quot;). &quot;</span>
  <span class="comment">;;(message &quot;hfy-mark-tags-other-file&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((cache-entry (assoc srcdir <a href="htmlfontify.el.html#hfy-tags-cache.422">hfy-tags-cache</a>))
	(list-cache  (assoc srcdir <a href="htmlfontify.el.html#hfy-tags-sortl.430">hfy-tags-sortl</a>))
	(no-comment  (<a href="htmlfontify.el.html#hfy-opt.502">hfy-opt</a>  'zap-comment-links))
	(no-strings  (<a href="htmlfontify.el.html#hfy-opt.502">hfy-opt</a>  'zap-string-links ))
	(cache-hash       nil)
	(tags-list        nil)
	(case-fold-search nil))
    (<span class="keyword">if</span> (and (setq cache-hash (cadr cache-entry))
	     (setq tags-list  (cadr list-cache )))	
	(mapcar
	 (<span class="keyword">lambda</span> (TAG)
	   (<span class="keyword">let*</span> ((start            nil)		  
		  (stop             nil)
		  (href             nil)
		  (case-fold-search nil)
		  (tmp-point        nil)
		  (maybe-start      nil)
		  (face-at          nil)
		  (tag-regex       (<a href="htmlfontify.el.html#hfy-word-regex.1280">hfy-word-regex</a> TAG))
		  (tag-map         (gethash TAG cache-hash))
		  (tag-files       (mapcar (<span class="keyword">lambda</span> (X) (car X))  tag-map)))
	     (goto-char (point-min))
	     (<span class="keyword">while</span> (search-forward TAG nil 'NOERROR)
	       (setq tmp-point   (point)
		     maybe-start (- (match-beginning 0) 1))
	       (goto-char maybe-start)
	       (<span class="keyword">if</span> (not (looking-at tag-regex))
		   nil
		 (setq start   (match-beginning 1))
		 (setq stop    (match-end 1))
		 (setq face-at
		       (and (or no-comment no-strings) (<a href="htmlfontify.el.html#hfy-face-at.809">hfy-face-at</a> start)))
		 (<span class="keyword">if</span> (or (text-property-any   start  (1+ stop)  'hfy-linkp  t)
			 (and no-comment (eq 'font-lock-comment-face face-at))
			 (and no-strings (eq 'font-lock-string-face  face-at)))
		     nil <span class="comment">;; already a link, NOOP
		   ;; mark the link. link to index if the tag has &gt; 1 def
		   ;; add the line number to the #name if it does not:
</span>		   (setq href (<a href="htmlfontify.el.html#hfy-href.1266">hfy-href</a> file tag-files TAG tag-map))
		   (put-text-property start (1+ start) 'hfy-link  href)
		   (put-text-property stop  (1+ stop ) 'hfy-endl  t   )
		   (put-text-property start (1+ stop ) 'hfy-linkp t   )))
	       (goto-char tmp-point)) ))
	 tags-list) )))

<span class="comment">;; cache the #(tag =&gt; file line point) entries for files under srcdir
;; and cache the descending sorted list of tags in the relevant alist,
;; also keyed by srcdir:
</span><a name="hfy-load-tags-cache.1342"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-load-tags-cache.1342">hfy-load-tags-cache</a></span> (srcdir)
  <span class="string">&quot;Run `</span><span class="constant"><a href="htmlfontify.el.html#hfy-etags-cmd.325">hfy-etags-cmd</a></span><span class="string">' on SRCDIR: load `</span><span class="constant"><a href="htmlfontify.el.html#hfy-tags-cache.422">hfy-tags-cache</a></span><span class="string">' and `</span><span class="constant"><a href="htmlfontify.el.html#hfy-tags-sortl.430">hfy-tags-sortl</a></span><span class="string">'.&quot;</span>
  <span class="comment">;;(message &quot;hfy-load-tags-cache&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((etags-buffer (get-buffer-create <span class="string">&quot;*hfy-etags*&quot;</span>))
	(cache-entry  (assoc srcdir <a href="htmlfontify.el.html#hfy-tags-cache.422">hfy-tags-cache</a>))
	(tlist-cache  (assoc srcdir <a href="htmlfontify.el.html#hfy-tags-sortl.430">hfy-tags-sortl</a>))
	(cache-hash    nil)
	(tags-list     nil)
	(hash-entry    nil)
	(tag-string    nil)
	(tag-line      nil)
	(tag-point     nil)
	(new-entry     nil)
	(etags-file    nil))
    (cd srcdir)
    (<span class="keyword">if</span> cache-entry (setq cache-hash (cadr cache-entry))
      (setq cache-hash (make-hash-table <span class="builtin">:test</span> 'equal))
      (setq <a href="htmlfontify.el.html#hfy-tags-cache.422">hfy-tags-cache</a> (list (list srcdir cache-hash) <a href="htmlfontify.el.html#hfy-tags-cache.422">hfy-tags-cache</a>)))
    (shell-command <a href="htmlfontify.el.html#hfy-etags-cmd.325">hfy-etags-cmd</a> etags-buffer)
    (clrhash cache-hash)
    <span class="comment">;; cache the TAG =&gt; ((file line point) (file line point) ... )
    ;; entries:
</span>    (<span class="keyword">save-excursion</span>
      (set-buffer etags-buffer)
      (goto-char (point-min))
      (<span class="keyword">while</span> (and (looking-at <span class="string">&quot;^\x0c&quot;</span>) (= 0 (forward-line 1)))
	(<span class="keyword">if</span> (and (looking-at <span class="string">&quot;^\\(.+\\),\\([0-9]+\\)$&quot;</span>)
		 (= 0 (forward-line 1)))
	    (<span class="keyword">progn</span>
	      (setq etags-file (match-string 1))
	      (<span class="keyword">while</span> (and (looking-at <a href="htmlfontify.el.html#etags-tag-regex.304">etags-tag-regex</a>) (= 0 (forward-line 1)))
		(setq tag-string (match-string 1))
		(setq tag-line   (string-to-int (match-string 2)))
		(setq tag-point  (string-to-int (match-string 3)))
		(setq hash-entry (gethash tag-string  cache-hash))
		(setq new-entry  (list etags-file tag-line tag-point))
		(setq hash-entry (cons new-entry hash-entry))
		(puthash tag-string hash-entry cache-hash))))) )
    <span class="comment">;; cache a list of tags in descending length order: 
</span>    (maphash (<span class="keyword">lambda</span> (K V) (setq tags-list (cons K tags-list))) cache-hash)
    (setq tags-list (sort tags-list (<span class="keyword">lambda</span> (A B) (&lt; (length B) (length A)))))
    (<span class="keyword">if</span> tlist-cache (setcar (cdr tlist-cache) tags-list)
      (setq <a href="htmlfontify.el.html#hfy-tags-sortl.430">hfy-tags-sortl</a> (cons (list srcdir tags-list) <a href="htmlfontify.el.html#hfy-tags-sortl.430">hfy-tags-sortl</a>)))
    (length tags-list)) )

<a name="hfy-write-index-i.1387"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-write-index-i.1387">hfy-write-index-i</a></span> (srcdir dstdir <span class="type">&amp;optional</span> stub)
  <span class="string">&quot;Write a tag index file for SRCDIR into DSTDIR.
`</span><span class="constant"><a href="htmlfontify.el.html#hfy-tags-cache.422">hfy-tags-cache</a></span><span class="string">' must already hav an entry for SRCDIR for this to work.
`</span><span class="constant"><a href="htmlfontify.el.html#hfy-page-header.220">hfy-page-header</a></span><span class="string">', `</span><span class="constant"><a href="htmlfontify.el.html#hfy-page-footer.236">hfy-page-footer</a></span><span class="string">', `</span><span class="constant"><a href="htmlfontify.el.html#hfy-link-extn.257">hfy-link-extn</a></span><span class="string">' and `</span><span class="constant"><a href="htmlfontify.el.html#hfy-extn.242">hfy-extn</a></span><span class="string">'
all play a part here.\n
If STUB is set, write an (appropriately named) index file specifically for
entries beginning with STUB.&quot;</span>
  <span class="comment">;;(message &quot;hfy-write-index&quot;);;DBUG
</span>  (<span class="keyword">let</span> ((cache-entry  (assoc srcdir <a href="htmlfontify.el.html#hfy-tags-cache.422">hfy-tags-cache</a>))
	(cache-hash    nil)
	(tag-list      nil)
	(index-file
	 (concat <a href="htmlfontify.el.html#hfy-index-file.274">hfy-index-file</a> (<span class="keyword">if</span> stub (concat <span class="string">&quot;.&quot;</span> stub) <span class="string">&quot;&quot;</span>) <a href="htmlfontify.el.html#hfy-extn.242">hfy-extn</a>))
	(index-buf     nil))
    (<span class="keyword">if</span> (and cache-entry
	     (setq cache-hash (cadr cache-entry))
	     (setq index-buf  (find-file-noselect index-file)))
	(<span class="keyword">progn</span>
	  (maphash (<span class="keyword">lambda</span> (K V) (setq tag-list (cons K tag-list))) cache-hash)
	  (setq tag-list (sort tag-list 'string&lt;))
	  (set-buffer index-buf)
	  (erase-buffer)
	  (insert (funcall <a href="htmlfontify.el.html#hfy-page-header.220">hfy-page-header</a> <a href="htmlfontify.el.html#hfy-index-file.274">hfy-index-file</a> <span class="string">&quot;&lt;!-- CSS --&gt;&quot;</span>))
	  (insert <span class="string">&quot;&lt;table&gt;\n&quot;</span>)
	  (mapcar
	   (<span class="keyword">lambda</span> (TAG)
	     (<span class="keyword">let</span> ((tag-started nil))
	       (mapcar
		(<span class="keyword">lambda</span> (DEF)
		  (<span class="keyword">if</span> (and stub (not (string-match (concat <span class="string">&quot;^&quot;</span> stub) TAG)))
		      nil <span class="comment">;; we have a stub and it didn't match: NOOP
</span>		    (<span class="keyword">let</span> ((file (car  DEF))
			  (line (cadr DEF)))
		      (insert
		       (format
			(concat
			 <span class="string">&quot;  &lt;tr&gt;                                   \n&quot;
			 &quot;   &lt;td&gt;%s&lt;/td&gt;                           \n&quot;
			 &quot;   &lt;td&gt;&lt;a href=\&quot;%s%s\&quot;&gt;%s&lt;/a&gt;&lt;/td&gt;      \n&quot;
			 &quot;   &lt;td&gt;&lt;a href=\&quot;%s%s#%s.%d\&quot;&gt;%d&lt;/a&gt;&lt;/td&gt;\n&quot;
			 &quot;  &lt;/tr&gt;                                  \n&quot;</span>)
			(<span class="keyword">if</span> (string= TAG tag-started) <span class="string">&quot;&amp;nbsp;&quot;</span>
			  (format <span class="string">&quot;&lt;a name=\&quot;%s\&quot;&gt;%s&lt;/a&gt;&quot;</span> TAG TAG))
			file (or <a href="htmlfontify.el.html#hfy-link-extn.257">hfy-link-extn</a> <a href="htmlfontify.el.html#hfy-extn.242">hfy-extn</a>) file
			file (or <a href="htmlfontify.el.html#hfy-link-extn.257">hfy-link-extn</a> <a href="htmlfontify.el.html#hfy-extn.242">hfy-extn</a>) TAG line line))
		      (setq tag-started TAG))))
		(gethash TAG cache-hash)))) tag-list) 
	  (insert <span class="string">&quot;&lt;/table&gt;\n&quot;</span>)
	  (insert (funcall <a href="htmlfontify.el.html#hfy-page-footer.236">hfy-page-footer</a> <a href="htmlfontify.el.html#hfy-index-file.274">hfy-index-file</a>))
	  (cd dstdir)
	  (write-file  index-file)
	  (kill-buffer index-buf )))) )

<a name="hfy-write-index.1440"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#hfy-write-index.1440">hfy-write-index</a></span> (srcdir dstdir)
  <span class="string">&quot;Write out the index file\(s\), as determined by `</span><span class="constant"><a href="htmlfontify.el.html#hfy-split-index.229">hfy-split-index</a></span><span class="string">'.&quot;</span>
  (<span class="keyword">if</span> (not <a href="htmlfontify.el.html#hfy-split-index.229">hfy-split-index</a>)
      (<a href="htmlfontify.el.html#hfy-write-index-i.1387">hfy-write-index-i</a> srcdir dstdir)
    (<span class="keyword">let</span> ((stub-list     nil)
	  (cache-hash    nil)
	  (cache-entry  (assoc srcdir <a href="htmlfontify.el.html#hfy-tags-cache.422">hfy-tags-cache</a>)))
      (<span class="keyword">if</span> (and cache-entry (setq cache-hash (cadr cache-entry)))
	  (maphash
	   (<span class="keyword">lambda</span> (K V)
	     (<span class="keyword">let</span> ((stub (upcase (substring K 0 1))))
	       (<span class="keyword">if</span> (member stub stub-list)
		   nil <span class="comment">;; seen this already: NOOP
</span>		 (setq stub-list (cons stub stub-list))
		 (<a href="htmlfontify.el.html#hfy-write-index-i.1387">hfy-write-index-i</a> srcdir dstdir stub)))) cache-hash)))) )

<a name="htmlfontify-run-etags.1456"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#htmlfontify-run-etags.1456">htmlfontify-run-etags</a></span> (srcdir)
  <span class="string">&quot;Load the etags cache for SRCDIR. See `</span><span class="constant"><a href="htmlfontify.el.html#hfy-load-tags-cache.1342">hfy-load-tags-cache</a></span><span class="string">'.&quot;</span>
  (interactive <span class="string">&quot;D source directory: &quot;</span>)
  (setq srcdir (directory-file-name srcdir))
  (<a href="htmlfontify.el.html#hfy-load-tags-cache.1342">hfy-load-tags-cache</a> srcdir))

<span class="comment">;;(defun hfy-test-read-args (foo bar)
;;  (interactive &quot;D source directory: \nD target directory: &quot;)
;;  (message &quot;foo: %S\nbar: %S&quot; foo bar))
</span>
<a name="htmlfontify-copy-and-link-dir.1466"></a>(<span class="keyword">defun</span> <span class="function-name"><a href="htmlfontify.el.html#htmlfontify-copy-and-link-dir.1466">htmlfontify-copy-and-link-dir</a></span> (srcdir dstdir <span class="type">&amp;optional</span> f-ext l-ext)
  <span class="string">&quot;Trawl SRCDIR and write fontified-and-hyperlinked output in DSTDIR.\n
F-EXT and L-EXT specify values for `</span><span class="constant"><a href="htmlfontify.el.html#hfy-extn.242">hfy-extn</a></span><span class="string">' and `</span><span class="constant"><a href="htmlfontify.el.html#hfy-link-extn.257">hfy-link-extn</a></span><span class="string">'.\n
You may also want to set `</span><span class="constant"><a href="htmlfontify.el.html#hfy-page-header.220">hfy-page-header</a></span><span class="string">' and `</span><span class="constant"><a href="htmlfontify.el.html#hfy-page-footer.236">hfy-page-footer</a></span><span class="string">'.&quot;</span>
  (interactive <span class="string">&quot;D source directory: \nD output directory: &quot;</span>)
  <span class="comment">;;(message &quot;htmlfontify-copy-and-link-dir&quot;)
</span>  (setq srcdir (directory-file-name srcdir))
  (setq dstdir (directory-file-name dstdir))
  (<span class="keyword">let</span> ((source-files <span class="string">&quot;SETME: list of source files, relative to srcdir&quot;</span>)
	(<a href="htmlfontify.el.html#hfy-extn.242">hfy-extn</a>            (or f-ext <span class="string">&quot;.html&quot;</span>))
	(<a href="htmlfontify.el.html#hfy-link-extn.257">hfy-link-extn</a>       (or l-ext <span class="string">&quot;.html&quot;</span>)))
    (<a href="htmlfontify.el.html#hfy-make-directory.1153">hfy-make-directory</a> dstdir)
    (setq source-files (<a href="htmlfontify.el.html#hfy-list-files.1133">hfy-list-files</a> srcdir))
    (mapcar (<span class="keyword">lambda</span> (file)
	      (<a href="htmlfontify.el.html#hfy-copy-and-fontify-file.1162">hfy-copy-and-fontify-file</a> srcdir dstdir file)) source-files)
    (<a href="htmlfontify.el.html#hfy-write-index.1440">hfy-write-index</a> srcdir dstdir)) )
  
(<span class="keyword">provide</span> '<span class="constant"><a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a></span>)
  
<span class="comment">;; TLF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; this is for part of the build system for rtfm.etla.org: 
;; it's not really part of htmlfontify-buffer - but it's an example
;; of how to use it:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (defun rtfm-build-page-header (file style)
;;   (format &quot;#define  TEMPLATE red+black.html
;; #define  DEBUG    1
;; #include &lt;build/menu-dirlist|&gt;\n
;; html-css-url := /css/red+black.css
;; title        := rtfm.etla.org ( %s / src/%s )
;; bodytag      := 
;; head         &lt;=STYLESHEET;\n
;; %s
;; STYLESHEET
;; main-title   := rtfm / %s / src/%s\n
;; main-content &lt;=MAIN_CONTENT;\n&quot; rtfm-section file style rtfm-section file))

;; (defun rtfm-build-page-footer (file) &quot;\nMAIN_CONTENT\n&quot;)

;; (defun rtfm-build-source-docs (section srcdir destdir)
;;   (interactive
;;    &quot;s section[eg- emacs / p4-blame]:\nD source-dir: \nD output-dir: &quot;)
;;   (require 'htmlfontify)
;;   (hfy-load-tags-cache srcdir)
;;   (let ((hfy-page-header  'rtfm-build-page-header)
;; 	(hfy-page-footer  'rtfm-build-page-footer)
;; 	(rtfm-section                     section)
;; 	(hfy-index-file                   &quot;index&quot;))
;;     (htmlfontify-run-etags srcdir)
;;     (htmlfontify-copy-and-link-dir srcdir destdir &quot;.src&quot; &quot;.html&quot;)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
</span>
</pre>

 
     </td>
    </tr>

   </table>
  </body>
</html>

Valid HTML 4.01! Valid CSS! Any Browser Debian Pepperfish