diff options
| author | Stefan Monnier | 2020-04-15 00:23:09 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2020-04-15 00:23:32 -0400 |
| commit | 72fc8ec6dd013e6964d58bf624e2b5ebf4177a64 (patch) | |
| tree | 8c15bd7c5d549f444624457100620d49a30fc66a | |
| parent | 26df9aae532827461047159836569406c707c211 (diff) | |
| download | emacs-72fc8ec6dd013e6964d58bf624e2b5ebf4177a64.tar.gz emacs-72fc8ec6dd013e6964d58bf624e2b5ebf4177a64.zip | |
* lisp/htmlfontify.el: Use `font-lock-ensure` unconditionally
Remove redundant `:group`s.
(hfy-force-fontification): Make it an obsolete alias for `font-lock-ensure`.
Update all callers.
(hfy-init-kludge-hooks, hfy-init-kludge-hook): Remove vars, not used any more.
(hfy-kludge-cperl-mode): Declare it obsolete.
| -rw-r--r-- | lisp/htmlfontify.el | 109 |
1 files changed, 25 insertions, 84 deletions
diff --git a/lisp/htmlfontify.el b/lisp/htmlfontify.el index 1d98b633d78..7a5d88ce834 100644 --- a/lisp/htmlfontify.el +++ b/lisp/htmlfontify.el | |||
| @@ -136,8 +136,8 @@ main-content <=MAIN_CONTENT;\\n\" rtfm-section file style rtfm-section file)) | |||
| 136 | \"s section[eg- emacs / p4-blame]:\\nD source-dir: \\nD output-dir: \") | 136 | \"s section[eg- emacs / p4-blame]:\\nD source-dir: \\nD output-dir: \") |
| 137 | (require \\='htmlfontify) | 137 | (require \\='htmlfontify) |
| 138 | (hfy-load-tags-cache srcdir) | 138 | (hfy-load-tags-cache srcdir) |
| 139 | (let ((hfy-page-header \\='rtfm-build-page-header) | 139 | (let ((hfy-page-header #\\='rtfm-build-page-header) |
| 140 | (hfy-page-footer \\='rtfm-build-page-footer) | 140 | (hfy-page-footer #\\='rtfm-build-page-footer) |
| 141 | (rtfm-section section) | 141 | (rtfm-section section) |
| 142 | (hfy-index-file \"index\")) | 142 | (hfy-index-file \"index\")) |
| 143 | (htmlfontify-run-etags srcdir) | 143 | (htmlfontify-run-etags srcdir) |
| @@ -151,7 +151,7 @@ main-content <=MAIN_CONTENT;\\n\" rtfm-section file style rtfm-section file)) | |||
| 151 | :link '(info-link "(htmlfontify) Customization") | 151 | :link '(info-link "(htmlfontify) Customization") |
| 152 | :prefix "hfy-") | 152 | :prefix "hfy-") |
| 153 | 153 | ||
| 154 | (defcustom hfy-page-header 'hfy-default-header | 154 | (defcustom hfy-page-header #'hfy-default-header |
| 155 | "Function called to build the header of the HTML source. | 155 | "Function called to build the header of the HTML source. |
| 156 | This is called with two arguments (the filename relative to the top | 156 | This is called with two arguments (the filename relative to the top |
| 157 | level source directory being etag'd and fontified), and a string containing | 157 | level source directory being etag'd and fontified), and a string containing |
| @@ -159,7 +159,6 @@ the <style>...</style> text to embed in the document. | |||
| 159 | It should return a string that will be used as the header for the | 159 | It should return a string that will be used as the header for the |
| 160 | htmlfontified version of the source file.\n | 160 | htmlfontified version of the source file.\n |
| 161 | See also `hfy-page-footer'." | 161 | See also `hfy-page-footer'." |
| 162 | :group 'htmlfontify | ||
| 163 | ;; FIXME: Why place such a :tag everywhere? Isn't it imposing your | 162 | ;; FIXME: Why place such a :tag everywhere? Isn't it imposing your |
| 164 | ;; own Custom preference on your users? --Stef | 163 | ;; own Custom preference on your users? --Stef |
| 165 | :tag "page-header" | 164 | :tag "page-header" |
| @@ -170,32 +169,27 @@ See also `hfy-page-footer'." | |||
| 170 | If non-nil, the index is split on the first letter of each tag. | 169 | If non-nil, the index is split on the first letter of each tag. |
| 171 | Useful when the index would otherwise be large and take | 170 | Useful when the index would otherwise be large and take |
| 172 | a long time to render or be difficult to navigate." | 171 | a long time to render or be difficult to navigate." |
| 173 | :group 'htmlfontify | ||
| 174 | :tag "split-index" | 172 | :tag "split-index" |
| 175 | :type '(boolean)) | 173 | :type '(boolean)) |
| 176 | 174 | ||
| 177 | (defcustom hfy-page-footer 'hfy-default-footer | 175 | (defcustom hfy-page-footer #'hfy-default-footer |
| 178 | "As `hfy-page-header', but generates the output footer. | 176 | "As `hfy-page-header', but generates the output footer. |
| 179 | It takes only one argument, the filename." | 177 | It takes only one argument, the filename." |
| 180 | :group 'htmlfontify | ||
| 181 | :tag "page-footer" | 178 | :tag "page-footer" |
| 182 | :type '(function)) | 179 | :type '(function)) |
| 183 | 180 | ||
| 184 | (defcustom hfy-extn ".html" | 181 | (defcustom hfy-extn ".html" |
| 185 | "File extension used for output files." | 182 | "File extension used for output files." |
| 186 | :group 'htmlfontify | ||
| 187 | :tag "extension" | 183 | :tag "extension" |
| 188 | :type '(string)) | 184 | :type '(string)) |
| 189 | 185 | ||
| 190 | (defcustom hfy-src-doc-link-style "text-decoration: underline;" | 186 | (defcustom hfy-src-doc-link-style "text-decoration: underline;" |
| 191 | "String to add to the `<style> a' variant of an htmlfontify CSS class." | 187 | "String to add to the `<style> a' variant of an htmlfontify CSS class." |
| 192 | :group 'htmlfontify | ||
| 193 | :tag "src-doc-link-style" | 188 | :tag "src-doc-link-style" |
| 194 | :type '(string)) | 189 | :type '(string)) |
| 195 | 190 | ||
| 196 | (defcustom hfy-src-doc-link-unstyle " text-decoration: none;" | 191 | (defcustom hfy-src-doc-link-unstyle " text-decoration: none;" |
| 197 | "Regex to remove from the `<style> a' variant of an htmlfontify CSS class." | 192 | "Regex to remove from the `<style> a' variant of an htmlfontify CSS class." |
| 198 | :group 'htmlfontify | ||
| 199 | :tag "src-doc-link-unstyle" | 193 | :tag "src-doc-link-unstyle" |
| 200 | :type '(regexp)) | 194 | :type '(regexp)) |
| 201 | 195 | ||
| @@ -204,32 +198,28 @@ It takes only one argument, the filename." | |||
| 204 | Useful where the htmlfontify output files are going to be processed | 198 | Useful where the htmlfontify output files are going to be processed |
| 205 | again, with a resulting change in file extension. If nil, then any | 199 | again, with a resulting change in file extension. If nil, then any |
| 206 | code using this should fall back to `hfy-extn'." | 200 | code using this should fall back to `hfy-extn'." |
| 207 | :group 'htmlfontify | ||
| 208 | :tag "link-extension" | 201 | :tag "link-extension" |
| 209 | :type '(choice string (const nil))) | 202 | :type '(choice string (const nil))) |
| 210 | 203 | ||
| 211 | (defcustom hfy-link-style-fun 'hfy-link-style-string | 204 | (defcustom hfy-link-style-fun #'hfy-link-style-string |
| 212 | "Function to customize the appearance of hyperlinks. | 205 | "Function to customize the appearance of hyperlinks. |
| 213 | Set this to a function, which will be called with one argument | 206 | Set this to a function, which will be called with one argument |
| 214 | \(a \"{ foo: bar; ...}\" CSS style-string) - it should return a copy of | 207 | \(a \"{ foo: bar; ...}\" CSS style-string) - it should return a copy of |
| 215 | its argument, altered so as to make any changes you want made for text which | 208 | its argument, altered so as to make any changes you want made for text which |
| 216 | is a hyperlink, in addition to being in the class to which that style would | 209 | is a hyperlink, in addition to being in the class to which that style would |
| 217 | normally be applied." | 210 | normally be applied." |
| 218 | :group 'htmlfontify | ||
| 219 | :tag "link-style-function" | 211 | :tag "link-style-function" |
| 220 | :type '(function)) | 212 | :type '(function)) |
| 221 | 213 | ||
| 222 | (defcustom hfy-index-file "hfy-index" | 214 | (defcustom hfy-index-file "hfy-index" |
| 223 | "Name (sans extension) of the tag definition index file produced during | 215 | "Name (sans extension) of the tag definition index file produced during |
| 224 | fontification-and-hyperlinking." | 216 | fontification-and-hyperlinking." |
| 225 | :group 'htmlfontify | ||
| 226 | :tag "index-file" | 217 | :tag "index-file" |
| 227 | :type '(string)) | 218 | :type '(string)) |
| 228 | 219 | ||
| 229 | (defcustom hfy-instance-file "hfy-instance" | 220 | (defcustom hfy-instance-file "hfy-instance" |
| 230 | "Name (sans extension) of the tag usage index file produced during | 221 | "Name (sans extension) of the tag usage index file produced during |
| 231 | fontification-and-hyperlinking." | 222 | fontification-and-hyperlinking." |
| 232 | :group 'htmlfontify | ||
| 233 | :tag "instance-file" | 223 | :tag "instance-file" |
| 234 | :type '(string)) | 224 | :type '(string)) |
| 235 | 225 | ||
| @@ -237,25 +227,13 @@ fontification-and-hyperlinking." | |||
| 237 | "Regex to match (with a single back-reference per match) strings in HTML | 227 | "Regex to match (with a single back-reference per match) strings in HTML |
| 238 | which should be quoted with `hfy-html-quote' (and `hfy-html-quote-map') | 228 | which should be quoted with `hfy-html-quote' (and `hfy-html-quote-map') |
| 239 | to make them safe." | 229 | to make them safe." |
| 240 | :group 'htmlfontify | ||
| 241 | :tag "html-quote-regex" | 230 | :tag "html-quote-regex" |
| 242 | :type '(regexp)) | 231 | :type '(regexp)) |
| 243 | 232 | ||
| 244 | (define-obsolete-variable-alias 'hfy-init-kludge-hooks 'hfy-init-kludge-hook | ||
| 245 | "23.2") | ||
| 246 | (defcustom hfy-init-kludge-hook '(hfy-kludge-cperl-mode) | ||
| 247 | "List of functions to call when starting `htmlfontify-buffer' to do any | ||
| 248 | kludging necessary to get highlighting modes to behave as you want, even | ||
| 249 | when not running under a window system." | ||
| 250 | :group 'htmlfontify | ||
| 251 | :tag "init-kludge-hooks" | ||
| 252 | :type '(hook)) | ||
| 253 | |||
| 254 | (define-obsolete-variable-alias 'hfy-post-html-hooks 'hfy-post-html-hook "24.3") | 233 | (define-obsolete-variable-alias 'hfy-post-html-hooks 'hfy-post-html-hook "24.3") |
| 255 | (defcustom hfy-post-html-hook nil | 234 | (defcustom hfy-post-html-hook nil |
| 256 | "List of functions to call after creating and filling the HTML buffer. | 235 | "List of functions to call after creating and filling the HTML buffer. |
| 257 | These functions will be called with the HTML buffer as the current buffer." | 236 | These functions will be called with the HTML buffer as the current buffer." |
| 258 | :group 'htmlfontify | ||
| 259 | :tag "post-html-hooks" | 237 | :tag "post-html-hooks" |
| 260 | :options '(set-auto-mode) | 238 | :options '(set-auto-mode) |
| 261 | :type '(hook)) | 239 | :type '(hook)) |
| @@ -267,7 +245,6 @@ potentially non-current face information doesn't necessarily work for | |||
| 267 | `default').\n | 245 | `default').\n |
| 268 | Example: I customize this to:\n | 246 | Example: I customize this to:\n |
| 269 | \((t :background \"black\" :foreground \"white\" :family \"misc-fixed\"))" | 247 | \((t :background \"black\" :foreground \"white\" :family \"misc-fixed\"))" |
| 270 | :group 'htmlfontify | ||
| 271 | :tag "default-face-definition" | 248 | :tag "default-face-definition" |
| 272 | :type '(alist)) | 249 | :type '(alist)) |
| 273 | 250 | ||
| @@ -281,7 +258,6 @@ in order, to:\n | |||
| 281 | 1 - The tag | 258 | 1 - The tag |
| 282 | 2 - The line | 259 | 2 - The line |
| 283 | 3 - The char (point) at which the tag occurs." | 260 | 3 - The char (point) at which the tag occurs." |
| 284 | :group 'htmlfontify | ||
| 285 | :tag "etag-regex" | 261 | :tag "etag-regex" |
| 286 | :type '(regexp)) | 262 | :type '(regexp)) |
| 287 | 263 | ||
| @@ -290,7 +266,6 @@ in order, to:\n | |||
| 290 | ("&" "&" ) | 266 | ("&" "&" ) |
| 291 | (">" ">" )) | 267 | (">" ">" )) |
| 292 | "Alist of char -> entity mappings used to make the text HTML-safe." | 268 | "Alist of char -> entity mappings used to make the text HTML-safe." |
| 293 | :group 'htmlfontify | ||
| 294 | :tag "html-quote-map" | 269 | :tag "html-quote-map" |
| 295 | :type '(alist :key-type (string))) | 270 | :type '(alist :key-type (string))) |
| 296 | (defconst hfy-e2x-etags-cmd "for src in `find . -type f`; | 271 | (defconst hfy-e2x-etags-cmd "for src in `find . -type f`; |
| @@ -332,7 +307,6 @@ done;") | |||
| 332 | hfy-etags-cmd-alist-default | 307 | hfy-etags-cmd-alist-default |
| 333 | "Alist of possible shell commands that will generate etags output that | 308 | "Alist of possible shell commands that will generate etags output that |
| 334 | `htmlfontify' can use. `%s' will be replaced by `hfy-etags-bin'." | 309 | `htmlfontify' can use. `%s' will be replaced by `hfy-etags-bin'." |
| 335 | :group 'htmlfontify | ||
| 336 | :tag "etags-cmd-alist" | 310 | :tag "etags-cmd-alist" |
| 337 | :type '(alist :key-type (string) :value-type (string))) | 311 | :type '(alist :key-type (string) :value-type (string))) |
| 338 | 312 | ||
| @@ -340,13 +314,11 @@ done;") | |||
| 340 | "Location of etags binary (we begin by assuming it's in your path).\n | 314 | "Location of etags binary (we begin by assuming it's in your path).\n |
| 341 | Note that if etags is not in your path, you will need to alter the shell | 315 | Note that if etags is not in your path, you will need to alter the shell |
| 342 | commands in `hfy-etags-cmd-alist'." | 316 | commands in `hfy-etags-cmd-alist'." |
| 343 | :group 'htmlfontify | ||
| 344 | :tag "etags-bin" | 317 | :tag "etags-bin" |
| 345 | :type '(file)) | 318 | :type '(file)) |
| 346 | 319 | ||
| 347 | (defcustom hfy-shell-file-name "/bin/sh" | 320 | (defcustom hfy-shell-file-name "/bin/sh" |
| 348 | "Shell (Bourne or compatible) to invoke for complex shell operations." | 321 | "Shell (Bourne or compatible) to invoke for complex shell operations." |
| 349 | :group 'htmlfontify | ||
| 350 | :tag "shell-file-name" | 322 | :tag "shell-file-name" |
| 351 | :type '(file)) | 323 | :type '(file)) |
| 352 | 324 | ||
| @@ -358,7 +330,6 @@ commands in `hfy-etags-cmd-alist'." | |||
| 358 | point-entered | 330 | point-entered |
| 359 | point-left) | 331 | point-left) |
| 360 | "Properties to omit when copying a fontified buffer for HTML transformation." | 332 | "Properties to omit when copying a fontified buffer for HTML transformation." |
| 361 | :group 'htmlfontify | ||
| 362 | :tag "ignored-properties" | 333 | :tag "ignored-properties" |
| 363 | :type '(repeat symbol)) | 334 | :type '(repeat symbol)) |
| 364 | 335 | ||
| @@ -387,7 +358,6 @@ file for the whole source tree from there on down. The command should emit | |||
| 387 | the etags output on stdout.\n | 358 | the etags output on stdout.\n |
| 388 | Two canned commands are provided - they drive Emacs's etags and | 359 | Two canned commands are provided - they drive Emacs's etags and |
| 389 | exuberant-ctags' etags respectively." | 360 | exuberant-ctags' etags respectively." |
| 390 | :group 'htmlfontify | ||
| 391 | :tag "etags-command" | 361 | :tag "etags-command" |
| 392 | :type (let ((clist (list '(string)))) | 362 | :type (let ((clist (list '(string)))) |
| 393 | (dolist (C hfy-etags-cmd-alist) | 363 | (dolist (C hfy-etags-cmd-alist) |
| @@ -398,14 +368,12 @@ exuberant-ctags' etags respectively." | |||
| 398 | "Command to run with the name of a file, to see whether it is a text file | 368 | "Command to run with the name of a file, to see whether it is a text file |
| 399 | or not. The command should emit a string containing the word `text' if | 369 | or not. The command should emit a string containing the word `text' if |
| 400 | the file is a text file, and a string not containing `text' otherwise." | 370 | the file is a text file, and a string not containing `text' otherwise." |
| 401 | :group 'htmlfontify | ||
| 402 | :tag "istext-command" | 371 | :tag "istext-command" |
| 403 | :type '(string)) | 372 | :type '(string)) |
| 404 | 373 | ||
| 405 | (defcustom hfy-find-cmd | 374 | (defcustom hfy-find-cmd |
| 406 | "find . -type f \\! -name \\*~ \\! -name \\*.flc \\! -path \\*/CVS/\\*" | 375 | "find . -type f \\! -name \\*~ \\! -name \\*.flc \\! -path \\*/CVS/\\*" |
| 407 | "Find command used to harvest a list of files to attempt to fontify." | 376 | "Find command used to harvest a list of files to attempt to fontify." |
| 408 | :group 'htmlfontify | ||
| 409 | :tag "find-command" | 377 | :tag "find-command" |
| 410 | :type '(string)) | 378 | :type '(string)) |
| 411 | 379 | ||
| @@ -434,7 +402,6 @@ of these values in the specification key constitutes a match, eg:\n | |||
| 434 | ((type tty) (class color))\n | 402 | ((type tty) (class color))\n |
| 435 | and so on." | 403 | and so on." |
| 436 | :type '(alist :key-type (symbol) :value-type (symbol)) | 404 | :type '(alist :key-type (symbol) :value-type (symbol)) |
| 437 | :group 'htmlfontify | ||
| 438 | :tag "display-class" | 405 | :tag "display-class" |
| 439 | :options '((type (choice (const :tag "X11" x-toolkit) | 406 | :options '((type (choice (const :tag "X11" x-toolkit) |
| 440 | (const :tag "Terminal" tty ) | 407 | (const :tag "Terminal" tty ) |
| @@ -481,7 +448,6 @@ which can never slow you down, but may result in incomplete fontification." | |||
| 481 | (const :tag "div-wrapper" div-wrapper ) | 448 | (const :tag "div-wrapper" div-wrapper ) |
| 482 | (const :tag "keep-overlays" keep-overlays ) | 449 | (const :tag "keep-overlays" keep-overlays ) |
| 483 | (const :tag "body-text-only" body-text-only )) | 450 | (const :tag "body-text-only" body-text-only )) |
| 484 | :group 'htmlfontify | ||
| 485 | :tag "optimizations") | 451 | :tag "optimizations") |
| 486 | 452 | ||
| 487 | (defvar hfy-tags-cache nil | 453 | (defvar hfy-tags-cache nil |
| @@ -599,13 +565,14 @@ If a window system is unavailable, calls `hfy-fallback-color-values'." | |||
| 599 | (x-color-values color)) | 565 | (x-color-values color)) |
| 600 | ;; blarg - tty colors are no good - go fetch some X colors: | 566 | ;; blarg - tty colors are no good - go fetch some X colors: |
| 601 | (hfy-fallback-color-values color)))) | 567 | (hfy-fallback-color-values color)))) |
| 602 | (define-obsolete-function-alias 'hfy-colour-vals 'hfy-color-vals "27.1") | 568 | (define-obsolete-function-alias 'hfy-colour-vals #'hfy-color-vals "27.1") |
| 603 | 569 | ||
| 604 | (defvar hfy-cperl-mode-kludged-p nil) | 570 | (defvar hfy-cperl-mode-kludged-p nil) |
| 605 | 571 | ||
| 606 | (defun hfy-kludge-cperl-mode () | 572 | (defun hfy-kludge-cperl-mode () |
| 607 | "CPerl mode does its damnedest not to do some of its fontification when not | 573 | "CPerl mode does its damnedest not to do some of its fontification when not |
| 608 | in a windowing system - try to trick it..." | 574 | in a windowing system - try to trick it..." |
| 575 | (declare (obsolete nil "28.1")) | ||
| 609 | (if (not hfy-cperl-mode-kludged-p) | 576 | (if (not hfy-cperl-mode-kludged-p) |
| 610 | (progn (if (not window-system) | 577 | (progn (if (not window-system) |
| 611 | (let ((window-system 'htmlfontify)) | 578 | (let ((window-system 'htmlfontify)) |
| @@ -728,7 +695,7 @@ STYLE is the inline CSS stylesheet (or tag referring to an external sheet)." | |||
| 728 | --> </script> | 695 | --> </script> |
| 729 | </head> | 696 | </head> |
| 730 | <body onload=\"stripe('index'); return true;\">\n" | 697 | <body onload=\"stripe('index'); return true;\">\n" |
| 731 | (mapconcat 'hfy-html-quote (mapcar 'char-to-string file) "") style)) | 698 | (mapconcat #'hfy-html-quote (mapcar #'char-to-string file) "") style)) |
| 732 | 699 | ||
| 733 | (defun hfy-default-footer (_file) | 700 | (defun hfy-default-footer (_file) |
| 734 | "Default value for `hfy-page-footer'. | 701 | "Default value for `hfy-page-footer'. |
| @@ -766,24 +733,24 @@ may happen." | |||
| 766 | (let ((white (mapcar (lambda (I) (float (1+ I))) (hfy-color-vals "white"))) | 733 | (let ((white (mapcar (lambda (I) (float (1+ I))) (hfy-color-vals "white"))) |
| 767 | (rgb16 (mapcar (lambda (I) (float (1+ I))) (hfy-color-vals color)))) | 734 | (rgb16 (mapcar (lambda (I) (float (1+ I))) (hfy-color-vals color)))) |
| 768 | (if rgb16 | 735 | (if rgb16 |
| 769 | ;;(apply 'format "rgb(%d, %d, %d)" | 736 | ;;(apply #'format "rgb(%d, %d, %d)" |
| 770 | ;; Use #rrggbb instead, it is smaller | 737 | ;; Use #rrggbb instead, it is smaller |
| 771 | (apply 'format "#%02x%02x%02x" | 738 | (apply #'format "#%02x%02x%02x" |
| 772 | (mapcar (lambda (X) | 739 | (mapcar (lambda (X) |
| 773 | (* (/ (nth X rgb16) | 740 | (* (/ (nth X rgb16) |
| 774 | (nth X white)) 255)) | 741 | (nth X white)) |
| 742 | 255)) | ||
| 775 | '(0 1 2)))))) | 743 | '(0 1 2)))))) |
| 776 | 744 | ||
| 777 | (defun hfy-family (family) (list (cons "font-family" family))) | 745 | (defun hfy-family (family) (list (cons "font-family" family))) |
| 778 | (defun hfy-bgcol (color) (list (cons "background" (hfy-triplet color)))) | 746 | (defun hfy-bgcol (color) (list (cons "background" (hfy-triplet color)))) |
| 779 | (defun hfy-color (color) (list (cons "color" (hfy-triplet color)))) | 747 | (defun hfy-color (color) (list (cons "color" (hfy-triplet color)))) |
| 780 | (define-obsolete-function-alias 'hfy-colour 'hfy-color "27.1") | 748 | (define-obsolete-function-alias 'hfy-colour #'hfy-color "27.1") |
| 781 | (defun hfy-width (width) (list (cons "font-stretch" (symbol-name width)))) | 749 | (defun hfy-width (width) (list (cons "font-stretch" (symbol-name width)))) |
| 782 | 750 | ||
| 783 | (defcustom hfy-font-zoom 1.05 | 751 | (defcustom hfy-font-zoom 1.05 |
| 784 | "Font scaling from Emacs to HTML." | 752 | "Font scaling from Emacs to HTML." |
| 785 | :type 'float | 753 | :type 'float) |
| 786 | :group 'htmlfontify) | ||
| 787 | 754 | ||
| 788 | (defun hfy-size (height) | 755 | (defun hfy-size (height) |
| 789 | "Derive a CSS font-size specifier from an Emacs font :height attribute HEIGHT. | 756 | "Derive a CSS font-size specifier from an Emacs font :height attribute HEIGHT. |
| @@ -1062,7 +1029,7 @@ haven't encountered them yet. Returns a `hfy-style-assoc'." | |||
| 1062 | (when (string-match "pt" (cdr css)) (setq x t))) | 1029 | (when (string-match "pt" (cdr css)) (setq x t))) |
| 1063 | (setq r (nconc r (list css))))) | 1030 | (setq r (nconc r (list css))))) |
| 1064 | ;;(message "r: %S" r) | 1031 | ;;(message "r: %S" r) |
| 1065 | (setq n (apply '* m)) | 1032 | (setq n (apply #'* m)) |
| 1066 | (nconc r (hfy-size (if x (round n) (* n 1.0)))) )) | 1033 | (nconc r (hfy-size (if x (round n) (* n 1.0)))) )) |
| 1067 | 1034 | ||
| 1068 | (defun hfy-face-resolve-face (fn) | 1035 | (defun hfy-face-resolve-face (fn) |
| @@ -1152,9 +1119,9 @@ See also `hfy-face-to-css'." | |||
| 1152 | (push (car E) seen) | 1119 | (push (car E) seen) |
| 1153 | (format " %s: %s; " (car E) (cdr E))))) | 1120 | (format " %s: %s; " (car E) (cdr E))))) |
| 1154 | css-list))) | 1121 | css-list))) |
| 1155 | (cons (hfy-css-name fn) (format "{%s}" (apply 'concat css-text)))) ) | 1122 | (cons (hfy-css-name fn) (format "{%s}" (apply #'concat css-text)))) ) |
| 1156 | 1123 | ||
| 1157 | (defvar hfy-face-to-css 'hfy-face-to-css-default | 1124 | (defvar hfy-face-to-css #'hfy-face-to-css-default |
| 1158 | "Handler for mapping faces to styles. | 1125 | "Handler for mapping faces to styles. |
| 1159 | The signature of the handler is of the form \(lambda (FN) ...). | 1126 | The signature of the handler is of the form \(lambda (FN) ...). |
| 1160 | FN is a font or `defface' specification (cf | 1127 | FN is a font or `defface' specification (cf |
| @@ -1510,7 +1477,7 @@ Uses `hfy-link-style-fun' to do this." | |||
| 1510 | ;; Fix-me: Add handling of page breaks here + scan for ^L | 1477 | ;; Fix-me: Add handling of page breaks here + scan for ^L |
| 1511 | ;; where appropriate. | 1478 | ;; where appropriate. |
| 1512 | (format "body, pre %s\n" (cddr (assq 'default css))) | 1479 | (format "body, pre %s\n" (cddr (assq 'default css))) |
| 1513 | (apply 'concat | 1480 | (apply #'concat |
| 1514 | (mapcar | 1481 | (mapcar |
| 1515 | (lambda (style) | 1482 | (lambda (style) |
| 1516 | (format | 1483 | (format |
| @@ -1611,7 +1578,7 @@ Insert \"</span>\". See `hfy-end-span-handler' for more | |||
| 1611 | information." | 1578 | information." |
| 1612 | (insert "</span>")) | 1579 | (insert "</span>")) |
| 1613 | 1580 | ||
| 1614 | (defvar hfy-begin-span-handler 'hfy-begin-span | 1581 | (defvar hfy-begin-span-handler #'hfy-begin-span |
| 1615 | "Handler to begin a span of text. | 1582 | "Handler to begin a span of text. |
| 1616 | The signature of the handler is \(lambda (STYLE TEXT-BLOCK | 1583 | The signature of the handler is \(lambda (STYLE TEXT-BLOCK |
| 1617 | TEXT-ID TEXT-BEGINS-BLOCK-P) ...). The handler must insert | 1584 | TEXT-ID TEXT-BEGINS-BLOCK-P) ...). The handler must insert |
| @@ -1640,7 +1607,7 @@ behavior. | |||
| 1640 | 1607 | ||
| 1641 | The default handler is `hfy-begin-span'.") | 1608 | The default handler is `hfy-begin-span'.") |
| 1642 | 1609 | ||
| 1643 | (defvar hfy-end-span-handler 'hfy-end-span | 1610 | (defvar hfy-end-span-handler #'hfy-end-span |
| 1644 | "Handler to end a span of text. | 1611 | "Handler to end a span of text. |
| 1645 | The signature of the handler is \(lambda () ...). The handler | 1612 | The signature of the handler is \(lambda () ...). The handler |
| 1646 | must insert appropriate tags to end a span of text. | 1613 | must insert appropriate tags to end a span of text. |
| @@ -1821,32 +1788,7 @@ fontified. This is a simple convenience wrapper around | |||
| 1821 | (htmlfontify-buffer) | 1788 | (htmlfontify-buffer) |
| 1822 | (buffer-string)))) | 1789 | (buffer-string)))) |
| 1823 | 1790 | ||
| 1824 | (defun hfy-force-fontification () | 1791 | (define-obsolete-function-alias 'hfy-force-fontification #'font-lock-ensure "28.1") |
| 1825 | "Try to force font-locking even when it is optimized away." | ||
| 1826 | (run-hooks 'hfy-init-kludge-hook) | ||
| 1827 | (eval-and-compile (require 'font-lock)) | ||
| 1828 | (if (boundp 'font-lock-cache-position) | ||
| 1829 | (or font-lock-cache-position | ||
| 1830 | (setq font-lock-cache-position (make-marker)))) | ||
| 1831 | (cond | ||
| 1832 | (noninteractive | ||
| 1833 | (message "hfy batch mode (%s:%S)" | ||
| 1834 | (or (buffer-file-name) (buffer-name)) major-mode) | ||
| 1835 | (if (fboundp 'font-lock-ensure) ; Emacs >= 25.1 | ||
| 1836 | (font-lock-ensure) | ||
| 1837 | (when font-lock-defaults | ||
| 1838 | ; Silence "interactive use only" warning on Emacs >= 25.1. | ||
| 1839 | (with-no-warnings (font-lock-fontify-buffer))))) | ||
| 1840 | ((fboundp #'jit-lock-fontify-now) | ||
| 1841 | (message "hfy jit-lock mode (%S %S)" window-system major-mode) | ||
| 1842 | (jit-lock-fontify-now)) | ||
| 1843 | (t | ||
| 1844 | (message "hfy interactive mode (%S %S)" window-system major-mode) | ||
| 1845 | ;; If jit-lock is not in use, then the buffer is already fontified! | ||
| 1846 | ;; (when (and font-lock-defaults | ||
| 1847 | ;; font-lock-mode) | ||
| 1848 | ;; (font-lock-fontify-region (point-min) (point-max) nil)) | ||
| 1849 | ))) | ||
| 1850 | 1792 | ||
| 1851 | ;;;###autoload | 1793 | ;;;###autoload |
| 1852 | (defun htmlfontify-buffer (&optional srcdir file) | 1794 | (defun htmlfontify-buffer (&optional srcdir file) |
| @@ -1874,8 +1816,7 @@ hyperlinks as appropriate." | |||
| 1874 | (setq file (match-string 1 file)))) ) | 1816 | (setq file (match-string 1 file)))) ) |
| 1875 | 1817 | ||
| 1876 | (if (not (hfy-opt 'skip-refontification)) | 1818 | (if (not (hfy-opt 'skip-refontification)) |
| 1877 | (save-excursion ;; Keep region | 1819 | (font-lock-ensure)) |
| 1878 | (hfy-force-fontification))) | ||
| 1879 | (if (called-interactively-p 'any) ;; display the buffer in interactive mode: | 1820 | (if (called-interactively-p 'any) ;; display the buffer in interactive mode: |
| 1880 | (switch-to-buffer (hfy-fontify-buffer srcdir file)) | 1821 | (switch-to-buffer (hfy-fontify-buffer srcdir file)) |
| 1881 | (hfy-fontify-buffer srcdir file))) | 1822 | (hfy-fontify-buffer srcdir file))) |
| @@ -1933,7 +1874,7 @@ adding an extension of `hfy-extn'. Fontification is actually done by | |||
| 1933 | ;; FIXME: Shouldn't this use expand-file-name? --Stef | 1874 | ;; FIXME: Shouldn't this use expand-file-name? --Stef |
| 1934 | (setq target (concat dstdir "/" file)) | 1875 | (setq target (concat dstdir "/" file)) |
| 1935 | (hfy-make-directory (hfy-dirname target)) | 1876 | (hfy-make-directory (hfy-dirname target)) |
| 1936 | (if (not (hfy-opt 'skip-refontification)) (hfy-force-fontification)) | 1877 | (if (not (hfy-opt 'skip-refontification)) (font-lock-ensure)) |
| 1937 | (if (or (hfy-fontified-p) (hfy-text-p srcdir file)) | 1878 | (if (or (hfy-fontified-p) (hfy-text-p srcdir file)) |
| 1938 | (progn (setq html (hfy-fontify-buffer srcdir file)) | 1879 | (progn (setq html (hfy-fontify-buffer srcdir file)) |
| 1939 | (set-buffer html) | 1880 | (set-buffer html) |
| @@ -2391,7 +2332,7 @@ You may also want to set `hfy-page-header' and `hfy-page-footer'." | |||
| 2391 | ;; (custom-save-delete 'hfy-set-hooks) | 2332 | ;; (custom-save-delete 'hfy-set-hooks) |
| 2392 | ;; (let ((standard-output (current-buffer))) | 2333 | ;; (let ((standard-output (current-buffer))) |
| 2393 | ;; (princ "(hfy-set-hooks\n;;auto-generated, only one copy allowed\n") | 2334 | ;; (princ "(hfy-set-hooks\n;;auto-generated, only one copy allowed\n") |
| 2394 | ;; (mapatoms 'hfy-pp-hook) | 2335 | ;; (mapatoms #'hfy-pp-hook) |
| 2395 | ;; (insert "\n)") | 2336 | ;; (insert "\n)") |
| 2396 | ;; ) | 2337 | ;; ) |
| 2397 | ;; ) | 2338 | ;; ) |
| @@ -2418,7 +2359,7 @@ You may also want to set `hfy-page-header' and `hfy-page-footer'." | |||
| 2418 | ;; FIXME: This saving&restoring of global customization | 2359 | ;; FIXME: This saving&restoring of global customization |
| 2419 | ;; variables can interfere with other customization settings for | 2360 | ;; variables can interfere with other customization settings for |
| 2420 | ;; those vars (in .emacs or in Customize). | 2361 | ;; those vars (in .emacs or in Customize). |
| 2421 | (mapc 'hfy-save-initvar | 2362 | (mapc #'hfy-save-initvar |
| 2422 | '(auto-mode-alist interpreter-mode-alist)) | 2363 | '(auto-mode-alist interpreter-mode-alist)) |
| 2423 | (princ ")\n") | 2364 | (princ ")\n") |
| 2424 | (indent-region start-pos (point) nil)) | 2365 | (indent-region start-pos (point) nil)) |