[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/htmlize 32c69e9 108/134: Add htmlize-face-overrides.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/htmlize 32c69e9 108/134: Add htmlize-face-overrides. |
Date: |
Sat, 7 Aug 2021 09:17:17 -0400 (EDT) |
branch: elpa/htmlize
commit 32c69e90953ec4b1001830c46a1b7b6002aa4c4e
Author: Hrvoje Niksic <hniksic@gmail.com>
Commit: Hrvoje Niksic <hniksic@gmail.com>
Add htmlize-face-overrides.
Originally contributed by Phillip Lord.
---
NEWS | 6 ++++++
htmlize.el | 35 ++++++++++++++++++++++++++++++++---
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index 484fc7a..ad49e85 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,11 @@
htmlize NEWS -- history of user-visible changes.
+* Changes in htmlize 1.51
+
+** `htmlize-face-overrides' can be used to override Emacs's face
+definitions.
+
+
* Changes in htmlize 1.47
** GNU Emacs 21 is no longer supported.
diff --git a/htmlize.el b/htmlize.el
index 8159877..0a275ef 100644
--- a/htmlize.el
+++ b/htmlize.el
@@ -289,6 +289,23 @@ running Emacs on non-X11 systems), this option is ignored."
:type 'boolean
:group 'htmlize)
+(defvar htmlize-face-overrides nil
+ "Overrides for face definitions.
+
+Normally face definitions are taken from Emacs settings for fonts
+in the current frame. For faces present in this plist, the
+definitions will be used instead. Keys in the plist are symbols
+naming the face and values are the overriding definitions. For
+example:
+
+ (setq htmlize-face-overrides
+ '(font-lock-warning-face \"black\"
+ font-lock-function-name-face \"red\"
+ font-lock-comment-face \"blue\"
+ default (:foreground \"dark-green\" :background \"yellow\")))
+
+This variable can be also be `let' bound when running `htmlize-buffer'.")
+
(defcustom htmlize-html-major-mode nil
"The mode the newly created HTML buffer will be put in.
Set this to nil if you prefer the default (fundamental) mode."
@@ -1180,7 +1197,7 @@ If no rgb.txt file is found, return nil."
;; htmlize supports attrlist by converting them to fstructs, the same
;; as with regular faces.
-(defun htmlize-attrlist-to-fstruct (attrlist)
+(defun htmlize-attrlist-to-fstruct (attrlist &optional name)
;; Like htmlize-face-to-fstruct, but accepts an ATTRLIST as input.
(let ((fstruct (make-htmlize-fstruct)))
(cond ((eq (car attrlist) 'foreground-color)
@@ -1198,7 +1215,7 @@ If no rgb.txt file is found, return nil."
(value (pop attrlist)))
(when (and value (not (eq value 'unspecified)))
(htmlize-face-set-from-keyword-attr fstruct attr value))))))
- (setf (htmlize-fstruct-css-name fstruct) "ATTRLIST")
+ (setf (htmlize-fstruct-css-name fstruct) (or name "custom"))
fstruct))
(defun htmlize-decode-face-prop (prop)
@@ -1235,6 +1252,17 @@ If no rgb.txt file is found, return nil."
(t
(apply #'nconc (mapcar #'htmlize-decode-face-prop prop)))))
+(defun htmlize-get-override-fstruct (face)
+ (let* ((raw-def (plist-get htmlize-face-overrides face))
+ (def (cond ((stringp raw-def) (list :foreground raw-def))
+ ((listp raw-def) raw-def)
+ (t
+ (error (format (concat "face override must be an "
+ "attribute list or string, got %s")
+ raw-def))))))
+ (and def
+ (htmlize-attrlist-to-fstruct def (symbol-name face)))))
+
(defun htmlize-make-face-map (faces)
;; Return a hash table mapping Emacs faces to htmlize's fstructs.
;; The keys are either face symbols or attrlists, so the test
@@ -1246,7 +1274,8 @@ If no rgb.txt file is found, return nil."
;; Haven't seen FACE yet; convert it to an fstruct and cache
;; it.
(let ((fstruct (if (symbolp face)
- (htmlize-face-to-fstruct face)
+ (or (htmlize-get-override-fstruct face)
+ (htmlize-face-to-fstruct face))
(htmlize-attrlist-to-fstruct face))))
(setf (gethash face face-map) fstruct)
(let* ((css-name (htmlize-fstruct-css-name fstruct))
- [nongnu] elpa/htmlize 3ed76d8 065/134: Use find-image to find the actual location of the image file in image-load-path., (continued)
- [nongnu] elpa/htmlize 3ed76d8 065/134: Use find-image to find the actual location of the image file in image-load-path., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 73333fc 068/134: Add an option `htmlize-use-images' to turn off image generation., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 5e04b38 072/134: Improve docs., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 1ea27b3 071/134: Escape double quote in attribute values., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 18693fd 081/134: Bumped version., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 4f0e317 085/134: Show `display' strings with the `htmlize-literal' property as raw HTML., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 4538849 088/134: Bumped version., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 0a17c7c 087/134: It's `htmlize-running-xemacs', not `running-xemacs'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 6f9bb1f 100/134: Bump version., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize f74ea31 106/134: Bump version., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 32c69e9 108/134: Add htmlize-face-overrides.,
ELPA Syncer <=
- [nongnu] elpa/htmlize 1f7bd72 110/134: Update supported version from 21 -> 22 in README, ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 06772e6 117/134: Don't use `alist-get', it is not available in Emacs 24. (#17), ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize a872d6b 119/134: Bump version., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 33aa3cb 023/134: Bump version., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 70529dd 028/134: Abandon compatibility with ancient Emacsen., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize bb3bda0 030/134: Trim comment., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize c19d29c 012/134: Version 0.67., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 9ccd74f 010/134: Version 0.64., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 9349d4b 014/134: Version 1.4., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 2e7cb2c 021/134: Version 1.37., ELPA Syncer, 2021/08/07