annotate lisp/htmlfontify.el @ 112448:9e4388bac77b

* etc/images/README: Add 2011 to copyright years for (un)checked.xpm.
author Glenn Morris <rgm@gnu.org>
date Sun, 23 Jan 2011 17:30:35 -0800
parents 56d3e9c28eb0
children 7e12e8b5864c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1 ;;; htmlfontify.el --- htmlise a buffer/source tree with optional hyperlinks
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2
112284
61f7601898b1 Refill some copyright headers.
Glenn Morris <rgm@gnu.org>
parents: 112230
diff changeset
3 ;; Copyright (C) 2002, 2003, 2009, 2010, 2011
61f7601898b1 Refill some copyright headers.
Glenn Morris <rgm@gnu.org>
parents: 112230
diff changeset
4 ;; Free Software Foundation, Inc.
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
5
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
6 ;; Emacs Lisp Archive Entry
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
7 ;; Package: htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
8 ;; Filename: htmlfontify.el
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
9 ;; Version: 0.21
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
10 ;; Keywords: html, hypermedia, markup, etags
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
11 ;; Author: Vivek Dasmohapatra <vivek@etla.org>
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
12 ;; Maintainer: Vivek Dasmohapatra <vivek@etla.org>
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
13 ;; Created: 2002-01-05
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
14 ;; Description: htmlise a buffer/source tree with optional hyperlinks
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
15 ;; URL: http://rtfm.etla.org/emacs/htmlfontify/
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
16 ;; Compatibility: Emacs23, Emacs22
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
17 ;; Incompatibility: Emacs19, Emacs20, Emacs21
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
18 ;; Last Updated: Thu 2009-11-19 01:31:21 +0000
110016
a3e1f7134e6e Add "Version:" and "Package:" Lisp file headers.
Chong Yidong <cyd@stupidchicken.com>
parents: 109302
diff changeset
19 ;; Version: 0.21
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
20
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
21 ;; This file is part of GNU Emacs.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
22
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
23 ;; GNU Emacs is free software: you can redistribute it and/or modify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
24 ;; it under the terms of the GNU General Public License as published by
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
25 ;; the Free Software Foundation, either version 3 of the License, or
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
26 ;; (at your option) any later version.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
27
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
28 ;; GNU Emacs is distributed in the hope that it will be useful,
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
29 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
30 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
31 ;; GNU General Public License for more details.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
32
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
33 ;; You should have received a copy of the GNU General Public License
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
34 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
35
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
36 ;;; Commentary:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
38 ;; I have made some changes to make it work for Emacs 22. A lot of
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
39 ;; small bug fixes related to the format of text and overlay
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
40 ;; properties (which might have changed since the beginning of 2003
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
41 ;; when this file was originally written).
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
42 ;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
43 ;; The function `hfy-face-at' currently carries much of the burden of
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
44 ;; my lacking understanding of the formats mentioned above and should
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
45 ;; need some knowledgeable help.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46 ;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47 ;; Another thing that maybe could be fixed is that overlay background
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48 ;; colors which are now only seen where there is text (in the XHTML
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
49 ;; output). A bit of CSS tweaking is necessary there.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50 ;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51 ;; The face 'default has a value :background "SystemWindow" for the
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
52 ;; background color. There is no explicit notion that this should be
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53 ;; considered transparent, but I have assumed that it could be handled
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
54 ;; like if it was here. (I am unsure that background and foreground
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55 ;; priorities are handled ok, but it looks ok in my tests now.)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56 ;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 ;; 2007-12-27 Lennart Borgman
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60 ;; Here's some elisp code to html-pretty-print an Emacs buffer, preserving
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 ;; the Emacs syntax/whatever highlighting. It also knows how to drive etags
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
62 ;; (exuberant-ctags or Emacs etags) and hyperlink the code according
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
63 ;; to its (etags') output.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65 ;; NOTE: Currently the hyperlinking code only knows how to drive GNU find
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 ;; and the exuberant and GNU variants of etags : I do not know of any other
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67 ;; etags variants, but mechanisms have been provided to allow htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
68 ;; to be taught how to drive them. As long as your version of find has
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
69 ;; the -path test and is reasonably sane, you should be fine.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
70
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
71 ;; A sample of the htmlfontified / hyperlinked output of this module can be
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
72 ;; found at http://rtfm.etla.org/sql/dbishell/src/ - it's not perfect, but
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
73 ;; it's a hell of a lot faster and more thorough than I could hope to be
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
74 ;; doing this by hand.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
75
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
76 ;; some user / horrified onlooker comments:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
77 ;; What? No! There's something deeply wrong here... (R. Shufflebotham)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
78 ;; You're a freak. (D. Silverstone)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
79 ;; Aren't we giving you enough to do? (J. Busuttil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
80 ;; You're almost as messed up as Lexx is! (N. Graves-Morris)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
81
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
82 ;;; History:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
83 ;; Changes: moved to changelog (CHANGES) file.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
84
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
85 ;;; Code:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
86 (eval-when-compile (require 'cl))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
87 (require 'faces)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
88 ;; (`facep' `face-attr-construct' `x-color-values' `color-values' `face-name')
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
89 (require 'custom)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 ;; (`defgroup' `defcustom')
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
91 (require 'font-lock)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
92 ;; (`font-lock-fontify-region')
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
93 (require 'cus-edit)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
94
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
95 (defconst htmlfontify-version 0.21)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
96
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
97 (defconst hfy-meta-tags
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
98 (format "<meta name=\"generator\" content=\"emacs %s; htmlfontify %0.2f\" />"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
99 emacs-version htmlfontify-version)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
100 "The generator meta tag for this version of htmlfontify.")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
101
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
102 (defconst htmlfontify-manual "Htmlfontify Manual"
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
103 "Copy and convert buffers and files to HTML, adding hyperlinks between files
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
104 \(driven by etags) if requested.
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
105 \nInteractive functions:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
106 `htmlfontify-buffer'
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
107 `htmlfontify-run-etags'
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
108 `htmlfontify-copy-and-link-dir'
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
109 `htmlfontify-load-rgb-file'
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
110 `htmlfontify-unload-rgb-file'\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
111 In order to:\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
112 fontify a file you have open: M-x htmlfontify-buffer
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
113 prepare the etags map for a directory: M-x htmlfontify-run-etags
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
114 copy a directory, fontifying as you go: M-x htmlfontify-copy-and-link-dir\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
115 The following might be useful when running non-windowed or in batch mode:
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
116 \(note that they shouldn't be necessary - we have a built in map)\n
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
117 load an X11 style rgb.txt file: M-x htmlfontify-load-rgb-file
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
118 unload the current rgb.txt file: M-x htmlfontify-unload-rgb-file\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
119 And here's a programmatic example:\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
120 \(defun rtfm-build-page-header (file style)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
121 (format \"#define TEMPLATE red+black.html
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
122 #define DEBUG 1
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
123 #include <build/menu-dirlist|>\\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
124 html-css-url := /css/red+black.css
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
125 title := rtfm.etla.org ( %s / src/%s )
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
126 bodytag :=
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
127 head <=STYLESHEET;\\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
128 %s
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
129 STYLESHEET
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
130 main-title := rtfm / %s / src/%s\\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
131 main-content <=MAIN_CONTENT;\\n\" rtfm-section file style rtfm-section file))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
132
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
133 \(defun rtfm-build-page-footer (file) \"\\nMAIN_CONTENT\\n\")
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
134
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
135 \(defun rtfm-build-source-docs (section srcdir destdir)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
136 (interactive
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
137 \"s section[eg- emacs / p4-blame]:\\nD source-dir: \\nD output-dir: \")
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
138 (require 'htmlfontify)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
139 (hfy-load-tags-cache srcdir)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
140 (let ((hfy-page-header 'rtfm-build-page-header)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
141 (hfy-page-footer 'rtfm-build-page-footer)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
142 (rtfm-section section)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
143 (hfy-index-file \"index\"))
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
144 (htmlfontify-run-etags srcdir)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
145 (htmlfontify-copy-and-link-dir srcdir destdir \".src\" \".html\")))")
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
146
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
147 (defgroup htmlfontify nil
107207
f9121af0ebc9 Minor doc fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
148 "Convert buffers and files to HTML."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
149 :group 'applications
107207
f9121af0ebc9 Minor doc fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
150 :link '(variable-link htmlfontify-manual)
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
151 :prefix "hfy-")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
152
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
153 (defcustom hfy-page-header 'hfy-default-header
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
154 "Function called with two arguments (the filename relative to the top
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
155 level source directory being etag'd and fontified), and a string containing
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
156 the <style>...</style> text to embed in the document- the string returned will
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
157 be used as the header for the htmlfontified version of the source file.\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
158 See also `hfy-page-footer'."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
159 :group 'htmlfontify
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
160 ;; FIXME: Why place such a :tag everywhere? Isn't it imposing your
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
161 ;; own Custom preference on your users? --Stef
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
162 :tag "page-header"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
163 :type '(function))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
164
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
165 (defcustom hfy-split-index nil
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
166 "Whether or not to split the index `hfy-index-file' alphabetically
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
167 on the first letter of each tag. Useful when the index would otherwise
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
168 be large and take a long time to render or be difficult to navigate."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
169 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
170 :tag "split-index"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
171 :type '(boolean))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
172
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
173 (defcustom hfy-page-footer 'hfy-default-footer
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
174 "As `hfy-page-header', but generates the output footer
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
175 \(and takes only one argument, the filename)."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
176 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
177 :tag "page-footer"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
178 :type '(function))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
179
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
180 (defcustom hfy-extn ".html"
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
181 "File extension used for output files."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
182 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
183 :tag "extension"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
184 :type '(string))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
185
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
186 (defcustom hfy-src-doc-link-style "text-decoration: underline;"
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
187 "String to add to the '<style> a' variant of an htmlfontify CSS class."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
188 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
189 :tag "src-doc-link-style"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
190 :type '(string))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
191
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
192 (defcustom hfy-src-doc-link-unstyle " text-decoration: none;"
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
193 "Regex to remove from the <style> a variant of an htmlfontify CSS class."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
194 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
195 :tag "src-doc-link-unstyle"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
196 :type '(string))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
197
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
198 (defcustom hfy-link-extn nil
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
199 "File extension used for href links.
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
200 Useful where the htmlfontify output files are going to be processed
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
201 again, with a resulting change in file extension. If nil, then any
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
202 code using this should fall back to `hfy-extn'."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
203 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
204 :tag "link-extension"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
205 :type '(choice string (const nil)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
206
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
207 (defcustom hfy-link-style-fun 'hfy-link-style-string
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
208 "Set this to a function, which will be called with one argument
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
209 \(a \"{ foo: bar; ...}\" CSS style-string) - it should return a copy of
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
210 its argument, altered so as to make any changes you want made for text which
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
211 is a hyperlink, in addition to being in the class to which that style would
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
212 normally be applied."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
213 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
214 :tag "link-style-function"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
215 :type '(function))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
216
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
217 (defcustom hfy-index-file "hfy-index"
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
218 "Name (sans extension) of the tag definition index file produced during
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
219 fontification-and-hyperlinking."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
220 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
221 :tag "index-file"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
222 :type '(string))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
223
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
224 (defcustom hfy-instance-file "hfy-instance"
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
225 "Name (sans extension) of the tag usage index file produced during
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
226 fontification-and-hyperlinking."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
227 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
228 :tag "instance-file"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
229 :type '(string))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
230
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
231 (defcustom hfy-html-quote-regex "\\(<\\|\"\\|&\\|>\\)"
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
232 "Regex to match (with a single back-reference per match) strings in HTML
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
233 which should be quoted with `hfy-html-quote' (and `hfy-html-quote-map')
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
234 to make them safe."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
235 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
236 :tag "html-quote-regex"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
237 :type '(regexp))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
238
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
239 (define-obsolete-variable-alias 'hfy-init-kludge-hooks 'hfy-init-kludge-hook
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
240 "23.2")
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
241 (defcustom hfy-init-kludge-hook '(hfy-kludge-cperl-mode)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
242 "List of functions to call when starting `htmlfontify-buffer' to do any
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
243 kludging necessary to get highlighting modes to behave as you want, even
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
244 when not running under a window system."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
245 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
246 :tag "init-kludge-hooks"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
247 :type '(hook))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
248
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
249 (defcustom hfy-post-html-hooks nil
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
250 "List of functions to call after creating and filling the HTML buffer.
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
251 These functions will be called with the html buffer as the current buffer."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
252 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
253 :tag "post-html-hooks"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
254 :options '(set-auto-mode)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
255 :type '(hook))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
256
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
257 (defcustom hfy-default-face-def nil
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
258 "Fallback `defface' specification for the face 'default, used when
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
259 `hfy-display-class' has been set (the normal htmlfontify way of extracting
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
260 potentially non-current face information doesn't necessarily work for
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
261 'default).\n
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
262 Example: I customize this to:\n
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
263 \((t :background \"black\" :foreground \"white\" :family \"misc-fixed\"))"
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
264 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
265 :tag "default-face-definition"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
266 :type '(alist))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
267
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
268 (defcustom hfy-etag-regex (concat ".*"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
269 "\x7f" "\\([^\x01\n]+\\)"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
270 "\x01" "\\([0-9]+\\)"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
271 "," "\\([0-9]+\\)$"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
272 "\\|" ".*\x7f[0-9]+,[0-9]+$")
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
273 "Regex used to parse an etags entry: must have 3 subexps, corresponding,
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
274 in order, to:\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
275 1 - The tag
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
276 2 - The line
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
277 3 - The char (point) at which the tag occurs."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
278 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
279 :tag "etag-regex"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
280 :type '(regexp))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
281
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
282 (defcustom hfy-html-quote-map '(("\"" "&quot;")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
283 ("<" "&lt;" )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
284 ("&" "&amp;" )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
285 (">" "&gt;" ))
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
286 "Alist of char -> entity mappings used to make the text HTML-safe."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
287 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
288 :tag "html-quote-map"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
289 :type '(alist :key-type (string)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
290 (eval-and-compile
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
291 (defconst hfy-e2x-etags-cmd "for src in `find . -type f`;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
292 do
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
293 ETAGS=%s;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
294 case ${src} in
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
295 *.ad[absm]|*.[CFHMSacfhlmpsty]|*.def|*.in[cs]|*.s[as]|*.src|*.cc|\\
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
296 *.hh|*.[chy]++|*.[ch]pp|*.[chy]xx|*.pdb|*.[ch]s|*.[Cc][Oo][Bb]|\\
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
297 *.[eh]rl|*.f90|*.for|*.java|*.[cem]l|*.clisp|*.lisp|*.[Ll][Ss][Pp]|\\
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
298 [Mm]akefile*|*.pas|*.[Pp][LlMm]|*.psw|*.lm|*.pc|*.prolog|*.oak|\\
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
299 *.p[sy]|*.sch|*.scheme|*.[Ss][Cc][Mm]|*.[Ss][Mm]|*.bib|*.cl[os]|\\
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
300 *.ltx|*.sty|*.TeX|*.tex|*.texi|*.texinfo|*.txi|*.x[bp]m|*.yy|\\
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
301 *.[Ss][Qq][Ll])
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
302 ${ETAGS} -o- ${src};
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
303 ;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
304 *)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
305 FTYPE=`file ${src}`;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
306 case ${FTYPE} in
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
307 *script*text*)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
308 ${ETAGS} -o- ${src};
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
309 ;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
310 *text*)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
311 SHEBANG=`head -n1 ${src} | grep '#!' -c`;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
312 if [ ${SHEBANG} -eq 1 ];
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
313 then
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
314 ${ETAGS} -o- ${src};
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
315 fi;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
316 ;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
317 esac;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
318 ;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
319 esac;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
320 done;")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
321
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
322 (defconst hfy-etags-cmd-alist-default
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
323 `(("emacs etags" . ,hfy-e2x-etags-cmd)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
324 ("exuberant ctags" . "%s -R -f -" )))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
325
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
326 (defcustom hfy-etags-cmd-alist
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
327 hfy-etags-cmd-alist-default
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
328 "Alist of possible shell commands that will generate etags output that
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
329 `htmlfontify' can use. '%s' will be replaced by `hfy-etags-bin'."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
330 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
331 :tag "etags-cmd-alist"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
332 :type '(alist :key-type (string) :value-type (string)) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
333
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
334 (defcustom hfy-etags-bin "etags"
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
335 "Location of etags binary (we begin by assuming it's in your path).\n
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
336 Note that if etags is not in your path, you will need to alter the shell
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
337 commands in `hfy-etags-cmd-alist'."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
338 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
339 :tag "etags-bin"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
340 :type '(file))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
341
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
342 (defcustom hfy-shell-file-name "/bin/sh"
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
343 "Shell (bourne or compatible) to invoke for complex shell operations."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
344 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
345 :tag "shell-file-name"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
346 :type '(file))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
347
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
348 (defcustom hfy-ignored-properties '(read-only
106505
7287842d7e07 Drop some properties to avoid surprises.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106352
diff changeset
349 intangible
7287842d7e07 Drop some properties to avoid surprises.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106352
diff changeset
350 modification-hooks
7287842d7e07 Drop some properties to avoid surprises.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106352
diff changeset
351 insert-in-front-hooks
7287842d7e07 Drop some properties to avoid surprises.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106352
diff changeset
352 insert-behind-hooks
7287842d7e07 Drop some properties to avoid surprises.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106352
diff changeset
353 point-entered
7287842d7e07 Drop some properties to avoid surprises.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106352
diff changeset
354 point-left)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
355 "Properties to omit when copying a fontified buffer for HTML transformation."
106505
7287842d7e07 Drop some properties to avoid surprises.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106352
diff changeset
356 :group 'htmlfontify
7287842d7e07 Drop some properties to avoid surprises.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106352
diff changeset
357 :tag "ignored-properties"
7287842d7e07 Drop some properties to avoid surprises.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106352
diff changeset
358 :type '(repeat symbol))
7287842d7e07 Drop some properties to avoid surprises.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106352
diff changeset
359
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
360 (defun hfy-which-etags ()
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
361 "Return a string indicating which flavour of etags we are using."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
362 (let ((v (shell-command-to-string (concat hfy-etags-bin " --version"))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
363 (cond ((string-match "exube" v) "exuberant ctags")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
364 ((string-match "GNU E" v) "emacs etags" )) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
365
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
366 (defcustom hfy-etags-cmd
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
367 (eval-and-compile (cdr (assoc (hfy-which-etags) hfy-etags-cmd-alist)))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
368 "The etags equivalent command to run in a source directory to generate a tags
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
369 file for the whole source tree from there on down. The command should emit
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
370 the etags output on stdout.\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
371 Two canned commands are provided - they drive Emacs' etags and
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
372 exuberant-ctags' etags respectively."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
373 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
374 :tag "etags-command"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
375 :type (eval-and-compile
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
376 (let ((clist (list '(string))))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
377 (dolist (C hfy-etags-cmd-alist)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
378 (push (list 'const :tag (car C) (cdr C)) clist))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
379 (cons 'choice clist)) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
380
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
381 (defcustom hfy-istext-command "file %s | sed -e 's@^[^:]*:[ \t]*@@'"
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
382 "Command to run with the name of a file, to see whether it is a text file
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
383 or not. The command should emit a string containing the word 'text' if
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
384 the file is a text file, and a string not containing 'text' otherwise."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
385 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
386 :tag "istext-command"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
387 :type '(string))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
388
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
389 (defcustom hfy-find-cmd
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
390 "find . -type f \\! -name \\*~ \\! -name \\*.flc \\! -path \\*/CVS/\\*"
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
391 "Find command used to harvest a list of files to attempt to fontify."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
392 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
393 :tag "find-command"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
394 :type '(string))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
395
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
396 (defcustom hfy-display-class nil
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
397 "Display class to use to determine which display class to use when
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
398 calculating a face's attributes. This is useful when, for example, you
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
399 are running Emacs on a tty or in batch mode, and want htmlfontify to have
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
400 access to the face spec you would use if you were connected to an X display.\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
401 Some valid class specification elements are:\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
402 '(class color)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
403 '(class grayscale)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
404 '(background dark)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
405 '(background light)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
406 '(type x-toolkit)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
407 '(type tty)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
408 '(type motif)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
409 '(type lucid)
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
410 Multiple values for a tag may be combined, to indicate that any one or more
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
411 of these values in the specification key constitutes a match, eg:\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
412 '((class color grayscale) (type tty)) would match any of:\n
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
413 '((class color))
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
414 '((class grayscale))
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
415 '((class color grayscale))
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
416 '((class color foo))
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
417 '((type tty))
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
418 '((type tty) (class color))\n
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
419 and so on."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
420 :type '(alist :key-type (symbol) :value-type (symbol))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
421 :group 'htmlfontify
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
422 :tag "display-class"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
423 :options '((type (choice (const :tag "X11" x-toolkit)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
424 (const :tag "Terminal" tty )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
425 (const :tag "Lucid Toolkit" lucid )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
426 (const :tag "Motif Toolkit" motif )))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
427
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
428 (class (choice (const :tag "Colour" color )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
429 (const :tag "Greyscale" grayscale)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
430
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
431 (background (choice (const :tag "Dark" dark )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
432 (const :tag "Bright" light ))) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
433
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
434 (defcustom hfy-optimisations (list 'keep-overlays)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
435 "Optimizations to turn on: So far, the following have been implemented:\n
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
436 merge-adjacent-tags: If two (or more) span tags are adjacent, identical and
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
437 separated by nothing more than whitespace, they will
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
438 be merged into one span.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
439 zap-comment-links : Suppress hyperlinking of tags found in comments.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
440 zap-string-links : Suppress hyperlinking of tags found in strings.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
441 div-wrapper : Add <div class=\"default\"> </div> tags around the
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
442 output.
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
443 keep-overlays : More of a bell (or possibly whistle) than an
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
444 optimization - If on, preserve overlay highlighting
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
445 (cf ediff or goo-font-lock) as well as basic faces.\n
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
446 And the following are planned but not yet available:\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
447 kill-context-leak : Suppress hyperlinking between files highlighted by
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
448 different modes.\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
449 Note: like compiler optimizations, these optimize the _output_ of the code,
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
450 not the processing of the source itself, and are therefore likely to slow
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
451 htmlfontify down, at least a little. Except for skip-refontification,
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
452 which can never slow you down, but may result in incomplete fontification."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
453 :type '(set (const :tag "merge-adjacent-tags" merge-adjacent-tags )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
454 (const :tag "zap-comment-links" zap-comment-links )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
455 (const :tag "zap-string-links" zap-string-links )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
456 (const :tag "skip-refontification" skip-refontification)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
457 (const :tag "kill-context-leak" kill-context-leak )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
458 (const :tag "div-wrapper" div-wrapper )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
459 (const :tag "keep-overlays" keep-overlays ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
460 :group 'htmlfontify
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
461 :tag "optimizations")
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
462
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
463 (defvar hfy-tags-cache nil
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
464 "Alist of the form:\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
465 \((\"/src/dir/0\" . tag-hash0) (\"/src/dir/1\" tag-hash1) ...)\n
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
466 Each tag hash entry then contains entries of the form:\n
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
467 \"tag_string\" => ((\"file/name.ext\" line char) ... )\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
468 ie an alist mapping (relative) file paths to line and character offsets.\n
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
469 See also `hfy-load-tags-cache'.")
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
470
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
471 (defvar hfy-tags-sortl nil
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
472 "Alist of the form ((\"/src/dir\" . (tag0 tag1 tag2)) ... )\n
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
473 where the tags are stored in descending order of length.\n
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
474 See also `hfy-load-tags-cache'.")
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
475
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
476 (defvar hfy-tags-rmap nil
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
477 "Alist of the form ((\"/src/dir\" . tag-rmap-hash))\n
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
478 where tag-rmap-hash has entries of the form:
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
479 \"tag_string\" => ( \"file/name.ext\" line char )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
480 Unlike `hfy-tags-cache' these are the locations of occurrences of
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
481 tagged items, not the locations of their definitions.")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
482
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
483 (defvar hfy-style-assoc 'please-ignore-this-line
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
484 "An assoc representing/describing an Emacs face.
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
485 Properties may be repeated, in which case later properties should be
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
486 treated as if they were inherited from a 'parent' font.
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
487 \(For some properties, only the first encountered value is of any importance,
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
488 for others the values might be cumulative, and for others they might be
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
489 cumulative in a complex way.)\n
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
490 Some examples:\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
491 \(hfy-face-to-style 'default) =>
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
492 ((\"background\" . \"rgb(0, 0, 0)\")
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
493 (\"color\" . \"rgb(255, 255, 255)\")
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
494 (\"font-style\" . \"normal\")
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
495 (\"font-weight\" . \"500\")
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
496 (\"font-stretch\" . \"normal\")
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
497 (\"font-family\" . \"misc-fixed\")
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
498 (\"font-size\" . \"13pt\")
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
499 (\"text-decoration\" . \"none\"))\n
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
500 \(hfy-face-to-style 'Info-title-3-face) =>
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
501 ((\"font-weight\" . \"700\")
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
502 (\"font-family\" . \"helv\")
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
503 (\"font-size\" . \"120%\")
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
504 (\"text-decoration\" . \"none\"))\n")
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
505
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
506 (defvar hfy-sheet-assoc 'please-ignore-this-line
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
507 "An assoc with elements of the form (face-name style-name . style-string):\n
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
508 '((default \"default\" . \"{background: black; color: white}\")
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
509 (font-lock-string-face \"string\" . \"{color: rgb(64,224,208)}\"))" )
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
510
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
511 (defvar hfy-facemap-assoc 'please-ignore-this-line
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
512 "An assoc of (point . FACE-SYMBOL) or (point . DEFFACE-LIST)
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
513 and (point . 'end) elements, in descending order of point value
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
514 \(ie from the file's end to its beginning).\n
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
515 The map is in reverse order because inserting a <style> tag (or any other
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
516 string) at `point' invalidates the map for all entries with a greater value of
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
517 point. By traversing the map from greatest to least point, we still invalidate
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
518 the map as we go, but only those points we have already dealt with (and
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
519 therefore no longer care about) will be invalid at any time.\n
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
520 '((64820 . end)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
521 (64744 . font-lock-comment-face)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
522 (64736 . end)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
523 (64722 . font-lock-string-face)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
524 (64630 . end)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
525 (64623 . font-lock-string-face)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
526 (64449 . end)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
527 (64446 . font-lock-keyword-face)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
528 (64406 . end)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
529 (64395 . font-lock-constant-face)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
530 (64393 . end)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
531 (64386 . font-lock-keyword-face)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
532 (64379 . end)
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
533 ;; big similar section elided. You get the idea.
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
534 (4285 . font-lock-constant-face)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
535 (4285 . end)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
536 (4221 . font-lock-comment-face)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
537 (4221 . end)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
538 (4197 . font-lock-constant-face)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
539 (4197 . end)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
540 (1 . font-lock-comment-face))")
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
541
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
542 (defvar hfy-tmpfont-stack nil
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
543 "An alist of derived fonts resulting from overlays.")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
544
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
545 (defconst hfy-hex-regex "[0-9A-Fa-f]")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
546
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
547 (defconst hfy-triplet-regex
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
548 (concat
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
549 "\\(" hfy-hex-regex hfy-hex-regex "\\)"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
550 "\\(" hfy-hex-regex hfy-hex-regex "\\)"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
551 "\\(" hfy-hex-regex hfy-hex-regex "\\)"))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
552
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
553 (defun hfy-interq (set-a set-b)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
554 "Return the intersection (using `eq') of two lists SET-A and SET-B."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
555 (let ((sa set-a) (interq nil) (elt nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
556 (while sa
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
557 (setq elt (car sa)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
558 sa (cdr sa))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
559 (if (memq elt set-b) (setq interq (cons elt interq)))) interq))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
560
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
561 (defun hfy-colour-vals (colour)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
562 "Where COLOUR is a color name or #XXXXXX style triplet, return a
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
563 list of three (16 bit) rgb values for said color.\n
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
564 If a window system is unavailable, calls `hfy-fallback-colour-values'."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
565 (if (string-match hfy-triplet-regex colour)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
566 (mapcar
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
567 (lambda (x) (* (string-to-number (match-string x colour) 16) 257))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
568 '(1 2 3))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
569 ;;(message ">> %s" colour)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
570 (if window-system
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
571 (if (fboundp 'color-values)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
572 (color-values colour)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
573 ;;(message "[%S]" window-system)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
574 (x-color-values colour))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
575 ;; blarg - tty colours are no good - go fetch some X colours:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
576 (hfy-fallback-colour-values colour))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
577
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
578 (defvar hfy-cperl-mode-kludged-p nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
579
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
580 (defun hfy-kludge-cperl-mode ()
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
581 "CPerl mode does its damndest not to do some of its fontification when not
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
582 in a windowing system - try to trick it..."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
583 (if (not hfy-cperl-mode-kludged-p)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
584 (progn (if (not window-system)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
585 (let ((window-system 'htmlfontify))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
586 (eval-and-compile (require 'cperl-mode))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
587 (setq cperl-syntaxify-by-font-lock t)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
588 (setq hfy-cperl-mode-kludged-p t))) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
589
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
590 (defun hfy-opt (symbol) "Is option SYMBOL set." (memq symbol hfy-optimisations))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
591
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
592 (defun hfy-default-header (file style)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
593 "Default value for `hfy-page-header'.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
594 FILE is the name of the file.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
595 STYLE is the inline CSS stylesheet (or tag referring to an external sheet)."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
596 ;; (format "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
597 ;; <html>\n <head>\n <title>%s</title>\n %s\n </head>\n <body>\n" file style))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
598 (format "<?xml version=\"1.0\" encoding=\"utf-8\"?>
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
599 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
600 \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
601 <html xmlns=\"http://www.w3.org/1999/xhtml\">
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
602 <head>
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
603 <title>%s</title>
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
604 %s
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
605 <script type=\"text/javascript\"><!--
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
606 // this function is needed to work around
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
607 // a bug in IE related to element attributes
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
608 function hasClass(obj)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
609 {
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
610 var result = false;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
611 if (obj.getAttributeNode(\"class\") != null)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
612 {
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
613 result = obj.getAttributeNode(\"class\").value;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
614 }
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
615 return result;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
616 }
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
617
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
618 function stripe(id)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
619 {
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
620 // the flag we'll use to keep track of
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
621 // whether the current row is odd or even
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
622 var even = false;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
623
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
624 // if arguments are provided to specify the colors
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
625 // of the even & odd rows, then use the them;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
626 // otherwise use the following defaults:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
627 var evenColor = arguments[1] ? arguments[1] : \"#fff\";
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
628 var oddColor = arguments[2] ? arguments[2] : \"#ddd\";
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
629
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
630 // obtain a reference to the desired table
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
631 // if no such table exists, abort
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
632 var table = document.getElementById(id);
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
633 if (! table) { return; }
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
634
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
635 // by definition, tables can have more than one tbody
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
636 // element, so we'll have to get the list of child
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
637 // &lt;tbody&gt;s
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
638 var tbodies = table.getElementsByTagName(\"tbody\");
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
639
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
640 // and iterate through them...
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
641 for (var h = 0; h < tbodies.length; h++)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
642 {
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
643 // find all the &lt;tr&gt; elements...
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
644 var trs = tbodies[h].getElementsByTagName(\"tr\");
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
645
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
646 // ... and iterate through them
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
647 for (var i = 0; i < trs.length; i++)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
648 {
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
649 // avoid rows that have a class attribute
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
650 // or backgroundColor style
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
651 if (! hasClass(trs[i]) &&
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
652 ! trs[i].style.backgroundColor)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
653 {
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
654 // get all the cells in this row...
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
655 var tds = trs[i].getElementsByTagName(\"td\");
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
656
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
657 // and iterate through them...
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
658 for (var j = 0; j < tds.length; j++)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
659 {
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
660 var mytd = tds[j];
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
661
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
662 // avoid cells that have a class attribute
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
663 // or backgroundColor style
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
664 if (! hasClass(mytd) &&
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
665 ! mytd.style.backgroundColor)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
666 {
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
667 mytd.style.backgroundColor =
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
668 even ? evenColor : oddColor;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
669 }
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
670 }
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
671 }
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
672 // flip from odd to even, or vice-versa
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
673 even = ! even;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
674 }
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
675 }
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
676 }
106270
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
677
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
678 function toggle_invis( name )
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
679 {
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
680 var filter =
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
681 { acceptNode:
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
682 function( node )
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
683 { var classname = node.id;
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
684 if( classname )
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
685 { var classbase = classname.substr( 0, name.length );
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
686 if( classbase == name ) { return NodeFilter.FILTER_ACCEPT; } }
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
687 return NodeFilter.FILTER_SKIP; } };
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
688 var walker = document.createTreeWalker( document.body ,
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
689 NodeFilter.SHOW_ELEMENT ,
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
690 filter ,
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
691 false );
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
692 while( walker.nextNode() )
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
693 {
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
694 var e = walker.currentNode;
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
695 if( e.style.display == \"none\" ) { e.style.display = \"inline\"; }
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
696 else { e.style.display = \"none\"; }
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
697 }
d059492ca39b Various minor fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106128
diff changeset
698 }
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
699 --> </script>
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
700 </head>
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
701 <body onload=\"stripe('index'); return true;\">\n"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
702 file style))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
703
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
704 (defun hfy-default-footer (file)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
705 "Default value for `hfy-page-footer'.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
706 FILE is the name of the file being rendered, in case it is needed."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
707 "\n </body>\n</html>\n")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
708
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
709 (defun hfy-link-style-string (style-string)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
710 "Replace the end of a CSS style declaration STYLE-STRING with the contents
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
711 of the variable `hfy-src-doc-link-style', removing text matching the regex
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
712 `hfy-src-doc-link-unstyle' first, if necessary."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
713 ;;(message "hfy-colour-vals");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
714 (if (string-match hfy-src-doc-link-unstyle style-string)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
715 (setq style-string (replace-match "" 'fixed-case 'literal style-string)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
716 (if (and (not (string-match hfy-src-doc-link-style style-string))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
717 (string-match "} *$" style-string))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
718 (concat (replace-match hfy-src-doc-link-style
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
719 'fixed-case
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
720 'literal
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
721 style-string) " }") style-string))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
722
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
723 ;; utility functions - cast emacs style specification values into their
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
724 ;; css2 equivalents:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
725 (defun hfy-triplet (colour)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
726 "Takes a COLOUR name (string) and return a CSS rgb(R, G, B) triplet string.
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
727 Uses the definition of \"white\" to map the numbers to the 0-255 range, so
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
728 if you've redefined white, (esp. if you've redefined it to have a triplet
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
729 member lower than that of the color you are processing) strange things
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
730 may happen."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
731 ;;(message "hfy-colour-vals");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
732 (let ((white (mapcar (lambda (I) (float (1+ I))) (hfy-colour-vals "white")))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
733 (rgb16 (mapcar (lambda (I) (float (1+ I))) (hfy-colour-vals colour))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
734 (if rgb16
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
735 ;;(apply 'format "rgb(%d, %d, %d)"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
736 ;; Use #rrggbb instead, it is smaller
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
737 (apply 'format "#%02x%02x%02x"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
738 (mapcar (lambda (X)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
739 (* (/ (nth X rgb16)
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
740 (nth X white)) 255))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
741 '(0 1 2))))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
742
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
743 (defun hfy-family (family) (list (cons "font-family" family)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
744 (defun hfy-bgcol (colour) (list (cons "background" (hfy-triplet colour))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
745 (defun hfy-colour (colour) (list (cons "color" (hfy-triplet colour))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
746 (defun hfy-width (width) (list (cons "font-stretch" (symbol-name width))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
747
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
748 (defcustom hfy-font-zoom 1.05
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
749 "Font scaling from Emacs to HTML."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
750 :type 'float
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
751 :group 'htmlfontify)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
752
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
753 (defun hfy-size (height)
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
754 "Derive a CSS font-size specifier from an Emacs font :height attribute HEIGHT.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
755 Does not cope with the case where height is a function to be applied to
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
756 the height of the underlying font."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
757 (list
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
758 (cond
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
759 ;;(t (cons "font-size" ": 1em"))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
760 ((floatp height)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
761 (cons "font-size" (format "%d%%" (* (* hfy-font-zoom height) 100))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
762 ((integerp height)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
763 (cons "font-size" (format "%dpt" (/ (* hfy-font-zoom height) 10 )))) )) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
764
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
765 (defun hfy-slant (slant)
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
766 "Derive a font-style CSS specifier from the Emacs :slant attribute SLANT:
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
767 CSS does not define the reverse-* styles, so just maps those to the
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
768 regular specifiers."
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
769 (list (cons "font-style"
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
770 (or (cdr (assq slant '((italic . "italic")
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
771 (reverse-italic . "italic" )
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
772 (oblique . "oblique")
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
773 (reverse-oblique . "oblique"))))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
774 "normal"))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
775
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
776 (defun hfy-weight (weight)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
777 "Derive a font-weight CSS specifier from an Emacs weight spec symbol WEIGHT."
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
778 (list (cons "font-weight" (cdr (assq weight '((ultra-bold . "900")
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
779 (extra-bold . "800")
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
780 (bold . "700")
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
781 (semi-bold . "600")
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
782 (normal . "500")
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
783 (semi-light . "400")
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
784 (light . "300")
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
785 (extra-light . "200")
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
786 (ultra-light . "100")))))))
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
787
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
788 (defun hfy-box-to-border-assoc (spec)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
789 (if spec
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
790 (let ((tag (car spec))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
791 (val (cadr spec)))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
792 (cons (case tag
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
793 (:color (cons "colour" val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
794 (:width (cons "width" val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
795 (:style (cons "style" val)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
796 (hfy-box-to-border-assoc (cddr spec))))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
797
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
798 (defun hfy-box-to-style (spec)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
799 (let* ((css (hfy-box-to-border-assoc spec))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
800 (col (cdr (assoc "colour" css)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
801 (s (cdr (assoc "style" css))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
802 (list
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
803 (if col (cons "border-color" (cdr (assoc "colour" css))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
804 (cons "border-width" (format "%dpx" (or (cdr (assoc "width" css)) 1)))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
805 (cons "border-style" (case s
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
806 (released-button "outset")
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
807 (pressed-button "inset" )
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
808 (t "solid" ))))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
809
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
810 (defun hfy-box (box)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
811 "Derive CSS border-* attributes from the Emacs :box attribute BOX."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
812 (if box
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
813 (cond
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
814 ((integerp box) (list (cons "border-width" (format "%dpx" box))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
815 ((stringp box) (list (cons "border" (format "solid %s 1px" box))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
816 ((listp box) (hfy-box-to-style box) ))) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
817
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
818 (defun hfy-decor (tag val)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
819 "Derive CSS text-decoration specifiers from various Emacs font attributes.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
820 TAG is an Emacs font attribute key (eg :underline).
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
821 VAL is ignored."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
822 (list
106128
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
823 ;; FIXME: Why not '("text-decoration" . "underline")? --Stef
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
824 (case tag
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
825 (:underline (cons "text-decoration" "underline" ))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
826 (:overline (cons "text-decoration" "overline" ))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
827 (:strike-through (cons "text-decoration" "line-through")))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
828
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
829 (defun hfy-invisible (&optional val)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
830 "This text should be invisible.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
831 Do something in CSS to make that happen.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
832 VAL is ignored here."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
833 '(("display" . "none")))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
834
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
835 (defun hfy-combined-face-spec (face)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
836 "Return a `defface' style alist of possible specifications for FACE.
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
837 Entries resulting from customization (`custom-set-faces') will take
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
838 precedence."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
839 (let ((spec nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
840 (setq spec (append (or (get face 'saved-face) (list))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
841 (or (get face 'face-defface-spec) (list))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
842 (if (and hfy-display-class hfy-default-face-def (eq face 'default))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
843 (setq spec (append hfy-default-face-def spec))) spec))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
844
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
845 (defun hfy-face-attr-for-class (face &optional class)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
846 "Return the face attributes for FACE.
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
847 If CLASS is set, it must be a `defface' alist key [see below],
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
848 in which case the first face specification returned by `hfy-combined-face-spec'
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
849 which *doesn't* clash with CLASS is returned.\n
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
850 \(A specification with a class of t is considered to match any class you
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
851 specify - this matches Emacs' behavior when deciding on which face attributes
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
852 to use, to the best of my understanding).\n
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
853 If CLASS is nil, then you just get get whatever `face-attr-construct' returns,
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
854 ie the current specification in effect for FACE.\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
855 *NOTE*: This function forces any face that is not 'default and which has
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
856 no :inherit property to inherit from 'default (this is because 'default
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
857 is magical in that Emacs' fonts behave as if they inherit implicitly from
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
858 'default, but no such behavior exists in HTML/CSS).\n
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
859 See also `hfy-display-class' for details of valid values for CLASS."
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
860 (let ((face-spec
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
861 (if class
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
862 (let ((face-props (hfy-combined-face-spec face))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
863 (face-specn nil)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
864 (face-class nil)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
865 (face-attrs nil)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
866 (face-score -1)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
867 (face-match nil))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
868 (while face-props
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
869 (setq face-specn (car face-props)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
870 face-class (car face-specn)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
871 face-attrs (cdr face-specn)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
872 face-props (cdr face-props))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
873 ;; if the current element CEL of CLASS is t we match
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
874 ;; if the current face-class is t, we match
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
875 ;; if the cdr of CEL has a non-nil
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
876 ;; intersection with the cdr of the first member of
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
877 ;; the current face-class with the same car as CEL, we match
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
878 ;; if we actually clash, then we can't match
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
879 (let ((cbuf class)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
880 (cel nil)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
881 (key nil)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
882 (val nil)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
883 (x nil)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
884 (next nil)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
885 (score 0))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
886 (while (and cbuf (not next))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
887 (setq cel (car cbuf)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
888 cbuf (cdr cbuf)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
889 key (car cel)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
890 val (cdr cel)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
891 val (if (listp val) val (list val)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
892 (cond
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
893 ((or (eq cel t)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
894 (memq face-class '(t default))) ;Default match.
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
895 (setq score 0) (ignore "t match"))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
896 ((not (cdr (assq key face-class))) ;Neither good nor bad.
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
897 nil (ignore "non match, non collision"))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
898 ((setq x (hfy-interq val (cdr (assq key face-class))))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
899 (setq score (+ score (length x)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
900 (ignore "intersection"))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
901 (t ;; nope.
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
902 (setq next t score -10) (ignore "collision")) ))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
903 (if (> score face-score)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
904 (progn
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
905 (setq face-match face-attrs
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
906 face-score score )
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
907 (ignore "%d << %S/%S" score face-class class))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
908 (ignore "--- %d ---- (insufficient)" score)) ))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
909 ;; matched ? last attrs : nil
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
910 (if face-match
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
911 (if (listp (car face-match)) (car face-match) face-match)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
912 nil))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
913 ;; Unfortunately the default face returns a
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
914 ;; :background. Fortunately we can remove it, but how do we do
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
915 ;; that in a non-system specific way?
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
916 (let ((spec (face-attr-construct face))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
917 (new-spec nil))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
918 (if (not (memq :background spec))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
919 spec
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
920 (while spec
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
921 (let ((a (nth 0 spec))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
922 (b (nth 1 spec)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
923 (unless (and (eq a :background)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
924 (stringp b)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
925 (string= b "SystemWindow"))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
926 (setq new-spec (cons a (cons b new-spec)))))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
927 (setq spec (cddr spec)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
928 new-spec)))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
929 (if (or (memq :inherit face-spec) (eq 'default face))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
930 face-spec
109282
3c15269db196 Minor fix for htmlfontify.el (Bug#6239).
Chong Yidong <cyd@stupidchicken.com>
parents: 108669
diff changeset
931 (append face-spec (list :inherit 'default)))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
932
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
933 ;; construct an assoc of (css-tag-name . css-tag-value) pairs
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
934 ;; from a face or assoc of face attributes:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
935
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
936 ;; Some tests etc:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
937 ;; (mumamo-message-with-face "testing face" 'highlight)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
938 ;; (mumamo-message-with-face "testing face" '(:foreground "red" :background "yellow"))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
939 ;; (hfy-face-to-style-i '(:inherit default foreground-color "red"))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
940 ;; default face=(:stipple nil :background "SystemWindow" :foreground
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
941 ;; "SystemWindowText" :inverse-video nil :box nil :strike-through
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
942 ;; nil :overline nil :underline nil :slant normal :weight normal
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
943 ;; :height 98 :width normal :family "outline-courier new")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
944 (defun hfy-face-to-style-i (fn)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
945 "The guts of `hfy-face-to-style': FN should be a `defface' font spec,
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
946 as returned by `face-attr-construct' or `hfy-face-attr-for-class'.
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
947 Note that this function does not get font-sizes right if they are based
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
948 on inherited modifiers (via the :inherit) attribute, and any other
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
949 modifiers that are cumulative if they appear multiple times need to be
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
950 merged by the user - `hfy-flatten-style' should do this."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
951 ;;(message "hfy-face-to-style-i");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
952
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
953 ;; fn's value could be something like
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
954 ;; (:inherit
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
955 ;; ((foreground-color . "blue"))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
956 ;; (foreground-color . "blue")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
957 ;; nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
958
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
959 (when fn
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
960 (let ((key (car fn))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
961 (val (cadr fn))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
962 (next (cddr fn))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
963 (that nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
964 (this nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
965 (parent nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
966 (if (eq key :inherit)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
967 (let ((vs (if (listp val) val (list val))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
968 ;; (let ((x '(a b))) (setq x (append '(c d) x)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
969 ;; (let ((x '(a b))) (setq x (append '(c d) x)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
970 (dolist (v vs)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
971 (setq parent
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
972 (append
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
973 parent
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
974 (hfy-face-to-style-i
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
975 (hfy-face-attr-for-class v hfy-display-class)) ))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
976 (setq this
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
977 (if val (case key
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
978 (:family (hfy-family val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
979 (:width (hfy-width val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
980 (:weight (hfy-weight val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
981 (:slant (hfy-slant val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
982 (:foreground (hfy-colour val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
983 (:background (hfy-bgcol val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
984 (:box (hfy-box val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
985 (:height (hfy-size val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
986 (:underline (hfy-decor key val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
987 (:overline (hfy-decor key val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
988 (:strike-through (hfy-decor key val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
989 (:invisible (hfy-invisible val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
990 (:bold (hfy-weight 'bold))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
991 (:italic (hfy-slant 'italic))))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
992 (setq that (hfy-face-to-style-i next))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
993 ;;(lwarn t :warning "%S => %S" fn (nconc this that parent))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
994 (nconc this that parent))) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
995
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
996 (defun hfy-size-to-int (spec)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
997 "Convert SPEC, a CSS font-size specifier, to an Emacs :height attribute value.
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
998 Used while merging multiple font-size attributes."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
999 ;;(message "hfy-size-to-int");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1000 (list
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1001 (if (string-match "\\([0-9]+\\)\\(%\\|pt\\)" spec)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1002 (cond ((string= "%" (match-string 2 spec))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1003 (/ (string-to-number (match-string 1 spec)) 100.0))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1004 ((string= "pt" (match-string 2 spec))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1005 (* (string-to-number (match-string 1 spec)) 10)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1006 (string-to-number spec))) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1007
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1008 ;; size is different, in that in order to get it right at all,
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1009 ;; we have to trawl the inheritance path, accumulating modifiers,
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1010 ;; _until_ we get to an absolute (pt) specifier, then combine the lot
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1011 (defun hfy-flatten-style (style)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1012 "Take STYLE (see `hfy-face-to-style-i', `hfy-face-to-style') and merge
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1013 any multiple attributes appropriately. Currently only font-size is merged
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1014 down to a single occurrence - others may need special handling, but I
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1015 haven't encountered them yet. Returns a `hfy-style-assoc'."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1016 ;;(message "(hfy-flatten-style %S)" style) ;;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1017 (let ((n 0)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1018 (m (list 1))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1019 (x nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1020 (r nil))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1021 (dolist (css style)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1022 (if (string= (car css) "font-size")
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1023 (progn
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1024 (when (not x) (setq m (nconc m (hfy-size-to-int (cdr css)))))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1025 (when (string-match "pt" (cdr css)) (setq x t)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1026 (setq r (nconc r (list css)))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1027 ;;(message "r: %S" r)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1028 (setq n (apply '* m))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1029 (nconc r (hfy-size (if x (round n) (* n 1.0)))) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1030
108669
c1945e85d4b9 * progmodes/verilog-mode.el (verilog-type-font-keywords): Use
Chong Yidong <cyd@stupidchicken.com>
parents: 107971
diff changeset
1031 (defun hfy-face-resolve-face (fn)
c1945e85d4b9 * progmodes/verilog-mode.el (verilog-type-font-keywords): Use
Chong Yidong <cyd@stupidchicken.com>
parents: 107971
diff changeset
1032 (cond
c1945e85d4b9 * progmodes/verilog-mode.el (verilog-type-font-keywords): Use
Chong Yidong <cyd@stupidchicken.com>
parents: 107971
diff changeset
1033 ((facep fn)
c1945e85d4b9 * progmodes/verilog-mode.el (verilog-type-font-keywords): Use
Chong Yidong <cyd@stupidchicken.com>
parents: 107971
diff changeset
1034 (hfy-face-attr-for-class fn hfy-display-class))
c1945e85d4b9 * progmodes/verilog-mode.el (verilog-type-font-keywords): Use
Chong Yidong <cyd@stupidchicken.com>
parents: 107971
diff changeset
1035 ((and (symbolp fn)
c1945e85d4b9 * progmodes/verilog-mode.el (verilog-type-font-keywords): Use
Chong Yidong <cyd@stupidchicken.com>
parents: 107971
diff changeset
1036 (facep (symbol-value fn)))
c1945e85d4b9 * progmodes/verilog-mode.el (verilog-type-font-keywords): Use
Chong Yidong <cyd@stupidchicken.com>
parents: 107971
diff changeset
1037 ;; Obsolete faces like `font-lock-reference-face' are defined as
c1945e85d4b9 * progmodes/verilog-mode.el (verilog-type-font-keywords): Use
Chong Yidong <cyd@stupidchicken.com>
parents: 107971
diff changeset
1038 ;; aliases for another face.
c1945e85d4b9 * progmodes/verilog-mode.el (verilog-type-font-keywords): Use
Chong Yidong <cyd@stupidchicken.com>
parents: 107971
diff changeset
1039 (hfy-face-attr-for-class (symbol-value fn) hfy-display-class))
c1945e85d4b9 * progmodes/verilog-mode.el (verilog-type-font-keywords): Use
Chong Yidong <cyd@stupidchicken.com>
parents: 107971
diff changeset
1040 (t nil)))
c1945e85d4b9 * progmodes/verilog-mode.el (verilog-type-font-keywords): Use
Chong Yidong <cyd@stupidchicken.com>
parents: 107971
diff changeset
1041
c1945e85d4b9 * progmodes/verilog-mode.el (verilog-type-font-keywords): Use
Chong Yidong <cyd@stupidchicken.com>
parents: 107971
diff changeset
1042
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1043 (defun hfy-face-to-style (fn)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1044 "Take FN, a font or `defface' style font specification,
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1045 \(as returned by `face-attr-construct' or `hfy-face-attr-for-class')
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1046 and return a `hfy-style-assoc'.\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1047 See also `hfy-face-to-style-i', `hfy-flatten-style'."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1048 ;;(message "hfy-face-to-style");;DBUG
108669
c1945e85d4b9 * progmodes/verilog-mode.el (verilog-type-font-keywords): Use
Chong Yidong <cyd@stupidchicken.com>
parents: 107971
diff changeset
1049 (let ((face-def (hfy-face-resolve-face fn))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1050 (final-style nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1051
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1052 (setq final-style (hfy-flatten-style (hfy-face-to-style-i face-def)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1053 ;;(message "%S" final-style)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1054 (if (not (assoc "text-decoration" final-style))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1055 (progn (setq final-style
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1056 ;; Fix-me: there is no need for this since
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1057 ;; text-decoration is not inherited.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1058 ;; but it's not wrong and if this ever changes it will
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1059 ;; be needed, so I think it's better to leave it in? -- v
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1060 (nconc final-style '(("text-decoration"."none"))))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1061 final-style))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1062
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1063 ;; strip redundant bits from a name. Technically, this could result in
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1064 ;; a collision, but it is pretty unlikely - will fix later...
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1065 ;; also handle ephemeral fonts created by overlays, which don't actually
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1066 ;; have names:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1067 (defun hfy-face-or-def-to-name (fn)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1068 "Render a font symbol or `defface' font spec FN into a name (string)."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1069 ;;(message "generating name for %s" fn)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1070 (if (not (listp fn))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1071 (format "%s" fn)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1072 (let* ((key (format "%s" fn))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1073 (entry (assoc key hfy-tmpfont-stack))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1074 (base (cadr (memq :inherit fn)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1075 (tag (cdr entry)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1076 ;;(message "checking for key «%s» in font stack [%d]"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1077 ;; key (if entry 1 0))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1078 (if entry nil ;; noop
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1079 (setq tag (format "%04d" (length hfy-tmpfont-stack))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1080 entry (cons key tag)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1081 hfy-tmpfont-stack (cons entry hfy-tmpfont-stack)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1082 ;;(message " -> name: %s-%s" (or base 'default) tag)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1083 (format "%s-%s" (or base 'default) tag)) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1084
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1085 (defun hfy-css-name (fn)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1086 "Strip the boring bits from a font-name FN and return a CSS style name."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1087 ;;(message "hfy-css-name");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1088 (let ((face-name (hfy-face-or-def-to-name fn)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1089 (if (or (string-match "font-lock-\\(.*\\)" face-name)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1090 (string-match "cperl-\\(.*\\)" face-name)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1091 (string-match "^[Ii]nfo-\\(.*\\)" face-name))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1092 (progn
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1093 (setq face-name (match-string 1 face-name))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1094 (if (string-match "\\(.*\\)-face$" face-name)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1095 (setq face-name (match-string 1 face-name))) face-name)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1096 face-name)) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1097
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1098 ;; construct an assoc of (stripped-name . "{ css-stuff-here }") pairs
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1099 ;; from a face:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1100 (defun hfy-face-to-css (fn)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1101 "Take FN, a font or `defface' specification (cf `face-attr-construct')
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1102 and return a CSS style specification.\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1103 See also `hfy-face-to-style'."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1104 ;;(message "hfy-face-to-css");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1105 (let ((css-list nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1106 (css-text nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1107 (seen nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1108 ;;(message "(hfy-face-to-style %S)" fn)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1109 (setq css-list (hfy-face-to-style fn))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1110 (setq css-text
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1111 (mapcar
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1112 (lambda (E)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1113 (if (car E)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1114 (unless (member (car E) seen)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1115 (push (car E) seen)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1116 (format " %s: %s; " (car E) (cdr E)))))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1117 css-list))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1118 (cons (hfy-css-name fn) (format "{%s}" (apply 'concat css-text)))) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1119
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1120 ;; extract a face from a list of char properties, if there is one:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1121 (defun hfy-p-to-face (props)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1122 "Given PROPS, a list of text properties, return the value of the face
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1123 property, or nil."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1124 (if props
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1125 (if (string= (car props) "face")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1126 (let ((propval (cadr props)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1127 (if (and (listp propval) (not (cdr propval)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1128 (car propval)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1129 propval))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1130 (hfy-p-to-face (cddr props)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1131 nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1132
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1133 (defun hfy-p-to-face-lennart (props)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1134 "Given PROPS, a list of text properties, return the value of the face
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1135 property, or nil."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1136 (when props
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1137 (let ((face (plist-get props 'face))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1138 (font-lock-face (plist-get props 'font-lock-face))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1139 (button (plist-get props 'button))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1140 ;;(face-rec (memq 'face props))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1141 ;;(button-rec (memq 'button props)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1142 )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1143 (if button
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1144 (let* ((category (plist-get props 'category))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1145 (face (when category (plist-get (symbol-plist category) 'face))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1146 face)
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1147 (or font-lock-face
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1148 face)))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1149
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1150 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1151 ;; (defun hfy-get-face-at (pos)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1152 ;; ;; (let ((face (get-char-property-and-overlay pos 'face)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1153 ;; ;; (when (and face (listp face)) (setq face (car face)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1154 ;; ;; (unless (listp face)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1155 ;; ;; face)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1156 ;; ;;(get-char-property pos 'face)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1157 ;; ;; Overlays are handled later
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1158 ;; (if (or (not show-trailing-whitespace)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1159 ;; (not (get-text-property pos 'hfy-show-trailing-whitespace)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1160 ;; (get-text-property pos 'face)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1161 ;; (list 'trailing-whitespace (get-text-property pos 'face)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1162 ;; )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1163
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1164 (defun hfy-prop-invisible-p (prop)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1165 "Is text property PROP an active invisibility property?"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1166 (or (and (eq buffer-invisibility-spec t) prop)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1167 (or (memq prop buffer-invisibility-spec)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1168 (assq prop buffer-invisibility-spec))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1169
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1170 (defun hfy-find-invisible-ranges ()
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1171 "Return a list of (start-point . end-point) cons cells of invisible regions."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1172 (let (invisible p i e s) ;; return-value pos invisible end start
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1173 (save-excursion
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1174 (setq p (goto-char (point-min)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1175 (when (invisible-p p) (setq s p i t))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1176 (while (< p (point-max))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1177 (if i ;; currently invisible
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1178 (when (not (invisible-p p)) ;; but became visible
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1179 (setq e p
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1180 i nil
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1181 invisible (cons (cons s e) invisible)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1182 ;; currently visible:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1183 (when (invisible-p p) ;; but have become invisible
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1184 (setq s p i t)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1185 (setq p (next-char-property-change p)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1186 ;; still invisible at buffer end?
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1187 (when i
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1188 (setq e (point-max)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1189 invisible (cons (cons s e) invisible))) ) invisible))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1190
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1191 (defun hfy-invisible-name (point map)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1192 "Generate a CSS style name for an invisible section of the buffer.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1193 POINT is the point inside the invisible region.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1194 MAP is the invisibility map as returned by `hfy-find-invisible-ranges'."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1195 ;;(message "(hfy-invisible-name %S %S)" point map)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1196 (let (name)
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1197 (dolist (range map)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1198 (when (and (>= point (car range))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1199 (< point (cdr range)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1200 (setq name (format "invisible-%S-%S" (car range) (cdr range)))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1201 name))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1202
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1203 ;; Fix-me: This function needs some cleanup by someone who understand
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1204 ;; all the formats that face properties can have.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1205 ;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1206 ;; overlay handling should be fine. haven't tested multiple stacked overlapping
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1207 ;; overlays recently, but the common case of a text property face + an overlay
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1208 ;; face produces the correct merged css style (or as close to it as css can get)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1209 ;; -- v
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1210 (defun hfy-face-at (p)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1211 "Find face in effect at point P.
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1212 If overlays are to be considered (see `hfy-optimisations') then this may
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1213 return a `defface' style list of face properties instead of a face symbol."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1214 ;;(message "hfy-face-at");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1215 ;; Fix-me: clean up, remove face-name etc
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1216 ;; not sure why we'd want to remove face-name? -- v
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1217 (let ((overlay-data nil)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1218 (base-face nil)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1219 ;; restored hfy-p-to-face as it handles faces like (bold) as
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1220 ;; well as face like 'bold - hfy-get-face-at doesn't dtrt -- v
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1221 (face-name (hfy-p-to-face (text-properties-at p)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1222 ;; (face-name (hfy-get-face-at p))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1223 (prop-seen nil)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1224 (extra-props nil)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1225 (text-props (text-properties-at p)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1226 ;;(message "face-name: %S" face-name)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1227 (when (and face-name (listp face-name) (facep (car face-name)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1228 ;;(message "face-name is a list %S" face-name)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1229 ;;(setq text-props (cons 'face face-name))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1230 (dolist (f face-name)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1231 (setq extra-props (if (listp f)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1232 ;; for things like (variable-pitch
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1233 ;; (:foreground "red"))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1234 (cons f extra-props)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1235 (cons :inherit (cons f extra-props)))))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1236 (setq base-face (car face-name)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1237 face-name nil))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1238 ;; text-properties-at => (face (:foreground "red" ...))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1239 ;; or => (face (compilation-info underline)) list of faces
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1240 ;; overlay-properties
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1241 ;; format= (evaporate t face ((foreground-color . "red")))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1242
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1243 ;; SO: if we have turned overlays off,
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1244 ;; or if there's no overlay data
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1245 ;; just bail out and return whatever face data we've accumulated so far
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1246 (if (or (not (hfy-opt 'keep-overlays))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1247 (not (setq overlay-data (hfy-overlay-props-at p))))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1248 (progn
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1249 ;;(message "· %d: %s; %S; %s"
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1250 ;; p face-name extra-props text-props)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1251 (or face-name base-face)) ;; no overlays or extra properties
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1252 ;; collect any face data and any overlay data for processing:
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1253 (when text-props
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1254 (push text-props overlay-data))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1255 (setq overlay-data (nreverse overlay-data))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1256 ;;(message "- %d: %s; %S; %s; %s"
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1257 ;; p face-name extra-props text-props overlay-data)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1258 ;; remember the basic face name so we don't keep repeating its specs:
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1259 (when face-name (setq base-face face-name))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1260 (dolist (P overlay-data)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1261 (let ((iprops (cadr (memq 'invisible P)))) ;FIXME: plist-get?
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1262 ;;(message "(hfy-prop-invisible-p %S)" iprops)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1263 (when (and iprops (hfy-prop-invisible-p iprops))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1264 (setq extra-props
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1265 (cons :invisible (cons t extra-props))) ))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1266 (let ((fprops (cadr (or (memq 'face P)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1267 (memq 'font-lock-face P)))))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1268 ;;(message "overlay face: %s" fprops)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1269 (if (not (listp fprops))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1270 (let ((this-face (if (stringp fprops) (intern fprops) fprops)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1271 (when (not (eq this-face base-face))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1272 (setq extra-props
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1273 (cons :inherit
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1274 (cons this-face extra-props))) ))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1275 (while fprops
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1276 (if (facep (car fprops))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1277 (let ((face (car fprops)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1278 (when (stringp face) (setq face (intern fprops)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1279 (setq extra-props
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1280 (cons :inherit
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1281 (cons face
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1282 extra-props)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1283 (setq fprops (cdr fprops)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1284 (let (p v)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1285 ;; Sigh.
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1286 (if (listp (car fprops))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1287 (if (nlistp (cdr (car fprops)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1288 (progn
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1289 ;; ((prop . val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1290 (setq p (caar fprops))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1291 (setq v (cdar fprops))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1292 (setq fprops (cdr fprops)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1293 ;; ((prop val))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1294 (setq p (caar fprops))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1295 (setq v (cadar fprops))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1296 (setq fprops (cdr fprops)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1297 (if (listp (cdr fprops))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1298 (progn
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1299 ;; (:prop val :prop val ...)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1300 (setq p (car fprops))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1301 (setq v (cadr fprops))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1302 (setq fprops (cddr fprops)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1303 (if (and (listp fprops)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1304 (not (listp (cdr fprops))))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1305 ;;(and (consp x) (cdr (last x)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1306 (progn
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1307 ;; (prop . val)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1308 (setq p (car fprops))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1309 (setq v (cdr fprops))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1310 (setq fprops nil))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1311 (error "Eh... another format! fprops=%s" fprops) )))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1312 (setq p (case p
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1313 ;; These are all the properties handled
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1314 ;; in `hfy-face-to-style-i'.
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1315 ;;
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1316 ;; Are these translations right?
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1317 ;; yes, they are -- v
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1318 (family :family )
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1319 (width :width )
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1320 (height :height )
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1321 (weight :weight )
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1322 (slant :slant )
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1323 (underline :underline )
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1324 (overline :overline )
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1325 (strike-through :strike-through)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1326 (box :box )
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1327 (foreground-color :foreground)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1328 (background-color :background)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1329 (bold :bold )
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1330 (italic :italic )
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1331 (t p)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1332 (if (memq p prop-seen) nil ;; noop
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1333 (setq prop-seen (cons p prop-seen)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1334 extra-props (cons p (cons v extra-props))))))))))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1335 ;;(message "+ %d: %s; %S" p face-name extra-props)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1336 (if extra-props
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1337 (if (listp face-name)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1338 (nconc extra-props face-name)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1339 (nconc extra-props (face-attr-construct face-name)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1340 face-name)) ))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1341
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1342 (defun hfy-overlay-props-at (p)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1343 "Grab overlay properties at point P.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1344 The plists are returned in descending priority order."
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1345 (sort (mapcar #'overlay-properties (overlays-at p))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1346 (lambda (A B) (> (or (cadr (memq 'priority A)) 0) ;FIXME: plist-get?
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1347 (or (cadr (memq 'priority B)) 0)))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1348
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1349 ;; construct an assoc of (face-name . (css-name . "{ css-style }")) elements:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1350 (defun hfy-compile-stylesheet ()
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1351 "Trawl the current buffer, construct and return a `hfy-sheet-assoc'."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1352 ;;(message "hfy-compile-stylesheet");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1353 (let ((pt (point-min))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1354 ;; Make the font stack stay:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1355 ;;(hfy-tmpfont-stack nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1356 (fn nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1357 (style nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1358 (save-excursion
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1359 (goto-char pt)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1360 (while (< pt (point-max))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1361 (if (and (setq fn (hfy-face-at pt)) (not (assoc fn style)))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1362 (push (cons fn (hfy-face-to-css fn)) style))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1363 (setq pt (next-char-property-change pt))) )
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1364 (push (cons 'default (hfy-face-to-css 'default)) style)))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1365
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1366 (defun hfy-fontified-p ()
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1367 "`font-lock' doesn't like to say it's been fontified when in batch
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1368 mode, but we want to know if we should fontify or raw copy, so in batch
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1369 mode we check for non-default face properties. Otherwise we test
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1370 variable `font-lock-mode' and variable `font-lock-fontified' for truth."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1371 ;;(message "font-lock-fontified: %S" font-lock-fontified)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1372 ;;(message "noninteractive : %S" noninteractive)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1373 ;;(message "font-lock-mode : %S" font-lock-mode)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1374 (and font-lock-fontified
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1375 (if noninteractive
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1376 (let ((pt (point-min))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1377 (face-name nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1378 (save-excursion
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1379 (goto-char pt)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1380 (while (and (< pt (point-max)) (not face-name))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1381 (setq face-name (hfy-face-at pt))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1382 (setq pt (next-char-property-change pt)))) face-name)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1383 font-lock-mode)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1384
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1385 ;; remember, the map is in reverse point order:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1386 ;; I wrote this while suffering the effects of a cold, and maybe a
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1387 ;; mild fever - I think it's correct, but it might be a little warped
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1388 ;; as my minfd keeps ... where was I? Oh yes, the bunnies...
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1389 (defun hfy-merge-adjacent-spans (face-map)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1390 "Where FACE-MAP is a `hfy-facemap-assoc' for the current buffer,
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1391 this function merges adjacent style blocks which are of the same value
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1392 and are separated by nothing more interesting than whitespace.\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1393 <span class=\"foo\">narf</span> <span class=\"foo\">brain</span>\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1394 \(as interpreted from FACE-MAP) would become:\n
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1395 <span class=\"foo\">narf brain</span>\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1396 Returns a modified copy of FACE-MAP."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1397 (let ((tmp-map face-map)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1398 (map-buf nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1399 (first-start nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1400 (first-stop nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1401 (last-start nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1402 (last-stop nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1403 (span-stop nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1404 (span-start nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1405 (reduced-map nil))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1406 ;;(push (car tmp-map) reduced-map)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1407 ;;(push (cadr tmp-map) reduced-map)
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1408 (while tmp-map
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1409 (setq first-start (cadddr tmp-map)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1410 first-stop (caddr tmp-map)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1411 last-start (cadr tmp-map)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1412 last-stop (car tmp-map)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1413 map-buf tmp-map
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1414 span-start last-start
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1415 span-stop last-stop )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1416 (while (and (equal (cdr first-start)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1417 (cdr last-start))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1418 (save-excursion
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1419 (goto-char (car first-stop))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1420 (not (re-search-forward "[^ \t\n\r]" (car last-start) t))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1421 (setq map-buf (cddr map-buf)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1422 span-start first-start
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1423 first-start (cadddr map-buf)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1424 first-stop (caddr map-buf)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1425 last-start (cadr map-buf)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1426 last-stop (car map-buf)))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1427 (push span-stop reduced-map)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1428 (push span-start reduced-map)
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1429 (setq tmp-map (memq last-start tmp-map))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1430 (setq tmp-map (cdr tmp-map)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1431 (setq reduced-map (nreverse reduced-map))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1432
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1433 ;; remember to generate 'synthetic' </span> entries -
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1434 ;; emacs copes by just having a stack of styles in effect
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1435 ;; and only using the top one: html has a more simplistic approach -
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1436 ;; we have to explicitly end a style, there's no way of temporarily
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1437 ;; overriding it w. another one... (afaik)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1438 (defun hfy-compile-face-map ()
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1439 ;; no need for special <a> version.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1440 ;; IME hyperlinks don't get underlined, esp when you htmlfontify a whole
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1441 ;; source tree, so the <a> version is needed -- v
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1442 ;; Fix-me: save table for multi-buffer
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1443 "Compile and return a `hfy-facemap-assoc' for the current buffer."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1444 ;;(message "hfy-compile-face-map");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1445 (let ((pt (point-min))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1446 (pt-narrow 1)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1447 (fn nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1448 (map nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1449 (prev-tag nil)) ;; t if the last tag-point was a span-start
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1450 ;; nil if it was a span-stop
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1451 (save-excursion
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1452 (goto-char pt)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1453 (while (< pt (point-max))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1454 (if (setq fn (hfy-face-at pt))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1455 (progn (if prev-tag (push (cons pt-narrow 'end) map))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1456 (push (cons pt-narrow fn) map)
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1457 (setq prev-tag t))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1458 (if prev-tag (push (cons pt-narrow 'end) map))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1459 (setq prev-tag nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1460 (setq pt (next-char-property-change pt))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1461 (setq pt-narrow (1+ (- pt (point-min)))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1462 (if (and map (not (eq 'end (cdar map))))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1463 (push (cons (- (point-max) (point-min)) 'end) map)))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1464 (if (hfy-opt 'merge-adjacent-tags) (hfy-merge-adjacent-spans map) map)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1465
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1466 (defun hfy-buffer ()
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1467 "Generate a buffer to hold the HTML output.
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1468 The filename of this buffer is derived from the source (current) buffer's
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1469 variable `buffer-file-name', if it is set, plus `hfy-extn'.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1470 Otherwise a plausible filename is constructed from `default-directory',
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1471 `buffer-name' and `hfy-extn'."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1472 (let* ((name (concat (buffer-name) hfy-extn))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1473 (src (buffer-file-name))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1474 (buf (get-buffer-create name)))
106128
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
1475 (with-current-buffer buf
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
1476 (setq buffer-file-name
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
1477 (if src (concat src hfy-extn)
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
1478 (expand-file-name (if (string-match "^.*/\\([^/]*\\)$" name)
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
1479 (match-string 1 name)
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
1480 name))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1481 buf)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1482
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1483 (defun hfy-lookup (face style)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1484 "Get a CSS style name for FACE from STYLE."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1485 (cadr (assoc face style)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1486
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1487 (defun hfy-link-style (style-string)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1488 "Copy, alter and return a STYLE-STRING to make it suitable for a hyperlink.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1489 Uses `hfy-link-style-fun' to do this."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1490 (if (functionp hfy-link-style-fun)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1491 (funcall hfy-link-style-fun style-string)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1492 style-string))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1493
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1494 (defun hfy-sprintf-stylesheet (css file)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1495 "Return the inline CSS style sheet for FILE as a string."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1496 (let ((stylesheet nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1497 (setq stylesheet
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1498 (concat
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1499 hfy-meta-tags
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1500 "\n<style type=\"text/css\"><!-- \n"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1501 ;; Fix-me: Add handling of page breaks here + scan for ^L
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1502 ;; where appropriate.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1503 (format "body %s\n" (cddr (assq 'default css)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1504 (apply 'concat
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1505 (mapcar
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1506 (lambda (style)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1507 (format
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1508 "span.%s %s\nspan.%s a %s\n"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1509 (cadr style) (cddr style)
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1510 (cadr style) (hfy-link-style (cddr style))))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1511 css))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1512 " --></style>\n"))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1513 (funcall hfy-page-header file stylesheet)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1514
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1515 ;; tag all the dangerous characters we want to escape
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1516 ;; (ie any "<> chars we _didn't_ put there explicitly for css markup)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1517 (defun hfy-html-enkludge-buffer ()
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1518 "Mark dangerous [\"<>] characters with the `hfy-quoteme' property.\n
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1519 See also `hfy-html-dekludge-buffer'."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1520 ;;(message "hfy-html-enkludge-buffer");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1521 (save-excursion
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1522 (goto-char (point-min))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1523 (while (re-search-forward hfy-html-quote-regex nil t)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1524 (put-text-property (match-beginning 0) (point) 'hfy-quoteme t))) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1525
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1526 ;; dangerous char -> &entity;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1527 (defun hfy-html-quote (char-string)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1528 "Map CHAR-STRING to an HTML safe string (entity) if need be."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1529 ;;(message "hfy-html-quote");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1530 (or (cadr (assoc char-string hfy-html-quote-map)) char-string) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1531
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1532 ;; actually entity-ise dangerous chars.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1533 ;; note that we can't do this until _after_ we have inserted the css
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1534 ;; markup, since we use a position-based map to insert this, and if we
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1535 ;; enter any other text before we do this, we'd have to track another
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1536 ;; map of offsets, which would be tedious...
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1537 (defun hfy-html-dekludge-buffer ()
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1538 "Transform all dangerous characters marked with the `hfy-quoteme' property
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1539 using `hfy-html-quote'.\n
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1540 See also `hfy-html-enkludge-buffer'."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1541 ;;(message "hfy-html-dekludge-buffer");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1542 (save-excursion
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1543 (goto-char (point-min))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1544 (while (re-search-forward hfy-html-quote-regex nil t)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1545 (if (get-text-property (match-beginning 0) 'hfy-quoteme)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1546 (replace-match (hfy-html-quote (match-string 1))) )) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1547
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1548 ;; Borrowed from font-lock.el
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1549 (defmacro hfy-save-buffer-state (varlist &rest body)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1550 "Bind variables according to VARLIST and eval BODY restoring buffer state.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1551 Do not record undo information during evaluation of BODY."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1552 (declare (indent 1) (debug let))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1553 (let ((modified (make-symbol "modified")))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1554 `(let* ,(append varlist
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1555 `((,modified (buffer-modified-p))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1556 (buffer-undo-list t)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1557 (inhibit-read-only t)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1558 (inhibit-point-motion-hooks t)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1559 (inhibit-modification-hooks t)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1560 deactivate-mark
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1561 buffer-file-name
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1562 buffer-file-truename))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1563 (progn
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1564 ,@body)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1565 (unless ,modified
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1566 (restore-buffer-modified-p nil)))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1567
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1568 (defun hfy-mark-trailing-whitespace ()
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1569 "Tag trailing whitespace with a hfy property if it is currently highlighted."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1570 (when show-trailing-whitespace
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1571 (let ((inhibit-read-only t))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1572 (save-excursion
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1573 (goto-char (point-min))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1574 (hfy-save-buffer-state nil
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1575 (while (re-search-forward "[ \t]+$" nil t)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1576 (put-text-property (match-beginning 0) (match-end 0)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1577 'hfy-show-trailing-whitespace t)))))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1578
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1579 (defun hfy-unmark-trailing-whitespace ()
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1580 "Undo the effect of `hfy-mark-trailing-whitespace'."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1581 (when show-trailing-whitespace
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1582 (hfy-save-buffer-state nil
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1583 (remove-text-properties (point-min) (point-max)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1584 '(hfy-show-trailing-whitespace)))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1585
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1586 (defun hfy-fontify-buffer (&optional srcdir file)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1587 "Implement the guts of `htmlfontify-buffer'.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1588 SRCDIR, if set, is the directory being htmlfontified.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1589 FILE, if set, is the file name."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1590 (if srcdir (setq srcdir (directory-file-name srcdir)))
106128
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
1591 (let* ( (html-buffer (hfy-buffer))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1592 (css-sheet nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1593 (css-map nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1594 (invis-ranges nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1595 (rovl nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1596 (orig-ovls (overlays-in (point-min) (point-max)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1597 (rmin (when mark-active (region-beginning)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1598 (rmax (when mark-active (region-end ))) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1599 (when (and mark-active
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1600 transient-mark-mode)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1601 (unless (and (= rmin (point-min))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1602 (= rmax (point-max)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1603 (setq rovl (make-overlay rmin rmax))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1604 (overlay-put rovl 'priority 1000)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1605 (overlay-put rovl 'face 'region)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1606 ;; copy the buffer, including fontification, and switch to it:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1607 (hfy-mark-trailing-whitespace)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1608 (setq css-sheet (hfy-compile-stylesheet )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1609 css-map (hfy-compile-face-map )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1610 invis-ranges (hfy-find-invisible-ranges))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1611 (hfy-unmark-trailing-whitespace)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1612 (when rovl
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1613 (delete-overlay rovl))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1614 (copy-to-buffer html-buffer (point-min) (point-max))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1615 (set-buffer html-buffer)
106505
7287842d7e07 Drop some properties to avoid surprises.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106352
diff changeset
1616 ;; rip out props that could interfere with our htmlisation of the buffer:
7287842d7e07 Drop some properties to avoid surprises.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106352
diff changeset
1617 (remove-text-properties (point-min) (point-max) hfy-ignored-properties)
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1618 ;; Apply overlay invisible spec
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1619 (setq orig-ovls
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1620 (sort orig-ovls
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1621 (lambda (A B)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1622 (> (or (cadr (memq 'priority (overlay-properties A))) 0)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1623 (or (cadr (memq 'priority (overlay-properties B))) 0)))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1624 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1625 ;; at this point, html-buffer retains the fontification of the parent:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1626 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1627 ;; we don't really need or want text in the html buffer to be invisible, as
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1628 ;; that can make it look like we've rendered invalid xhtml when all that's
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1629 ;; happened is some tags are in the invisible portions of the buffer:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1630 (setq buffer-invisibility-spec nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1631 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1632 ;; #####################################################################
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1633 ;; if we are in etags mode, add properties to mark the anchors and links
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1634 (if (and srcdir file)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1635 (progn
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1636 (hfy-mark-tag-names srcdir file) ;; mark anchors
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1637 (hfy-mark-tag-hrefs srcdir file))) ;; mark links
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1638 ;; #####################################################################
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1639 ;; mark the 'dangerous' characters
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1640 ;;(message "marking dangerous characters")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1641 (hfy-html-enkludge-buffer)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1642 ;; trawl the position-based face-map, inserting span tags as we go
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1643 ;; note that we cannot change any character positions before this point
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1644 ;; or we will invalidate the map:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1645 ;; NB: This also means we have to trawl the map in descending file-offset
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1646 ;; order, obviously.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1647 ;; ---------------------------------------------------------------------
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1648 ;; Remember, inserting pushes properties to the right, which we don't
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1649 ;; actually want to happen for link properties, so we have to flag
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1650 ;; them and move them by hand - if you don't, you end up with
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1651 ;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1652 ;; <span class="foo"><a href="bar">texta</span><span class="bletch"></a>...
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1653 ;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1654 ;; instead of:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1655 ;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1656 ;; <span class="foo"><a href="bar">texta</a></span><span class="bletch">...
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1657 ;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1658 ;; If my analysis of the problem is correct, we can detect link-ness by
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1659 ;; either hfy-linkp or hfy-endl properties at the insertion point, but I
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1660 ;; think we only need to relocate the hfy-endl property, as the hfy-linkp
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1661 ;; property has already served its main purpose by this point.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1662 ;;(message "mapcar over the CSS-MAP")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1663 (message "invis-ranges:\n%S" invis-ranges)
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1664 (dolist (point-face css-map)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1665 (let ((pt (car point-face))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1666 (fn (cdr point-face))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1667 (move-link nil))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1668 (goto-char pt)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1669 (setq move-link
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1670 (or (get-text-property pt 'hfy-linkp)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1671 (get-text-property pt 'hfy-endl )))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1672 (if (eq 'end fn)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1673 (insert "</span>")
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1674 (if (not (and srcdir file))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1675 nil
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1676 (when move-link
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1677 (remove-text-properties (point) (1+ (point)) '(hfy-endl nil))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1678 (put-text-property pt (1+ pt) 'hfy-endl t) ))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1679 ;; if we have invisible blocks, we need to do some extra magic:
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1680 (if invis-ranges
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1681 (let ((iname (hfy-invisible-name pt invis-ranges))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1682 (fname (hfy-lookup fn css-sheet )))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1683 (when (assq pt invis-ranges)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1684 (insert
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1685 (format "<span onclick=\"toggle_invis('%s');\">" iname))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1686 (insert "…</span>"))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1687 (insert
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1688 (format "<span class=\"%s\" id=\"%s-%d\">" fname iname pt)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1689 (insert (format "<span class=\"%s\">" (hfy-lookup fn css-sheet))))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1690 (if (not move-link) nil
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1691 ;;(message "removing prop2 @ %d" (point))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1692 (if (remove-text-properties (point) (1+ (point)) '(hfy-endl nil))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1693 (put-text-property pt (1+ pt) 'hfy-endl t))))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1694 ;; #####################################################################
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1695 ;; Invisibility
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1696 ;; Maybe just make the text invisible in XHTML?
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1697 ;; DONE -- big block of obsolete invisibility code elided here -- v
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1698 ;; #####################################################################
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1699 ;; (message "checking to see whether we should link...")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1700 (if (and srcdir file)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1701 (let ((lp 'hfy-link)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1702 (pt nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1703 (pr nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1704 (rr nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1705 ;; (message " yes we should.")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1706 ;; translate 'hfy-anchor properties to anchors
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1707 (setq pt (point-min))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1708 (while (setq pt (next-single-property-change pt 'hfy-anchor))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1709 (if (setq pr (get-text-property pt 'hfy-anchor))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1710 (progn (goto-char pt)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1711 (remove-text-properties pt (1+ pt) '(hfy-anchor nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1712 (insert (concat "<a name=\"" pr "\"></a>")))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1713 ;; translate alternate 'hfy-link and 'hfy-endl props to opening
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1714 ;; and closing links. (this should avoid those spurious closes
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1715 ;; we sometimes get by generating only paired tags)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1716 (setq pt (point-min))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1717 (while (setq pt (next-single-property-change pt lp))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1718 (if (not (setq pr (get-text-property pt lp))) nil
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1719 (goto-char pt)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1720 (remove-text-properties pt (1+ pt) (list lp nil))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1721 (case lp
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1722 (hfy-link
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1723 (if (setq rr (get-text-property pt 'hfy-inst))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1724 (insert (format "<a name=\"%s\"></a>" rr)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1725 (insert (format "<a href=\"%s\">" pr))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1726 (setq lp 'hfy-endl))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1727 (hfy-endl
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1728 (insert "</a>") (setq lp 'hfy-link)) ))) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1729
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1730 ;; #####################################################################
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1731 ;; transform the dangerous chars. This changes character positions
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1732 ;; since entities have > char length.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1733 ;; note that this deletes the dangerous characters, and therefore
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1734 ;; destroys any properties they may contain (such as 'hfy-endl),
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1735 ;; so we have to do this after we use said properties:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1736 ;; (message "munging dangerous characters")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1737 (hfy-html-dekludge-buffer)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1738 ;; insert the stylesheet at the top:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1739 (goto-char (point-min))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1740 ;;(message "inserting stylesheet")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1741 (insert (hfy-sprintf-stylesheet css-sheet file))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1742 (if (hfy-opt 'div-wrapper) (insert "<div class=\"default\">"))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1743 (insert "\n<pre>")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1744 (goto-char (point-max))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1745 (insert "</pre>\n")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1746 (if (hfy-opt 'div-wrapper) (insert "</div>"))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1747 ;;(message "inserting footer")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1748 (insert (funcall hfy-page-footer file))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1749 ;; call any post html-generation hooks:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1750 (run-hooks 'hfy-post-html-hooks)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1751 ;; return the html buffer
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1752 (set-buffer-modified-p nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1753 html-buffer))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1754
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1755 (defun hfy-force-fontification ()
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1756 "Try to force font-locking even when it is optimized away."
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1757 (run-hooks 'hfy-init-kludge-hook)
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1758 (eval-and-compile (require 'font-lock))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1759 (if (boundp 'font-lock-cache-position)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1760 (or font-lock-cache-position
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1761 (set 'font-lock-cache-position (make-marker))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1762 (if (not noninteractive)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1763 (progn
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1764 (message "hfy interactive mode (%S %S)" window-system major-mode)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1765 (when (and font-lock-defaults
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1766 font-lock-mode)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1767 (font-lock-fontify-region (point-min) (point-max) nil)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1768 (message "hfy batch mode (%s:%S)"
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1769 (or (buffer-file-name) (buffer-name)) major-mode)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1770 (when font-lock-defaults
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1771 (font-lock-fontify-buffer)) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1772
107971
ab970852cf46 Add some autoloads.
Glenn Morris <rgm@gnu.org>
parents: 107207
diff changeset
1773 ;;;###autoload
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1774 (defun htmlfontify-buffer (&optional srcdir file)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1775 "Create a new buffer, named for the current buffer + a .html extension,
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1776 containing an inline CSS-stylesheet and formatted CSS-markup HTML
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1777 that reproduces the look of the current Emacs buffer as closely
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1778 as possible.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1779
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1780 Dangerous characters in the existing buffer are turned into HTML
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1781 entities, so you should even be able to do HTML-within-HTML
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1782 fontified display.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1783
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1784 You should, however, note that random control or eight-bit
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1785 characters such as ^L (\x0c) or ¤ (\xa4) won't get mapped yet.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1786
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1787 If the SRCDIR and FILE arguments are set, lookup etags derived
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1788 entries in the `hfy-tags-cache' and add HTML anchors and
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1789 hyperlinks as appropriate."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1790 (interactive)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1791 ;; pick up the file name in case we didn't receive it
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1792 (if (not file)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1793 (progn (setq file (or (buffer-file-name) (buffer-name)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1794 (if (string-match "/\\([^/]*\\)$" file)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1795 (setq file (match-string 1 file)))) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1796
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1797 (if (not (hfy-opt 'skip-refontification))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1798 (save-excursion ;; Keep region
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1799 (hfy-force-fontification)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1800 (if (interactive-p) ;; display the buffer in interactive mode:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1801 (switch-to-buffer (hfy-fontify-buffer srcdir file))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1802 (hfy-fontify-buffer srcdir file)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1803
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1804 ;; recursive file listing
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1805 (defun hfy-list-files (directory)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1806 "Return a list of files under DIRECTORY.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1807 Strips any leading \"./\" from each filename."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1808 ;;(message "hfy-list-files");;DBUG
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1809 ;; FIXME: this changes the dir of the currrent buffer. Is that right??
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1810 (cd directory)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1811 (mapcar (lambda (F) (if (string-match "^./\\(.*\\)" F) (match-string 1 F) F))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1812 (split-string (shell-command-to-string hfy-find-cmd))) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1813
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1814 ;; strip the filename off, return a directiry name
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1815 ;; not a particularly thorough implementaion, but it will be
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1816 ;; fed pretty carefully, so it should be Ok:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1817 (defun hfy-dirname (file)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1818 "Return everything preceding the last \"/\" from a relative filename FILE,
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1819 on the assumption that this will produce a relative directory name.
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1820 Hardly bombproof, but good enough in the context in which it is being used."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1821 ;;(message "hfy-dirname");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1822 (let ((f (directory-file-name file)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1823 (and (string-match "^\\(.*\\)/" f) (match-string 1 f))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1824
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1825 ;; create a directory, cf mkdir -p
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1826 (defun hfy-make-directory (dir)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1827 "Approx. equivalent of mkdir -p DIR."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1828 ;;(message "hfy-make-directory");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1829 (if (file-exists-p dir)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1830 (if (file-directory-p dir) t)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1831 (make-directory dir t)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1832
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1833 (defun hfy-text-p (srcdir file)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1834 "Is SRCDIR/FILE text? Uses `hfy-istext-command' to determine this."
106128
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
1835 (let* ((cmd (format hfy-istext-command (expand-file-name file srcdir)))
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
1836 (rsp (shell-command-to-string cmd)))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1837 (if (string-match "text" rsp) t nil)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1838
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1839 ;; open a file, check fontification, if fontified, write a fontified copy
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1840 ;; to the destination directory, otherwise just copy the file:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1841 (defun hfy-copy-and-fontify-file (srcdir dstdir file)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1842 "Open FILE in SRCDIR - if fontified, write a fontified copy to DSTDIR
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1843 adding an extension of `hfy-extn'. Fontification is actually done by
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1844 `htmlfontify-buffer'. If the buffer is not fontified, just copy it."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1845 ;;(message "hfy-copy-and-fontify-file");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1846 (let (;;(fast-lock-minimum-size hfy-fast-lock-save)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1847 ;;(font-lock-support-mode 'fast-lock-mode)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1848 ;;(window-system (or window-system 'htmlfontify))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1849 (target nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1850 (source nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1851 (html nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1852 (cd srcdir)
106128
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
1853 (with-current-buffer (setq source (find-file-noselect file))
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
1854 ;; FIXME: Shouldn't this use expand-file-name? --Stef
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1855 (setq target (concat dstdir "/" file))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1856 (hfy-make-directory (hfy-dirname target))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1857 (if (not (hfy-opt 'skip-refontification)) (hfy-force-fontification))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1858 (if (or (hfy-fontified-p) (hfy-text-p srcdir file))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1859 (progn (setq html (hfy-fontify-buffer srcdir file))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1860 (set-buffer html)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1861 (write-file (concat target hfy-extn))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1862 (kill-buffer html))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1863 ;; #o0200 == 128, but emacs20 doesn't know that
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1864 (if (and (file-exists-p target) (not (file-writable-p target)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1865 (set-file-modes target (logior (file-modes target) 128)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1866 (copy-file (buffer-file-name source) target 'overwrite))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1867 (kill-buffer source)) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1868
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1869 ;; list of tags in file in srcdir
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1870 (defun hfy-tags-for-file (srcdir file)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1871 "List of etags tags that have definitions in this FILE.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1872 Looks up the tags cache in `hfy-tags-cache' using SRCDIR as the key."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1873 ;;(message "hfy-tags-for-file");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1874 (let ((cache-entry (assoc srcdir hfy-tags-cache))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1875 (cache-hash nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1876 (tag-list nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1877 (if (setq cache-hash (cadr cache-entry))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1878 (maphash
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1879 (lambda (K V)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1880 (if (assoc file V)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1881 (setq tag-list (cons K tag-list)))) cache-hash))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1882 tag-list))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1883
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1884 ;; mark the tags native to this file for anchors
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1885 (defun hfy-mark-tag-names (srcdir file)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1886 "Mark tags in FILE (lookup SRCDIR in `hfy-tags-cache') with the `hfy-anchor'
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1887 property, with a value of \"tag.line-number\"."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1888 ;;(message "(hfy-mark-tag-names %s %s)" srcdir file);;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1889 (let ((cache-entry (assoc srcdir hfy-tags-cache))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1890 (cache-hash nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1891 (if (setq cache-hash (cadr cache-entry))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1892 (mapcar
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1893 (lambda (TAG)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1894 (mapcar
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1895 (lambda (TLIST)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1896 (if (string= file (car TLIST))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1897 (let* ((line (cadr TLIST) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1898 (chr (caddr TLIST) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1899 (link (format "%s.%d" TAG line) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1900 (put-text-property (+ 1 chr)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1901 (+ 2 chr)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1902 'hfy-anchor link))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1903 (gethash TAG cache-hash)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1904 (hfy-tags-for-file srcdir file)))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1905
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1906 (defun hfy-relstub (file &optional start)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1907 "Return a \"../\" stub of the appropriate length for the current source
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1908 tree depth, as determined from FILE (a filename).
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1909 START is the offset at which to start looking for the / character in FILE."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1910 ;;(message "hfy-relstub");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1911 (let ((c ""))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1912 (while (setq start (string-match "/" file start))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1913 (setq start (1+ start)) (setq c (concat c "../"))) c))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1914
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1915 (defun hfy-href-stub (this-file def-files tag)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1916 "Return an href stub for a tag href in THIS-FILE.
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1917 If DEF-FILES (list of files containing definitions for the tag in question)
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1918 contains only one entry, the href should link straight to that file.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1919 Otherwise, the link should be to the index file.\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1920 We are not yet concerned with the file extensions/tag line number and so on at
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1921 this point.\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1922 If `hfy-split-index' is set, and the href wil be to an index file rather than
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1923 a source file, append a .X to `hfy-index-file', where X is the uppercased
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1924 first character of TAG.\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1925 See also `hfy-relstub', `hfy-index-file'."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1926 ;;(message "hfy-href-stub");;DBUG
106128
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
1927 ;; FIXME: Why not use something like
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
1928 ;; (file-relative-name (if ...) (file-name-directory this-file)) ? --Stef
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1929 (concat
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1930 (hfy-relstub this-file)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1931 (if (= 1 (length def-files)) (car def-files)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1932 (if (not hfy-split-index) hfy-index-file
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1933 (concat hfy-index-file "." (upcase (substring tag 0 1)))))) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1934
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1935 (defun hfy-href (this-file def-files tag tag-map)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1936 "Return a relative href to the tag in question, based on\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1937 THIS-FILE `hfy-link-extn' `hfy-extn' DEF-FILES TAG and TAG-MAP\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1938 THIS-FILE is the current source file
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1939 DEF-FILES is a list of file containing possible link endpoints for TAG
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1940 TAG is the tag in question
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1941 TAG-MAP is the entry in `hfy-tags-cache'."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1942 ;;(message "hfy-href");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1943 (concat
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1944 (hfy-href-stub this-file def-files tag)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1945 (or hfy-link-extn hfy-extn) "#" tag ;;(.src -> .html)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1946 (if (= 1 (length def-files))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1947 (concat "." (format "%d" (cadr (assoc (car def-files) tag-map)))))) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1948
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1949 (defun hfy-word-regex (string)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1950 "Return a regex that matches STRING as the first `match-string', with non
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1951 word characters on either side."
106128
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
1952 ;; FIXME: Should this use [^$[:alnum:]_] instead? --Stef
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1953 (concat "[^$A-Za-z_0-9]\\(" (regexp-quote string) "\\)[^A-Za-z_0-9]"))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1954
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1955 ;; mark all tags for hyperlinking, except the tags at
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1956 ;; their own points of definition, iyswim:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1957 (defun hfy-mark-tag-hrefs (srcdir file)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1958 "Mark href start points with the `hfy-link' prop (value: href string).\n
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
1959 Mark href end points with the `hfy-endl' prop (value t).\n
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1960 Avoid overlapping links, and mark links in descending length of
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1961 tag name in order to prevent subtags from usurping supertags,
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1962 \(eg \"term\" for \"terminal\").
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1963 SRCDIR is the directory being \"published\".
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1964 FILE is the specific file we are rendering."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1965 ;;(message "hfy-mark-tag-hrefs");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1966 (let ((cache-entry (assoc srcdir hfy-tags-cache))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1967 (list-cache (assoc srcdir hfy-tags-sortl))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1968 (rmap-cache (assoc srcdir hfy-tags-rmap ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1969 (no-comment (hfy-opt 'zap-comment-links))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1970 (no-strings (hfy-opt 'zap-string-links ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1971 (cache-hash nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1972 (tags-list nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1973 (tags-rmap nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1974 (case-fold-search nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1975 ;; extract the tag mapping hashes (fwd and rev) and the tag list:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1976 (if (and (setq cache-hash (cadr cache-entry))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1977 (setq tags-rmap (cadr rmap-cache ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1978 (setq tags-list (cadr list-cache )))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1979 (mapcar
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1980 (lambda (TAG)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1981 (let* ((start nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1982 (stop nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1983 (href nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1984 (name nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1985 (case-fold-search nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1986 (tmp-point nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1987 (maybe-start nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1988 (face-at nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1989 (rmap-entry nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1990 (rnew-elt nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1991 (rmap-line nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1992 (tag-regex (hfy-word-regex TAG))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1993 (tag-map (gethash TAG cache-hash))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
1994 (tag-files (mapcar #'car tag-map)))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1995 ;; find instances of TAG and do what needs to be done:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1996 (goto-char (point-min))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1997 (while (search-forward TAG nil 'NOERROR)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1998 (setq tmp-point (point)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1999 maybe-start (- (match-beginning 0) 1))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2000 (goto-char maybe-start)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2001 (if (not (looking-at tag-regex))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2002 nil
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2003 (setq start (match-beginning 1))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2004 (setq stop (match-end 1))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2005 (setq face-at
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2006 (and (or no-comment no-strings) (hfy-face-at start)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2007 (if (listp face-at)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2008 (setq face-at (cadr (memq :inherit face-at))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2009 (if (or (text-property-any start (1+ stop) 'hfy-linkp t)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2010 (and no-comment (eq 'font-lock-comment-face face-at))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2011 (and no-strings (eq 'font-lock-string-face face-at)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2012 nil ;; already a link, NOOP
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2013
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2014 ;; set a reverse map entry:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2015 (setq rmap-line (line-number-at-pos)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2016 rmap-entry (gethash TAG tags-rmap)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2017 rnew-elt (list file rmap-line start)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2018 rmap-entry (cons rnew-elt rmap-entry)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2019 name (format "%s.%d" TAG rmap-line))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2020 (put-text-property start (1+ start) 'hfy-inst name)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2021 (puthash TAG rmap-entry tags-rmap)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2022
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2023 ;; mark the link. link to index if the tag has > 1 def
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2024 ;; add the line number to the #name if it does not:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2025 (setq href (hfy-href file tag-files TAG tag-map))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2026 (put-text-property start (1+ start) 'hfy-link href)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2027 (put-text-property stop (1+ stop ) 'hfy-endl t )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2028 (put-text-property start (1+ stop ) 'hfy-linkp t )))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2029 (goto-char tmp-point)) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2030 tags-list) )))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2031
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2032 (defun hfy-shell ()
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2033 "Return `shell-file-name', or \"/bin/sh\" if it is a non-bourne shell."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2034 (if (string-match "\\<bash\\>\\|\\<sh\\>\\|\\<dash\\>" shell-file-name)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2035 shell-file-name
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2036 (or hfy-shell-file-name "/bin/sh")))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2037
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2038 ;; cache the #(tag => file line point) entries for files under srcdir
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2039 ;; and cache the descending sorted list of tags in the relevant alist,
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2040 ;; also keyed by srcdir:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2041 (defun hfy-load-tags-cache (srcdir)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2042 "Run `hfy-etags-cmd' on SRCDIR, then call `hfy-parse-tags-buffer'."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2043 ;;(message "hfy-load-tags-cache");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2044 (let ((etags-buffer (get-buffer-create "*hfy-tags*"))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2045 (etags-command (format hfy-etags-cmd hfy-etags-bin))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2046 (shell-file-name (hfy-shell)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2047 (cd srcdir)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2048 (shell-command etags-command etags-buffer)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2049 (hfy-parse-tags-buffer srcdir etags-buffer)) )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2050
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2051 ;; break this out from `hfy-load-tags-cache' to make the tar file
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2052 ;; functionality easier to implement.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2053 ;; ( tar file functionality not merged here because it requires a
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2054 ;; hacked copy of etags capable of tagging stdin: if Francesco
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2055 ;; Potorti accepts a patch, or otherwise implements stdin tagging,
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2056 ;; then I will provide a `htmlfontify-tar-file' defun )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2057 (defun hfy-parse-tags-buffer (srcdir buffer)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2058 "Parse a BUFFER containing etags formatted output, loading the
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2059 `hfy-tags-cache' and `hfy-tags-sortl' entries for SRCDIR."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2060 (let ((cache-entry (assoc srcdir hfy-tags-cache))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2061 (tlist-cache (assoc srcdir hfy-tags-sortl))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2062 (trmap-cache (assoc srcdir hfy-tags-rmap ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2063 (cache-hash nil) (trmap-hash nil) (tags-list nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2064 (hash-entry nil) (tag-string nil) (tag-line nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2065 (tag-point nil) (new-entry nil) (etags-file nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2066
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2067 ;; (re)initialise the tag reverse map:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2068 (if trmap-cache (setq trmap-hash (cadr trmap-cache))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2069 (setq trmap-hash (make-hash-table :test 'equal))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2070 (setq hfy-tags-rmap (list (list srcdir trmap-hash) hfy-tags-rmap)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2071 (clrhash trmap-hash)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2072
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2073 ;; (re)initialise the tag cache:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2074 (if cache-entry (setq cache-hash (cadr cache-entry))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2075 (setq cache-hash (make-hash-table :test 'equal))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2076 (setq hfy-tags-cache (list (list srcdir cache-hash) hfy-tags-cache)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2077 (clrhash cache-hash)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2078
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2079 ;; cache the TAG => ((file line point) (file line point) ... ) entries:
106128
ed77a6edfaa1 * hfy-cmap.el (hfy-rgb-file): Use locate-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106126
diff changeset
2080 (with-current-buffer buffer
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2081 (goto-char (point-min))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2082
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2083 (while (and (looking-at "^\x0c") (= 0 (forward-line 1)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2084 ;;(message "^L boundary")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2085 (if (and (looking-at "^\\(.+\\),\\([0-9]+\\)$")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2086 (= 0 (forward-line 1)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2087 (progn
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2088 (setq etags-file (match-string 1))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2089 ;;(message "TAGS for file: %s" etags-file)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2090 (while (and (looking-at hfy-etag-regex) (= 0 (forward-line 1)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2091 (setq tag-string (match-string 1))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2092 (if (= 0 (length tag-string)) nil ;; noop
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2093 (setq tag-line (round (string-to-number (match-string 2))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2094 (setq tag-point (round (string-to-number (match-string 3))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2095 (setq hash-entry (gethash tag-string cache-hash))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2096 (setq new-entry (list etags-file tag-line tag-point))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2097 (push new-entry hash-entry)
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2098 ;;(message "HASH-ENTRY %s %S" tag-string new-entry)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2099 (puthash tag-string hash-entry cache-hash)))) )))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2100
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2101 ;; cache a list of tags in descending length order:
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2102 (maphash (lambda (K V) (push K tags-list)) cache-hash)
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2103 (setq tags-list (sort tags-list (lambda (A B) (< (length B) (length A)))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2104
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2105 ;; put the tag list into the cache:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2106 (if tlist-cache (setcar (cdr tlist-cache) tags-list)
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2107 (push (list srcdir tags-list) hfy-tags-sortl))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2108
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2109 ;; return the number of tags found:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2110 (length tags-list) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2111
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2112 (defun hfy-prepare-index-i (srcdir dstdir filename &optional stub map)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2113 "Prepare a tags index buffer for SRCDIR.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2114 `hfy-tags-cache' must already have an entry for SRCDIR for this to work.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2115 `hfy-page-header', `hfy-page-footer', `hfy-link-extn' and `hfy-extn'
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2116 all play a part here.\n
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
2117 If STUB is set, prepare an (appropriately named) index buffer
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2118 specifically for entries beginning with STUB.\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2119 If MAP is set, use that instead of `hfy-tags-cache'.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2120 FILENAME is the name of the file being indexed.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2121 DSTDIR is the output directory, where files will be written."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2122 ;;(message "hfy-write-index");;DBUG
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2123 (let ((cache-entry (assoc srcdir (or map hfy-tags-cache)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2124 (cache-hash nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2125 (tag-list nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2126 (index-file
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2127 (concat filename (if stub (concat "." stub) "") hfy-extn))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2128 (index-buf nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2129 (if (not (and cache-entry
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2130 (setq cache-hash (cadr cache-entry))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2131 (setq index-buf (get-buffer-create index-file))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2132 nil ;; noop
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2133 (maphash (lambda (K V) (push K tag-list)) cache-hash)
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2134 (setq tag-list (sort tag-list 'string<))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2135 (set-buffer index-buf)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2136 (erase-buffer)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2137 (insert (funcall hfy-page-header filename "<!-- CSS -->"))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2138 (insert "<table class=\"index\">\n")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2139
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2140 (dolist (TAG tag-list)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2141 (let ((tag-started nil))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2142 (dolist (DEF (gethash TAG cache-hash))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2143 (if (and stub (not (string-match (concat "^" stub) TAG)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2144 nil ;; we have a stub and it didn't match: NOOP
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2145 (let ((file (car DEF))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2146 (line (cadr DEF)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2147 (insert
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2148 (format
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2149 (concat
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2150 " <tr> \n"
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2151 " <td>%s</td> \n"
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2152 " <td><a href=\"%s%s\">%s</a></td> \n"
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2153 " <td><a href=\"%s%s#%s.%d\">%d</a></td>\n"
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2154 " </tr> \n")
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2155 (if (string= TAG tag-started) "&nbsp;"
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2156 (format "<a name=\"%s\">%s</a>" TAG TAG))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2157 file (or hfy-link-extn hfy-extn) file
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2158 file (or hfy-link-extn hfy-extn) TAG line line))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2159 (setq tag-started TAG))))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2160 (insert "</table>\n")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2161 (insert (funcall hfy-page-footer filename))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2162 (and dstdir (cd dstdir))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2163 (set-visited-file-name index-file)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2164 index-buf) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2165
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2166 (defun hfy-prepare-index (srcdir dstdir)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
2167 "Return a list of index buffer(s), as determined by `hfy-split-index'.
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2168 SRCDIR and DSTDIR are the source and output directories respectively."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2169 (if (not hfy-split-index)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2170 (list (hfy-prepare-index-i srcdir dstdir hfy-index-file nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2171 (let ((stub-list nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2172 (cache-hash nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2173 (index-list nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2174 (cache-entry (assoc srcdir hfy-tags-cache)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2175 (if (and cache-entry (setq cache-hash (cadr cache-entry)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2176 (maphash
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2177 (lambda (K V)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2178 (let ((stub (upcase (substring K 0 1))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2179 (if (member stub stub-list)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2180 nil ;; seen this already: NOOP
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2181 (setq
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2182 stub-list (cons stub stub-list)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2183 index-list (cons (hfy-prepare-index-i srcdir
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2184 dstdir
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2185 hfy-index-file
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2186 stub)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2187 index-list)) ))) cache-hash) ) index-list)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2188
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2189 (defun hfy-prepare-tag-map (srcdir dstdir)
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
2190 "Prepare the counterpart(s) to the index buffer(s) - a list of buffers
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
2191 with the same structure, but listing (and linking to) instances of tags
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
2192 \(as opposed to their definitions).\n
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2193 SRCDIR and DSTDIR are the source and output directories respectively.
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
2194 See also `hfy-prepare-index', `hfy-split-index'."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2195 (if (not hfy-split-index)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2196 (list (hfy-prepare-index-i srcdir
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2197 dstdir
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2198 hfy-instance-file
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2199 nil
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2200 hfy-tags-rmap))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2201 (let ((stub-list nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2202 (cache-hash nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2203 (index-list nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2204 (cache-entry (assoc srcdir hfy-tags-rmap)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2205
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2206 (if (and cache-entry (setq cache-hash (cadr cache-entry)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2207 (maphash
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2208 (lambda (K V)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2209 (let ((stub (upcase (substring K 0 1))))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2210 (if (member stub stub-list)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2211 nil ;; seen this already: NOOP
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2212 (setq
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2213 stub-list (cons stub stub-list)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2214 index-list (cons (hfy-prepare-index-i srcdir
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2215 dstdir
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2216 hfy-instance-file
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2217 stub
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2218 hfy-tags-rmap)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2219 index-list)) ))) cache-hash) ) index-list)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2220
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2221 (defun hfy-subtract-maps (srcdir)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2222 "Internal function - strips definitions of tags from the instance map.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2223 SRCDIR is the directory being \"published\".
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
2224 See also `hfy-tags-cache', `hfy-tags-rmap'."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2225 (let ((new-list nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2226 (old-list nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2227 (def-list nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2228 (exc-list nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2229 (fwd-map (cadr (assoc srcdir hfy-tags-cache)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2230 (rev-map (cadr (assoc srcdir hfy-tags-rmap )))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2231 (taglist (cadr (assoc srcdir hfy-tags-sortl))))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2232 (dolist (TAG taglist)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2233 (setq def-list (gethash TAG fwd-map)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2234 old-list (gethash TAG rev-map)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2235 exc-list (mapcar (lambda (P) (list (car P) (cadr P))) def-list)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2236 new-list nil)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2237 (dolist (P old-list)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2238 (or (member (list (car P) (cadr P)) exc-list)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2239 (push P new-list)))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2240 (puthash TAG new-list rev-map))))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2241
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2242 (defun htmlfontify-run-etags (srcdir)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2243 "Load the etags cache for SRCDIR.
106795
8802f28da1a8 Fix typos and remove superfluous backslash-quoting in htmlfontify.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 106505
diff changeset
2244 See also `hfy-load-tags-cache'."
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2245 (interactive "D source directory: ")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2246 (setq srcdir (directory-file-name srcdir))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2247 (hfy-load-tags-cache srcdir))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2248
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2249 ;;(defun hfy-test-read-args (foo bar)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2250 ;; (interactive "D source directory: \nD target directory: ")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2251 ;; (message "foo: %S\nbar: %S" foo bar))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2252
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2253 (defun hfy-save-kill-buffers (buffer-list &optional dstdir)
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2254 (dolist (B buffer-list)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2255 (set-buffer B)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2256 (and dstdir (file-directory-p dstdir) (cd dstdir))
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2257 (save-buffer)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2258 (kill-buffer B)))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2259
107971
ab970852cf46 Add some autoloads.
Glenn Morris <rgm@gnu.org>
parents: 107207
diff changeset
2260 ;;;###autoload
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2261 (defun htmlfontify-copy-and-link-dir (srcdir dstdir &optional f-ext l-ext)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2262 "Trawl SRCDIR and write fontified-and-hyperlinked output in DSTDIR.
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2263 F-EXT and L-EXT specify values for `hfy-extn' and `hfy-link-extn'.\n
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2264 You may also want to set `hfy-page-header' and `hfy-page-footer'."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2265 (interactive "D source directory: \nD output directory: ")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2266 ;;(message "htmlfontify-copy-and-link-dir")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2267 (setq srcdir (directory-file-name srcdir))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2268 (setq dstdir (directory-file-name dstdir))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2269 (let ((source-files "SETME: list of source files, relative to srcdir")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2270 (tr-cache (assoc srcdir hfy-tags-rmap))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2271 (hfy-extn (or f-ext ".html"))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2272 (hfy-link-extn (or l-ext ".html")))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2273 ;; oops, forgot to load etags for srcdir:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2274 (if tr-cache nil
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2275 (message "autoload of tags cache")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2276 (hfy-load-tags-cache srcdir)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2277 (setq tr-cache (assoc srcdir hfy-tags-rmap)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2278 ;; clear out the old cache:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2279 (clrhash (cadr tr-cache))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2280 (hfy-make-directory dstdir)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2281 (setq source-files (hfy-list-files srcdir))
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2282 (dolist (file source-files)
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2283 (hfy-copy-and-fontify-file srcdir dstdir file))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2284 (hfy-subtract-maps srcdir)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2285 (hfy-save-kill-buffers (hfy-prepare-index srcdir dstdir) dstdir)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2286 (hfy-save-kill-buffers (hfy-prepare-tag-map srcdir dstdir) dstdir) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2287
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2288 ;; name of the init file we want:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2289 (defun hfy-initfile ()
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2290 "Return the expected location of the htmlfontify specific init/custom file."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2291 (let* ((file (or (getenv "HFY_INITFILE") ".hfy.el")))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2292 (expand-file-name file "~") ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2293
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2294
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2295 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2296 ;; incomplete as yet : transfer hook settings to hfy init file:
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2297 ;; (defalias 'hfy-set-hooks 'custom-set-variables)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2298
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2299 ;; (defun hfy-pp-hook (H)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2300 ;; (and (string-match "-hook$" (symbol-name H))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2301 ;; (boundp H)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2302 ;; (symbol-value H)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2303 ;; (insert (format "\n '(%S %S)" H (symbol-value H)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2304 ;; )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2305 ;; )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2306
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2307 ;; (defun hfy-save-hooks ()
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2308 ;; (let ((custom-file (hfy-initfile)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2309 ;; (custom-save-delete 'hfy-set-hooks)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2310 ;; (let ((standard-output (current-buffer)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2311 ;; (princ "(hfy-set-hooks\n;;auto-generated, only one copy allowed\n")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2312 ;; (mapatoms 'hfy-pp-hook)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2313 ;; (insert "\n)")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2314 ;; )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2315 ;; )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2316 ;; )
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2317 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2318
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2319 (defalias 'hfy-init-progn 'progn)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2320
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2321 (defun hfy-save-initvar (sym)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2322 (princ (format "(setq %s\n '" sym))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2323 (pp (symbol-value sym))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2324 (princ ")\n"))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2325
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2326 (defun htmlfontify-save-initfile ()
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2327 "Save the htmlfontify settings to the htmlfontify init file."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2328 (interactive)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2329 (let* ((start-pos nil)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2330 (custom-file (hfy-initfile))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2331 (standard-output (find-file-noselect custom-file 'nowarn)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2332 (save-excursion
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2333 (custom-save-delete 'hfy-init-progn)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2334 (setq start-pos (point))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2335 (princ "(hfy-init-progn\n;;auto-generated, only one copy allowed\n")
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2336 ;; FIXME: This saving&restoring of global customization
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2337 ;; variables can interfere with other customization settings for
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2338 ;; those vars (in .emacs or in Customize).
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2339 (mapc 'hfy-save-initvar
106271
8d51419ae1f3 Misc coding convention cleanups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106270
diff changeset
2340 '(auto-mode-alist interpreter-mode-alist))
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2341 (princ ")\n")
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2342 (indent-region start-pos (point) nil))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2343 (custom-save-all) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2344
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2345 (defun htmlfontify-load-initfile ()
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2346 "Load the htmlfontify specific init/custom file."
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2347 (interactive)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2348 (let ((file (hfy-initfile)))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2349 (load file 'NOERROR nil nil) ))
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2350
108099
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2351
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2352 ;;;### (autoloads (hfy-fallback-colour-values htmlfontify-load-rgb-file)
112330
56d3e9c28eb0 Merge from mainline.
Paul Eggert <eggert@cs.ucla.edu>
parents: 112284
diff changeset
2353 ;;;;;; "hfy-cmap" "hfy-cmap.el" "f7f81749b08e0aec14aac431f8b5ac8b")
108099
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2354 ;;; Generated autoloads from hfy-cmap.el
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2355
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2356 (autoload 'htmlfontify-load-rgb-file "hfy-cmap" "\
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2357 Load an X11 style rgb.txt FILE.
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2358 Search `hfy-rgb-load-path' if FILE is not specified.
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2359 Loads the variable `hfy-rgb-txt-colour-map', which is used by
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2360 `hfy-fallback-colour-values'.
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2361
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2362 \(fn &optional FILE)" t nil)
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2363
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2364 (autoload 'hfy-fallback-colour-values "hfy-cmap" "\
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2365 Use a fallback method for obtaining the rgb values for a color.
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2366
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2367 \(fn COLOUR-STRING)" nil nil)
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2368
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2369 ;;;***
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2370
3040d386675c Minor htmlfontify simplifications.
Glenn Morris <rgm@gnu.org>
parents: 107971
diff changeset
2371
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2372 (provide 'htmlfontify)
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2373
110819
c8c94070c034 * lisp/htmlfontify.el: Add utf-8 coding cookie (eg for ellipsis at l1686).
Glenn Morris <rgm@gnu.org>
parents: 110087
diff changeset
2374 ;; Local Variables:
c8c94070c034 * lisp/htmlfontify.el: Add utf-8 coding cookie (eg for ellipsis at l1686).
Glenn Morris <rgm@gnu.org>
parents: 110087
diff changeset
2375 ;; coding: utf-8
c8c94070c034 * lisp/htmlfontify.el: Add utf-8 coding cookie (eg for ellipsis at l1686).
Glenn Morris <rgm@gnu.org>
parents: 110087
diff changeset
2376 ;; End:
c8c94070c034 * lisp/htmlfontify.el: Add utf-8 coding cookie (eg for ellipsis at l1686).
Glenn Morris <rgm@gnu.org>
parents: 110087
diff changeset
2377
106126
10d66efa4c61 New files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2378 ;;; htmlfontify.el ends here