From c3cf6728d7f4bb1836aefaa78c8eb3e74f722085 Mon Sep 17 00:00:00 2001 From: Lucien Pullen Date: Sun, 16 Apr 2017 16:00:23 -0600 Subject: [PATCH] psgml: conditionally set face from major mode * psgml-parse.el (sgml-set-face): In addition to never (nil) and always (t), can be a list of major mode functions to only set face in those modes. --- psgml-parse.el | 12 +++++++----- psgml.el | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/psgml-parse.el b/psgml-parse.el index 5609767..eb9828e 100644 --- a/psgml-parse.el +++ b/psgml-parse.el @@ -1317,8 +1317,9 @@ was successful or nil if failed." "Set the type of the markup parsed to TYPE. The markup starts at position given by variable `sgml-markup-start' and ends at point." - (when (and sgml-set-face - (null sgml-current-eref)) + (when (and (or (eq sgml-set-face t) + (find major-mode sgml-set-face)) + (null sgml-current-eref)) (sgml-set-face-for sgml-markup-start (point) type)) (setq sgml-markup-type type)) @@ -2821,7 +2822,7 @@ overrides the entity type in entity look up." (when (and (not executing-macro) (or (and (boundp 'which-function-mode) which-function-mode ) - sgml-set-face) + (or (eq sgml-set-face t) (find major-mode sgml-set-face)) sgml-buffer-parse-state (sit-for 0)) (let ((deactivate-mark nil)) @@ -2833,7 +2834,8 @@ overrides the entity type in entity look up." (sgml-element-gi sgml-last-element))) (let ((eol-pos (save-excursion (end-of-line 1) (point)))) ;; Set face on current line - (when (and sgml-set-face (not (input-pending-p))) + (when (and (or (eq sgml-set-face t) (find major-mode sgml-set-face)) + (not (input-pending-p))) (save-excursion (condition-case nil (sgml-parse-to @@ -2846,7 +2848,7 @@ overrides the entity type in entity look up." (defun sgml-fontify-buffer (delay) (and - sgml-set-face + (or (eq sgml-set-face t) (find major-mode sgml-set-face)) (null (sgml-tree-etag-epos (sgml-pstate-top-tree sgml-buffer-parse-state))) (sit-for delay) diff --git a/psgml.el b/psgml.el index 142079a..b0ff140 100644 --- a/psgml.el +++ b/psgml.el @@ -849,7 +849,9 @@ sgml-normalize-trims If non-nil, sgml-normalize will trim off white space from end of element when adding end tag. sgml-indent-step How much to increment indent for every element level. sgml-indent-data If non-nil, indent in data/mixed context also. -sgml-set-face If non-nil, psgml will set the face of parsed markup. +sgml-set-face If non-nil, psgml will set the face of parsed markup, + either always (when t) or when the buffer's major mode matches + one of the listed function names. sgml-markup-faces The faces used when the above variable is non-nil. sgml-public-map Mapping from public identifiers to file names. sgml-offer-save If non-nil, ask about saving modified buffers before -- 2.3.4