SGML: Colorizing with emacs and psgml

Colorizing with emacs and psgml

Collection of postings on "Colorizing with emacs and psgml." See "PSGML and Fonts", where David Megginson explains how to map font faces to any or all of the symbols 'comment', 'doctype', 'end-tag', 'entity', 'ignored', 'ms-end', 'ms-start', 'pi','sgml', 'short-ref', 'start-tag' and so forth.

From owner-tei-l@LISTSERV.UIC.EDU Tue Jul  1 18:35:48 1997
Date: Tue, 01 Jul 1997 18:19:30 -0500 (CDT)
From: John_Lavagnino@BROWN.EDU
Subject: Colorizing with emacs and psgml
Sender: "TEI (Text Encoding Initiative) public discussion list"
 <TEI-L@LISTSERV.UIC.EDU>
To: TEI-L@LISTSERV.UIC.EDU

I attach the stuff I use to get colors with psgml and emacs.  You can
either stick all this directly into your .emacs file, or you can put
it all into a file called foo.el and say

(load "appropriate-directory-name-here/foo.el")

in your .emacs file.  See the embedded comments for notes on what
colors are available and how to change the colors selected here (which
were chosen by a person who's partially colorblind).

Note that all this is a waste of your time, and will in fact generate
a lot of error messages, if you aren't using the X windowing system.
If you're running emacs on a Unix box but are using telnet to connect
to that box, you aren't going to get colors; if you're connecting to
Unix from a Macintosh or Intel box, you have to use X software---a
commercial program like Exodus or Exceed---at the microcomputer end
for this to work.  I haven't used emacs on Microsoft's operating
systems so I don't know what the story in in those cases.  You can
also run one of the various free Unix clones on your microcomputer and
get X for free that way.

John Lavagnino


; Although psgml is set up for autoloading, we just go ahead
; and always require it anyway.

(autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t )
(require 'psgml)

;;--- SGML colorizing with psgml

;;   Create a new face for each different category of thing that
;; psgml can highlight.  These are based on the defaults in
;; psgml 1.0a10, except that we usually say "default" instead of
;; "bold", since we're generally going to use colors instead of bold
;; type.
;;   sgml-sgml-face is the only one that's not self-explanatory: it's
;; applied to the entire SGML declaration.

(copy-face 'default 'sgml-start-tag-face)
(copy-face 'default 'sgml-end-tag-face)
(copy-face 'italic 'sgml-comment-face)
(copy-face 'bold 'sgml-pi-face)
(copy-face 'bold 'sgml-sgml-face)
(copy-face 'bold 'sgml-doctype-face)
(copy-face 'default 'sgml-entity-face)
(copy-face 'bold 'sgml-shortref-face)

;;   Make various modifications to the faces.  See the documentation for
;; the face modification commands in the Emacs manual for more on this,
;; and the file faces.el in the Emacs lisp directory.
;;   Individual users can make further modifications to the appropriate
;; faces in their .emacs files, using any of the commands for
;; modifying faces.
;;   In Emacs or Xemacs, use M-x list-colors-display to get a display showing
;; the names and appearance of all the available colors. There is also
;; a text file associated with most Unix X implementations called
;; rgb.txt: this lists the color names, but won't show you what they
;; look like.

(set-face-foreground 'sgml-start-tag-face "blue")
(set-face-foreground 'sgml-end-tag-face "LightSteelBlue")
(set-face-foreground 'sgml-entity-face "LightGray")

;; Use the new faces in psgml highlighting.

(setq-default sgml-set-face t)

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

;;; End of file


 --------------------------------------------------------------------

From owner-tei-l@LISTSERV.UIC.EDU Wed Jul  2 11:02:50 1997
Date:         Wed, 2 Jul 1997 10:38:14 CDT
Reply-To: Peter Flynn <pflynn%curia@BUREAU.UCC.IE>
Sender: "TEI (Text Encoding Initiative) public discussion list"
              <TEI-L@LISTSERV.UIC.EDU>
From: Peter Flynn <pflynn%curia@BUREAU.UCC.IE>
Subject:      Re: Colorizing with emacs and psgml
To: TEI-L@LISTSERV.UIC.EDU
Status: RO

At 18:19 01/07/97 -0500, John Lavagnino wrote:
>I attach the stuff I use to get colors with psgml and emacs.

Some day I'd like to try and add a syntax to psgml to handle attribute
names and attribute values, so that they'd get colorised too.

>Note that all this is a waste of your time, and will in fact generate
>a lot of error messages, if you aren't using the X windowing system.

Not quite so...I use it on NTemacs (under Win95) and it works perfectly.

>If you're running emacs on a Unix box but are using telnet to connect
>to that box, you aren't going to get colors;

This is unfortunately true...I was once told that the author (Richard
Stallman) doesn't like supporting the VT100 (ANSI) escape sequences for
colour (so has never bothered to implement them) because doing so would
mean going via UNIX's termcap, and life is too short to get involved
with changes to termcap (believe me). Not his fault, really.

>if you're connecting to
>Unix from a Macintosh or Intel box, you have to use X software---a
>commercial program like Exodus or Exceed---at the microcomputer end
>for this to work.

I use Reflection X which is expensive but wonderful. There is also
a recently-announced free X Window emulator for PCs whose name I have
forgotten but I want to try that out too.

> I haven't used emacs on Microsoft's operating
>systems so I don't know what the story in in those cases.

Surprisingly good.

>You can
>also run one of the various free Unix clones on your microcomputer and
>get X for free that way.

You could try, but having given up on ever getting Linux to work, a
co-worker got FreeBSD installed in half a day and it looks really,
really good.

Apparently it is possible to get Linux to install, but the routines
to do it look like something from the 70s. Rebuilding the kernel for
a trivial change like adding a network card is just sheer lunacy (and
just produces reams of compiler errors anyway). Not recommended.

///Peter

 -----------------------------------------------------------------------

From owner-tei-l@LISTSERV.UIC.EDU Thu Jul  3 14:44:39 1997

Date:         Thu, 3 Jul 1997 14:28:58 CDT
Reply-To: Boris Tobotras <tobotras@JET.MSK.SU>
Sender: "TEI (Text Encoding Initiative) public discussion list"
              <TEI-L@LISTSERV.UIC.EDU>
From: Boris Tobotras <tobotras@JET.MSK.SU>
Subject:      Re: Colorizing with emacs and psgml
To: TEI-L@LISTSERV.UIC.EDU
Status: R

On Wed, 02 Jul 1997 10:38:14 CDT, Peter Flynn wrote:

> >If you're running emacs on a Unix box but are using telnet to connect
> >to that box, you aren't going to get colors;
>
> This is unfortunately true...I was once told that the author (Richard
> Stallman) doesn't like supporting the VT100 (ANSI) escape sequences for
> colour (so has never bothered to implement them) because doing so would
> mean going via UNIX's termcap, and life is too short to get involved
> with changes to termcap (believe me). Not his fault, really.

    Maybe this is true with GNU Emacs, but XEmacs starting with 19.14 is
able to use colors in tty mode.

--
    Best regards, -- Boris.

  -----------------------------------------------------------------------

From owner-tei-l@LISTSERV.UIC.EDU Thu Jul  3 15:02:52 1997
Date: Thu, 03 Jul 1997 14:26:41 -0500 (CDT)
From: "Juan A. Trujillo" <trujillo@MAIL.UTEXAS.EDU>
Subject: Re: Colorizing with emacs and psgml
Sender: "TEI (Text Encoding Initiative) public discussion list"
 <TEI-L@LISTSERV.UIC.EDU>
To: TEI-L@LISTSERV.UIC.EDU
Reply-to: "Juan A. Trujillo" <trujillo@MAIL.UTEXAS.EDU>
Message-id: <199707031712.MAA06595@mail.utexas.edu>
MIME-version: 1.0
X-Mailer: PMMail 1.92 For OS/2
Content-type: text/plain; charset="iso-8859-1"
Content-transfer-encoding: 7bit
Priority: Normal
Approved-By: tei-l <U59467@UICVM.UIC.EDU>
Status: R

On Tue, 1 Jul 1997 18:19:30 CDT, John_Lavagnino@BROWN.EDU wrote:

>I attach the stuff I use to get colors with psgml and emacs.

(edited)

>Note that all this is a waste of your time, and will in fact generate
>a lot of error messages, if you aren't using the X windowing system.
>If you're running emacs on a Unix box but are using telnet to connect
>to that box, you aren't going to get colors; if you're connecting to
>Unix from a Macintosh or Intel box, you have to use X software---a
>commercial program like Exodus or Exceed---at the microcomputer end
>for this to work.  I haven't used emacs on Microsoft's operating
>systems so I don't know what the story in in those cases.  You can
>also run one of the various free Unix clones on your microcomputer and
>get X for free that way.

Not that anyone will take this seriously, I will point out that this
colorization file works fine under the PM version of emacs for
OS/2. I assume that it would work under XFree86OS/2, but I
have not really taken the time to configure emacsx on my
machine.

Despite its lack of popularity in the market these days, I am
really pleased with this platform for SGML work. It allows me
to play both sides of the fence--my copy of Author/Editor runs
great, but I still have really good support for UNIX tools
such as emacs, perl, sed, etc. in the form of ports based
on the EMX/gcc compiler. And it is shaping up to be a good
platform for Java, too.

Anyway, I just thought I'd point out one other fairly inexpensive option
to installing a full-fledged UNIX clone or to staying within the
limitations of M$ operating environments.