* textmodes/css-mode.el (css-current-defun-name): New function.
(css-mode): Use it.
* textmodes/sgml-mode.el (html-current-defun-name): New function.
(html-mode): Use it.
+2012-12-01 Jari Aalto <jari.aalto@cante.net>
+
+ * textmodes/css-mode.el (css-current-defun-name): New function.
+ (css-mode): Use it.
+
+ * textmodes/sgml-mode.el (html-current-defun-name): New function.
+ (html-mode): Use it.
+
2012-12-01 Chong Yidong <cyd@gnu.org>
Modularize add-log-current-defun (Bug#2224).
(setq-local parse-sexp-ignore-comments t)
(setq-local indent-line-function 'css-indent-line)
(setq-local fill-paragraph-function 'css-fill-paragraph)
+ (setq-local add-log-current-defun-function #'css-current-defun-name)
(when css-electric-keys
(let ((fc (make-char-table 'auto-fill-chars)))
(set-char-table-parent fc auto-fill-chars)
(save-excursion (indent-line-to indent))
(indent-line-to indent)))))
+(defun css-current-defun-name ()
+ "Return the name of the CSS section at point, or nil."
+ (save-excursion
+ (let ((max (max (point-min) (- (point) 1600)))) ; approx 20 lines back
+ (when (search-backward "{" max t)
+ (skip-chars-backward " \t\r\n")
+ (beginning-of-line)
+ (if (looking-at "^[ \t]*\\([^{\r\n]*[^ {\t\r\n]\\)")
+ (match-string-no-properties 1))))))
+
(provide 'css-mode)
;;; css-mode.el ends here
(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)