Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
;;; sgml-mode.el --- SGML- and HTML-editing modes
|
1992-07-17 06:48:03 +00:00
|
|
|
|
|
2003-01-11 22:47:33 +00:00
|
|
|
|
;; Copyright (C) 1992,95,96,98,2001,2002, 2003 Free Software Foundation, Inc.
|
1992-07-22 03:58:44 +00:00
|
|
|
|
|
1997-04-13 05:07:27 +00:00
|
|
|
|
;; Author: James Clark <jjc@jclark.com>
|
2002-03-04 02:14:31 +00:00
|
|
|
|
;; Maintainer: FSF
|
1998-12-14 03:22:44 +00:00
|
|
|
|
;; Adapted-By: ESR, Daniel Pfeiffer <occitan@esperanto.org>,
|
1997-04-16 21:43:01 +00:00
|
|
|
|
;; F.Potorti@cnuce.cnr.it
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
;; Keywords: wp, hypermedia, comm, languages
|
1992-07-17 06:48:03 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
1995-06-15 20:42:24 +00:00
|
|
|
|
;; the Free Software Foundation; either version 2, or (at your option)
|
1992-07-17 06:48:03 +00:00
|
|
|
|
;; any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
|
|
|
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
;; Boston, MA 02111-1307, USA.
|
1992-07-17 06:48:03 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
;; Configurable major mode for editing document in the SGML standard general
|
|
|
|
|
;; markup language. As an example contains a mode for editing the derived
|
|
|
|
|
;; HTML hypertext markup language.
|
1992-07-17 06:48:03 +00:00
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
1999-08-04 19:18:55 +00:00
|
|
|
|
(eval-when-compile
|
|
|
|
|
(require 'skeleton)
|
2002-04-03 21:36:58 +00:00
|
|
|
|
(require 'outline)
|
|
|
|
|
(require 'cl))
|
1998-11-16 17:50:28 +00:00
|
|
|
|
|
1997-04-13 05:07:27 +00:00
|
|
|
|
(defgroup sgml nil
|
|
|
|
|
"SGML editing mode"
|
|
|
|
|
:group 'languages)
|
|
|
|
|
|
2002-03-29 19:38:22 +00:00
|
|
|
|
(defcustom sgml-basic-offset 2
|
|
|
|
|
"*Specifies the basic indentation level for `sgml-indent-line'."
|
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'sgml)
|
|
|
|
|
|
1997-04-23 18:58:33 +00:00
|
|
|
|
(defcustom sgml-transformation 'identity
|
1997-04-16 21:43:01 +00:00
|
|
|
|
"*Default value for `skeleton-transformation' (which see) in SGML mode."
|
|
|
|
|
:type 'function
|
1997-04-22 04:32:00 +00:00
|
|
|
|
:group 'sgml)
|
1997-04-16 21:43:01 +00:00
|
|
|
|
|
|
|
|
|
(put 'sgml-transformation 'variable-interactive
|
|
|
|
|
"aTransformation function: ")
|
|
|
|
|
|
1999-08-04 19:18:55 +00:00
|
|
|
|
(defcustom sgml-mode-hook nil
|
|
|
|
|
"Hook run by command `sgml-mode'.
|
|
|
|
|
`text-mode-hook' is run first."
|
|
|
|
|
:group 'sgml
|
|
|
|
|
:type 'hook)
|
|
|
|
|
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
;; As long as Emacs' syntax can't be complemented with predicates to context
|
|
|
|
|
;; sensitively confirm the syntax of characters, we have to live with this
|
|
|
|
|
;; kludgy kind of tradeoff.
|
1996-10-07 18:29:22 +00:00
|
|
|
|
(defvar sgml-specials '(?\")
|
1997-04-24 19:37:13 +00:00
|
|
|
|
"List of characters that have a special meaning for SGML mode.
|
2002-02-28 16:14:50 +00:00
|
|
|
|
This list is used when first loading the `sgml-mode' library.
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
The supported characters and potential disadvantages are:
|
|
|
|
|
|
|
|
|
|
?\\\" Makes \" in text start a string.
|
|
|
|
|
?' Makes ' in text start a string.
|
|
|
|
|
?- Makes -- in text start a comment.
|
|
|
|
|
|
1998-06-01 16:51:52 +00:00
|
|
|
|
When only one of ?\\\" or ?' are included, \"'\" or '\"', as can be found in
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
DTDs, start a string. To partially avoid this problem this also makes these
|
1996-10-07 18:29:22 +00:00
|
|
|
|
self insert as named entities depending on `sgml-quick-keys'.
|
|
|
|
|
|
|
|
|
|
Including ?- has the problem of affecting dashes that have nothing to do
|
|
|
|
|
with comments, so we normally turn it off.")
|
1996-01-24 17:12:21 +00:00
|
|
|
|
|
|
|
|
|
(defvar sgml-quick-keys nil
|
2002-04-01 23:32:15 +00:00
|
|
|
|
"Use <, >, &, /, SPC and `sgml-specials' keys \"electrically\" when non-nil.
|
2002-02-28 16:14:50 +00:00
|
|
|
|
This takes effect when first loading the `sgml-mode' library.")
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
(defvar sgml-mode-map
|
2001-06-17 09:01:23 +00:00
|
|
|
|
(let ((map (make-keymap)) ;`sparse' doesn't allow binding to charsets.
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(menu-map (make-sparse-keymap "SGML")))
|
|
|
|
|
(define-key map "\C-c\C-i" 'sgml-tags-invisible)
|
|
|
|
|
(define-key map "/" 'sgml-slash)
|
1996-01-24 17:12:21 +00:00
|
|
|
|
(define-key map "\C-c\C-n" 'sgml-name-char)
|
|
|
|
|
(define-key map "\C-c\C-t" 'sgml-tag)
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(define-key map "\C-c\C-a" 'sgml-attributes)
|
|
|
|
|
(define-key map "\C-c\C-b" 'sgml-skip-tag-backward)
|
|
|
|
|
(define-key map [?\C-c left] 'sgml-skip-tag-backward)
|
|
|
|
|
(define-key map "\C-c\C-f" 'sgml-skip-tag-forward)
|
|
|
|
|
(define-key map [?\C-c right] 'sgml-skip-tag-forward)
|
|
|
|
|
(define-key map "\C-c\C-d" 'sgml-delete-tag)
|
|
|
|
|
(define-key map "\C-c\^?" 'sgml-delete-tag)
|
|
|
|
|
(define-key map "\C-c?" 'sgml-tag-help)
|
2002-04-02 11:26:12 +00:00
|
|
|
|
(define-key map "\C-c/" 'sgml-close-tag)
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(define-key map "\C-c8" 'sgml-name-8bit-mode)
|
|
|
|
|
(define-key map "\C-c\C-v" 'sgml-validate)
|
2001-10-05 16:21:14 +00:00
|
|
|
|
(when sgml-quick-keys
|
|
|
|
|
(define-key map "&" 'sgml-name-char)
|
|
|
|
|
(define-key map "<" 'sgml-tag)
|
|
|
|
|
(define-key map " " 'sgml-auto-attributes)
|
|
|
|
|
(define-key map ">" 'sgml-maybe-end-tag)
|
|
|
|
|
(when (memq ?\" sgml-specials)
|
|
|
|
|
(define-key map "\"" 'sgml-name-self))
|
|
|
|
|
(when (memq ?' sgml-specials)
|
|
|
|
|
(define-key map "'" 'sgml-name-self)))
|
2001-06-18 19:04:09 +00:00
|
|
|
|
(define-key map (vector (make-char 'latin-iso8859-1))
|
|
|
|
|
'sgml-maybe-name-self)
|
2001-10-22 09:45:39 +00:00
|
|
|
|
(let ((c 127)
|
|
|
|
|
(map (nth 1 map)))
|
|
|
|
|
(while (< (setq c (1+ c)) 256)
|
|
|
|
|
(aset map c 'sgml-maybe-name-self)))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(define-key map [menu-bar sgml] (cons "SGML" menu-map))
|
|
|
|
|
(define-key menu-map [sgml-validate] '("Validate" . sgml-validate))
|
|
|
|
|
(define-key menu-map [sgml-name-8bit-mode]
|
|
|
|
|
'("Toggle 8 Bit Insertion" . sgml-name-8bit-mode))
|
|
|
|
|
(define-key menu-map [sgml-tags-invisible]
|
|
|
|
|
'("Toggle Tag Visibility" . sgml-tags-invisible))
|
|
|
|
|
(define-key menu-map [sgml-tag-help]
|
|
|
|
|
'("Describe Tag" . sgml-tag-help))
|
|
|
|
|
(define-key menu-map [sgml-delete-tag]
|
|
|
|
|
'("Delete Tag" . sgml-delete-tag))
|
|
|
|
|
(define-key menu-map [sgml-skip-tag-forward]
|
|
|
|
|
'("Forward Tag" . sgml-skip-tag-forward))
|
|
|
|
|
(define-key menu-map [sgml-skip-tag-backward]
|
|
|
|
|
'("Backward Tag" . sgml-skip-tag-backward))
|
|
|
|
|
(define-key menu-map [sgml-attributes]
|
|
|
|
|
'("Insert Attributes" . sgml-attributes))
|
|
|
|
|
(define-key menu-map [sgml-tag] '("Insert Tag" . sgml-tag))
|
|
|
|
|
map)
|
|
|
|
|
"Keymap for SGML mode. See also `sgml-specials'.")
|
|
|
|
|
|
2002-03-28 16:06:38 +00:00
|
|
|
|
(defun sgml-make-syntax-table (specials)
|
|
|
|
|
(let ((table (make-syntax-table text-mode-syntax-table)))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(modify-syntax-entry ?< "(>" table)
|
|
|
|
|
(modify-syntax-entry ?> ")<" table)
|
2002-03-28 16:06:38 +00:00
|
|
|
|
(modify-syntax-entry ?: "_" table)
|
|
|
|
|
(modify-syntax-entry ?_ "_" table)
|
|
|
|
|
(modify-syntax-entry ?. "_" table)
|
|
|
|
|
(if (memq ?- specials)
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(modify-syntax-entry ?- "_ 1234" table))
|
2002-03-28 16:06:38 +00:00
|
|
|
|
(if (memq ?\" specials)
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(modify-syntax-entry ?\" "\"\"" table))
|
2002-03-28 16:06:38 +00:00
|
|
|
|
(if (memq ?' specials)
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(modify-syntax-entry ?\' "\"'" table))
|
2002-03-28 16:06:38 +00:00
|
|
|
|
table))
|
|
|
|
|
|
|
|
|
|
(defvar sgml-mode-syntax-table (sgml-make-syntax-table sgml-specials)
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
"Syntax table used in SGML mode. See also `sgml-specials'.")
|
|
|
|
|
|
2002-03-28 16:06:38 +00:00
|
|
|
|
(defconst sgml-tag-syntax-table
|
|
|
|
|
(let ((table (sgml-make-syntax-table '(?- ?\" ?\'))))
|
|
|
|
|
(dolist (char '(?\( ?\) ?\{ ?\} ?\[ ?\] ?$ ?% ?& ?* ?+ ?/))
|
|
|
|
|
(modify-syntax-entry char "." table))
|
|
|
|
|
table)
|
|
|
|
|
"Syntax table used to parse SGML tags.")
|
|
|
|
|
|
1997-04-13 05:07:27 +00:00
|
|
|
|
(defcustom sgml-name-8bit-mode nil
|
2001-10-22 09:45:39 +00:00
|
|
|
|
"*When non-nil, insert non-ASCII characters as named entities."
|
1997-04-13 05:07:27 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'sgml)
|
1992-07-17 06:48:03 +00:00
|
|
|
|
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(defvar sgml-char-names
|
|
|
|
|
[nil nil nil nil nil nil nil nil
|
|
|
|
|
nil nil nil nil nil nil nil nil
|
|
|
|
|
nil nil nil nil nil nil nil nil
|
|
|
|
|
nil nil nil nil nil nil nil nil
|
1997-04-16 21:43:01 +00:00
|
|
|
|
"nbsp" "excl" "quot" "num" "dollar" "percnt" "amp" "apos"
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
"lpar" "rpar" "ast" "plus" "comma" "hyphen" "period" "sol"
|
|
|
|
|
nil nil nil nil nil nil nil nil
|
|
|
|
|
nil nil "colon" "semi" "lt" "eq" "gt" "quest"
|
|
|
|
|
"commat" nil nil nil nil nil nil nil
|
|
|
|
|
nil nil nil nil nil nil nil nil
|
|
|
|
|
nil nil nil nil nil nil nil nil
|
|
|
|
|
nil nil nil "lsqb" nil "rsqb" "uarr" "lowbar"
|
|
|
|
|
"lsquo" nil nil nil nil nil nil nil
|
|
|
|
|
nil nil nil nil nil nil nil nil
|
|
|
|
|
nil nil nil nil nil nil nil nil
|
|
|
|
|
nil nil nil "lcub" "verbar" "rcub" "tilde" nil
|
|
|
|
|
nil nil nil nil nil nil nil nil
|
|
|
|
|
nil nil nil nil nil nil nil nil
|
|
|
|
|
nil nil nil nil nil nil nil nil
|
|
|
|
|
nil nil nil nil nil nil nil nil
|
|
|
|
|
"nbsp" "iexcl" "cent" "pound" "curren" "yen" "brvbar" "sect"
|
|
|
|
|
"uml" "copy" "ordf" "laquo" "not" "shy" "reg" "macr"
|
|
|
|
|
"ring" "plusmn" "sup2" "sup3" "acute" "micro" "para" "middot"
|
1999-10-30 21:06:34 +00:00
|
|
|
|
"cedil" "sup1" "ordm" "raquo" "frac14" "frac12" "frac34" "iquest"
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
"Agrave" "Aacute" "Acirc" "Atilde" "Auml" "Aring" "AElig" "Ccedil"
|
|
|
|
|
"Egrave" "Eacute" "Ecirc" "Euml" "Igrave" "Iacute" "Icirc" "Iuml"
|
|
|
|
|
"ETH" "Ntilde" "Ograve" "Oacute" "Ocirc" "Otilde" "Ouml" nil
|
|
|
|
|
"Oslash" "Ugrave" "Uacute" "Ucirc" "Uuml" "Yacute" "THORN" "szlig"
|
|
|
|
|
"agrave" "aacute" "acirc" "atilde" "auml" "aring" "aelig" "ccedil"
|
|
|
|
|
"egrave" "eacute" "ecirc" "euml" "igrave" "iacute" "icirc" "iuml"
|
|
|
|
|
"eth" "ntilde" "ograve" "oacute" "ocirc" "otilde" "ouml" "divide"
|
|
|
|
|
"oslash" "ugrave" "uacute" "ucirc" "uuml" "yacute" "thorn" "yuml"]
|
|
|
|
|
"Vector of symbolic character names without `&' and `;'.")
|
|
|
|
|
|
2001-10-22 09:45:39 +00:00
|
|
|
|
(put 'sgml-table 'char-table-extra-slots 0)
|
|
|
|
|
|
|
|
|
|
(defvar sgml-char-names-table
|
|
|
|
|
(let ((table (make-char-table 'sgml-table))
|
|
|
|
|
(i 32)
|
|
|
|
|
elt)
|
|
|
|
|
(while (< i 256)
|
|
|
|
|
(setq elt (aref sgml-char-names i))
|
|
|
|
|
(if elt (aset table (make-char 'latin-iso8859-1 i) elt))
|
|
|
|
|
(setq i (1+ i)))
|
|
|
|
|
table)
|
|
|
|
|
"A table for mapping non-ASCII characters into SGML entity names.
|
|
|
|
|
Currently, only Latin-1 characters are supported.")
|
|
|
|
|
|
1999-07-23 23:05:21 +00:00
|
|
|
|
;; nsgmls is a free SGML parser in the SP suite available from
|
|
|
|
|
;; ftp.jclark.com and otherwise packaged for GNU systems.
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
;; Its error messages can be parsed by next-error.
|
|
|
|
|
;; The -s option suppresses output.
|
|
|
|
|
|
1999-07-23 23:05:21 +00:00
|
|
|
|
(defcustom sgml-validate-command "nsgmls -s" ; replaced old `sgmls'
|
1992-07-17 06:48:03 +00:00
|
|
|
|
"*The command to validate an SGML document.
|
|
|
|
|
The file name of current buffer file name will be appended to this,
|
1997-04-13 05:07:27 +00:00
|
|
|
|
separated by a space."
|
|
|
|
|
:type 'string
|
1999-08-04 19:18:55 +00:00
|
|
|
|
:version "21.1"
|
1997-04-13 05:07:27 +00:00
|
|
|
|
:group 'sgml)
|
1992-07-17 06:48:03 +00:00
|
|
|
|
|
|
|
|
|
(defvar sgml-saved-validate-command nil
|
|
|
|
|
"The command last used to validate in this buffer.")
|
|
|
|
|
|
2001-06-17 09:01:23 +00:00
|
|
|
|
;; I doubt that null end tags are used much for large elements,
|
|
|
|
|
;; so use a small distance here.
|
1997-04-13 05:07:27 +00:00
|
|
|
|
(defcustom sgml-slash-distance 1000
|
1997-04-24 19:37:13 +00:00
|
|
|
|
"*If non-nil, is the maximum distance to search for matching `/'."
|
1997-04-13 05:07:27 +00:00
|
|
|
|
:type '(choice (const nil) integer)
|
|
|
|
|
:group 'sgml)
|
1992-07-17 06:48:03 +00:00
|
|
|
|
|
2002-03-29 19:38:22 +00:00
|
|
|
|
(defconst sgml-name-re "[_:[:alpha:]][-_.:[:alnum:]]*")
|
|
|
|
|
(defconst sgml-tag-name-re (concat "<\\([!/?]?" sgml-name-re "\\)"))
|
|
|
|
|
(defconst sgml-attrs-re "\\(?:[^\"'/><]\\|\"[^\"]*\"\\|'[^']*'\\)*")
|
|
|
|
|
(defconst sgml-start-tag-regex (concat "<" sgml-name-re sgml-attrs-re)
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
"Regular expression that matches a non-empty start tag.
|
1997-04-24 19:37:13 +00:00
|
|
|
|
Any terminating `>' or `/' is not matched.")
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
|
1998-04-27 01:22:08 +00:00
|
|
|
|
;; internal
|
|
|
|
|
(defconst sgml-font-lock-keywords-1
|
2002-03-29 19:38:22 +00:00
|
|
|
|
`((,(concat "<\\([!?]" sgml-name-re "\\)") 1 font-lock-keyword-face)
|
|
|
|
|
(,(concat "<\\(/?" sgml-name-re"\\)") 1 font-lock-function-name-face)
|
2002-03-28 16:06:38 +00:00
|
|
|
|
;; FIXME: this doesn't cover the variables using a default value.
|
2002-03-29 19:38:22 +00:00
|
|
|
|
(,(concat "\\(" sgml-name-re "\\)=[\"']") 1 font-lock-variable-name-face)
|
|
|
|
|
(,(concat "[&%]" sgml-name-re ";?") . font-lock-variable-name-face)))
|
2001-10-25 22:25:30 +00:00
|
|
|
|
|
|
|
|
|
(defconst sgml-font-lock-keywords-2
|
|
|
|
|
(append
|
|
|
|
|
sgml-font-lock-keywords-1
|
|
|
|
|
'((eval
|
|
|
|
|
. (cons (concat "<"
|
|
|
|
|
(regexp-opt (mapcar 'car sgml-tag-face-alist) t)
|
|
|
|
|
"\\([ \t][^>]*\\)?>\\([^<]+\\)</\\1>")
|
|
|
|
|
'(3 (cdr (assoc (downcase (match-string 1))
|
2003-01-11 22:47:33 +00:00
|
|
|
|
sgml-tag-face-alist)) prepend))))))
|
1998-04-27 01:22:08 +00:00
|
|
|
|
|
|
|
|
|
;; for font-lock, but must be defvar'ed after
|
|
|
|
|
;; sgml-font-lock-keywords-1 and sgml-font-lock-keywords-2 above
|
|
|
|
|
(defvar sgml-font-lock-keywords sgml-font-lock-keywords-1
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
"*Rules for highlighting SGML code. See also `sgml-tag-face-alist'.")
|
|
|
|
|
|
2001-10-25 22:25:30 +00:00
|
|
|
|
(defvar sgml-font-lock-syntactic-keywords
|
|
|
|
|
;; Use the `b' style of comments to avoid interference with the -- ... --
|
|
|
|
|
;; comments recognized when `sgml-specials' includes ?-.
|
|
|
|
|
;; FIXME: beware of <!--> blabla <!--> !!
|
|
|
|
|
'(("\\(<\\)!--" (1 "< b"))
|
|
|
|
|
("--[ \t\n]*\\(>\\)" (1 "> b")))
|
|
|
|
|
"Syntactic keywords for `sgml-mode'.")
|
|
|
|
|
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
;; internal
|
|
|
|
|
(defvar sgml-face-tag-alist ()
|
|
|
|
|
"Alist of face and tag name for facemenu.")
|
|
|
|
|
|
|
|
|
|
(defvar sgml-tag-face-alist ()
|
|
|
|
|
"Tag names and face or list of faces to fontify with when invisible.
|
|
|
|
|
When `font-lock-maximum-decoration' is 1 this is always used for fontifying.
|
|
|
|
|
When more these are fontified together with `sgml-font-lock-keywords'.")
|
|
|
|
|
|
|
|
|
|
(defvar sgml-display-text ()
|
|
|
|
|
"Tag names as lowercase symbols, and display string when invisible.")
|
|
|
|
|
|
|
|
|
|
;; internal
|
|
|
|
|
(defvar sgml-tags-invisible nil)
|
|
|
|
|
|
1997-04-13 05:07:27 +00:00
|
|
|
|
(defcustom sgml-tag-alist
|
1996-01-24 17:12:21 +00:00
|
|
|
|
'(("![" ("ignore" t) ("include" t))
|
|
|
|
|
("!attlist")
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("!doctype")
|
|
|
|
|
("!element")
|
|
|
|
|
("!entity"))
|
|
|
|
|
"*Alist of tag names for completing read and insertion rules.
|
|
|
|
|
This alist is made up as
|
|
|
|
|
|
|
|
|
|
((\"tag\" . TAGRULE)
|
|
|
|
|
...)
|
|
|
|
|
|
2002-04-09 12:02:20 +00:00
|
|
|
|
TAGRULE is a list of optionally t (no endtag) or `\\n' (separate endtag by
|
|
|
|
|
newlines) or a skeleton with nil, t or `\\n' in place of the interactor
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
followed by an ATTRIBUTERULE (for an always present attribute) or an
|
|
|
|
|
attribute alist.
|
|
|
|
|
|
|
|
|
|
The attribute alist is made up as
|
|
|
|
|
|
|
|
|
|
((\"attribute\" . ATTRIBUTERULE)
|
|
|
|
|
...)
|
|
|
|
|
|
2002-04-09 12:02:20 +00:00
|
|
|
|
ATTRIBUTERULE is a list of optionally t (no value when no input) followed by
|
1997-04-13 05:07:27 +00:00
|
|
|
|
an optional alist of possible values."
|
|
|
|
|
:type '(repeat (cons (string :tag "Tag Name")
|
|
|
|
|
(repeat :tag "Tag Rule" sexp)))
|
|
|
|
|
:group 'sgml)
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
1997-04-13 05:07:27 +00:00
|
|
|
|
(defcustom sgml-tag-help
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
'(("!" . "Empty declaration for comment")
|
|
|
|
|
("![" . "Embed declarations with parser directive")
|
|
|
|
|
("!attlist" . "Tag attributes declaration")
|
|
|
|
|
("!doctype" . "Document type (DTD) declaration")
|
|
|
|
|
("!element" . "Tag declaration")
|
|
|
|
|
("!entity" . "Entity (macro) declaration"))
|
1997-04-13 05:07:27 +00:00
|
|
|
|
"*Alist of tag name and short description."
|
|
|
|
|
:type '(repeat (cons (string :tag "Tag Name")
|
|
|
|
|
(string :tag "Description")))
|
|
|
|
|
:group 'sgml)
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(defcustom sgml-xml-mode nil
|
2001-10-27 16:07:35 +00:00
|
|
|
|
"*When non-nil, tag insertion functions will be XML-compliant.
|
|
|
|
|
If this variable is customized, the custom value is used always.
|
|
|
|
|
Otherwise, it is set to be buffer-local when the file has
|
|
|
|
|
a DOCTYPE or an XML declaration."
|
|
|
|
|
:type 'boolean
|
2002-05-12 17:30:42 +00:00
|
|
|
|
:version "21.4"
|
2001-10-27 16:07:35 +00:00
|
|
|
|
:group 'sgml)
|
|
|
|
|
|
2001-10-28 04:10:40 +00:00
|
|
|
|
(defvar sgml-empty-tags nil
|
|
|
|
|
"List of tags whose !ELEMENT definition says EMPTY.")
|
|
|
|
|
|
2002-03-29 19:38:22 +00:00
|
|
|
|
(defvar sgml-unclosed-tags nil
|
|
|
|
|
"List of tags whose !ELEMENT definition says the end-tag is optional.")
|
|
|
|
|
|
2001-10-27 16:07:35 +00:00
|
|
|
|
(defun sgml-xml-guess ()
|
|
|
|
|
"Guess whether the current buffer is XML."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(when (or (string= "xml" (file-name-extension (or buffer-file-name "")))
|
|
|
|
|
(looking-at "\\s-*<\\?xml")
|
|
|
|
|
(when (re-search-forward
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(mapconcat 'identity
|
|
|
|
|
'("<!DOCTYPE" "\\(\\w+\\)" "\\(\\w+\\)"
|
|
|
|
|
"\"\\([^\"]+\\)\"" "\"\\([^\"]+\\)\"")
|
|
|
|
|
"\\s-+"))
|
|
|
|
|
nil t)
|
|
|
|
|
(string-match "X\\(HT\\)?ML" (match-string 3))))
|
|
|
|
|
(set (make-local-variable 'sgml-xml-mode) t))))
|
2001-10-27 16:07:35 +00:00
|
|
|
|
|
1998-11-16 17:50:28 +00:00
|
|
|
|
(defvar v2) ; free for skeleton
|
|
|
|
|
|
2002-04-08 21:32:05 +00:00
|
|
|
|
(defun sgml-comment-indent-new-line (&optional soft)
|
|
|
|
|
(let ((comment-start "-- ")
|
|
|
|
|
(comment-start-skip "\\(<!\\)?--[ \t]*")
|
|
|
|
|
(comment-end " --")
|
|
|
|
|
(comment-style 'plain))
|
|
|
|
|
(comment-indent-new-line soft)))
|
|
|
|
|
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(defun sgml-mode-facemenu-add-face-function (face end)
|
|
|
|
|
(if (setq face (cdr (assq face sgml-face-tag-alist)))
|
|
|
|
|
(progn
|
|
|
|
|
(setq face (funcall skeleton-transformation face))
|
|
|
|
|
(setq facemenu-end-add-face (concat "</" face ">"))
|
|
|
|
|
(concat "<" face ">"))
|
|
|
|
|
(error "Face not configured for %s mode" mode-name)))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(define-derived-mode sgml-mode text-mode "SGML"
|
|
|
|
|
"Major mode for editing SGML documents.
|
|
|
|
|
Makes > match <.
|
2002-04-01 23:32:15 +00:00
|
|
|
|
Keys <, &, SPC within <>, \", / and ' can be electric depending on
|
2002-03-17 23:55:15 +00:00
|
|
|
|
`sgml-quick-keys'.
|
|
|
|
|
|
|
|
|
|
An argument of N to a tag-inserting command means to wrap it around
|
|
|
|
|
the next N words. In Transient Mark mode, when the mark is active,
|
|
|
|
|
N defaults to -1, which means to wrap it around the current region.
|
|
|
|
|
|
|
|
|
|
If you like upcased tags, put (setq sgml-transformation 'upcase) in
|
|
|
|
|
your `.emacs' file.
|
|
|
|
|
|
|
|
|
|
Use \\[sgml-validate] to validate your document with an SGML parser.
|
|
|
|
|
|
|
|
|
|
Do \\[describe-variable] sgml- SPC to see available variables.
|
|
|
|
|
Do \\[describe-key] on the following bindings to discover what they do.
|
|
|
|
|
\\{sgml-mode-map}"
|
1992-07-17 06:48:03 +00:00
|
|
|
|
(make-local-variable 'sgml-saved-validate-command)
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(make-local-variable 'facemenu-end-add-face)
|
|
|
|
|
;;(make-local-variable 'facemenu-remove-face-function)
|
2001-10-27 16:07:35 +00:00
|
|
|
|
;; A start or end tag by itself on a line separates a paragraph.
|
|
|
|
|
;; This is desirable because SGML discards a newline that appears
|
|
|
|
|
;; immediately after a start tag or immediately before an end tag.
|
2002-03-29 19:38:22 +00:00
|
|
|
|
(set (make-local-variable 'paragraph-start) (concat "[ \t]*$\\|\
|
|
|
|
|
\[ \t]*</?\\(" sgml-name-re sgml-attrs-re "\\)?>"))
|
|
|
|
|
(set (make-local-variable 'paragraph-separate)
|
|
|
|
|
(concat paragraph-start "$"))
|
2001-10-27 16:07:35 +00:00
|
|
|
|
(set (make-local-variable 'adaptive-fill-regexp) "[ \t]*")
|
2002-04-01 12:43:47 +00:00
|
|
|
|
(set (make-local-variable 'indent-line-function) 'sgml-indent-line)
|
2001-10-27 16:07:35 +00:00
|
|
|
|
(set (make-local-variable 'comment-start) "<!-- ")
|
|
|
|
|
(set (make-local-variable 'comment-end) " -->")
|
|
|
|
|
(set (make-local-variable 'comment-indent-function) 'sgml-comment-indent)
|
2002-04-08 21:32:05 +00:00
|
|
|
|
(set (make-local-variable 'comment-line-break-function)
|
|
|
|
|
'sgml-comment-indent-new-line)
|
2001-10-27 16:07:35 +00:00
|
|
|
|
(set (make-local-variable 'skeleton-further-elements)
|
|
|
|
|
'((completion-ignore-case t)))
|
|
|
|
|
(set (make-local-variable 'skeleton-end-hook)
|
|
|
|
|
(lambda ()
|
|
|
|
|
(or (eolp)
|
|
|
|
|
(not (or (eq v2 '\n) (eq (car-safe v2) '\n)))
|
|
|
|
|
(newline-and-indent))))
|
|
|
|
|
(set (make-local-variable 'font-lock-defaults)
|
|
|
|
|
'((sgml-font-lock-keywords
|
|
|
|
|
sgml-font-lock-keywords-1
|
|
|
|
|
sgml-font-lock-keywords-2)
|
|
|
|
|
nil t nil nil
|
|
|
|
|
(font-lock-syntactic-keywords
|
|
|
|
|
. sgml-font-lock-syntactic-keywords)))
|
|
|
|
|
(set (make-local-variable 'facemenu-add-face-function)
|
|
|
|
|
'sgml-mode-facemenu-add-face-function)
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(sgml-xml-guess)
|
|
|
|
|
(if sgml-xml-mode
|
|
|
|
|
(setq mode-name "XML")
|
|
|
|
|
(set (make-local-variable 'skeleton-transformation) sgml-transformation))
|
2001-03-07 00:03:50 +00:00
|
|
|
|
;; This will allow existing comments within declarations to be
|
|
|
|
|
;; recognized.
|
|
|
|
|
(set (make-local-variable 'comment-start-skip) "\\(?:<!\\)?--[ \t]*")
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(set (make-local-variable 'comment-end-skip) "[ \t]*--\\([ \t\n]*>\\)?")
|
|
|
|
|
;; This definition probably is not useful in derived modes.
|
2001-10-27 16:07:35 +00:00
|
|
|
|
(set (make-local-variable 'imenu-generic-expression)
|
2002-03-29 19:38:22 +00:00
|
|
|
|
(concat "<!\\(element\\|entity\\)[ \t\n]+%?[ \t\n]*\\("
|
|
|
|
|
sgml-name-re "\\)")))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
2002-05-28 16:51:06 +00:00
|
|
|
|
;; Some programs (such as Glade 2) generate XML which has
|
|
|
|
|
;; -*- mode: xml -*-.
|
|
|
|
|
(defalias 'xml-mode 'sgml-mode)
|
|
|
|
|
|
1992-07-17 06:48:03 +00:00
|
|
|
|
(defun sgml-comment-indent ()
|
2001-03-07 00:03:50 +00:00
|
|
|
|
(if (looking-at "--") comment-column 0))
|
1992-07-17 06:48:03 +00:00
|
|
|
|
|
|
|
|
|
(defun sgml-slash (arg)
|
2002-04-01 23:32:15 +00:00
|
|
|
|
"Insert ARG slash characters.
|
|
|
|
|
Behaves electrically if `sgml-quick-keys' is non-nil."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(cond
|
|
|
|
|
((not (and (eq (char-before) ?<) (= arg 1)))
|
|
|
|
|
(sgml-slash-matching arg))
|
|
|
|
|
((eq sgml-quick-keys 'indent)
|
|
|
|
|
(insert-char ?/ 1)
|
|
|
|
|
(indent-according-to-mode))
|
|
|
|
|
((eq sgml-quick-keys 'close)
|
|
|
|
|
(delete-backward-char 1)
|
2002-04-02 11:26:12 +00:00
|
|
|
|
(sgml-close-tag))
|
2002-04-01 23:32:15 +00:00
|
|
|
|
(t
|
|
|
|
|
(sgml-slash-matching arg))))
|
|
|
|
|
|
|
|
|
|
(defun sgml-slash-matching (arg)
|
1997-04-24 19:37:13 +00:00
|
|
|
|
"Insert `/' and display any previous matching `/'.
|
|
|
|
|
Two `/'s are treated as matching if the first `/' ends a net-enabling
|
|
|
|
|
start tag, and the second `/' is the corresponding null end tag."
|
1992-07-17 06:48:03 +00:00
|
|
|
|
(interactive "p")
|
|
|
|
|
(insert-char ?/ arg)
|
|
|
|
|
(if (> arg 0)
|
|
|
|
|
(let ((oldpos (point))
|
|
|
|
|
(blinkpos)
|
|
|
|
|
(level 0))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(save-restriction
|
|
|
|
|
(if sgml-slash-distance
|
|
|
|
|
(narrow-to-region (max (point-min)
|
|
|
|
|
(- (point) sgml-slash-distance))
|
|
|
|
|
oldpos))
|
|
|
|
|
(if (and (re-search-backward sgml-start-tag-regex (point-min) t)
|
|
|
|
|
(eq (match-end 0) (1- oldpos)))
|
|
|
|
|
()
|
|
|
|
|
(goto-char (1- oldpos))
|
|
|
|
|
(while (and (not blinkpos)
|
|
|
|
|
(search-backward "/" (point-min) t))
|
|
|
|
|
(let ((tagend (save-excursion
|
|
|
|
|
(if (re-search-backward sgml-start-tag-regex
|
|
|
|
|
(point-min) t)
|
|
|
|
|
(match-end 0)
|
|
|
|
|
nil))))
|
|
|
|
|
(if (eq tagend (point))
|
|
|
|
|
(if (eq level 0)
|
|
|
|
|
(setq blinkpos (point))
|
|
|
|
|
(setq level (1- level)))
|
|
|
|
|
(setq level (1+ level)))))))
|
2001-10-26 17:40:59 +00:00
|
|
|
|
(when blinkpos
|
|
|
|
|
(goto-char blinkpos)
|
|
|
|
|
(if (pos-visible-in-window-p)
|
|
|
|
|
(sit-for 1)
|
|
|
|
|
(message "Matches %s"
|
|
|
|
|
(buffer-substring (line-beginning-position)
|
|
|
|
|
(1+ blinkpos)))))))))
|
1992-07-17 06:48:03 +00:00
|
|
|
|
|
2002-03-04 02:14:31 +00:00
|
|
|
|
;; Why doesn't this use the iso-cvt table or, preferably, generate the
|
|
|
|
|
;; inverse of the extensive table in the SGML Quail input method? -- fx
|
|
|
|
|
;; I guess that's moot since it only works with Latin-1 anyhow.
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(defun sgml-name-char (&optional char)
|
|
|
|
|
"Insert a symbolic character name according to `sgml-char-names'.
|
2001-10-22 09:45:39 +00:00
|
|
|
|
Non-ASCII chars may be inserted either with the meta key, as in M-SPC for
|
|
|
|
|
no-break space or M-- for a soft hyphen; or via an input method or
|
|
|
|
|
encoded keyboard operation."
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(interactive "*")
|
|
|
|
|
(insert ?&)
|
|
|
|
|
(or char
|
1997-04-17 21:22:21 +00:00
|
|
|
|
(setq char (read-quoted-char "Enter char or octal number")))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(delete-backward-char 1)
|
|
|
|
|
(insert char)
|
|
|
|
|
(undo-boundary)
|
2002-11-12 16:46:19 +00:00
|
|
|
|
(sgml-namify-char))
|
|
|
|
|
|
|
|
|
|
(defun sgml-namify-char ()
|
|
|
|
|
"Change the char before point into its `&name;' equivalent.
|
|
|
|
|
Uses `sgml-char-names'."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let* ((char (char-before))
|
|
|
|
|
(name
|
|
|
|
|
(cond
|
|
|
|
|
((null char) (error "No char before point"))
|
|
|
|
|
((< char 256) (or (aref sgml-char-names char) char))
|
|
|
|
|
((aref sgml-char-names-table char))
|
|
|
|
|
((encode-char char 'ucs)))))
|
|
|
|
|
(if (not name)
|
|
|
|
|
(error "Don't know the name of `%c'" char)
|
|
|
|
|
(delete-backward-char 1)
|
|
|
|
|
(insert (format (if (numberp name) "&#%d;" "&%s;") name)))))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
(defun sgml-name-self ()
|
|
|
|
|
"Insert a symbolic character name according to `sgml-char-names'."
|
|
|
|
|
(interactive "*")
|
|
|
|
|
(sgml-name-char last-command-char))
|
|
|
|
|
|
|
|
|
|
(defun sgml-maybe-name-self ()
|
|
|
|
|
"Insert a symbolic character name according to `sgml-char-names'."
|
|
|
|
|
(interactive "*")
|
|
|
|
|
(if sgml-name-8bit-mode
|
2001-10-22 09:45:39 +00:00
|
|
|
|
(let ((mc last-command-char))
|
|
|
|
|
(if (< mc 256)
|
|
|
|
|
(setq mc (unibyte-char-to-multibyte mc)))
|
|
|
|
|
(or mc (setq mc last-command-char))
|
|
|
|
|
(sgml-name-char mc))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(self-insert-command 1)))
|
|
|
|
|
|
|
|
|
|
(defun sgml-name-8bit-mode ()
|
2002-03-04 02:14:31 +00:00
|
|
|
|
"Toggle whether to insert named entities instead of non-ASCII characters.
|
|
|
|
|
This only works for Latin-1 input."
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(interactive)
|
1997-04-23 18:58:33 +00:00
|
|
|
|
(setq sgml-name-8bit-mode (not sgml-name-8bit-mode))
|
2001-10-22 09:45:39 +00:00
|
|
|
|
(message "sgml name entity mode is now %s"
|
1997-04-23 18:58:33 +00:00
|
|
|
|
(if sgml-name-8bit-mode "ON" "OFF")))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
1997-04-24 19:37:13 +00:00
|
|
|
|
;; When an element of a skeleton is a string "str", it is passed
|
|
|
|
|
;; through skeleton-transformation and inserted. If "str" is to be
|
|
|
|
|
;; inserted literally, one should obtain it as the return value of a
|
|
|
|
|
;; function, e.g. (identity "str").
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
2002-11-12 16:46:19 +00:00
|
|
|
|
(defvar sgml-tag-last nil)
|
|
|
|
|
(defvar sgml-tag-history nil)
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(define-skeleton sgml-tag
|
1997-04-24 19:37:13 +00:00
|
|
|
|
"Prompt for a tag and insert it, optionally with attributes.
|
|
|
|
|
Completion and configuration are done according to `sgml-tag-alist'.
|
1997-04-23 18:58:33 +00:00
|
|
|
|
If you like tags and attributes in uppercase do \\[set-variable]
|
1997-04-24 19:37:13 +00:00
|
|
|
|
skeleton-transformation RET upcase RET, or put this in your `.emacs':
|
|
|
|
|
(setq sgml-transformation 'upcase)"
|
2002-05-14 09:51:03 +00:00
|
|
|
|
(funcall (or skeleton-transformation 'identity)
|
2002-11-12 16:46:19 +00:00
|
|
|
|
(setq sgml-tag-last
|
|
|
|
|
(completing-read
|
|
|
|
|
(if (> (length sgml-tag-last) 0)
|
|
|
|
|
(format "Tag (default %s): " sgml-tag-last)
|
|
|
|
|
"Tag: ")
|
|
|
|
|
sgml-tag-alist nil nil nil 'sgml-tag-history sgml-tag-last)))
|
2001-03-07 00:03:50 +00:00
|
|
|
|
?< str |
|
1997-04-23 18:58:33 +00:00
|
|
|
|
(("") -1 '(undo-boundary) (identity "<")) | ; see comment above
|
2001-10-28 04:10:40 +00:00
|
|
|
|
`(("") '(setq v2 (sgml-attributes ,str t)) ?>
|
|
|
|
|
(cond
|
|
|
|
|
((string= "![" ,str)
|
|
|
|
|
(backward-char)
|
|
|
|
|
'(("") " [ " _ " ]]"))
|
2002-03-17 23:55:15 +00:00
|
|
|
|
((and (eq v2 t) sgml-xml-mode (member ,str sgml-empty-tags))
|
2001-10-28 04:10:40 +00:00
|
|
|
|
'(("") -1 "/>"))
|
2002-03-17 23:55:15 +00:00
|
|
|
|
((or (and (eq v2 t) (not sgml-xml-mode)) (string-match "^[/!?]" ,str))
|
2001-10-28 04:10:40 +00:00
|
|
|
|
nil)
|
|
|
|
|
((symbolp v2)
|
|
|
|
|
;; Make sure we don't fall into an infinite loop.
|
|
|
|
|
;; For xhtml's `tr' tag, we should maybe use \n instead.
|
|
|
|
|
(if (eq v2 t) (setq v2 nil))
|
|
|
|
|
;; We use `identity' to prevent skeleton from passing
|
|
|
|
|
;; `str' through skeleton-transformation a second time.
|
|
|
|
|
'(("") v2 _ v2 "</" (identity ',str) ?>))
|
|
|
|
|
((eq (car v2) t)
|
|
|
|
|
(cons '("") (cdr v2)))
|
|
|
|
|
(t
|
|
|
|
|
(append '(("") (car v2))
|
|
|
|
|
(cdr v2)
|
|
|
|
|
'(resume: (car v2) _ "</" (identity ',str) ?>))))))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
(autoload 'skeleton-read "skeleton")
|
|
|
|
|
|
1997-04-23 18:58:33 +00:00
|
|
|
|
(defun sgml-attributes (tag &optional quiet)
|
1997-04-24 19:37:13 +00:00
|
|
|
|
"When at top level of a tag, interactively insert attributes.
|
1997-04-23 18:58:33 +00:00
|
|
|
|
|
1997-04-24 19:37:13 +00:00
|
|
|
|
Completion and configuration of TAG are done according to `sgml-tag-alist'.
|
|
|
|
|
If QUIET, do not print a message when there are no attributes for TAG."
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(interactive (list (save-excursion (sgml-beginning-of-tag t))))
|
1997-04-23 18:58:33 +00:00
|
|
|
|
(or (stringp tag) (error "Wrong context for adding attribute"))
|
|
|
|
|
(if tag
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(let ((completion-ignore-case t)
|
1997-04-23 18:58:33 +00:00
|
|
|
|
(alist (cdr (assoc (downcase tag) sgml-tag-alist)))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
car attribute i)
|
|
|
|
|
(if (or (symbolp (car alist))
|
|
|
|
|
(symbolp (car (car alist))))
|
|
|
|
|
(setq car (car alist)
|
|
|
|
|
alist (cdr alist)))
|
|
|
|
|
(or quiet
|
|
|
|
|
(message "No attributes configured."))
|
|
|
|
|
(if (stringp (car alist))
|
|
|
|
|
(progn
|
1997-04-23 18:58:33 +00:00
|
|
|
|
(insert (if (eq (preceding-char) ? ) "" ? )
|
|
|
|
|
(funcall skeleton-transformation (car alist)))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(sgml-value alist))
|
|
|
|
|
(setq i (length alist))
|
|
|
|
|
(while (> i 0)
|
|
|
|
|
(insert ? )
|
|
|
|
|
(insert (funcall skeleton-transformation
|
|
|
|
|
(setq attribute
|
|
|
|
|
(skeleton-read '(completing-read
|
1997-04-23 18:58:33 +00:00
|
|
|
|
"Attribute: "
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
alist)))))
|
|
|
|
|
(if (string= "" attribute)
|
|
|
|
|
(setq i 0)
|
1998-02-17 20:08:22 +00:00
|
|
|
|
(sgml-value (assoc (downcase attribute) alist))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(setq i (1- i))))
|
|
|
|
|
(if (eq (preceding-char) ? )
|
|
|
|
|
(delete-backward-char 1)))
|
|
|
|
|
car)))
|
|
|
|
|
|
|
|
|
|
(defun sgml-auto-attributes (arg)
|
1997-04-24 19:37:13 +00:00
|
|
|
|
"Self insert the character typed; at top level of tag, prompt for attributes.
|
|
|
|
|
With prefix argument, only self insert."
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(interactive "*P")
|
|
|
|
|
(let ((point (point))
|
|
|
|
|
tag)
|
|
|
|
|
(if (or arg
|
|
|
|
|
(not sgml-tag-alist) ; no message when nothing configured
|
|
|
|
|
(symbolp (setq tag (save-excursion (sgml-beginning-of-tag t))))
|
|
|
|
|
(eq (aref tag 0) ?/))
|
|
|
|
|
(self-insert-command (prefix-numeric-value arg))
|
|
|
|
|
(sgml-attributes tag)
|
|
|
|
|
(setq last-command-char ? )
|
|
|
|
|
(or (> (point) point)
|
|
|
|
|
(self-insert-command 1)))))
|
|
|
|
|
|
|
|
|
|
(defun sgml-tag-help (&optional tag)
|
1997-04-24 19:37:13 +00:00
|
|
|
|
"Display description of tag TAG. If TAG is omitted, use the tag at point."
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(or tag
|
|
|
|
|
(save-excursion
|
|
|
|
|
(if (eq (following-char) ?<)
|
|
|
|
|
(forward-char))
|
|
|
|
|
(setq tag (sgml-beginning-of-tag))))
|
|
|
|
|
(or (stringp tag)
|
|
|
|
|
(error "No tag selected"))
|
|
|
|
|
(setq tag (downcase tag))
|
1996-01-25 00:57:01 +00:00
|
|
|
|
(message "%s"
|
1998-02-17 20:08:22 +00:00
|
|
|
|
(or (cdr (assoc (downcase tag) sgml-tag-help))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(and (eq (aref tag 0) ?/)
|
1998-02-17 20:08:22 +00:00
|
|
|
|
(cdr (assoc (downcase (substring tag 1)) sgml-tag-help)))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
"No description available")))
|
|
|
|
|
|
2002-03-28 16:06:38 +00:00
|
|
|
|
(defun sgml-maybe-end-tag (&optional arg)
|
|
|
|
|
"Name self unless in position to end a tag or a prefix ARG is given."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(if (or arg (eq (car (sgml-lexical-context)) 'tag))
|
|
|
|
|
(self-insert-command (prefix-numeric-value arg))
|
|
|
|
|
(sgml-name-self)))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
(defun sgml-skip-tag-backward (arg)
|
|
|
|
|
"Skip to beginning of tag or matching opening tag if present.
|
1997-04-24 19:37:13 +00:00
|
|
|
|
With prefix argument ARG, repeat this ARG times."
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(interactive "p")
|
2002-11-12 16:46:19 +00:00
|
|
|
|
;; FIXME: use sgml-get-context or something similar.
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(while (>= arg 1)
|
|
|
|
|
(search-backward "<" nil t)
|
|
|
|
|
(if (looking-at "</\\([^ \n\t>]+\\)")
|
|
|
|
|
;; end tag, skip any nested pairs
|
|
|
|
|
(let ((case-fold-search t)
|
2002-11-01 17:41:41 +00:00
|
|
|
|
(re (concat "</?" (regexp-quote (match-string 1))
|
|
|
|
|
;; Ignore empty tags like <foo/>.
|
|
|
|
|
"\\([^>]*[^/>]\\)?>")))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(while (and (re-search-backward re nil t)
|
|
|
|
|
(eq (char-after (1+ (point))) ?/))
|
|
|
|
|
(forward-char 1)
|
|
|
|
|
(sgml-skip-tag-backward 1))))
|
|
|
|
|
(setq arg (1- arg))))
|
|
|
|
|
|
2002-11-01 17:41:41 +00:00
|
|
|
|
(defun sgml-skip-tag-forward (arg)
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
"Skip to end of tag or matching closing tag if present.
|
1997-04-24 19:37:13 +00:00
|
|
|
|
With prefix argument ARG, repeat this ARG times.
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
Return t iff after a closing tag."
|
|
|
|
|
(interactive "p")
|
2002-11-12 16:46:19 +00:00
|
|
|
|
;; FIXME: Use sgml-get-context or something similar.
|
|
|
|
|
;; It currently might jump to an unrelated </P> if the <P>
|
|
|
|
|
;; we're skipping has no matching </P>.
|
2002-11-01 17:41:41 +00:00
|
|
|
|
(let ((return t))
|
2002-11-12 16:46:19 +00:00
|
|
|
|
(with-syntax-table sgml-tag-syntax-table
|
|
|
|
|
(while (>= arg 1)
|
|
|
|
|
(skip-chars-forward "^<>")
|
|
|
|
|
(if (eq (following-char) ?>)
|
|
|
|
|
(up-list -1))
|
|
|
|
|
(if (looking-at "<\\([^/ \n\t>]+\\)\\([^>]*[^/>]\\)?>")
|
|
|
|
|
;; start tag, skip any nested same pairs _and_ closing tag
|
|
|
|
|
(let ((case-fold-search t)
|
|
|
|
|
(re (concat "</?" (regexp-quote (match-string 1))
|
|
|
|
|
;; Ignore empty tags like <foo/>.
|
|
|
|
|
"\\([^>]*[^/>]\\)?>"))
|
|
|
|
|
point close)
|
|
|
|
|
(forward-list 1)
|
|
|
|
|
(setq point (point))
|
|
|
|
|
;; FIXME: This re-search-forward will mistakenly match
|
|
|
|
|
;; tag-like text inside attributes.
|
|
|
|
|
(while (and (re-search-forward re nil t)
|
|
|
|
|
(not (setq close
|
|
|
|
|
(eq (char-after (1+ (match-beginning 0))) ?/)))
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(sgml-skip-tag-forward 1))
|
|
|
|
|
(setq close nil))
|
|
|
|
|
(unless close
|
|
|
|
|
(goto-char point)
|
|
|
|
|
(setq return nil)))
|
|
|
|
|
(forward-list 1))
|
|
|
|
|
(setq arg (1- arg)))
|
|
|
|
|
return)))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
(defun sgml-delete-tag (arg)
|
2002-11-12 16:46:19 +00:00
|
|
|
|
;; FIXME: Should be called sgml-kill-tag or should not touch the kill-ring.
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
"Delete tag on or after cursor, and matching closing or opening tag.
|
1997-04-24 19:37:13 +00:00
|
|
|
|
With prefix argument ARG, repeat this ARG times."
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(interactive "p")
|
|
|
|
|
(while (>= arg 1)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let* (close open)
|
1996-01-24 17:12:21 +00:00
|
|
|
|
(if (looking-at "[ \t\n]*<")
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
;; just before tag
|
|
|
|
|
(if (eq (char-after (match-end 0)) ?/)
|
|
|
|
|
;; closing tag
|
|
|
|
|
(progn
|
|
|
|
|
(setq close (point))
|
|
|
|
|
(goto-char (match-end 0))))
|
|
|
|
|
;; on tag?
|
|
|
|
|
(or (save-excursion (setq close (sgml-beginning-of-tag)
|
|
|
|
|
close (and (stringp close)
|
|
|
|
|
(eq (aref close 0) ?/)
|
|
|
|
|
(point))))
|
|
|
|
|
;; not on closing tag
|
|
|
|
|
(let ((point (point)))
|
|
|
|
|
(sgml-skip-tag-backward 1)
|
|
|
|
|
(if (or (not (eq (following-char) ?<))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(forward-list 1)
|
|
|
|
|
(<= (point) point)))
|
|
|
|
|
(error "Not on or before tag")))))
|
|
|
|
|
(if close
|
|
|
|
|
(progn
|
|
|
|
|
(sgml-skip-tag-backward 1)
|
|
|
|
|
(setq open (point))
|
|
|
|
|
(goto-char close)
|
|
|
|
|
(kill-sexp 1))
|
|
|
|
|
(setq open (point))
|
2002-11-12 16:46:19 +00:00
|
|
|
|
(when (sgml-skip-tag-forward 1)
|
|
|
|
|
(kill-sexp -1)))
|
|
|
|
|
;; Delete any resulting empty line. If we didn't kill-sexp,
|
|
|
|
|
;; this *should* do nothing, because we're right after the tag.
|
|
|
|
|
(if (progn (forward-line 0) (looking-at "\\(?:[ \t]*$\\)\n?"))
|
|
|
|
|
(delete-region (match-beginning 0) (match-end 0)))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(goto-char open)
|
2002-11-12 16:46:19 +00:00
|
|
|
|
(kill-sexp 1)
|
|
|
|
|
(if (progn (forward-line 0) (looking-at "\\(?:[ \t]*$\\)\n?"))
|
|
|
|
|
(delete-region (match-beginning 0) (match-end 0)))))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(setq arg (1- arg))))
|
2002-04-09 12:02:20 +00:00
|
|
|
|
|
1997-04-16 21:43:01 +00:00
|
|
|
|
|
|
|
|
|
;; Put read-only last to enable setting this even when read-only enabled.
|
|
|
|
|
(or (get 'sgml-tag 'invisible)
|
|
|
|
|
(setplist 'sgml-tag
|
|
|
|
|
(append '(invisible t
|
|
|
|
|
point-entered sgml-point-entered
|
|
|
|
|
rear-nonsticky t
|
|
|
|
|
read-only t)
|
|
|
|
|
(symbol-plist 'sgml-tag))))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
(defun sgml-tags-invisible (arg)
|
|
|
|
|
"Toggle visibility of existing tags."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(let ((modified (buffer-modified-p))
|
|
|
|
|
(inhibit-read-only t)
|
2001-06-17 09:01:23 +00:00
|
|
|
|
(inhibit-modification-hooks t)
|
|
|
|
|
;; Avoid spurious the `file-locked' checks.
|
|
|
|
|
(buffer-file-name nil)
|
1997-04-16 21:43:01 +00:00
|
|
|
|
;; This is needed in case font lock gets called,
|
|
|
|
|
;; since it moves point and might call sgml-point-entered.
|
2001-10-25 22:25:30 +00:00
|
|
|
|
;; How could it get called? -stef
|
1997-04-16 21:43:01 +00:00
|
|
|
|
(inhibit-point-motion-hooks t)
|
2001-10-25 22:25:30 +00:00
|
|
|
|
string)
|
2001-06-17 09:01:23 +00:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
2001-10-28 04:10:40 +00:00
|
|
|
|
(if (set (make-local-variable 'sgml-tags-invisible)
|
|
|
|
|
(if arg
|
|
|
|
|
(>= (prefix-numeric-value arg) 0)
|
|
|
|
|
(not sgml-tags-invisible)))
|
2002-03-28 16:06:38 +00:00
|
|
|
|
(while (re-search-forward sgml-tag-name-re nil t)
|
2001-10-25 22:25:30 +00:00
|
|
|
|
(setq string
|
|
|
|
|
(cdr (assq (intern-soft (downcase (match-string 1)))
|
|
|
|
|
sgml-display-text)))
|
2001-06-17 09:01:23 +00:00
|
|
|
|
(goto-char (match-beginning 0))
|
2001-10-25 22:25:30 +00:00
|
|
|
|
(and (stringp string)
|
2001-06-17 09:01:23 +00:00
|
|
|
|
(not (overlays-at (point)))
|
2001-10-28 04:10:40 +00:00
|
|
|
|
(let ((ol (make-overlay (point) (match-beginning 1))))
|
|
|
|
|
(overlay-put ol 'before-string string)
|
|
|
|
|
(overlay-put ol 'sgml-tag t)))
|
2001-06-17 09:01:23 +00:00
|
|
|
|
(put-text-property (point)
|
|
|
|
|
(progn (forward-list) (point))
|
|
|
|
|
'category 'sgml-tag))
|
2001-10-25 22:25:30 +00:00
|
|
|
|
(let ((pos (point-min)))
|
2001-06-17 09:01:23 +00:00
|
|
|
|
(while (< (setq pos (next-overlay-change pos)) (point-max))
|
2001-10-28 04:10:40 +00:00
|
|
|
|
(dolist (ol (overlays-at pos))
|
2001-10-28 04:12:46 +00:00
|
|
|
|
(if (overlay-get ol 'sgml-tag)
|
2001-10-28 04:10:40 +00:00
|
|
|
|
(delete-overlay ol)))))
|
2001-10-25 22:25:30 +00:00
|
|
|
|
(remove-text-properties (point-min) (point-max) '(category nil))))
|
2001-06-17 09:01:23 +00:00
|
|
|
|
(restore-buffer-modified-p modified))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(run-hooks 'sgml-tags-invisible-hook)
|
|
|
|
|
(message "")))
|
|
|
|
|
|
|
|
|
|
(defun sgml-point-entered (x y)
|
|
|
|
|
;; Show preceding or following hidden tag, depending of cursor direction.
|
|
|
|
|
(let ((inhibit-point-motion-hooks t))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(message "Invisible tag: %s"
|
2001-06-17 09:01:23 +00:00
|
|
|
|
;; Strip properties, otherwise, the text is invisible.
|
|
|
|
|
(buffer-substring-no-properties
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(point)
|
|
|
|
|
(if (or (and (> x y)
|
|
|
|
|
(not (eq (following-char) ?<)))
|
|
|
|
|
(and (< x y)
|
|
|
|
|
(eq (preceding-char) ?>)))
|
|
|
|
|
(backward-list)
|
|
|
|
|
(forward-list)))))))
|
2002-04-09 12:02:20 +00:00
|
|
|
|
|
1997-04-16 21:43:01 +00:00
|
|
|
|
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(autoload 'compile-internal "compile")
|
|
|
|
|
|
1992-07-17 06:48:03 +00:00
|
|
|
|
(defun sgml-validate (command)
|
|
|
|
|
"Validate an SGML document.
|
|
|
|
|
Runs COMMAND, a shell command, in a separate process asynchronously
|
1997-04-24 19:37:13 +00:00
|
|
|
|
with output going to the buffer `*compilation*'.
|
1992-07-17 06:48:03 +00:00
|
|
|
|
You can then use the command \\[next-error] to find the next error message
|
|
|
|
|
and move to the line in the SGML document that caused it."
|
|
|
|
|
(interactive
|
|
|
|
|
(list (read-string "Validate command: "
|
|
|
|
|
(or sgml-saved-validate-command
|
|
|
|
|
(concat sgml-validate-command
|
|
|
|
|
" "
|
|
|
|
|
(let ((name (buffer-file-name)))
|
|
|
|
|
(and name
|
|
|
|
|
(file-name-nondirectory name))))))))
|
|
|
|
|
(setq sgml-saved-validate-command command)
|
1998-12-31 14:40:03 +00:00
|
|
|
|
(save-some-buffers (not compilation-ask-about-save) nil)
|
1993-05-26 18:20:35 +00:00
|
|
|
|
(compile-internal command "No more errors"))
|
1992-07-17 06:48:03 +00:00
|
|
|
|
|
2002-04-16 10:38:30 +00:00
|
|
|
|
(defsubst sgml-at-indentation-p ()
|
|
|
|
|
"Return true if point is at the first non-whitespace character on the line."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(skip-chars-backward " \t")
|
|
|
|
|
(bolp)))
|
|
|
|
|
|
2002-03-28 16:06:38 +00:00
|
|
|
|
(defun sgml-lexical-context (&optional limit)
|
|
|
|
|
"Return the lexical context at point as (TYPE . START).
|
|
|
|
|
START is the location of the start of the lexical element.
|
2002-04-03 12:13:29 +00:00
|
|
|
|
TYPE is one of `string', `comment', `tag', `cdata', or `text'.
|
2002-03-28 16:06:38 +00:00
|
|
|
|
|
2002-04-09 12:27:17 +00:00
|
|
|
|
Optional argument LIMIT is the position to start parsing from.
|
|
|
|
|
If nil, start from a preceding tag at indentation."
|
2002-03-28 16:06:38 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((pos (point))
|
2002-04-03 21:17:38 +00:00
|
|
|
|
text-start state)
|
2002-04-09 12:27:17 +00:00
|
|
|
|
(if limit
|
|
|
|
|
(goto-char limit)
|
|
|
|
|
;; Skip tags backwards until we find one at indentation
|
|
|
|
|
(while (and (ignore-errors (sgml-parse-tag-backward))
|
|
|
|
|
(not (sgml-at-indentation-p)))))
|
2002-03-29 19:38:22 +00:00
|
|
|
|
(with-syntax-table sgml-tag-syntax-table
|
|
|
|
|
(while (< (point) pos)
|
|
|
|
|
;; When entering this loop we're inside text.
|
2002-04-02 12:07:27 +00:00
|
|
|
|
(setq text-start (point))
|
2002-03-29 19:38:22 +00:00
|
|
|
|
(skip-chars-forward "^<" pos)
|
2002-04-03 21:17:38 +00:00
|
|
|
|
(setq state
|
|
|
|
|
(cond
|
2002-04-08 21:32:05 +00:00
|
|
|
|
((= (point) pos)
|
2002-04-03 21:17:38 +00:00
|
|
|
|
;; We got to the end without seeing a tag.
|
|
|
|
|
nil)
|
|
|
|
|
((looking-at "<!\\[[A-Z]+\\[")
|
|
|
|
|
;; We've found a CDATA section or similar.
|
|
|
|
|
(let ((cdata-start (point)))
|
|
|
|
|
(unless (search-forward "]]>" pos 'move)
|
|
|
|
|
(list 0 nil nil 'cdata nil nil nil nil cdata-start))))
|
|
|
|
|
(t
|
2002-04-11 21:59:45 +00:00
|
|
|
|
;; We've reached a tag. Parse it.
|
2002-04-03 21:17:38 +00:00
|
|
|
|
;; FIXME: Handle net-enabling start-tags
|
|
|
|
|
(parse-partial-sexp (point) pos 0))))))
|
|
|
|
|
(cond
|
|
|
|
|
((eq (nth 3 state) 'cdata) (cons 'cdata (nth 8 state)))
|
|
|
|
|
((nth 3 state) (cons 'string (nth 8 state)))
|
|
|
|
|
((nth 4 state) (cons 'comment (nth 8 state)))
|
|
|
|
|
((and state (> (nth 0 state) 0)) (cons 'tag (nth 1 state)))
|
|
|
|
|
(t (cons 'text text-start))))))
|
2002-03-28 16:06:38 +00:00
|
|
|
|
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(defun sgml-beginning-of-tag (&optional top-level)
|
|
|
|
|
"Skip to beginning of tag and return its name.
|
2002-03-28 16:06:38 +00:00
|
|
|
|
If this can't be done, return nil."
|
|
|
|
|
(let ((context (sgml-lexical-context)))
|
|
|
|
|
(if (eq (car context) 'tag)
|
|
|
|
|
(progn
|
|
|
|
|
(goto-char (cdr context))
|
|
|
|
|
(when (looking-at sgml-tag-name-re)
|
|
|
|
|
(match-string-no-properties 1)))
|
|
|
|
|
(if top-level nil
|
2002-03-29 22:20:15 +00:00
|
|
|
|
(when (not (eq (car context) 'text))
|
2002-03-28 16:06:38 +00:00
|
|
|
|
(goto-char (cdr context))
|
|
|
|
|
(sgml-beginning-of-tag t))))))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
(defun sgml-value (alist)
|
2002-04-01 12:08:13 +00:00
|
|
|
|
"Interactively insert value taken from attribute-rule ALIST.
|
2001-10-26 17:40:59 +00:00
|
|
|
|
See `sgml-tag-alist' for info about attribute rules."
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(setq alist (cdr alist))
|
|
|
|
|
(if (stringp (car alist))
|
|
|
|
|
(insert "=\"" (car alist) ?\")
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(if (and (eq (car alist) t) (not sgml-xml-mode))
|
2001-10-26 17:40:59 +00:00
|
|
|
|
(when (cdr alist)
|
2001-10-28 04:10:40 +00:00
|
|
|
|
(insert "=\"")
|
|
|
|
|
(setq alist (skeleton-read '(completing-read "Value: " (cdr alist))))
|
|
|
|
|
(if (string< "" alist)
|
|
|
|
|
(insert alist ?\")
|
|
|
|
|
(delete-backward-char 2)))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(insert "=\"")
|
2001-10-26 17:40:59 +00:00
|
|
|
|
(when alist
|
|
|
|
|
(insert (skeleton-read '(completing-read "Value: " alist))))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(insert ?\"))))
|
2001-10-25 22:25:30 +00:00
|
|
|
|
|
|
|
|
|
(defun sgml-quote (start end &optional unquotep)
|
2002-07-13 19:23:05 +00:00
|
|
|
|
"Quote SGML text in region START ... END.
|
|
|
|
|
Only &, < and > are quoted, the rest is left untouched.
|
|
|
|
|
With prefix argument UNQUOTEP, unquote the region."
|
|
|
|
|
(interactive "r\nP")
|
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region start end)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(if unquotep
|
|
|
|
|
;; FIXME: We should unquote other named character references as well.
|
|
|
|
|
(while (re-search-forward
|
|
|
|
|
"\\(&\\(amp\\|\\(l\\|\\(g\\)\\)t\\)\\)[][<>&;\n\t \"%!'(),/=?]"
|
|
|
|
|
nil t)
|
|
|
|
|
(replace-match (if (match-end 4) ">" (if (match-end 3) "<" "&")) t t
|
|
|
|
|
nil (if (eq (char-before (match-end 0)) ?\;) 0 1)))
|
|
|
|
|
(while (re-search-forward "[&<>]" nil t)
|
|
|
|
|
(replace-match (cdr (assq (char-before) '((?& . "&")
|
|
|
|
|
(?< . "<")
|
|
|
|
|
(?> . ">"))))
|
|
|
|
|
t t)))))
|
|
|
|
|
|
|
|
|
|
(defun sgml-pretty-print (beg end)
|
|
|
|
|
"Simple-minded pretty printer for SGML.
|
|
|
|
|
Re-indents the code and inserts newlines between BEG and END.
|
|
|
|
|
You might want to turn on `auto-fill-mode' to get better results."
|
|
|
|
|
;; TODO:
|
|
|
|
|
;; - insert newline between some start-tag and text.
|
|
|
|
|
;; - don't insert newline in front of some end-tags.
|
|
|
|
|
(interactive "r")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(if (< beg end)
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(goto-char end)
|
|
|
|
|
(setq end beg)
|
|
|
|
|
(setq beg (point)))
|
|
|
|
|
;; Don't use narrowing because it screws up auto-indent.
|
|
|
|
|
(setq end (copy-marker end t))
|
|
|
|
|
(with-syntax-table sgml-tag-syntax-table
|
|
|
|
|
(while (re-search-forward "<" end t)
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(unless (or ;;(looking-at "</")
|
|
|
|
|
(progn (skip-chars-backward " \t") (bolp)))
|
|
|
|
|
(reindent-then-newline-and-indent))
|
|
|
|
|
(forward-sexp 1)))
|
|
|
|
|
;; (indent-region beg end)
|
|
|
|
|
))
|
2001-06-17 09:01:23 +00:00
|
|
|
|
|
2002-04-01 23:32:15 +00:00
|
|
|
|
|
|
|
|
|
;; Parsing
|
|
|
|
|
|
|
|
|
|
(defstruct (sgml-tag
|
|
|
|
|
(:constructor sgml-make-tag (type start end name)))
|
|
|
|
|
type start end name)
|
|
|
|
|
|
|
|
|
|
(defsubst sgml-parse-tag-name ()
|
|
|
|
|
"Skip past a tag-name, and return the name."
|
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
(point) (progn (skip-syntax-forward "w_") (point))))
|
|
|
|
|
|
2002-04-09 12:27:17 +00:00
|
|
|
|
(defsubst sgml-looking-back-at (str)
|
|
|
|
|
"Return t if the test before point matches STR."
|
|
|
|
|
(let ((start (- (point) (length str))))
|
2002-04-02 12:07:27 +00:00
|
|
|
|
(and (>= start (point-min))
|
2002-04-09 12:27:17 +00:00
|
|
|
|
(equal str (buffer-substring-no-properties start (point))))))
|
2002-04-01 23:32:15 +00:00
|
|
|
|
|
2002-11-12 16:46:19 +00:00
|
|
|
|
(defun sgml-parse-tag-backward (&optional limit)
|
2002-04-01 23:32:15 +00:00
|
|
|
|
"Parse an SGML tag backward, and return information about the tag.
|
|
|
|
|
Assume that parsing starts from within a textual context.
|
|
|
|
|
Leave point at the beginning of the tag."
|
|
|
|
|
(let (tag-type tag-start tag-end name)
|
2002-11-12 16:46:19 +00:00
|
|
|
|
(or (search-backward ">" limit 'move)
|
2002-04-14 12:50:10 +00:00
|
|
|
|
(error "No tag found"))
|
2002-04-01 23:32:15 +00:00
|
|
|
|
(setq tag-end (1+ (point)))
|
|
|
|
|
(cond
|
|
|
|
|
((sgml-looking-back-at "--") ; comment
|
|
|
|
|
(setq tag-type 'comment
|
|
|
|
|
tag-start (search-backward "<!--" nil t)))
|
|
|
|
|
((sgml-looking-back-at "]]") ; cdata
|
2002-04-08 21:32:05 +00:00
|
|
|
|
(setq tag-type 'cdata
|
2002-04-03 12:13:29 +00:00
|
|
|
|
tag-start (re-search-backward "<!\\[[A-Z]+\\[" nil t)))
|
2002-04-01 23:32:15 +00:00
|
|
|
|
(t
|
|
|
|
|
(setq tag-start
|
|
|
|
|
(with-syntax-table sgml-tag-syntax-table
|
|
|
|
|
(goto-char tag-end)
|
|
|
|
|
(backward-sexp)
|
|
|
|
|
(point)))
|
|
|
|
|
(goto-char (1+ tag-start))
|
|
|
|
|
(case (char-after)
|
|
|
|
|
(?! ; declaration
|
|
|
|
|
(setq tag-type 'decl))
|
|
|
|
|
(?? ; processing-instruction
|
|
|
|
|
(setq tag-type 'pi))
|
|
|
|
|
(?/ ; close-tag
|
|
|
|
|
(forward-char 1)
|
|
|
|
|
(setq tag-type 'close
|
|
|
|
|
name (sgml-parse-tag-name)))
|
2002-04-02 11:26:12 +00:00
|
|
|
|
(?% ; JSP tags
|
|
|
|
|
(setq tag-type 'jsp))
|
2002-04-01 23:32:15 +00:00
|
|
|
|
(t ; open or empty tag
|
|
|
|
|
(setq tag-type 'open
|
|
|
|
|
name (sgml-parse-tag-name))
|
|
|
|
|
(if (or (eq ?/ (char-before (- tag-end 1)))
|
|
|
|
|
(sgml-empty-tag-p name))
|
|
|
|
|
(setq tag-type 'empty))))))
|
|
|
|
|
(goto-char tag-start)
|
|
|
|
|
(sgml-make-tag tag-type tag-start tag-end name)))
|
|
|
|
|
|
|
|
|
|
(defun sgml-get-context (&optional full)
|
|
|
|
|
"Determine the context of the current position.
|
|
|
|
|
If FULL is `empty', return even if the context is empty (i.e.
|
|
|
|
|
we just skipped over some element and got to a beginning of line).
|
|
|
|
|
If FULL is non-nil, parse back to the beginning of the buffer, otherwise
|
|
|
|
|
parse until we find a start-tag as the first thing on a line.
|
|
|
|
|
|
|
|
|
|
The context is a list of tag-info structures. The last one is the tag
|
|
|
|
|
immediately enclosing the current position."
|
|
|
|
|
(let ((here (point))
|
|
|
|
|
(ignore nil)
|
|
|
|
|
(context nil)
|
|
|
|
|
tag-info)
|
|
|
|
|
;; CONTEXT keeps track of the tag-stack
|
|
|
|
|
;; IGNORE keeps track of the nesting level of point relative to the
|
|
|
|
|
;; first (outermost) tag on the context. This is the list of
|
|
|
|
|
;; enclosing start-tags we'll have to ignore.
|
|
|
|
|
(skip-chars-backward " \t\n") ; Make sure we're not at indentation.
|
|
|
|
|
(while
|
2002-04-11 21:59:45 +00:00
|
|
|
|
(and (or ignore
|
2002-04-01 23:32:15 +00:00
|
|
|
|
(not (if full (eq full 'empty) context))
|
|
|
|
|
(not (sgml-at-indentation-p))
|
|
|
|
|
(and context
|
|
|
|
|
(/= (point) (sgml-tag-start (car context)))
|
|
|
|
|
(sgml-unclosed-tag-p (sgml-tag-name (car context)))))
|
|
|
|
|
(setq tag-info (ignore-errors (sgml-parse-tag-backward))))
|
2002-10-18 08:30:49 +00:00
|
|
|
|
|
2002-04-01 23:32:15 +00:00
|
|
|
|
;; This tag may enclose things we thought were tags. If so,
|
|
|
|
|
;; discard them.
|
|
|
|
|
(while (and context
|
|
|
|
|
(> (sgml-tag-end tag-info)
|
|
|
|
|
(sgml-tag-end (car context))))
|
|
|
|
|
(setq context (cdr context)))
|
2002-10-18 08:30:49 +00:00
|
|
|
|
|
2002-04-01 23:32:15 +00:00
|
|
|
|
(cond
|
|
|
|
|
|
|
|
|
|
;; start-tag
|
|
|
|
|
((eq (sgml-tag-type tag-info) 'open)
|
|
|
|
|
(cond
|
|
|
|
|
((null ignore)
|
|
|
|
|
(if (and context
|
|
|
|
|
(sgml-unclosed-tag-p (sgml-tag-name tag-info))
|
|
|
|
|
(eq t (compare-strings
|
|
|
|
|
(sgml-tag-name tag-info) nil nil
|
|
|
|
|
(sgml-tag-name (car context)) nil nil t)))
|
|
|
|
|
;; There was an implicit end-tag.
|
|
|
|
|
nil
|
|
|
|
|
(push tag-info context)))
|
|
|
|
|
((eq t (compare-strings (sgml-tag-name tag-info) nil nil
|
|
|
|
|
(car ignore) nil nil t))
|
|
|
|
|
(setq ignore (cdr ignore)))
|
|
|
|
|
(t
|
|
|
|
|
;; The open and close tags don't match.
|
|
|
|
|
(if (not sgml-xml-mode)
|
|
|
|
|
(unless (sgml-unclosed-tag-p (sgml-tag-name tag-info))
|
2002-07-13 19:23:05 +00:00
|
|
|
|
(message "Unclosed tag <%s>" (sgml-tag-name tag-info))
|
|
|
|
|
(let ((tmp ignore))
|
|
|
|
|
;; We could just assume that the tag is simply not closed
|
|
|
|
|
;; but it's a bad assumption when tags *are* closed but
|
|
|
|
|
;; not properly nested.
|
|
|
|
|
(while (and (cdr tmp)
|
|
|
|
|
(not (eq t (compare-strings
|
|
|
|
|
(sgml-tag-name tag-info) nil nil
|
|
|
|
|
(cadr tmp) nil nil t))))
|
|
|
|
|
(setq tmp (cdr tmp)))
|
|
|
|
|
(if (cdr tmp) (setcdr tmp (cddr tmp)))))
|
2002-04-01 23:32:15 +00:00
|
|
|
|
(message "Unmatched tags <%s> and </%s>"
|
|
|
|
|
(sgml-tag-name tag-info) (pop ignore))))))
|
|
|
|
|
|
|
|
|
|
;; end-tag
|
|
|
|
|
((eq (sgml-tag-type tag-info) 'close)
|
|
|
|
|
(if (sgml-empty-tag-p (sgml-tag-name tag-info))
|
|
|
|
|
(message "Spurious </%s>: empty tag" (sgml-tag-name tag-info))
|
|
|
|
|
(push (sgml-tag-name tag-info) ignore)))
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
;; return context
|
|
|
|
|
context))
|
|
|
|
|
|
|
|
|
|
(defun sgml-show-context (&optional full)
|
|
|
|
|
"Display the current context.
|
|
|
|
|
If FULL is non-nil, parse back to the beginning of the buffer."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(with-output-to-temp-buffer "*XML Context*"
|
2002-07-13 19:23:05 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((context (sgml-get-context)))
|
|
|
|
|
(when full
|
|
|
|
|
(let ((more nil))
|
|
|
|
|
(while (setq more (sgml-get-context))
|
|
|
|
|
(setq context (nconc more context)))))
|
|
|
|
|
(pp context)))))
|
2002-04-01 23:32:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Editing shortcuts
|
|
|
|
|
|
2002-04-02 11:26:12 +00:00
|
|
|
|
(defun sgml-close-tag ()
|
2002-11-12 16:46:19 +00:00
|
|
|
|
"Close current element.
|
|
|
|
|
Depending on context, inserts a matching close-tag, or closes
|
|
|
|
|
the current start-tag or the current comment or the current cdata, ..."
|
2002-04-01 23:32:15 +00:00
|
|
|
|
(interactive)
|
2002-04-02 11:26:12 +00:00
|
|
|
|
(case (car (sgml-lexical-context))
|
|
|
|
|
(comment (insert " -->"))
|
|
|
|
|
(cdata (insert "]]>"))
|
|
|
|
|
(pi (insert " ?>"))
|
|
|
|
|
(jsp (insert " %>"))
|
|
|
|
|
(tag (insert " />"))
|
|
|
|
|
(text
|
|
|
|
|
(let ((context (save-excursion (sgml-get-context))))
|
|
|
|
|
(if context
|
2002-04-11 21:59:45 +00:00
|
|
|
|
(progn
|
2002-04-02 11:26:12 +00:00
|
|
|
|
(insert "</" (sgml-tag-name (car (last context))) ">")
|
|
|
|
|
(indent-according-to-mode)))))
|
|
|
|
|
(otherwise
|
|
|
|
|
(error "Nothing to close"))))
|
2002-04-01 23:32:15 +00:00
|
|
|
|
|
2002-04-01 12:08:13 +00:00
|
|
|
|
(defun sgml-empty-tag-p (tag-name)
|
|
|
|
|
"Return non-nil if TAG-NAME is an implicitly empty tag."
|
|
|
|
|
(and (not sgml-xml-mode)
|
|
|
|
|
(member-ignore-case tag-name sgml-empty-tags)))
|
|
|
|
|
|
|
|
|
|
(defun sgml-unclosed-tag-p (tag-name)
|
|
|
|
|
"Return non-nil if TAG-NAME is a tag for which an end-tag is optional."
|
|
|
|
|
(and (not sgml-xml-mode)
|
|
|
|
|
(member-ignore-case tag-name sgml-unclosed-tags)))
|
|
|
|
|
|
2002-03-28 16:06:38 +00:00
|
|
|
|
(defun sgml-calculate-indent ()
|
|
|
|
|
"Calculate the column to which this line should be indented."
|
|
|
|
|
(let ((lcon (sgml-lexical-context)))
|
2002-04-01 12:08:13 +00:00
|
|
|
|
|
2002-03-28 16:06:38 +00:00
|
|
|
|
;; Indent comment-start markers inside <!-- just like comment-end markers.
|
|
|
|
|
(if (and (eq (car lcon) 'tag)
|
|
|
|
|
(looking-at "--")
|
|
|
|
|
(save-excursion (goto-char (cdr lcon)) (looking-at "<!--")))
|
|
|
|
|
(setq lcon (cons 'comment (+ (cdr lcon) 2))))
|
|
|
|
|
|
|
|
|
|
(case (car lcon)
|
2002-04-01 12:08:13 +00:00
|
|
|
|
|
2002-03-28 16:06:38 +00:00
|
|
|
|
(string
|
|
|
|
|
;; Go back to previous non-empty line.
|
|
|
|
|
(while (and (> (point) (cdr lcon))
|
|
|
|
|
(zerop (forward-line -1))
|
|
|
|
|
(looking-at "[ \t]*$")))
|
|
|
|
|
(if (> (point) (cdr lcon))
|
|
|
|
|
;; Previous line is inside the string.
|
|
|
|
|
(current-indentation)
|
|
|
|
|
(goto-char (cdr lcon))
|
|
|
|
|
(1+ (current-column))))
|
|
|
|
|
|
|
|
|
|
(comment
|
|
|
|
|
(let ((mark (looking-at "--")))
|
|
|
|
|
;; Go back to previous non-empty line.
|
|
|
|
|
(while (and (> (point) (cdr lcon))
|
|
|
|
|
(zerop (forward-line -1))
|
|
|
|
|
(or (looking-at "[ \t]*$")
|
|
|
|
|
(if mark (not (looking-at "[ \t]*--"))))))
|
|
|
|
|
(if (> (point) (cdr lcon))
|
|
|
|
|
;; Previous line is inside the comment.
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(goto-char (cdr lcon)))
|
|
|
|
|
(when (and (not mark) (looking-at "--"))
|
|
|
|
|
(forward-char 2) (skip-chars-forward " \t"))
|
|
|
|
|
(current-column)))
|
|
|
|
|
|
2002-04-02 12:07:27 +00:00
|
|
|
|
(cdata
|
|
|
|
|
(current-column))
|
|
|
|
|
|
2002-03-28 16:06:38 +00:00
|
|
|
|
(tag
|
|
|
|
|
(goto-char (1+ (cdr lcon)))
|
|
|
|
|
(skip-chars-forward "^ \t\n") ;Skip tag name.
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(if (not (eolp))
|
|
|
|
|
(current-column)
|
|
|
|
|
;; This is the first attribute: indent.
|
|
|
|
|
(goto-char (1+ (cdr lcon)))
|
|
|
|
|
(+ (current-column) sgml-basic-offset)))
|
|
|
|
|
|
2002-04-01 12:08:13 +00:00
|
|
|
|
(text
|
2002-03-28 16:06:38 +00:00
|
|
|
|
(while (looking-at "</")
|
|
|
|
|
(forward-sexp 1)
|
|
|
|
|
(skip-chars-forward " \t"))
|
2002-03-29 22:20:15 +00:00
|
|
|
|
(let* ((here (point))
|
|
|
|
|
(unclosed (and ;; (not sgml-xml-mode)
|
|
|
|
|
(looking-at sgml-tag-name-re)
|
|
|
|
|
(member-ignore-case (match-string 1)
|
|
|
|
|
sgml-unclosed-tags)
|
|
|
|
|
(match-string 1)))
|
|
|
|
|
(context
|
|
|
|
|
;; If possible, align on the previous non-empty text line.
|
|
|
|
|
;; Otherwise, do a more serious parsing to find the
|
|
|
|
|
;; tag(s) relative to which we should be indenting.
|
|
|
|
|
(if (and (not unclosed) (skip-chars-backward " \t")
|
|
|
|
|
(< (skip-chars-backward " \t\n") 0)
|
|
|
|
|
(back-to-indentation)
|
|
|
|
|
(> (point) (cdr lcon)))
|
|
|
|
|
nil
|
|
|
|
|
(goto-char here)
|
2002-04-01 23:32:15 +00:00
|
|
|
|
(nreverse (sgml-get-context (if unclosed nil 'empty)))))
|
2002-03-29 22:20:15 +00:00
|
|
|
|
(there (point)))
|
|
|
|
|
;; Ignore previous unclosed start-tag in context.
|
|
|
|
|
(while (and context unclosed
|
|
|
|
|
(eq t (compare-strings
|
2002-04-01 23:32:15 +00:00
|
|
|
|
(sgml-tag-name (car context)) nil nil
|
2002-03-29 22:20:15 +00:00
|
|
|
|
unclosed nil nil t)))
|
|
|
|
|
(setq context (cdr context)))
|
|
|
|
|
;; Indent to reflect nesting.
|
|
|
|
|
(if (and context
|
2002-04-01 23:32:15 +00:00
|
|
|
|
(goto-char (sgml-tag-end (car context)))
|
2002-03-29 22:20:15 +00:00
|
|
|
|
(skip-chars-forward " \t\n")
|
2002-04-01 23:32:15 +00:00
|
|
|
|
(< (point) here) (sgml-at-indentation-p))
|
2002-03-29 22:20:15 +00:00
|
|
|
|
(current-column)
|
|
|
|
|
(goto-char there)
|
|
|
|
|
(+ (current-column)
|
2002-04-01 12:08:13 +00:00
|
|
|
|
(* sgml-basic-offset (length context))))))
|
2002-10-18 08:30:49 +00:00
|
|
|
|
|
2002-04-01 12:08:13 +00:00
|
|
|
|
(otherwise
|
|
|
|
|
(error "Unrecognised context %s" (car lcon)))
|
|
|
|
|
|
|
|
|
|
)))
|
2002-03-28 16:06:38 +00:00
|
|
|
|
|
|
|
|
|
(defun sgml-indent-line ()
|
|
|
|
|
"Indent the current line as SGML."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let* ((savep (point))
|
|
|
|
|
(indent-col
|
|
|
|
|
(save-excursion
|
2002-03-29 19:38:22 +00:00
|
|
|
|
(back-to-indentation)
|
2002-03-28 16:06:38 +00:00
|
|
|
|
(if (>= (point) savep) (setq savep nil))
|
|
|
|
|
(sgml-calculate-indent))))
|
|
|
|
|
(if savep
|
|
|
|
|
(save-excursion (indent-line-to indent-col))
|
|
|
|
|
(indent-line-to indent-col))))
|
|
|
|
|
|
2002-04-11 21:59:45 +00:00
|
|
|
|
(defun sgml-guess-indent ()
|
|
|
|
|
"Guess an appropriate value for `sgml-basic-offset'.
|
|
|
|
|
Base the guessed identation level on the first indented tag in the buffer.
|
|
|
|
|
Add this to `sgml-mode-hook' for convenience."
|
|
|
|
|
(interactive)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
2002-05-22 09:40:48 +00:00
|
|
|
|
(if (re-search-forward "^\\([ \t]+\\)<" 500 'noerror)
|
2002-04-11 21:59:45 +00:00
|
|
|
|
(progn
|
|
|
|
|
(set (make-local-variable 'sgml-basic-offset)
|
2002-09-29 06:00:18 +00:00
|
|
|
|
(1- (current-column)))
|
2002-04-11 21:59:45 +00:00
|
|
|
|
(message "Guessed sgml-basic-offset = %d"
|
|
|
|
|
sgml-basic-offset)
|
|
|
|
|
))))
|
|
|
|
|
|
2002-03-29 19:38:22 +00:00
|
|
|
|
(defun sgml-parse-dtd ()
|
|
|
|
|
"Simplistic parse of the current buffer as a DTD.
|
|
|
|
|
Currently just returns (EMPTY-TAGS UNCLOSED-TAGS)."
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(let ((empty nil)
|
|
|
|
|
(unclosed nil))
|
|
|
|
|
(while (re-search-forward "<!ELEMENT[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+[-O][ \t\n]+\\([-O]\\)[ \t\n]+\\([^ \t\n]+\\)" nil t)
|
|
|
|
|
(cond
|
|
|
|
|
((string= (match-string 3) "EMPTY")
|
|
|
|
|
(push (match-string-no-properties 1) empty))
|
|
|
|
|
((string= (match-string 2) "O")
|
|
|
|
|
(push (match-string-no-properties 1) unclosed))))
|
|
|
|
|
(setq empty (sort (mapcar 'downcase empty) 'string<))
|
|
|
|
|
(setq unclosed (sort (mapcar 'downcase unclosed) 'string<))
|
|
|
|
|
(list empty unclosed)))
|
|
|
|
|
|
2001-06-17 09:01:23 +00:00
|
|
|
|
;;; HTML mode
|
|
|
|
|
|
1999-08-04 19:18:55 +00:00
|
|
|
|
(defcustom html-mode-hook nil
|
|
|
|
|
"Hook run by command `html-mode'.
|
|
|
|
|
`text-mode-hook' and `sgml-mode-hook' are run first."
|
|
|
|
|
:group 'sgml
|
|
|
|
|
:type 'hook
|
|
|
|
|
:options '(html-autoview-mode))
|
|
|
|
|
|
1996-01-24 17:12:21 +00:00
|
|
|
|
(defvar html-quick-keys sgml-quick-keys
|
1996-01-26 19:39:42 +00:00
|
|
|
|
"Use C-c X combinations for quick insertion of frequent tags when non-nil.
|
1996-01-24 17:12:21 +00:00
|
|
|
|
This defaults to `sgml-quick-keys'.
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
This takes effect when first loading the library.")
|
|
|
|
|
|
|
|
|
|
(defvar html-mode-map
|
2001-04-06 16:24:42 +00:00
|
|
|
|
(let ((map (make-sparse-keymap))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(menu-map (make-sparse-keymap "HTML")))
|
2001-04-06 16:24:42 +00:00
|
|
|
|
(set-keymap-parent map sgml-mode-map)
|
1996-06-15 23:19:40 +00:00
|
|
|
|
(define-key map "\C-c6" 'html-headline-6)
|
|
|
|
|
(define-key map "\C-c5" 'html-headline-5)
|
|
|
|
|
(define-key map "\C-c4" 'html-headline-4)
|
|
|
|
|
(define-key map "\C-c3" 'html-headline-3)
|
|
|
|
|
(define-key map "\C-c2" 'html-headline-2)
|
|
|
|
|
(define-key map "\C-c1" 'html-headline-1)
|
1996-01-24 17:12:21 +00:00
|
|
|
|
(define-key map "\C-c\r" 'html-paragraph)
|
|
|
|
|
(define-key map "\C-c\n" 'html-line)
|
|
|
|
|
(define-key map "\C-c\C-c-" 'html-horizontal-rule)
|
1996-06-15 23:19:40 +00:00
|
|
|
|
(define-key map "\C-c\C-co" 'html-ordered-list)
|
|
|
|
|
(define-key map "\C-c\C-cu" 'html-unordered-list)
|
1996-01-24 17:12:21 +00:00
|
|
|
|
(define-key map "\C-c\C-cr" 'html-radio-buttons)
|
|
|
|
|
(define-key map "\C-c\C-cc" 'html-checkboxes)
|
|
|
|
|
(define-key map "\C-c\C-cl" 'html-list-item)
|
|
|
|
|
(define-key map "\C-c\C-ch" 'html-href-anchor)
|
|
|
|
|
(define-key map "\C-c\C-cn" 'html-name-anchor)
|
|
|
|
|
(define-key map "\C-c\C-ci" 'html-image)
|
2001-10-26 17:40:59 +00:00
|
|
|
|
(when html-quick-keys
|
|
|
|
|
(define-key map "\C-c-" 'html-horizontal-rule)
|
|
|
|
|
(define-key map "\C-co" 'html-ordered-list)
|
|
|
|
|
(define-key map "\C-cu" 'html-unordered-list)
|
|
|
|
|
(define-key map "\C-cr" 'html-radio-buttons)
|
|
|
|
|
(define-key map "\C-cc" 'html-checkboxes)
|
|
|
|
|
(define-key map "\C-cl" 'html-list-item)
|
|
|
|
|
(define-key map "\C-ch" 'html-href-anchor)
|
|
|
|
|
(define-key map "\C-cn" 'html-name-anchor)
|
|
|
|
|
(define-key map "\C-ci" 'html-image))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(define-key map "\C-c\C-s" 'html-autoview-mode)
|
|
|
|
|
(define-key map "\C-c\C-v" 'browse-url-of-buffer)
|
|
|
|
|
(define-key map [menu-bar html] (cons "HTML" menu-map))
|
|
|
|
|
(define-key menu-map [html-autoview-mode]
|
|
|
|
|
'("Toggle Autoviewing" . html-autoview-mode))
|
|
|
|
|
(define-key menu-map [browse-url-of-buffer]
|
|
|
|
|
'("View Buffer Contents" . browse-url-of-buffer))
|
|
|
|
|
(define-key menu-map [nil] '("--"))
|
1996-06-15 23:19:40 +00:00
|
|
|
|
;;(define-key menu-map "6" '("Heading 6" . html-headline-6))
|
|
|
|
|
;;(define-key menu-map "5" '("Heading 5" . html-headline-5))
|
|
|
|
|
;;(define-key menu-map "4" '("Heading 4" . html-headline-4))
|
|
|
|
|
(define-key menu-map "3" '("Heading 3" . html-headline-3))
|
|
|
|
|
(define-key menu-map "2" '("Heading 2" . html-headline-2))
|
|
|
|
|
(define-key menu-map "1" '("Heading 1" . html-headline-1))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(define-key menu-map "l" '("Radio Buttons" . html-radio-buttons))
|
1996-01-24 17:12:21 +00:00
|
|
|
|
(define-key menu-map "c" '("Checkboxes" . html-checkboxes))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(define-key menu-map "l" '("List Item" . html-list-item))
|
1996-06-15 23:19:40 +00:00
|
|
|
|
(define-key menu-map "u" '("Unordered List" . html-unordered-list))
|
|
|
|
|
(define-key menu-map "o" '("Ordered List" . html-ordered-list))
|
1996-01-24 17:12:21 +00:00
|
|
|
|
(define-key menu-map "-" '("Horizontal Rule" . html-horizontal-rule))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(define-key menu-map "\n" '("Line Break" . html-line))
|
|
|
|
|
(define-key menu-map "\r" '("Paragraph" . html-paragraph))
|
|
|
|
|
(define-key menu-map "i" '("Image" . html-image))
|
|
|
|
|
(define-key menu-map "h" '("Href Anchor" . html-href-anchor))
|
|
|
|
|
(define-key menu-map "n" '("Name Anchor" . html-name-anchor))
|
|
|
|
|
map)
|
|
|
|
|
"Keymap for commands for use in HTML mode.")
|
|
|
|
|
|
|
|
|
|
(defvar html-face-tag-alist
|
|
|
|
|
'((bold . "b")
|
|
|
|
|
(italic . "i")
|
|
|
|
|
(underline . "u")
|
|
|
|
|
(modeline . "rev"))
|
|
|
|
|
"Value of `sgml-face-tag-alist' for HTML mode.")
|
|
|
|
|
|
|
|
|
|
(defvar html-tag-face-alist
|
|
|
|
|
'(("b" . bold)
|
|
|
|
|
("big" . bold)
|
|
|
|
|
("blink" . highlight)
|
|
|
|
|
("cite" . italic)
|
|
|
|
|
("em" . italic)
|
|
|
|
|
("h1" bold underline)
|
|
|
|
|
("h2" bold-italic underline)
|
|
|
|
|
("h3" italic underline)
|
|
|
|
|
("h4" . underline)
|
|
|
|
|
("h5" . underline)
|
|
|
|
|
("h6" . underline)
|
|
|
|
|
("i" . italic)
|
|
|
|
|
("rev" . modeline)
|
|
|
|
|
("s" . underline)
|
|
|
|
|
("small" . default)
|
|
|
|
|
("strong" . bold)
|
|
|
|
|
("title" bold underline)
|
|
|
|
|
("tt" . default)
|
|
|
|
|
("u" . underline)
|
|
|
|
|
("var" . italic))
|
|
|
|
|
"Value of `sgml-tag-face-alist' for HTML mode.")
|
|
|
|
|
|
|
|
|
|
(defvar html-display-text
|
|
|
|
|
'((img . "[/]")
|
|
|
|
|
(hr . "----------")
|
|
|
|
|
(li . "o "))
|
|
|
|
|
"Value of `sgml-display-text' for HTML mode.")
|
2001-10-05 16:21:14 +00:00
|
|
|
|
|
2002-04-09 12:02:20 +00:00
|
|
|
|
|
1998-06-27 19:46:22 +00:00
|
|
|
|
;; should code exactly HTML 3 here when that is finished
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(defvar html-tag-alist
|
1997-04-23 18:58:33 +00:00
|
|
|
|
(let* ((1-7 '(("1") ("2") ("3") ("4") ("5") ("6") ("7")))
|
2001-06-17 09:01:23 +00:00
|
|
|
|
(1-9 `(,@1-7 ("8") ("9")))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(align '(("align" ("left") ("center") ("right"))))
|
|
|
|
|
(valign '(("top") ("middle") ("bottom") ("baseline")))
|
|
|
|
|
(rel '(("next") ("previous") ("parent") ("subdocument") ("made")))
|
|
|
|
|
(href '("href" ("ftp:") ("file:") ("finger:") ("gopher:") ("http:")
|
|
|
|
|
("mailto:") ("news:") ("rlogin:") ("telnet:") ("tn3270:")
|
1996-01-24 17:12:21 +00:00
|
|
|
|
("wais:") ("/cgi-bin/")))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(name '("name"))
|
|
|
|
|
(link `(,href
|
|
|
|
|
("rel" ,@rel)
|
|
|
|
|
("rev" ,@rel)
|
|
|
|
|
("title")))
|
2001-10-05 16:21:14 +00:00
|
|
|
|
(list '((nil \n ("List item: " "<li>" str
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(if sgml-xml-mode "</li>") \n))))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(cell `(t
|
2001-06-17 09:01:23 +00:00
|
|
|
|
,@align
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("valign" ,@valign)
|
|
|
|
|
("colspan" ,@1-9)
|
|
|
|
|
("rowspan" ,@1-9)
|
|
|
|
|
("nowrap" t))))
|
|
|
|
|
;; put ,-expressions first, else byte-compile chokes (as of V19.29)
|
|
|
|
|
;; and like this it's more efficient anyway
|
|
|
|
|
`(("a" ,name ,@link)
|
|
|
|
|
("base" t ,@href)
|
|
|
|
|
("dir" ,@list)
|
1997-04-23 18:58:33 +00:00
|
|
|
|
("font" nil "size" ("-1") ("+1") ("-2") ("+2") ,@1-7)
|
2001-10-28 04:10:40 +00:00
|
|
|
|
("form" (\n _ \n "<input type=\"submit\" value=\"\""
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(if sgml-xml-mode "/>" ">"))
|
1996-01-24 17:12:21 +00:00
|
|
|
|
("action" ,@(cdr href)) ("method" ("get") ("post")))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("h1" ,@align)
|
|
|
|
|
("h2" ,@align)
|
|
|
|
|
("h3" ,@align)
|
|
|
|
|
("h4" ,@align)
|
|
|
|
|
("h5" ,@align)
|
|
|
|
|
("h6" ,@align)
|
|
|
|
|
("hr" t ("size" ,@1-9) ("width") ("noshade" t) ,@align)
|
|
|
|
|
("img" t ("align" ,@valign ("texttop") ("absmiddle") ("absbottom"))
|
|
|
|
|
("src") ("alt") ("width" "1") ("height" "1")
|
|
|
|
|
("border" "1") ("vspace" "1") ("hspace" "1") ("ismap" t))
|
|
|
|
|
("input" t ("size" ,@1-9) ("maxlength" ,@1-9) ("checked" t) ,name
|
1996-01-24 17:12:21 +00:00
|
|
|
|
("type" ("text") ("password") ("checkbox") ("radio")
|
|
|
|
|
("submit") ("reset"))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("value"))
|
|
|
|
|
("link" t ,@link)
|
|
|
|
|
("menu" ,@list)
|
1997-04-23 18:58:33 +00:00
|
|
|
|
("ol" ,@list ("type" ("A") ("a") ("I") ("i") ("1")))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("p" t ,@align)
|
|
|
|
|
("select" (nil \n
|
|
|
|
|
("Text: "
|
2002-03-17 23:55:15 +00:00
|
|
|
|
"<option>" str (if sgml-xml-mode "</option>") \n))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
,name ("size" ,@1-9) ("multiple" t))
|
|
|
|
|
("table" (nil \n
|
|
|
|
|
((completing-read "Cell kind: " '(("td") ("th"))
|
|
|
|
|
nil t "t")
|
2001-10-28 04:10:40 +00:00
|
|
|
|
"<tr><" str ?> _
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(if sgml-xml-mode (concat "<" str "></tr>")) \n))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("border" t ,@1-9) ("width" "10") ("cellpadding"))
|
|
|
|
|
("td" ,@cell)
|
|
|
|
|
("textarea" ,name ("rows" ,@1-9) ("cols" ,@1-9))
|
|
|
|
|
("th" ,@cell)
|
1997-04-23 18:58:33 +00:00
|
|
|
|
("ul" ,@list ("type" ("disc") ("circle") ("square")))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
,@sgml-tag-alist
|
|
|
|
|
|
|
|
|
|
("abbrev")
|
|
|
|
|
("acronym")
|
|
|
|
|
("address")
|
|
|
|
|
("array" (nil \n
|
2002-03-17 23:55:15 +00:00
|
|
|
|
("Item: " "<item>" str (if sgml-xml-mode "</item>") \n))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
"align")
|
|
|
|
|
("au")
|
|
|
|
|
("b")
|
|
|
|
|
("big")
|
|
|
|
|
("blink")
|
|
|
|
|
("blockquote" \n)
|
|
|
|
|
("body" \n ("background" ".gif") ("bgcolor" "#") ("text" "#")
|
|
|
|
|
("link" "#") ("alink" "#") ("vlink" "#"))
|
2002-03-17 23:55:15 +00:00
|
|
|
|
("box" (nil _ "<over>" _ (if sgml-xml-mode "</over>")))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("br" t ("clear" ("left") ("right")))
|
|
|
|
|
("caption" ("valign" ("top") ("bottom")))
|
|
|
|
|
("center" \n)
|
|
|
|
|
("cite")
|
|
|
|
|
("code" \n)
|
2002-03-17 23:55:15 +00:00
|
|
|
|
("dd" ,(not sgml-xml-mode))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("del")
|
|
|
|
|
("dfn")
|
2001-06-17 09:01:23 +00:00
|
|
|
|
("div")
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("dl" (nil \n
|
|
|
|
|
( "Term: "
|
2002-03-17 23:55:15 +00:00
|
|
|
|
"<dt>" str (if sgml-xml-mode "</dt>")
|
|
|
|
|
"<dd>" _ (if sgml-xml-mode "</dd>") \n)))
|
|
|
|
|
("dt" (t _ (if sgml-xml-mode "</dt>")
|
|
|
|
|
"<dd>" (if sgml-xml-mode "</dd>") \n))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("em")
|
1997-04-23 18:58:33 +00:00
|
|
|
|
;("fn" "id" "fn") ; ???
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("head" \n)
|
|
|
|
|
("html" (\n
|
|
|
|
|
"<head>\n"
|
|
|
|
|
"<title>" (setq str (read-input "Title: ")) "</title>\n"
|
1999-02-26 16:40:13 +00:00
|
|
|
|
"</head>\n"
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
"<body>\n<h1>" str "</h1>\n" _
|
|
|
|
|
"\n<address>\n<a href=\"mailto:"
|
1996-02-08 17:27:23 +00:00
|
|
|
|
user-mail-address
|
1999-02-26 16:40:13 +00:00
|
|
|
|
"\">" (user-full-name) "</a>\n</address>\n"
|
|
|
|
|
"</body>"
|
|
|
|
|
))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("i")
|
|
|
|
|
("ins")
|
|
|
|
|
("isindex" t ("action") ("prompt"))
|
|
|
|
|
("kbd")
|
|
|
|
|
("lang")
|
2002-03-17 23:55:15 +00:00
|
|
|
|
("li" ,(not sgml-xml-mode))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("math" \n)
|
|
|
|
|
("nobr")
|
|
|
|
|
("option" t ("value") ("label") ("selected" t))
|
|
|
|
|
("over" t)
|
|
|
|
|
("person")
|
|
|
|
|
("pre" \n)
|
|
|
|
|
("q")
|
|
|
|
|
("rev")
|
|
|
|
|
("s")
|
|
|
|
|
("samp")
|
|
|
|
|
("small")
|
2001-10-25 22:25:30 +00:00
|
|
|
|
("span" nil
|
|
|
|
|
("class"
|
|
|
|
|
("builtin")
|
|
|
|
|
("comment")
|
|
|
|
|
("constant")
|
|
|
|
|
("function-name")
|
|
|
|
|
("keyword")
|
|
|
|
|
("string")
|
|
|
|
|
("type")
|
|
|
|
|
("variable-name")
|
|
|
|
|
("warning")))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("strong")
|
|
|
|
|
("sub")
|
|
|
|
|
("sup")
|
|
|
|
|
("title")
|
|
|
|
|
("tr" t)
|
|
|
|
|
("tt")
|
|
|
|
|
("u")
|
|
|
|
|
("var")
|
|
|
|
|
("wbr" t)))
|
|
|
|
|
"*Value of `sgml-tag-alist' for HTML mode.")
|
|
|
|
|
|
|
|
|
|
(defvar html-tag-help
|
|
|
|
|
`(,@sgml-tag-help
|
|
|
|
|
("a" . "Anchor of point or link elsewhere")
|
|
|
|
|
("abbrev" . "?")
|
|
|
|
|
("acronym" . "?")
|
|
|
|
|
("address" . "Formatted mail address")
|
|
|
|
|
("array" . "Math array")
|
|
|
|
|
("au" . "?")
|
|
|
|
|
("b" . "Bold face")
|
|
|
|
|
("base" . "Base address for URLs")
|
|
|
|
|
("big" . "Font size")
|
|
|
|
|
("blink" . "Blinking text")
|
|
|
|
|
("blockquote" . "Indented quotation")
|
|
|
|
|
("body" . "Document body")
|
|
|
|
|
("box" . "Math fraction")
|
|
|
|
|
("br" . "Line break")
|
|
|
|
|
("caption" . "Table caption")
|
|
|
|
|
("center" . "Centered text")
|
|
|
|
|
("changed" . "Change bars")
|
|
|
|
|
("cite" . "Citation of a document")
|
|
|
|
|
("code" . "Formatted source code")
|
|
|
|
|
("dd" . "Definition of term")
|
|
|
|
|
("del" . "?")
|
|
|
|
|
("dfn" . "?")
|
|
|
|
|
("dir" . "Directory list (obsolete)")
|
|
|
|
|
("dl" . "Definition list")
|
|
|
|
|
("dt" . "Term to be definined")
|
2001-10-05 16:21:14 +00:00
|
|
|
|
("em" . "Emphasised")
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("embed" . "Embedded data in foreign format")
|
|
|
|
|
("fig" . "Figure")
|
|
|
|
|
("figa" . "Figure anchor")
|
|
|
|
|
("figd" . "Figure description")
|
|
|
|
|
("figt" . "Figure text")
|
1997-04-23 18:58:33 +00:00
|
|
|
|
;("fn" . "?") ; ???
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
("font" . "Font size")
|
|
|
|
|
("form" . "Form with input fields")
|
|
|
|
|
("group" . "Document grouping")
|
|
|
|
|
("h1" . "Most important section headline")
|
|
|
|
|
("h2" . "Important section headline")
|
|
|
|
|
("h3" . "Section headline")
|
|
|
|
|
("h4" . "Minor section headline")
|
|
|
|
|
("h5" . "Unimportant section headline")
|
|
|
|
|
("h6" . "Least important section headline")
|
|
|
|
|
("head" . "Document header")
|
|
|
|
|
("hr" . "Horizontal rule")
|
|
|
|
|
("html" . "HTML Document")
|
|
|
|
|
("i" . "Italic face")
|
|
|
|
|
("img" . "Graphic image")
|
|
|
|
|
("input" . "Form input field")
|
|
|
|
|
("ins" . "?")
|
|
|
|
|
("isindex" . "Input field for index search")
|
|
|
|
|
("kbd" . "Keybard example face")
|
|
|
|
|
("lang" . "Natural language")
|
|
|
|
|
("li" . "List item")
|
|
|
|
|
("link" . "Link relationship")
|
|
|
|
|
("math" . "Math formula")
|
|
|
|
|
("menu" . "Menu list (obsolete)")
|
|
|
|
|
("mh" . "Form mail header")
|
|
|
|
|
("nextid" . "Allocate new id")
|
|
|
|
|
("nobr" . "Text without line break")
|
|
|
|
|
("ol" . "Ordered list")
|
|
|
|
|
("option" . "Selection list item")
|
|
|
|
|
("over" . "Math fraction rule")
|
|
|
|
|
("p" . "Paragraph start")
|
|
|
|
|
("panel" . "Floating panel")
|
|
|
|
|
("person" . "?")
|
|
|
|
|
("pre" . "Preformatted fixed width text")
|
|
|
|
|
("q" . "?")
|
|
|
|
|
("rev" . "Reverse video")
|
|
|
|
|
("s" . "?")
|
|
|
|
|
("samp" . "Sample text")
|
|
|
|
|
("select" . "Selection list")
|
|
|
|
|
("small" . "Font size")
|
|
|
|
|
("sp" . "Nobreak space")
|
|
|
|
|
("strong" . "Standout text")
|
|
|
|
|
("sub" . "Subscript")
|
|
|
|
|
("sup" . "Superscript")
|
|
|
|
|
("table" . "Table with rows and columns")
|
|
|
|
|
("tb" . "Table vertical break")
|
|
|
|
|
("td" . "Table data cell")
|
|
|
|
|
("textarea" . "Form multiline edit area")
|
|
|
|
|
("th" . "Table header cell")
|
|
|
|
|
("title" . "Document title")
|
|
|
|
|
("tr" . "Table row separator")
|
|
|
|
|
("tt" . "Typewriter face")
|
|
|
|
|
("u" . "Underlined text")
|
|
|
|
|
("ul" . "Unordered list")
|
|
|
|
|
("var" . "Math variable face")
|
|
|
|
|
("wbr" . "Enable <br> within <nobr>"))
|
|
|
|
|
"*Value of `sgml-tag-help' for HTML mode.")
|
2002-04-09 12:02:20 +00:00
|
|
|
|
|
1998-06-27 19:46:22 +00:00
|
|
|
|
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
;;;###autoload
|
2001-10-25 22:25:30 +00:00
|
|
|
|
(define-derived-mode html-mode sgml-mode "HTML"
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
"Major mode based on SGML mode for editing HTML documents.
|
1998-11-06 09:31:52 +00:00
|
|
|
|
This allows inserting skeleton constructs used in hypertext documents with
|
1996-01-24 17:12:21 +00:00
|
|
|
|
completion. See below for an introduction to HTML. Use
|
|
|
|
|
\\[browse-url-of-buffer] to see how this comes out. See also `sgml-mode' on
|
|
|
|
|
which this is based.
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
1996-01-24 17:12:21 +00:00
|
|
|
|
Do \\[describe-variable] html- SPC and \\[describe-variable] sgml- SPC to see available variables.
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
To write fairly well formatted pages you only need to know few things. Most
|
|
|
|
|
browsers have a function to read the source code of the page being seen, so
|
|
|
|
|
you can imitate various tricks. Here's a very short HTML primer which you
|
|
|
|
|
can also view with a browser to see what happens:
|
|
|
|
|
|
|
|
|
|
<title>A Title Describing Contents</title> should be on every page. Pages can
|
|
|
|
|
have <h1>Very Major Headlines</h1> through <h6>Very Minor Headlines</h6>
|
|
|
|
|
<hr> Parts can be separated with horizontal rules.
|
|
|
|
|
|
|
|
|
|
<p>Paragraphs only need an opening tag. Line breaks and multiple spaces are
|
|
|
|
|
ignored unless the text is <pre>preformatted.</pre> Text can be marked as
|
|
|
|
|
<b>bold</b>, <i>italic</i> or <u>underlined</u> using the normal M-g or
|
|
|
|
|
Edit/Text Properties/Face commands.
|
|
|
|
|
|
|
|
|
|
Pages can have <a name=\"SOMENAME\">named points</a> and can link other points
|
|
|
|
|
to them with <a href=\"#SOMENAME\">see also somename</a>. In the same way <a
|
|
|
|
|
href=\"URL\">see also URL</a> where URL is a filename relative to current
|
1997-04-24 19:37:13 +00:00
|
|
|
|
directory, or absolute as in `http://www.cs.indiana.edu/elisp/w3/docs.html'.
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
Images in many formats can be inlined with <img src=\"URL\">.
|
|
|
|
|
|
1997-04-24 19:37:13 +00:00
|
|
|
|
If you mainly create your own documents, `sgml-specials' might be
|
|
|
|
|
interesting. But note that some HTML 2 browsers can't handle `''.
|
|
|
|
|
To work around that, do:
|
|
|
|
|
(eval-after-load \"sgml-mode\" '(aset sgml-char-names ?' nil))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
\\{html-mode-map}"
|
2001-10-25 22:25:30 +00:00
|
|
|
|
(set (make-local-variable 'sgml-display-text) html-display-text)
|
|
|
|
|
(set (make-local-variable 'sgml-tag-face-alist) html-tag-face-alist)
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(make-local-variable 'sgml-tag-alist)
|
|
|
|
|
(make-local-variable 'sgml-face-tag-alist)
|
|
|
|
|
(make-local-variable 'sgml-tag-help)
|
|
|
|
|
(make-local-variable 'outline-regexp)
|
|
|
|
|
(make-local-variable 'outline-heading-end-regexp)
|
|
|
|
|
(make-local-variable 'outline-level)
|
1997-01-21 09:27:59 +00:00
|
|
|
|
(make-local-variable 'sentence-end)
|
|
|
|
|
(setq sentence-end
|
1999-03-09 19:24:33 +00:00
|
|
|
|
(if sentence-end-double-space
|
|
|
|
|
"[.?!][]\"')}]*\\(<[^>]*>\\)*\\($\\| $\\|\t\\| \\)[ \t\n]*"
|
2001-10-25 22:25:30 +00:00
|
|
|
|
"[.?!][]\"')}]*\\(<[^>]*>\\)*\\($\\|[ \t]\\)[ \t\n]*"))
|
1998-07-19 00:04:01 +00:00
|
|
|
|
(setq sgml-tag-alist html-tag-alist
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
sgml-face-tag-alist html-face-tag-alist
|
|
|
|
|
sgml-tag-help html-tag-help
|
|
|
|
|
outline-regexp "^.*<[Hh][1-6]\\>"
|
|
|
|
|
outline-heading-end-regexp "</[Hh][1-6]>"
|
|
|
|
|
outline-level (lambda ()
|
2002-03-04 02:14:31 +00:00
|
|
|
|
(char-before (match-end 0))))
|
1998-06-27 19:46:22 +00:00
|
|
|
|
(setq imenu-create-index-function 'html-imenu-index)
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(when sgml-xml-mode (setq mode-name "XHTML"))
|
2001-10-28 04:10:40 +00:00
|
|
|
|
(set (make-local-variable 'sgml-empty-tags)
|
2002-03-29 19:38:22 +00:00
|
|
|
|
;; From HTML-4.01's loose.dtd, parsed with `sgml-parse-dtd',
|
|
|
|
|
;; plus manual addition of "wbr".
|
|
|
|
|
'("area" "base" "basefont" "br" "col" "frame" "hr" "img" "input"
|
|
|
|
|
"isindex" "link" "meta" "param" "wbr"))
|
|
|
|
|
(set (make-local-variable 'sgml-unclosed-tags)
|
|
|
|
|
;; From HTML-4.01's loose.dtd, parsed with `sgml-parse-dtd'.
|
|
|
|
|
'("body" "colgroup" "dd" "dt" "head" "html" "li" "option"
|
|
|
|
|
"p" "tbody" "td" "tfoot" "th" "thead" "tr"))
|
2001-06-17 09:01:23 +00:00
|
|
|
|
;; It's for the user to decide if it defeats it or not -stef
|
|
|
|
|
;; (make-local-variable 'imenu-sort-function)
|
|
|
|
|
;; (setq imenu-sort-function nil) ; sorting the menu defeats the purpose
|
2001-10-25 22:25:30 +00:00
|
|
|
|
)
|
2002-04-09 12:02:20 +00:00
|
|
|
|
|
1998-06-27 19:46:22 +00:00
|
|
|
|
(defvar html-imenu-regexp
|
|
|
|
|
"\\s-*<h\\([1-9]\\)[^\n<>]*>\\(<[^\n<>]*>\\)*\\s-*\\([^\n<>]*\\)"
|
|
|
|
|
"*A regular expression matching a head line to be added to the menu.
|
|
|
|
|
The first `match-string' should be a number from 1-9.
|
|
|
|
|
The second `match-string' matches extra tags and is ignored.
|
|
|
|
|
The third `match-string' will be the used in the menu.")
|
|
|
|
|
|
|
|
|
|
(defun html-imenu-index ()
|
2002-10-18 08:30:49 +00:00
|
|
|
|
"Return a table of contents for an HTML buffer for use with Imenu."
|
1998-06-27 19:46:22 +00:00
|
|
|
|
(let (toc-index)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (re-search-forward html-imenu-regexp nil t)
|
|
|
|
|
(setq toc-index
|
|
|
|
|
(cons (cons (concat (make-string
|
|
|
|
|
(* 2 (1- (string-to-number (match-string 1))))
|
|
|
|
|
?\ )
|
|
|
|
|
(match-string 3))
|
2001-10-26 17:40:59 +00:00
|
|
|
|
(line-beginning-position))
|
1998-06-27 19:46:22 +00:00
|
|
|
|
toc-index))))
|
|
|
|
|
(nreverse toc-index)))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
2002-11-12 16:46:19 +00:00
|
|
|
|
(define-minor-mode html-autoview-mode
|
1999-08-04 19:18:55 +00:00
|
|
|
|
"Toggle automatic viewing via `browse-url-of-buffer' upon saving buffer.
|
1998-06-27 19:46:22 +00:00
|
|
|
|
With positive prefix ARG always turns viewing on, with negative ARG always off.
|
|
|
|
|
Can be used as a value for `html-mode-hook'."
|
2002-11-12 16:46:19 +00:00
|
|
|
|
nil nil nil
|
2002-11-18 04:32:11 +00:00
|
|
|
|
:group 'sgml
|
2002-11-12 16:46:19 +00:00
|
|
|
|
(if html-autoview-mode
|
|
|
|
|
(add-hook 'after-save-hook 'browse-url-of-buffer nil t)
|
|
|
|
|
(remove-hook 'after-save-hook 'browse-url-of-buffer t)))
|
2002-04-09 12:02:20 +00:00
|
|
|
|
|
1998-06-27 19:46:22 +00:00
|
|
|
|
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(define-skeleton html-href-anchor
|
|
|
|
|
"HTML anchor tag with href attribute."
|
1997-04-16 21:43:01 +00:00
|
|
|
|
"URL: "
|
|
|
|
|
'(setq input "http:")
|
|
|
|
|
"<a href=\"" str "\">" _ "</a>")
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
(define-skeleton html-name-anchor
|
|
|
|
|
"HTML anchor tag with name attribute."
|
1997-04-16 21:43:01 +00:00
|
|
|
|
"Name: "
|
|
|
|
|
"<a name=\"" str "\">" _ "</a>")
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
1996-06-15 23:19:40 +00:00
|
|
|
|
(define-skeleton html-headline-1
|
|
|
|
|
"HTML level 1 headline tags."
|
|
|
|
|
nil
|
|
|
|
|
"<h1>" _ "</h1>")
|
|
|
|
|
|
|
|
|
|
(define-skeleton html-headline-2
|
|
|
|
|
"HTML level 2 headline tags."
|
|
|
|
|
nil
|
|
|
|
|
"<h2>" _ "</h2>")
|
|
|
|
|
|
|
|
|
|
(define-skeleton html-headline-3
|
|
|
|
|
"HTML level 3 headline tags."
|
|
|
|
|
nil
|
|
|
|
|
"<h3>" _ "</h3>")
|
|
|
|
|
|
|
|
|
|
(define-skeleton html-headline-4
|
|
|
|
|
"HTML level 4 headline tags."
|
|
|
|
|
nil
|
|
|
|
|
"<h4>" _ "</h4>")
|
|
|
|
|
|
|
|
|
|
(define-skeleton html-headline-5
|
|
|
|
|
"HTML level 5 headline tags."
|
|
|
|
|
nil
|
|
|
|
|
"<h5>" _ "</h5>")
|
|
|
|
|
|
|
|
|
|
(define-skeleton html-headline-6
|
|
|
|
|
"HTML level 6 headline tags."
|
|
|
|
|
nil
|
|
|
|
|
"<h6>" _ "</h6>")
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
(define-skeleton html-horizontal-rule
|
|
|
|
|
"HTML horizontal rule tag."
|
|
|
|
|
nil
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(if sgml-xml-mode "<hr/>" "<hr>") \n)
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
(define-skeleton html-image
|
|
|
|
|
"HTML image tag."
|
|
|
|
|
nil
|
2001-10-05 16:21:14 +00:00
|
|
|
|
"<img src=\"" _ "\""
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(if sgml-xml-mode "/>" ">"))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
(define-skeleton html-line
|
|
|
|
|
"HTML line break tag."
|
|
|
|
|
nil
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(if sgml-xml-mode "<br/>" "<br>") \n)
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
1996-06-15 23:19:40 +00:00
|
|
|
|
(define-skeleton html-ordered-list
|
|
|
|
|
"HTML ordered list tags."
|
|
|
|
|
nil
|
1997-04-16 21:43:01 +00:00
|
|
|
|
"<ol>" \n
|
2002-03-17 23:55:15 +00:00
|
|
|
|
"<li>" _ (if sgml-xml-mode "</li>") \n
|
1996-06-15 23:19:40 +00:00
|
|
|
|
"</ol>")
|
|
|
|
|
|
|
|
|
|
(define-skeleton html-unordered-list
|
|
|
|
|
"HTML unordered list tags."
|
|
|
|
|
nil
|
1997-04-16 21:43:01 +00:00
|
|
|
|
"<ul>" \n
|
2002-03-17 23:55:15 +00:00
|
|
|
|
"<li>" _ (if sgml-xml-mode "</li>") \n
|
1996-06-15 23:19:40 +00:00
|
|
|
|
"</ul>")
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
(define-skeleton html-list-item
|
|
|
|
|
"HTML list item tag."
|
|
|
|
|
nil
|
|
|
|
|
(if (bolp) nil '\n)
|
2002-03-17 23:55:15 +00:00
|
|
|
|
"<li>" _ (if sgml-xml-mode "</li>"))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
|
|
|
|
(define-skeleton html-paragraph
|
|
|
|
|
"HTML paragraph tag."
|
|
|
|
|
nil
|
|
|
|
|
(if (bolp) nil ?\n)
|
2002-03-17 23:55:15 +00:00
|
|
|
|
\n "<p>" _ (if sgml-xml-mode "</p>"))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
1996-01-24 17:12:21 +00:00
|
|
|
|
(define-skeleton html-checkboxes
|
|
|
|
|
"Group of connected checkbox inputs."
|
|
|
|
|
nil
|
1997-04-16 21:43:01 +00:00
|
|
|
|
'(setq v1 nil
|
|
|
|
|
v2 nil)
|
|
|
|
|
("Value: "
|
1997-04-23 18:58:33 +00:00
|
|
|
|
"<input type=\"" (identity "checkbox") ; see comment above about identity
|
1997-04-16 21:43:01 +00:00
|
|
|
|
"\" name=\"" (or v1 (setq v1 (skeleton-read "Name: ")))
|
1996-01-24 17:12:21 +00:00
|
|
|
|
"\" value=\"" str ?\"
|
2001-10-05 16:21:14 +00:00
|
|
|
|
(when (y-or-n-p "Set \"checked\" attribute? ")
|
|
|
|
|
(funcall skeleton-transformation " checked"))
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(if sgml-xml-mode "/>" ">")
|
1997-04-16 21:43:01 +00:00
|
|
|
|
(skeleton-read "Text: " (capitalize str))
|
|
|
|
|
(or v2 (setq v2 (if (y-or-n-p "Newline after text? ")
|
2001-10-05 16:21:14 +00:00
|
|
|
|
(funcall skeleton-transformation
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(if sgml-xml-mode "<br/>" "<br>"))
|
1997-04-16 21:43:01 +00:00
|
|
|
|
"")))
|
|
|
|
|
\n))
|
1996-01-24 17:12:21 +00:00
|
|
|
|
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
(define-skeleton html-radio-buttons
|
|
|
|
|
"Group of connected radio button inputs."
|
|
|
|
|
nil
|
1997-04-16 21:43:01 +00:00
|
|
|
|
'(setq v1 nil
|
|
|
|
|
v2 (cons nil nil))
|
|
|
|
|
("Value: "
|
1997-04-23 18:58:33 +00:00
|
|
|
|
"<input type=\"" (identity "radio") ; see comment above about identity
|
1997-04-16 21:43:01 +00:00
|
|
|
|
"\" name=\"" (or (car v2) (setcar v2 (skeleton-read "Name: ")))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
"\" value=\"" str ?\"
|
2001-10-05 16:21:14 +00:00
|
|
|
|
(when (and (not v1) (setq v1 (y-or-n-p "Set \"checked\" attribute? ")))
|
|
|
|
|
(funcall skeleton-transformation " checked"))
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(if sgml-xml-mode "/>" ">")
|
1997-04-16 21:43:01 +00:00
|
|
|
|
(skeleton-read "Text: " (capitalize str))
|
|
|
|
|
(or (cdr v2) (setcdr v2 (if (y-or-n-p "Newline after text? ")
|
2001-10-05 16:21:14 +00:00
|
|
|
|
(funcall skeleton-transformation
|
2002-03-17 23:55:15 +00:00
|
|
|
|
(if sgml-xml-mode "<br/>" "<br>"))
|
1997-04-16 21:43:01 +00:00
|
|
|
|
"")))
|
|
|
|
|
\n))
|
Also load for .sgm and .dtd files.
(sgml-specials, sgml-name-8bit-mode, sgml-char-names)
(sgml-font-lock-keywords, sgml-face-tag-alist, sgml-tag-face-alist)
(sgml-display-text, sgml-tag-alist, sgml-tag-help)
(sgml-auto-attributes): New variables.
(sgml-mode-common): New function.
(sgml-mode): Most code moved to it.
(sgml-name-char, sgml-name-self, sgml-maybe-name-self)
(sgml-name-8bit-mode, sgml-tag, sgml-attributes, sgml-auto-attributes)
(sgml-tag-help, sgml-maybe-end-tag, sgml-skip-tag-backward)
(sgml-skip-tag-forward, sgml-tags-invisible): New commands.
(sgml-beginning-of-tag, sgml-value): New functions.
1996-01-12 21:14:51 +00:00
|
|
|
|
|
2001-06-17 09:01:23 +00:00
|
|
|
|
(provide 'sgml-mode)
|
2001-07-16 11:39:42 +00:00
|
|
|
|
|
1992-07-17 06:48:03 +00:00
|
|
|
|
;;; sgml-mode.el ends here
|