/[emacs]/emacs/lisp/textmodes/sgml-mode.el
ViewVC logotype

Diff of /emacs/lisp/textmodes/sgml-mode.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.79 by monnier, Mon Apr 8 21:32:05 2002 UTC revision 1.80 by mdub, Tue Apr 9 12:02:20 2002 UTC
# Line 84  with comments, so we normally turn it of Line 84  with comments, so we normally turn it of
84    "Use <, >, &, /, SPC and `sgml-specials' keys \"electrically\" when non-nil.    "Use <, >, &, /, SPC and `sgml-specials' keys \"electrically\" when non-nil.
85  This takes effect when first loading the `sgml-mode' library.")  This takes effect when first loading the `sgml-mode' library.")
86    
   
87  (defvar sgml-mode-map  (defvar sgml-mode-map
88    (let ((map (make-keymap))     ;`sparse' doesn't allow binding to charsets.    (let ((map (make-keymap))     ;`sparse' doesn't allow binding to charsets.
89          (menu-map (make-sparse-keymap "SGML")))          (menu-map (make-sparse-keymap "SGML")))
# Line 138  This takes effect when first loading the Line 137  This takes effect when first loading the
137      map)      map)
138    "Keymap for SGML mode.  See also `sgml-specials'.")    "Keymap for SGML mode.  See also `sgml-specials'.")
139    
   
140  (defun sgml-make-syntax-table (specials)  (defun sgml-make-syntax-table (specials)
141    (let ((table (make-syntax-table text-mode-syntax-table)))    (let ((table (make-syntax-table text-mode-syntax-table)))
142      (modify-syntax-entry ?< "(>" table)      (modify-syntax-entry ?< "(>" table)
# Line 164  This takes effect when first loading the Line 162  This takes effect when first loading the
162      table)      table)
163    "Syntax table used to parse SGML tags.")    "Syntax table used to parse SGML tags.")
164    
   
165  (defcustom sgml-name-8bit-mode nil  (defcustom sgml-name-8bit-mode nil
166    "*When non-nil, insert non-ASCII characters as named entities."    "*When non-nil, insert non-ASCII characters as named entities."
167    :type 'boolean    :type 'boolean
# Line 219  This takes effect when first loading the Line 216  This takes effect when first loading the
216    "A table for mapping non-ASCII characters into SGML entity names.    "A table for mapping non-ASCII characters into SGML entity names.
217  Currently, only Latin-1 characters are supported.")  Currently, only Latin-1 characters are supported.")
218    
   
219  ;; nsgmls is a free SGML parser in the SP suite available from  ;; nsgmls is a free SGML parser in the SP suite available from
220  ;; ftp.jclark.com and otherwise packaged for GNU systems.  ;; ftp.jclark.com and otherwise packaged for GNU systems.
221  ;; Its error messages can be parsed by next-error.  ;; Its error messages can be parsed by next-error.
# Line 236  separated by a space." Line 232  separated by a space."
232  (defvar sgml-saved-validate-command nil  (defvar sgml-saved-validate-command nil
233    "The command last used to validate in this buffer.")    "The command last used to validate in this buffer.")
234    
   
235  ;; I doubt that null end tags are used much for large elements,  ;; I doubt that null end tags are used much for large elements,
236  ;; so use a small distance here.  ;; so use a small distance here.
237  (defcustom sgml-slash-distance 1000  (defcustom sgml-slash-distance 1000
# Line 292  Any terminating `>' or `/' is not matche Line 287  Any terminating `>' or `/' is not matche
287  When `font-lock-maximum-decoration' is 1 this is always used for fontifying.  When `font-lock-maximum-decoration' is 1 this is always used for fontifying.
288  When more these are fontified together with `sgml-font-lock-keywords'.")  When more these are fontified together with `sgml-font-lock-keywords'.")
289    
   
290  (defvar sgml-display-text ()  (defvar sgml-display-text ()
291    "Tag names as lowercase symbols, and display string when invisible.")    "Tag names as lowercase symbols, and display string when invisible.")
292    
293  ;; internal  ;; internal
294  (defvar sgml-tags-invisible nil)  (defvar sgml-tags-invisible nil)
295    
   
296  (defcustom sgml-tag-alist  (defcustom sgml-tag-alist
297    '(("![" ("ignore" t) ("include" t))    '(("![" ("ignore" t) ("include" t))
298      ("!attlist")      ("!attlist")
# Line 312  This alist is made up as Line 305  This alist is made up as
305    ((\"tag\" . TAGRULE)    ((\"tag\" . TAGRULE)
306     ...)     ...)
307    
308  TAGRULE is a list of optionally `t' (no endtag) or `\\n' (separate endtag by  TAGRULE is a list of optionally t (no endtag) or `\\n' (separate endtag by
309  newlines) or a skeleton with `nil', `t' or `\\n' in place of the interactor  newlines) or a skeleton with nil, t or `\\n' in place of the interactor
310  followed by an ATTRIBUTERULE (for an always present attribute) or an  followed by an ATTRIBUTERULE (for an always present attribute) or an
311  attribute alist.  attribute alist.
312    
# Line 322  The attribute alist is made up as Line 315  The attribute alist is made up as
315    ((\"attribute\" . ATTRIBUTERULE)    ((\"attribute\" . ATTRIBUTERULE)
316     ...)     ...)
317    
318  ATTRIBUTERULE is a list of optionally `t' (no value when no input) followed by  ATTRIBUTERULE is a list of optionally t (no value when no input) followed by
319  an optional alist of possible values."  an optional alist of possible values."
320    :type '(repeat (cons (string :tag "Tag Name")    :type '(repeat (cons (string :tag "Tag Name")
321                         (repeat :tag "Tag Rule" sexp)))                         (repeat :tag "Tag Rule" sexp)))
# Line 388  Otherwise, it is set to be buffer-local Line 381  Otherwise, it is set to be buffer-local
381          (concat "<" face ">"))          (concat "<" face ">"))
382      (error "Face not configured for %s mode" mode-name)))      (error "Face not configured for %s mode" mode-name)))
383    
   
384  ;;;###autoload  ;;;###autoload
385  (define-derived-mode sgml-mode text-mode "SGML"  (define-derived-mode sgml-mode text-mode "SGML"
386    "Major mode for editing SGML documents.    "Major mode for editing SGML documents.
# Line 454  Do \\[describe-key] on the following bin Line 446  Do \\[describe-key] on the following bin
446         (concat "<!\\(element\\|entity\\)[ \t\n]+%?[ \t\n]*\\("         (concat "<!\\(element\\|entity\\)[ \t\n]+%?[ \t\n]*\\("
447                 sgml-name-re "\\)")))                 sgml-name-re "\\)")))
448    
   
449  (defun sgml-comment-indent ()  (defun sgml-comment-indent ()
450    (if (looking-at "--") comment-column 0))    (if (looking-at "--") comment-column 0))
451    
   
   
452  (defun sgml-slash (arg)  (defun sgml-slash (arg)
453    "Insert ARG slash characters.    "Insert ARG slash characters.
454  Behaves electrically if `sgml-quick-keys' is non-nil."  Behaves electrically if `sgml-quick-keys' is non-nil."
# Line 516  start tag, and the second `/' is the cor Line 505  start tag, and the second `/' is the cor
505                         (buffer-substring (line-beginning-position)                         (buffer-substring (line-beginning-position)
506                                           (1+ blinkpos)))))))))                                           (1+ blinkpos)))))))))
507    
   
508  ;; Why doesn't this use the iso-cvt table or, preferably, generate the  ;; Why doesn't this use the iso-cvt table or, preferably, generate the
509  ;; inverse of the extensive table in the SGML Quail input method?  -- fx  ;; inverse of the extensive table in the SGML Quail input method?  -- fx
510  ;; I guess that's moot since it only works with Latin-1 anyhow.  ;; I guess that's moot since it only works with Latin-1 anyhow.
# Line 666  With prefix argument, only self insert." Line 654  With prefix argument, only self insert."
654        (or (> (point) point)        (or (> (point) point)
655            (self-insert-command 1)))))            (self-insert-command 1)))))
656    
   
657  (defun sgml-tag-help (&optional tag)  (defun sgml-tag-help (&optional tag)
658    "Display description of tag TAG.  If TAG is omitted, use the tag at point."    "Display description of tag TAG.  If TAG is omitted, use the tag at point."
659    (interactive)    (interactive)
# Line 684  With prefix argument, only self insert." Line 671  With prefix argument, only self insert."
671                      (cdr (assoc (downcase (substring tag 1)) sgml-tag-help)))                      (cdr (assoc (downcase (substring tag 1)) sgml-tag-help)))
672                 "No description available")))                 "No description available")))
673    
   
674  (defun sgml-maybe-end-tag (&optional arg)  (defun sgml-maybe-end-tag (&optional arg)
675    "Name self unless in position to end a tag or a prefix ARG is given."    "Name self unless in position to end a tag or a prefix ARG is given."
676    (interactive "P")    (interactive "P")
# Line 781  With prefix argument ARG, repeat this AR Line 767  With prefix argument ARG, repeat this AR
767          (goto-char open)          (goto-char open)
768          (kill-sexp 1)))          (kill-sexp 1)))
769      (setq arg (1- arg))))      (setq arg (1- arg))))
770    
771    
772  ;; Put read-only last to enable setting this even when read-only enabled.  ;; Put read-only last to enable setting this even when read-only enabled.
773  (or (get 'sgml-tag 'invisible)  (or (get 'sgml-tag 'invisible)
# Line 849  With prefix argument ARG, repeat this AR Line 836  With prefix argument ARG, repeat this AR
836                               (eq (preceding-char) ?>)))                               (eq (preceding-char) ?>)))
837                      (backward-list)                      (backward-list)
838                    (forward-list)))))))                    (forward-list)))))))
839    
840    
841  (autoload 'compile-internal "compile")  (autoload 'compile-internal "compile")
842    
# Line 870  and move to the line in the SGML documen Line 858  and move to the line in the SGML documen
858    (save-some-buffers (not compilation-ask-about-save) nil)    (save-some-buffers (not compilation-ask-about-save) nil)
859    (compile-internal command "No more errors"))    (compile-internal command "No more errors"))
860    
   
861  (defun sgml-lexical-context (&optional limit)  (defun sgml-lexical-context (&optional limit)
862    "Return the lexical context at point as (TYPE . START).    "Return the lexical context at point as (TYPE . START).
863  START is the location of the start of the lexical element.  START is the location of the start of the lexical element.
# Line 960  With prefix argument, unquote the region Line 947  With prefix argument, unquote the region
947        (replace-match (cdr (assq (char-before) '((?& . "&amp;")        (replace-match (cdr (assq (char-before) '((?& . "&amp;")
948                                                  (?< . "&lt;")                                                  (?< . "&lt;")
949                                                  (?> . "&gt;"))))))))                                                  (?> . "&gt;"))))))))
   
950    
951  (defsubst sgml-at-indentation-p ()  (defsubst sgml-at-indentation-p ()
952    "Return true if point is at the first non-whitespace character on the line."    "Return true if point is at the first non-whitespace character on the line."
# Line 1330  This takes effect when first loading the Line 1316  This takes effect when first loading the
1316      map)      map)
1317    "Keymap for commands for use in HTML mode.")    "Keymap for commands for use in HTML mode.")
1318    
   
1319  (defvar html-face-tag-alist  (defvar html-face-tag-alist
1320    '((bold . "b")    '((bold . "b")
1321      (italic . "i")      (italic . "i")
# Line 1361  This takes effect when first loading the Line 1346  This takes effect when first loading the
1346      ("var" . italic))      ("var" . italic))
1347    "Value of `sgml-tag-face-alist' for HTML mode.")    "Value of `sgml-tag-face-alist' for HTML mode.")
1348    
   
1349  (defvar html-display-text  (defvar html-display-text
1350    '((img . "[/]")    '((img . "[/]")
1351      (hr . "----------")      (hr . "----------")
1352      (li . "o "))      (li . "o "))
1353    "Value of `sgml-display-text' for HTML mode.")    "Value of `sgml-display-text' for HTML mode.")
   
1354    
1355    
1356  ;; should code exactly HTML 3 here when that is finished  ;; should code exactly HTML 3 here when that is finished
1357  (defvar html-tag-alist  (defvar html-tag-alist
1358    (let* ((1-7 '(("1") ("2") ("3") ("4") ("5") ("6") ("7")))    (let* ((1-7 '(("1") ("2") ("3") ("4") ("5") ("6") ("7")))
# Line 1607  This takes effect when first loading the Line 1591  This takes effect when first loading the
1591      ("var" . "Math variable face")      ("var" . "Math variable face")
1592      ("wbr" . "Enable <br> within <nobr>"))      ("wbr" . "Enable <br> within <nobr>"))
1593  "*Value of `sgml-tag-help' for HTML mode.")  "*Value of `sgml-tag-help' for HTML mode.")
1594    
1595    
1596  ;;;###autoload  ;;;###autoload
1597  (define-derived-mode html-mode sgml-mode "HTML"  (define-derived-mode html-mode sgml-mode "HTML"
# Line 1680  To work around that, do: Line 1665  To work around that, do:
1665    ;; (make-local-variable 'imenu-sort-function)    ;; (make-local-variable 'imenu-sort-function)
1666    ;; (setq imenu-sort-function nil) ; sorting the menu defeats the purpose    ;; (setq imenu-sort-function nil) ; sorting the menu defeats the purpose
1667    )    )
1668    
1669  (defvar html-imenu-regexp  (defvar html-imenu-regexp
1670    "\\s-*<h\\([1-9]\\)[^\n<>]*>\\(<[^\n<>]*>\\)*\\s-*\\([^\n<>]*\\)"    "\\s-*<h\\([1-9]\\)[^\n<>]*>\\(<[^\n<>]*>\\)*\\s-*\\([^\n<>]*\\)"
1671    "*A regular expression matching a head line to be added to the menu.    "*A regular expression matching a head line to be added to the menu.
# Line 1716  Can be used as a value for `html-mode-ho Line 1701  Can be used as a value for `html-mode-ho
1701      (add-hook 'after-save-hook 'browse-url-of-buffer nil t))      (add-hook 'after-save-hook 'browse-url-of-buffer nil t))
1702    (message "Autoviewing turned %s."    (message "Autoviewing turned %s."
1703             (if arg "off" "on")))             (if arg "off" "on")))
1704    
1705    
1706  (define-skeleton html-href-anchor  (define-skeleton html-href-anchor
1707    "HTML anchor tag with href attribute."    "HTML anchor tag with href attribute."

Legend:
Removed from v.1.79  
changed lines
  Added in v.1.80

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26