[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xml sgml & psgml

From: Adam Hardy
Subject: Re: xml sgml & psgml
Date: Wed, 05 Feb 2003 14:39:31 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2) Gecko/20021202

Kai Großjohann wrote:
> Adam Hardy <> writes:
>>I'm editing some xml files and I am having a few problems. I installed
>>the latest version of psgml from sourceforge and put some config code
>>in my .emacs but I am unable to get indentation to work.
> Often, it helps to (setq sgml-indent-data t), but you don't give
> enough information to see whether it will help.

I don't have that in my .emacs - but adding it makes it work. I don't suppose it's got electric support?

How did you find out about that? I found what I found through searching with google. Reading the lisp code was too difficult at my level of understanding to serve as documentation.

To answer another of my original questions, would the following .emacs config enable psgml? And can I do anything to test whether this psgml is enabled?

;;; Set up PSGML
; Add PSGML to load-path so Emacs can find it.
; Note the forward slashes in the path... this is platform-independent so I
; would suggest using them over back slashes. If you use back slashes, they
; MUST BE doubled, as Emacs treats backslash as an escape character.
(setq load-path (append (list nil "/usr/share/emacs/21.2/lisp/psgml-1.3.1") load-path))

; Use PSGML for sgml and xml major modes.
(autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t)
(autoload 'xml-mode "psgml" "Major mode to edit XML files." t)

;;; Set up file-extension/mode associations.
; Note that I use xml-mode for html... that's because i'm writing
; XHTML and I want my html to conform to XML.
(setq auto-mode-alist
      (append '(
                ("\\.sgml" . sgml-mode)
                ("\\.idd" . sgml-mode)
                ("\\.ide" . sgml-mode)
                ("\\.htm" . xml-mode)
                ("\\.html" . xml-mode)
                ("\\.xml" . xml-mode)
                ("\\.xsl" . xml-mode)
                ("\\.fo" . xml-mode)
;;; Set up and enable syntax coloring.
; Create faces  to assign markup categories.
(make-face 'sgml-doctype-face)
(make-face 'sgml-pi-face)
(make-face 'sgml-comment-face)
(make-face 'sgml-sgml-face)
(make-face 'sgml-start-tag-face)
(make-face 'sgml-end-tag-face)
(make-face 'sgml-entity-face)

; Assign attributes to faces. Background of white assumed.
(set-face-foreground 'sgml-doctype-face "blue1")
(set-face-foreground 'sgml-sgml-face "cyan1")
(set-face-foreground 'sgml-pi-face "magenta")
(set-face-foreground 'sgml-comment-face "purple")
(set-face-foreground 'sgml-start-tag-face "Red")
(set-face-foreground 'sgml-end-tag-face "Red")
(set-face-foreground 'sgml-entity-face "Blue")

; Assign faces to markup categories.
(setq sgml-markup-faces
      '((doctype        . sgml-doctype-face)
        (pi             . sgml-pi-face)
        (comment        . sgml-comment-face)
        (sgml   . sgml-sgml-face)
        (comment        . sgml-comment-face)
        (start-tag      . sgml-start-tag-face)
        (end-tag        . sgml-end-tag-face)
        (entity . sgml-entity-face)))

; PSGML - enable face settings
(setq sgml-set-face t)

; Auto-activate parsing the DTD when a document is loaded.
; If this isn't enabled, syntax coloring won't take affect until
; you manually invoke "DTD->Parse DTD"
(setq sgml-auto-activate-dtd t)

;;; Set up my "DTD->Insert DTD" menu.
;(setq sgml-custom-dtd '
;      (
;       ( "XHTML 1.0 Transitional"
; "<?xml version=\"1.0\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"xhtml1-transitional.dtd\">" )
;       ( "XHTML 1.0 Frameset"
; "<?xml version=\"1.0\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"xhtml1-frameset.dtd\">" )
; I use XHTML now!
;       ( "HTML 4.01 Transitional"
; "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">" )
;       ( "HTML 4.01 Strict"
;        "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">" )
;       ( "HTML 4.01 Frameset"
;        "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\">" )
;       )

; From Lennart Staflin - re-enabling launch of browser (from original HTML mode)
(defun my-psgml-hook ()
  (local-set-key "\C-c\C-b" 'browse-url-of-buffer)

(add-hook 'sgml-mode-hook 'my-psgml-hook)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]