unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [ELPA] Update package: psgml
@ 2017-04-16 22:38 Lucien Pullen
  2017-04-17 16:34 ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Lucien Pullen @ 2017-04-16 22:38 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 253 bytes --]

Update how PSGML uses `sgml-set-face' to include a list of major modes.
If the current major mode isn't in the list, treat as nil, otherwise t.

This allows PSGML's parser to be used in other major modes without
clobbering font locking in the process.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-psgml-conditionally-set-face-from-major-mode.patch --]
[-- Type: text/x-patch, Size: 3090 bytes --]

From c3cf6728d7f4bb1836aefaa78c8eb3e74f722085 Mon Sep 17 00:00:00 2001
From: Lucien Pullen <drurowin@gmail.com>
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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-04-26 12:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-16 22:38 [ELPA] Update package: psgml Lucien Pullen
2017-04-17 16:34 ` Stefan Monnier
2017-04-19  7:39   ` Lucien Pullen
2017-04-19 12:35     ` Stefan Monnier
2017-04-21  8:06       ` [ELPA] Update package: psgml (discard patch) Lucien Pullen
2017-04-21 14:00         ` Stefan Monnier
2017-04-26 10:50           ` Lucien Pullen
2017-04-26 12:34             ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).