🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.sgml
Article #751

Re: PSGML w\XML support - syntax colouring?

#751
From: Matt Gushee
Date: Fri, 29 May 1998 00:00
92 lines
3910 bytes
paul.groves@oucs.ox.ac.uk (Paul Groves) writes:

> Does anyone have any tips and\or elisp code to get David Megginson's
> XML patch for PSGML (an SGML major mode for Emacs) to syntax colour
> tags when in *XML-mode*. In SGML-mode the font-faces defined (e.g. red
> tags, green DTD declarations etc.) in my .emacs file work fine, but in
> XML mode I get no colouring at all (but I do get all the other PSGML
> features).

I haven't tried the XML mode yet, but I had a similar problem a while
back -- I had coloring for HTML but not for SGML. The key to this was
the variable 'sgml-markup-faces,' whose value is an alist of the form
((this-tag . some-face) (that-tag . another-face) ...) -- as you
perhaps know. I just had a look at the code of the XML patch, and it
does not appear to define separate faces for XML; it does set
'sgml-markup-faces' to values like 'bold', 'italic', etc., with no
mention of anything that might be colored. So I would guess that your
settings are overriding those defaults for SGML mode but not for XML.

My solution was to define custom faces for SGML, and then set
'sgml-markup-faces' to use my faces. I hope this is helpful just as
an idea; I'm including some of my code here, but I suspect it won't
work for you because I use XEmacs, and I believe faces are done in a
rather different way from FSF Emacs. But, just in case it's of any
use:

(defgroup sgml-faces
  '((sgml-dtd-face custom-face)
    (sgml-start-tag-face custom-face)
    (sgml-end-tag-face custom-face)
    (sgml-comment-face custom-face)
    (sgml-entity-face custom-face)
    (sgml-shortref-face custom-face))
  "My faces for SGML & HTML editing buffers."
  :group 'sgml)

(defface sgml-dtd-face
  '((((class color))
     (:foreground "red" :bold t :family "Helvetica"))
    (t (:bold t)))
  "Face for displaying DTD declarations."
  :group 'sgml-faces)

(defface sgml-start-tag-face
  '((((class color))
     (:foreground "blue")))
  "Face for displaying start tags."
  :group 'sgml-faces)

(defface sgml-end-tag-face
  '((((class color))
     (:foreground "SkyBlue2")))
  "Face for displaying end tags."
  :group 'sgml-faces)

(defface sgml-comment-face
  '((((class color))
     (:foreground "red" :italic t :family "Helvetica"
		  :size "12pt")))
    "Face for displaying SGML comments."
    :group 'sgml-faces)

(defface sgml-entity-face
  '((((class color))
     (:foreground "ForestGreen")))
  "Face for displaying SGML entities."
  :group 'sgml-faces)

(defface sgml-shortref-face
  '((((class color))
     (:foreground "DarkRed")))
  "Face for displaying short references in SGML markup."
  :group 'sgml-faces)

Does FSF Emacs have a GUI for customization? I think not -- so in your 
.emacs you could then do:

(setq sgml-markup-faces
'((start-tag . sgml-start-tag-face)
   (end-tag . sgml-end-tag-face)
   (comment . sgml-comment-face)
   (pi . bold)
   (sgml . bold)
   (doctype . sgml-dtd-face)
   (entity . sgml-entity-face)
   (shortref . sgml-shortref-face)))

Hope this helps a bit.

Matt Gushee
Oshamanbe, Hokkaido, Japan
Technical Details
Message-ID: <m3u369mxde.fsf@crab91.it.osha.sut.ac.jp>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <356ada45.451127207@news.ox.ac.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fa82c,e14601e24d87f01c
X-Google-Attributes: gidfa82c,public
X-Google-Thread: 103b8b,e14601e24d87f01c
X-Google-Attributes: gid103b8b,public
X-Google-Thread: 102b9a,e14601e24d87f01c
X-Google-Attributes: gid102b9a,public
From: Matt Gushee <matt@it.osha.sut.ac.jp>
Subject: Re: PSGML w\XML support - syntax colouring?
Date: 1998/05/29
Message-ID: <m3u369mxde.fsf@crab91.it.osha.sut.ac.jp>
X-Deja-AN: 357543263
References: <356ada45.451127207@news.ox.ac.uk>
Followup-To: comp.text.sgml
Mime-Version: 1.0 (generated by tm-edit 7.108)
Content-Type: text/plain; charset=US-ASCII
Organization: Science University of Tokyo, Oshamanbe Campus, HOKKAIDO, Japan
Newsgroups: comp.text.sgml,comp.emacs,gnu.emacs.help