From 75eaebfba8023ac09832bdc56b40b31f36ba0c99 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Fri, 19 Aug 2011 01:47:48 +0530 Subject: [PATCH 4/6] htmlfontify.el: Allow customization of face to style mappings * contrib/lisp/htmlfontify.el (hfy-face-to-css-default): Same as the earlier hfy-face-to-css. (hfy-face-to-css): Re-defined to be a variable. (hfy-compile-stylesheet): Related changes. --- contrib/lisp/htmlfontify.el | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-) diff --git a/contrib/lisp/htmlfontify.el b/contrib/lisp/htmlfontify.el index b4b1af2..3f5bdbd 100755 --- a/contrib/lisp/htmlfontify.el +++ b/contrib/lisp/htmlfontify.el @@ -1114,10 +1114,9 @@ See also `hfy-face-to-style-i', `hfy-flatten-style'." ;; construct an assoc of (stripped-name . "{ css-stuff-here }") pairs ;; from a face: -(defun hfy-face-to-css (fn) - "Take FN, a font or `defface' specification (cf `face-attr-construct') -and return a CSS style specification.\n -See also `hfy-face-to-style'." +(defun hfy-face-to-css-default (fn) + "Default handler for mapping faces to styles. +See also `hfy-face-to-css'." ;;(message "hfy-face-to-css");;DBUG (let* ((css-list (hfy-face-to-style fn)) (seen nil) @@ -1131,6 +1130,17 @@ See also `hfy-face-to-style'." css-list))) (cons (hfy-css-name fn) (format "{%s}" (apply 'concat css-text)))) ) +(defvar hfy-face-to-css 'hfy-face-to-css-default + "Handler for mapping faces to styles. +The signature of the handler is of the form \(lambda (FN) ...\). +FN is a font or `defface' specification (cf +`face-attr-construct'). The handler should return a cons cell of +the form (STYLE-NAME . STYLE-SPEC). + +The default handler is `hfy-face-to-css-default'. + +See also `hfy-face-to-style'.") + (defalias 'hfy-prop-invisible-p (if (fboundp 'invisible-p) #'invisible-p (lambda (prop) @@ -1328,9 +1338,9 @@ The plists are returned in descending priority order." (goto-char pt) (while (< pt (point-max)) (if (and (setq fn (hfy-face-at pt)) (not (assoc fn style))) - (push (cons fn (hfy-face-to-css fn)) style)) + (push (cons fn (funcall hfy-face-to-css fn)) style)) (setq pt (next-char-property-change pt))) ) - (push (cons 'default (hfy-face-to-css 'default)) style))) + (push (cons 'default (funcall hfy-face-to-css 'default)) style))) (defun hfy-fontified-p () "`font-lock' doesn't like to say it's been fontified when in batch -- 1.7.2.3