unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Font locking in PSGML mode
@ 2003-03-12  1:56 chris
  2003-03-12  9:30 ` Kai Großjohann
  2003-03-12 17:02 ` Kevin Rodgers
  0 siblings, 2 replies; 11+ messages in thread
From: chris @ 2003-03-12  1:56 UTC (permalink / raw)


When I load a file into Emacs that starts sgml mode, there is no
syntax coloring. After I parse the DTD, the font coloring starts
working, but only on text that I manually move my cursor through. As I
move through each element, it becomes colorized. 

Is there a way to get this to happen automatically? I have the
following in my .emacs 

(require 'font-lock)
(global-font-lock-mode t)
(setq font-lock-support-mode 'lazy-lock-mode)
(setq font-lock-maximum-decoration t)

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

(add-to-list 'sgml-catalog-files "/etc/sgml/catalog")
(add-to-list 'sgml-catalog-files "/etc/xml/catalog")

(setq auto-mode-alist
      (append '(
                ("\\.sgml\\'" . sgml-mode)
                ("\\.xml\\'" . xml-mode)
                ("\\.html\\'" . xml-mode)
                ("\\.php\\'" . xml-mode)
                )
              auto-mode-alist
              )
      )

(setq-default sgml-set-face t)

(make-face 'sgml-comment-face)
(make-face 'sgml-doctype-face)
(make-face 'sgml-end-tag-face)
(make-face 'sgml-entity-face)
(make-face 'sgml-ignored-face)
(make-face 'sgml-ms-end-face)
(make-face 'sgml-ms-start-face)
(make-face 'sgml-pi-face)
(make-face 'sgml-sgml-face)
(make-face 'sgml-short-ref-face)
(make-face 'sgml-start-tag-face)

(set-face-foreground 'sgml-comment-face "dark magenta")
(set-face-foreground 'sgml-doctype-face "red")
(set-face-foreground 'sgml-end-tag-face "blue")
(set-face-foreground 'sgml-entity-face "magenta")
(set-face-foreground 'sgml-ignored-face "gray40")
(set-face-background 'sgml-ignored-face "gray60")
(set-face-foreground 'sgml-ms-end-face "green")
(set-face-foreground 'sgml-ms-start-face "yellow")
(set-face-foreground 'sgml-pi-face "lime green")
(set-face-foreground 'sgml-sgml-face "brown")
(set-face-foreground 'sgml-short-ref-face "deep sky blue")
(set-face-foreground 'sgml-start-tag-face "dark green")

(setq-default sgml-markup-faces
'((comment . sgml-comment-face)
 (doctype . sgml-doctype-face)
 (end-tag . sgml-end-tag-face)
 (entity . sgml-entity-face)
 (ignored . sgml-ignored-face)
 (ms-end . sgml-ms-end-face)
 (ms-start . sgml-ms-start-face)
 (pi . sgml-pi-face)
 (sgml . sgml-sgml-face)
 (short-ref . sgml-short-ref-face)
 (start-tag . sgml-start-tag-face)))

(setq-default sgml-indent-data t)

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

* Re: Font locking in PSGML mode
  2003-03-12  1:56 Font locking in PSGML mode chris
@ 2003-03-12  9:30 ` Kai Großjohann
  2003-03-13  4:16   ` chris
  2003-03-13  6:11   ` Karl Eichwalder
  2003-03-12 17:02 ` Kevin Rodgers
  1 sibling, 2 replies; 11+ messages in thread
From: Kai Großjohann @ 2003-03-12  9:30 UTC (permalink / raw)


chris <chrisl_ak@hotmail.com> writes:

> When I load a file into Emacs that starts sgml mode, there is no
> syntax coloring. After I parse the DTD, the font coloring starts
> working, but only on text that I manually move my cursor through. As I
> move through each element, it becomes colorized. 
>
> Is there a way to get this to happen automatically? I have the
> following in my .emacs 

Note that psgml does NOT use font-lock for its syntax highlighting.
This is because it is difficult to design regular expressions that do
the right thing: with the right SGML declaration, you can tell the
system to use different characters instead of "<" and ">", for
example.

But I've been using xxml.el for XML sources.  I think xxml.el uses
font-lock.  (But I haven't looked.)  xxml.el works for HTML, too.  So
I think as long as your SGML files use the normal pointy brackets
syntax and the SGML declaration doesn't do weird things, you should
be fine.
-- 
A preposition is not a good thing to end a sentence with.

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

* Re: Font locking in PSGML mode
  2003-03-12  1:56 Font locking in PSGML mode chris
  2003-03-12  9:30 ` Kai Großjohann
@ 2003-03-12 17:02 ` Kevin Rodgers
  2003-03-13  4:17   ` chris
  1 sibling, 1 reply; 11+ messages in thread
From: Kevin Rodgers @ 2003-03-12 17:02 UTC (permalink / raw)


chris wrote:

> When I load a file into Emacs that starts sgml mode, there is no
> syntax coloring. After I parse the DTD, the font coloring starts
> working, but only on text that I manually move my cursor through. As I
> move through each element, it becomes colorized. 
> 
> Is there a way to get this to happen automatically?


1. How do you parse the DTD?

2. Here's a variable declaration and some code I use in an sgml-mode-hook
    function:

(defvar psgml-auto-parse 'query
   "*If t, `\\[sgml-mode'] automatically invokes `\\[sgml-next-trouble-spot]';
if a number, automatically parse the buffer if the buffer's size is smaller;
if non-nil and non-t, query the user whether to parse the buffer.")

   (if (and (cond ((eq psgml-auto-parse t))
		 ((numberp psgml-auto-parse)
		  (<= (buffer-size) psgml-auto-parse))
		 ((not (null psgml-auto-parse)) ; symbolp
		  (y-or-n-p "Parse SGML document? ")))
	   (or (null sgml-top-tree)
	       (null (sgml-tree-end sgml-top-tree))))
       (progn
	(sgml-next-trouble-spot)	; doesn't return a meaningful value,
					; or signal an error...
	(if (eobp)
	    (goto-char (point-min)))))

-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

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

* Re: Font locking in PSGML mode
  2003-03-12  9:30 ` Kai Großjohann
@ 2003-03-13  4:16   ` chris
  2003-03-13  9:00     ` Kai Großjohann
  2003-03-13  6:11   ` Karl Eichwalder
  1 sibling, 1 reply; 11+ messages in thread
From: chris @ 2003-03-13  4:16 UTC (permalink / raw)


On Wed, 12 Mar 2003 10:30:39 +0100,
Kai Großjohann <kai.grossjohann@uni-duisburg.de> spake thusly:

>> When I load a file into Emacs that starts sgml mode, there is no
>> syntax coloring. After I parse the DTD, the font coloring starts
>> working, but only on text that I manually move my cursor through. As I
>> move through each element, it becomes colorized. 
>>
>> Is there a way to get this to happen automatically? I have the
>> following in my .emacs 
> 
> Note that psgml does NOT use font-lock for its syntax highlighting.
> This is because it is difficult to design regular expressions that do
> the right thing: with the right SGML declaration, you can tell the
> system to use different characters instead of "<" and ">", for
> example.

Well, I'd like to stick with PSGML for the editing rather than use
another mode (though I will check xxml.el out anyway). So, is there a
way to automatically simulate what happens when I hold the arrow key
down through the entire page to get the syntax coloring to appear?
Crude, but possibly effective...
 
> But I've been using xxml.el for XML sources.  I think xxml.el uses
> font-lock.  (But I haven't looked.)  xxml.el works for HTML, too.  So
> I think as long as your SGML files use the normal pointy brackets
> syntax and the SGML declaration doesn't do weird things, you should
> be fine.

I'll probably install this for quick editing and use SGML as primary...

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

* Re: Font locking in PSGML mode
  2003-03-12 17:02 ` Kevin Rodgers
@ 2003-03-13  4:17   ` chris
  2003-03-13 18:27     ` Kevin Rodgers
  0 siblings, 1 reply; 11+ messages in thread
From: chris @ 2003-03-13  4:17 UTC (permalink / raw)


On Wed, 12 Mar 2003 10:02:34 -0700, 
Kevin Rodgers <kevin.rodgers@ihs.com> spake thusly:

>> When I load a file into Emacs that starts sgml mode, there is no
>> syntax coloring. After I parse the DTD, the font coloring starts
>> working, but only on text that I manually move my cursor through. As I
>> move through each element, it becomes colorized. 
>> 
>> Is there a way to get this to happen automatically?
> 
> 
> 1. How do you parse the DTD?

I've been doing it manually, but I am off to try your code right now...

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

* Re: Font locking in PSGML mode
  2003-03-12  9:30 ` Kai Großjohann
  2003-03-13  4:16   ` chris
@ 2003-03-13  6:11   ` Karl Eichwalder
  1 sibling, 0 replies; 11+ messages in thread
From: Karl Eichwalder @ 2003-03-13  6:11 UTC (permalink / raw)


kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:

> But I've been using xxml.el for XML sources.

xxml.el works for files using SGML features like minimization; it isn't
limited to the XML subset.  I does not support certain XML add-on
features like XInclude.

> I think xxml.el uses font-lock.

Yes, that's right.

-- 
ke@suse.de (work) / keichwa@gmx.net (home):              |
http://www.gnu.franken.de/ke/                            |      ,__o
Free Translation Project:                                |    _-\_<,
http://www.iro.umontreal.ca/contrib/po/HTML/             |   (*)/'(*)

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

* Re: Font locking in PSGML mode
  2003-03-13  4:16   ` chris
@ 2003-03-13  9:00     ` Kai Großjohann
  2003-03-14 19:05       ` Karl Eichwalder
  0 siblings, 1 reply; 11+ messages in thread
From: Kai Großjohann @ 2003-03-13  9:00 UTC (permalink / raw)


chris <chrisl_ak@hotmail.com> writes:

> Well, I'd like to stick with PSGML for the editing rather than use
> another mode (though I will check xxml.el out anyway).

xxml.el is a PSGML addon that changes only the highlighting.
-- 
A preposition is not a good thing to end a sentence with.

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

* Re: Font locking in PSGML mode
  2003-03-13  4:17   ` chris
@ 2003-03-13 18:27     ` Kevin Rodgers
  2003-03-15  0:00       ` Chris
  0 siblings, 1 reply; 11+ messages in thread
From: Kevin Rodgers @ 2003-03-13 18:27 UTC (permalink / raw)


chris wrote:

> On Wed, 12 Mar 2003 10:02:34 -0700, 
> Kevin Rodgers <kevin.rodgers@ihs.com> spake thusly:
> 
>>1. How do you parse the DTD?
>>
> 
> I've been doing it manually, but I am off to try your code right now...

Via the DTD -> Parse DTD menu bar (or the C-c C-p key binding), or the
DTD -> Load Parsed DTD menu bar?

Does your document contain a <!DOCTYPE ...> declaration?  If so, does it
reference the DTD via a PUBLIC or a SYSTEM identifier?

-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

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

* Re: Font locking in PSGML mode
  2003-03-13  9:00     ` Kai Großjohann
@ 2003-03-14 19:05       ` Karl Eichwalder
  2003-03-15  0:02         ` Chris
  0 siblings, 1 reply; 11+ messages in thread
From: Karl Eichwalder @ 2003-03-14 19:05 UTC (permalink / raw)


kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:

> xxml.el is a PSGML addon that changes only the highlighting.

...and filling if enabled ;)

-- 
ke@suse.de (work) / keichwa@gmx.net (home):              |
http://www.gnu.franken.de/ke/                            |      ,__o
Free Translation Project:                                |    _-\_<,
http://www.iro.umontreal.ca/contrib/po/HTML/             |   (*)/'(*)

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

* Re: Font locking in PSGML mode
  2003-03-13 18:27     ` Kevin Rodgers
@ 2003-03-15  0:00       ` Chris
  0 siblings, 0 replies; 11+ messages in thread
From: Chris @ 2003-03-15  0:00 UTC (permalink / raw)


Kevin Rodgers <kevin.rodgers@ihs.com> wrote in message news:<3E70CD9E.5080605@ihs.com>...
> chris wrote:
> 
> > On Wed, 12 Mar 2003 10:02:34 -0700, 
> > Kevin Rodgers <kevin.rodgers@ihs.com> spake thusly:
> > 
> >>1. How do you parse the DTD?
> >>
> > 
> > I've been doing it manually, but I am off to try your code right now...
> 
> Via the DTD -> Parse DTD menu bar (or the C-c C-p key binding), or the
> DTD -> Load Parsed DTD menu bar?
> 
> Does your document contain a <!DOCTYPE ...> declaration?  If so, does it
> reference the DTD via a PUBLIC or a SYSTEM identifier?

Using DTD -> Parse DTD. I am using a PUBLIC identifier in my DOCTYPE
declaration.

Is there a better way to do this? I am still learning this whole
system for document production.

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

* Re: Font locking in PSGML mode
  2003-03-14 19:05       ` Karl Eichwalder
@ 2003-03-15  0:02         ` Chris
  0 siblings, 0 replies; 11+ messages in thread
From: Chris @ 2003-03-15  0:02 UTC (permalink / raw)


Karl Eichwalder <keichwa@gmx.net> wrote in message news:<shof4dhiq1.fsf@tux.gnu.franken.de>...
> kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:
> 
> > xxml.el is a PSGML addon that changes only the highlighting.
> 
> ...and filling if enabled ;)

Gotcha. Thanks to you both.

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

end of thread, other threads:[~2003-03-15  0:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-12  1:56 Font locking in PSGML mode chris
2003-03-12  9:30 ` Kai Großjohann
2003-03-13  4:16   ` chris
2003-03-13  9:00     ` Kai Großjohann
2003-03-14 19:05       ` Karl Eichwalder
2003-03-15  0:02         ` Chris
2003-03-13  6:11   ` Karl Eichwalder
2003-03-12 17:02 ` Kevin Rodgers
2003-03-13  4:17   ` chris
2003-03-13 18:27     ` Kevin Rodgers
2003-03-15  0:00       ` Chris

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).