Add `add-log-current-defun-function's for CSS and HTML mode.
* 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.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
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).
|
||||
|
||||
@@ -275,6 +275,7 @@
|
||||
(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)
|
||||
@@ -480,5 +481,15 @@
|
||||
(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
|
||||
|
||||
@@ -1932,6 +1932,19 @@ This takes effect when first loading the library.")
|
||||
(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))))
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(define-derived-mode html-mode sgml-mode '(sgml-xml-mode "XHTML" "HTML")
|
||||
@@ -1979,6 +1992,7 @@ To work around that, do:
|
||||
(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)
|
||||
|
||||
Reference in New Issue
Block a user