|
rtfm / Emacs / htmlfontify / again...
|
|
<!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="../"><<</a> <br> <a href="htmlfontify.el.html">htmlfontify.el</a><br> <a href="hfy-cmap.el.html">hfy-cmap.el</a><br> <a href="index.html">index</a><br> <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 <vivek@etla.org> ;; 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 -> 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 <span><a>foo</span></a> 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 >> </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 << ;; emacs 20 compatibility: </span>(<span class="keyword">eval-and-compile</span> (<span class="keyword">if</span> (<= 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">&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">&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">&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">&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">"Return the `</span><span class="constant">car</span><span class="string">' of the `</span><span class="constant">cddr</span><span class="string">' of LIST."</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">"Return the `</span><span class="constant">cadr</span><span class="string">' of the `</span><span class="constant">cddr</span><span class="string">' of LIST."</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">"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">'"</span> <span class="builtin">:group</span> 'applications <span class="builtin">:prefix</span> <span class="string">"hfy-"</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">"*Function called with two arguments \(the filename relative to the top level source directory being etag\'d and fontified), and a string containing the <style>...</style> 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">'"</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">"*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."</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">"*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\)."</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">".html" "*File extension used for output files"</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">"text-decoration: underline;" "*String to add to the \'<style> a\' variant of an <a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a> css class."</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">" text-decoration: none;" "*Regex to remove from the <style> a variant of an <a href="htmlfontify.el.html#htmlfontify.210">htmlfontify</a> css class."</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">"*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">'."</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">"*Set this to a function, which will be called with one argument \(a \"{ foo: bar; ...}\" 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."</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">"hfy-index" "*Name \(sans extension\) of the index file produced during fontification-and-hyperlinking."</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">"\\(<\\|\"\\|&\\|>\\)" "*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."</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">"*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."</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">"*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 \"black\" :foreground \"white\" :family \"misc-fixed\"\)\)"</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">".*" "\x7f" "\\(.+\\)" "\x01" "\\([0-9]+\\)" "," "\\([0-9]+\\)$"</span>) <span class="string">"*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."</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;"</span>) (<span class="string">"<" "&lt;"</span> ) (<span class="string">"&" "&amp;"</span> ) (<span class="string">">" "&gt;"</span> )) <span class="string">"*Alist of char -> entity mappings used to make the text html-safe."</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">"etags -R -f -" "*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."</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">"find . -type f \\! -name \\*~ \\! -name \\*.flc \\! -path \\*/CVS/\\*" "*find command used to harvest a list of files to attempt to fontify."</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">"*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."</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">"X11"</span> x-toolkit) (const <span class="builtin">:tag</span> <span class="string">"Terminal"</span> tty ) (const <span class="builtin">:tag</span> <span class="string">"Lucid Toolkit"</span> lucid ) (const <span class="builtin">:tag</span> <span class="string">"Motif Toolkit"</span> motif ))) (class (choice (const <span class="builtin">:tag</span> <span class="string">"Colour"</span> color ) (const <span class="builtin">:tag</span> <span class="string">"Greyscale"</span> grayscale))) (background (choice (const <span class="builtin">:tag</span> <span class="string">"Dark"</span> dark ) (const <span class="builtin">:tag</span> <span class="string">"Bright"</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">"*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."</span> <span class="builtin">:type</span> '(set (const <span class="builtin">:tag</span> <span class="string">"merge-adjacent-tags"</span> merge-adjacent-tags) (const <span class="builtin">:tag</span> <span class="string">"zap-comment-links"</span> zap-comment-links ) (const <span class="builtin">:tag</span> <span class="string">"zap-string-links"</span> zap-string-links ) (const <span class="builtin">:tag</span> <span class="string">"kill-context-leak"</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">"*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"</span> <span class="builtin">:type</span> '(choice (const <span class="builtin">:tag</span> <span class="string">"none"</span> nil) (integer <span class="builtin">:tag</span> <span class="string">"size"</span>) (repeat <span class="builtin">:menu-tag</span> <span class="string">"mode specific"</span> <span class="builtin">:tag</span> <span class="string">"mode specific"</span> <span class="builtin">:value</span> ((t . nil)) (cons <span class="builtin">:tag</span> <span class="string">"Instance"</span> (radio <span class="builtin">:tag</span> <span class="string">"Mode"</span> (const <span class="builtin">:tag</span> <span class="string">"all"</span> t) (symbol <span class="builtin">:tag</span> <span class="string">"name"</span>)) (radio <span class="builtin">:tag</span> <span class="string">"Size"</span> (const <span class="builtin">:tag</span> <span class="string">"none"</span> nil) (integer <span class="builtin">:tag</span> <span class="string">"size"</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">"Alist of the form\n \(\(\"/src/dir/0\" . tag-hash0\) \(\"/src/dir/1\" tag-hash1\) ...\)\n Each tag hash entry then contains entries of the form:\n \"tag_string\" => ((\"file/name.ext\" 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">'."</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">"Alist of the form \(\(\"/src/dir\" . (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">'."</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">"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\) => \(\(\"background\" . \"rgb\(0, 0, 0\)\"\) \(\"color\" . \"rgb\(255, 255, 255\)\"\) \(\"font-style\" . \"normal\"\) \(\"font-weight\" . \"500\"\) \(\"font-stretch\" . \"normal\"\) \(\"font-family\" . \"misc-fixed\"\) \(\"font-size\" . \"13pt\"\) \(\"text-decoration\" . \"none\"\)\)\n \(<a href="htmlfontify.el.html#hfy-face-to-style.745">hfy-face-to-style</a> 'Info-title-3-face\) => \(\(\"font-weight\" . \"700\"\) \(\"font-family\" . \"helv\"\) \(\"font-size\" . \"120%\"\) \(\"text-decoration\" . \"none\"\)\)\n"</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">"[0-9A-Fa-f]"</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">"\\("</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">"\\)" "\\("</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">"\\)" "\\("</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">"\\)"</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">"Return the intersection \(using `</span><span class="constant">eq</span><span class="string">'\) of 2 lists."</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 "hfy-colour-vals");;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 ">> %s" colour) </span> (<span class="keyword">if</span> window-system (<span class="keyword">if</span> (fboundp 'color-values) (color-values colour) <span class="comment">;;(message "[%S]" 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">"cperl mode does its damndest not to do some of its fontification when not in a windowing system - try to trick it..."</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">"cperl-mode"</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">"Default value for `</span><span class="constant"><a href="htmlfontify.el.html#hfy-page-header.220">hfy-page-header</a></span><span class="string">'"</span> (format <span class="string">"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> <html>\n <head>\n <title>%s</title>\n %s\n </head>\n <body>\n"</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">"Default value for `</span><span class="constant"><a href="htmlfontify.el.html#hfy-page-footer.236">hfy-page-footer</a></span><span class="string">'" "\n </body>\n</html>\n"</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">"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."</span> <span class="comment">;;(message "hfy-colour-vals");;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">""</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">"} *$"</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">" }"</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">"Takes a colour name (string) and return a css rgb(R, G, B) triplet string. Uses the definition of \"white\" 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)"</span> <span class="comment">;;(message "hfy-colour-vals");;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">"white"</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">"rgb(%d, %d, %d)"</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">"font-family"</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">"background"</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">"color"</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">"font-stretch"</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">"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"</span> (list (<span class="keyword">cond</span> ((floatp height) (cons <span class="string">"font-size"</span> (format <span class="string">"%d%%"</span> (* height 100)))) ((integerp height) (cons <span class="string">"font-size"</span> (format <span class="string">"%dpt"</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">"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."</span> (list (cons <span class="string">"font-style"</span> (<span class="keyword">cond</span> ((eq 'italic slant) <span class="string">"italic"</span> ) ((eq 'reverse-italic slant) <span class="string">"italic"</span> ) ((eq 'oblique slant) <span class="string">"oblique"</span>) ((eq 'reverse-oblique slant) <span class="string">"oblique"</span>) (t <span class="string">"normal"</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">"Derive a font-weight css specifier from an emacs weight spec symbol."</span> (list (cons <span class="string">"font-weight"</span> (<span class="keyword">cond</span> ((eq 'ultra-bold weight) <span class="string">"900"</span>) ((eq 'extra-bold weight) <span class="string">"800"</span>) ((eq 'bold weight) << |