(defun sgml-lt ()
"Insert ISO entity reference for less-than."
(interactive)
(insert "<"))
(defun sgml-nbsp ()
"Insert ISO entity reference for non-breaking space."
(interactive)
(insert " "))
(defun sgml-para ()
"Insert para tags and position cursor."
(interactive)
(sgml-insert-element 'para))
(defun sgml-literal ()
"Insert literal element."
(interactive)
(sgml-insert-element 'literal))
(defun sgml-kill-to-eoelement ()
"Kill to end of element."
(interactive)
(let ((start (point)))
(sgml-end-of-element)
(kill-region start (point))))
(defun sgml-copy-element ()
"Copy the current element to the buffer."
(interactive)
(sgml-backward-up-element)
(let ((start (point)))
(sgml-forward-element)
(kill-ring-save start (point))))
(defun sgml-fill-and-save ()
"Rejustify element at cursor and save file."
(interactive)
(sgml-fill-element (sgml-find-element-of (point))) (save-buffer))
(defun my-psgml-mode-hook ()
"It looks this is the only way to set variables for psgml"
(setq
sgml-insert-missing-element-comment nil
sgml-auto-insert-required-elements t
sgml-live-element-indicator t
sgml-ommittag-transparent t
sgml-balanced-tag-edit t
sgml-indent-data t
sgml-indent-step 2
sgml-set-face t
sgml-validate-command "xmllint -noout -valid %s %s"
sgml-markup-faces '((comment . font-lock-comment-face)
(start-tag . font-lock-keyword-face)
(end-tag . font-lock-builtin-face)
(doctype . font-lock-type-face)
(entity . font-lock-function-name-face)
(pi . bold)
(sgml . bold)
(shortref . font-lock-string-face)
))
(define-key sgml-mode-map "\C-c<" 'sgml-lt)
(define-key sgml-mode-map "\C-ce" 'sgml-nbsp)
(define-key sgml-mode-map "\C-cp" 'sgml-para)
(define-key sgml-mode-map "\C-cl" 'sgml-literal)
(define-key sgml-mode-map "\C-ck" 'sgml-kill-to-eoelement)
(define-key sgml-mode-map "\C-cw" 'sgml-copy-element)
(define-key sgml-mode-map [f2] 'sgml-fill-and-save)
)
(add-hook 'sgml-mode-hook 'my-psgml-mode-hook)
(add-hook 'xml-mode-hook 'my-psgml-mode-hook)