Mercurial > hg > xemacs-beta
diff lisp/psgml/psgml.el @ 2:ac2d302a0011 r19-15b2
Import from CVS: tag r19-15b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:35 +0200 |
parents | 376386a54a3c |
children | bcdc7deadc19 |
line wrap: on
line diff
--- a/lisp/psgml/psgml.el Mon Aug 13 08:45:53 2007 +0200 +++ b/lisp/psgml/psgml.el Mon Aug 13 08:46:35 2007 +0200 @@ -1,7 +1,7 @@ ;;; psgml.el --- SGML-editing mode with parsing support -;; $Id: psgml.el,v 1.1.1.1 1996/12/18 03:35:23 steve Exp $ +;; $Id: psgml.el,v 1.1.1.2 1996/12/18 03:47:15 steve Exp $ -;; Copyright (C) 1993, 1994, 1995 Lennart Staflin +;; Copyright (C) 1993, 1994, 1995, 1996 Lennart Staflin ;; Copyright (C) 1992 Free Software Foundation, Inc. ;; Author: Lennart Staflin <lenst@lysator.liu.se> @@ -50,12 +50,13 @@ ;;; Code: -(defconst psgml-version "1.0a9" +(defconst psgml-version "1.0a12" "Version of psgml package.") (defconst psgml-maintainer-address "lenst@lysator.liu.se") (require 'cl) +(require 'easymenu) (defvar sgml-debug nil) @@ -69,6 +70,7 @@ "Abbrev table in use in sgml-mode.") (define-abbrev-table 'sgml-mode-abbrev-table ()) +;;; Wing addition (defvar sgml-mode-syntax-table nil "Syntax table used in sgml mode.") @@ -245,7 +247,7 @@ (defvar sgml-balanced-tag-edit t "*If non-nil, always insert start-end tag pairs.") -(defvar sgml-omittag-transparent (not sgml-balanced-tag-edit) +(defvar sgml-omittag-transparent (not sgml-balanced-tag-edit) ;; wing change "*If non-nil, will show legal tags inside elements with omittable start tags and legal tags beyond omittable end tags.") @@ -275,6 +277,10 @@ ("Yes" . t) ("Ask" . ask))) +(defvar sgml-trace-entity-lookup nil + "*If non-nil, log messages about catalog files used to look for +external entities.") + (defvar sgml-indent-step 2 "*How much to increment indent for every element level. If nil, no indentation. @@ -287,6 +293,7 @@ Setting this variable automatically makes it local to the current buffer.") (make-variable-buffer-local 'sgml-indent-data) +;;; Wing addition (defvar sgml-inhibit-indent-tags nil "*List of tags within which indentation is inhibited. The tags should be given as strings.") @@ -296,6 +303,7 @@ Set this before loading psgml.") (defvar sgml-system-path nil + ;; wing addition "*List of directories used to look for system identifiers. The directory listed in `sgml-data-directory' is always searched in addition to the directories listed here.") @@ -303,7 +311,7 @@ (defun sgml-parse-colon-path (cd-path) "Explode a colon-separated list of paths into a string list." - (let (cd-prefix cd-list (cd-start 0) cd-colon) + (let (cd-list (cd-start 0) cd-colon) (setq cd-path (concat cd-path ":")) (while (setq cd-colon (string-match ":" cd-path cd-start)) (setq cd-list @@ -317,6 +325,7 @@ (defvar sgml-public-map (sgml-parse-colon-path (or (getenv "SGML_PATH") + ;; Wing change (concat "%S:" (directory-file-name sgml-data-directory) "%o/%c/%d"))) @@ -345,15 +354,17 @@ (defvar sgml-catalog-files (sgml-parse-colon-path (or (getenv "SGML_CATALOG_FILES") + ;; Wing addition (concat "CATALOG:" - (expand-file-name - "CATALOG" - sgml-data-directory)))) + (expand-file-name + "CATALOG" + sgml-data-directory)))) "*List of catalog entry files. The files are in the format defined in the SGML Open Draft Technical Resolution on Entity Management.") (put 'sgml-catalog-files 'sgml-type 'list) +;;; Wing addition (defvar sgml-ecat-files (list "ECAT" "~/sgml/ECAT" @@ -442,7 +453,7 @@ ;;; Its error messages can be parsed by next-error. ;;; The -s option suppresses output. -(defvar sgml-validate-command "sgmls -s %s %s" +(defvar sgml-validate-command "nsgmls -s %s %s" "*The shell command to validate an SGML document. This is a `format' control string that by default should contain two @@ -470,8 +481,10 @@ format control string instead of the defaults.") (defvar sgml-validate-error-regexps - '(("\\(error\\|warning\\) at \\([^,]+\\), line \\([0-9]+\\)" 2 3) - ("^\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):E: " 1 2 3)) + '((":\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[EX]: " 1 2 3) + ("\\(error\\|warning\\) at \\([^,]+\\), line \\([0-9]+\\)" 2 3) + ("\n[a-zA-Z]?:?[^0-9 \n\t:]+:[ \t]*\\([^ \n\t:]+\\):\ +\\([0-9]+\\):\\(\\([0-9]+\\)[: \t]\\)?" 1 2 4)) "Alist of regexps to recognize error messages from `sgml-validate'. See `compilation-error-regexp-alist'.") @@ -512,6 +525,8 @@ sgml-balanced-tag-edit sgml-omittag-transparent sgml-leave-point-after-insert + sgml-insert-missing-element-comment + sgml-insert-end-tag-on-new-line sgml-warn-about-undefined-elements sgml-warn-about-undefined-entities sgml-ignore-undefined-elements @@ -521,6 +536,7 @@ sgml-validate-command sgml-markup-faces sgml-system-identifiers-are-preferred + sgml-trace-entity-lookup sgml-system-path sgml-public-map sgml-catalog-files @@ -610,10 +626,9 @@ (defun sgml-save-options () "Save user options for sgml-mode that have buffer local values." (interactive) - (let ((l sgml-file-options)) - (loop for var in sgml-file-options do - (when (sgml-valid-option var) - (sgml-set-local-variable var (symbol-value var)))))) + (loop for var in sgml-file-options do + (when (sgml-valid-option var) + (sgml-set-local-variable var (symbol-value var))))) ;;;; Run hook with args @@ -795,12 +810,138 @@ (define-key sgml-mode-map "\e\C-t" 'sgml-transpose-element) (define-key sgml-mode-map "\M-\t" 'sgml-complete) -;;; Menu bar +;;;; Menu bar + +(easy-menu-define + sgml-dtd-menu sgml-mode-map "DTD menu" + '("DTD")) + +(defconst sgml-dtd-root-menu + '("DTD" + ["Parse DTD" sgml-parse-prolog t] + ("Info" + ["General DTD info" sgml-general-dtd-info t] + ["Describe element type" sgml-describe-element-type t] + ["Describe entity" sgml-describe-entity t] + ["List elements" sgml-list-elements t] + ["List attributes" sgml-list-attributes t] + ["List terminals" sgml-list-terminals t] + ["List content elements" sgml-list-content-elements t] + ["List occur in elements" sgml-list-occur-in-elements t] + ) + "--" + ["Load Parsed DTD" sgml-load-dtd t] + ["Save Parsed DTD" sgml-save-dtd t] + )) + +(easy-menu-define + sgml-view-menu sgml-mode-map "View menu" + '("View" + ["Fold Element" sgml-fold-element t] + ["Fold Subelement" sgml-fold-subelement t] + ["Unfold Line" sgml-unfold-line t] + ["Unfold Element" sgml-unfold-element t] + ["Expand" sgml-expand-element t] + ["Fold Region" sgml-fold-region t] + ["Unfold All" sgml-unfold-all t] + ["Hide Tags" sgml-hide-tags t] + ["Hide Attributes" sgml-hide-attributes t] + ["Show All Tags" sgml-show-tags t] + ) + ) + + +(defconst sgml-markup-root-menu + '("Markup" + ["Insert Element" sgml-element-menu t] + ["Insert Start-Tag" sgml-start-tag-menu t] + ["Insert End-Tag" sgml-end-tag-menu t] + ["Tag Region" sgml-tag-region-menu t] + ["Insert Attribute" sgml-attrib-menu t] + ["Insert Entity" sgml-entities-menu t] + )) + +(easy-menu-define + sgml-markup-menu sgml-mode-map "Markup menu" + sgml-markup-root-menu) -(eval-when-compile - (autoload 'sgml-build-custom-menus "psgml-other")) ; Avoid compiler warnings +(easy-menu-define + sgml-move-menu sgml-mode-map "Menu of move commands" + '("Move" + ["Next trouble spot" sgml-next-trouble-spot t] + ["Next data field" sgml-next-data-field t] + ["Forward element" sgml-forward-element t] + ["Backward element" sgml-backward-element t] + ["Up element" sgml-up-element t] + ["Down element" sgml-down-element t] + ["Backward up element" sgml-backward-up-element t] + ["Beginning of element" sgml-beginning-of-element t] + ["End of element" sgml-end-of-element t] + )) + +(easy-menu-define + sgml-modify-menu sgml-mode-map "Menu of modification commands" + '("Modify" + ["Normalize" sgml-normalize t] + ["Expand All Short References" sgml-expand-all-shortrefs t] + ["Expand Entity Reference" sgml-expand-entity-reference t] + ["Normalize Element" sgml-normalize-element t] + ["Make Character Reference" sgml-make-character-reference t] + ["Unmake Character Reference" (sgml-make-character-reference t) t] + ["Fill Element" sgml-fill-element t] + ["Change Element Name..." sgml-change-element-name t] + ["Edit Attributes..." sgml-edit-attributes t] + ["Kill Markup" sgml-kill-markup t] + ["Kill Element" sgml-kill-element t] + ["Untag Element" sgml-untag-element t] + ["Trim and leave element" sgml-trim-and-leave-element t] + ["Decode Character Entities" sgml-charent-to-display-char t] + ["Encode Characters" sgml-display-char-to-charent t] + ) + ) -;; load menu file at the end +(easy-menu-define + sgml-main-menu sgml-mode-map "Main menu" + '("SGML" + ["Reset Buffer" normal-mode t] + ["End Element" sgml-insert-end-tag t] + ["Show Context" sgml-show-context t] + ["What Element" sgml-what-element t] + ["List Valid Tags" sgml-list-valid-tags t] + ["Show/Hide Warning Log" sgml-show-or-clear-log t] + ["Validate" sgml-validate t] + ["File Options >" sgml-file-options-menu t] + ["User Options >" sgml-user-options-menu t] + ["Save File Options" sgml-save-options t] + ["Submit Bug Report" sgml-submit-bug-report t] + ) + ) + + +(defun sgml-build-custom-menus () + "Build custom parts of Markup and DTD menus." + (let ((button3 (lookup-key (current-local-map) [button3]))) + (easy-menu-define + sgml-markup-menu sgml-mode-map "Markup menu" + (append sgml-markup-root-menu + (list "----") + (loop for e in sgml-custom-markup collect + (vector (first e) + (` (sgml-insert-markup (, (cadr e)))) + t)))) + (easy-menu-define + sgml-dtd-menu sgml-mode-map "DTD menu" + (append sgml-dtd-root-menu + (list "----") + (loop for e in sgml-custom-dtd collect + (vector (first e) + (` (sgml-doctype-insert (, (cadr e)) + '(, (cddr e)))) + t)))) + (unless (or (null button3) + (numberp button3)) + (local-set-key [button3] button3)))) + ;;;; Post command hook @@ -815,7 +956,9 @@ (make-variable-buffer-local 'sgml-buffer-parse-state) (eval-and-compile ; Interface to psgml-parse - (loop for fun in '(sgml-need-dtd sgml-update-display sgml-subst-expand + (loop for fun in '(sgml-need-dtd sgml-update-display + sgml-fontify-buffer + sgml-subst-expand sgml-declaration) do (autoload fun "psgml-parse"))) @@ -828,7 +971,8 @@ (not (zerop (buffer-size))) (looking-at ".*<")) (setq sgml-auto-activate-dtd-tried t) - (sgml-need-dtd)) + (sgml-need-dtd) + (sgml-fontify-buffer 0)) (when sgml-buffer-parse-state (sgml-update-display)))) @@ -953,7 +1097,13 @@ (setq sgml-default-dtd-file nil))) (add-hook 'post-command-hook 'sgml-command-post 'append) (run-hooks 'text-mode-hook 'sgml-mode-hook) - (sgml-build-custom-menus)) + (sgml-build-custom-menus) + (easy-menu-add sgml-main-menu) + (easy-menu-add sgml-modify-menu) + (easy-menu-add sgml-move-menu) + (easy-menu-add sgml-markup-menu) + (easy-menu-add sgml-view-menu) + (easy-menu-add sgml-dtd-menu)) (defun sgml-default-dtd-file () (and (buffer-file-name) @@ -1162,6 +1312,7 @@ nil nil nil) (autoload 'sgml-indent-line "psgml-edit" nil) +(autoload 'sgml-element-endable-p "psgml-edit" nil) ;;; Generated by sgml-build-autoloads @@ -1294,8 +1445,7 @@ (cond (sgml-running-xemacs - (require 'psgml-xemacs) - (add-hook 'sgml-mode-hook 'sgml-install-xemacs-menus)) + (require 'psgml-xemacs)) (t (require 'psgml-other)))