;;; sgml-mode.el --- SGML- and HTML-editing modes -*- coding: utf-8 -*-
-;; Copyright (C) 1992, 1995-1996, 1998, 2001-2012
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1995-1996, 1998, 2001-2013 Free Software
+;; Foundation, Inc.
;; Author: James Clark <jjc@jclark.com>
;; Maintainer: FSF
:type 'integer
:group 'sgml)
+(defcustom sgml-xml-mode nil
+ "When non-nil, tag insertion functions will be XML-compliant.
+It is set to be buffer-local when the file has
+a DOCTYPE or an XML declaration."
+ :type 'boolean
+ :version "22.1"
+ :group 'sgml)
+
(defcustom sgml-transformation-function 'identity
"Default value for `skeleton-transformation-function' in SGML mode."
:type 'function
+ :initialize 'custom-initialize-default
+ :set (lambda (sym val)
+ (set-default sym val)
+ (mapc (lambda (buff)
+ (with-current-buffer buff
+ (and (eq major-mode 'sgml-mode)
+ (not sgml-xml-mode)
+ (setq skeleton-transformation-function val))))
+ (buffer-list)))
:group 'sgml)
(put 'sgml-transformation-function 'variable-interactive
(string :tag "Description")))
:group 'sgml)
-(defcustom sgml-xml-mode nil
- "When non-nil, tag insertion functions will be XML-compliant.
-It is set to be buffer-local when the file has
-a DOCTYPE or an XML declaration."
- :type 'boolean
- :version "22.1"
- :group 'sgml)
-
(defvar sgml-empty-tags nil
"List of tags whose !ELEMENT definition says EMPTY.")
(define-skeleton sgml-tag
"Prompt for a tag and insert it, optionally with attributes.
Completion and configuration are done according to `sgml-tag-alist'.
-If you like tags and attributes in uppercase do \\[set-variable]
-`skeleton-transformation-function' RET `upcase' RET, or put this
-in your `.emacs':
- (setq sgml-transformation-function 'upcase)"
+If you like tags and attributes in uppercase, customize
+`sgml-transformation-function' to 'upcase."
(funcall (or skeleton-transformation-function 'identity)
(setq sgml-tag-last
(completing-read
("ul" . "Unordered list")
("var" . "Math variable face")
("wbr" . "Enable <br> within <nobr>"))
- "Value of `sgml-tag-help' for HTML mode.")
+ "Value of variable `sgml-tag-help' for HTML mode.")
(defvar outline-regexp)
(defvar outline-heading-end-regexp)
(defvar outline-level)
+(defun html-current-defun-name ()
+ "Return the name of the last HTML title or heading, or nil."
+ (save-excursion
+ (if (re-search-backward
+ (concat
+ "<[ \t\r\n]*"
+ "\\(?:[hH][0-6]\\|title\\|TITLE\\|Title\\)"
+ "[^>]*>"
+ "[ \t\r\n]*"
+ "\\([^<\r\n]*[^ <\t\r\n]+\\)")
+ nil t)
+ (match-string-no-properties 1))))
+
\f
;;;###autoload
(define-derived-mode html-mode sgml-mode '(sgml-xml-mode "XHTML" "HTML")
(setq-local outline-heading-end-regexp "</[Hh][1-6]>")
(setq-local outline-level
(lambda () (char-before (match-end 0))))
+ (setq-local add-log-current-defun-function #'html-current-defun-name)
(setq-local sentence-end-base "[.?!][]\"'”)}]*\\(<[^>]*>\\)*")
(setq imenu-create-index-function 'html-imenu-index)