aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJari Aalto2012-12-01 13:51:33 +0800
committerChong Yidong2012-12-01 13:51:33 +0800
commitf38cd76e55fd04f0386859cede6f876c1bd1620d (patch)
treea8e7ae854812a435b6567d12749fcca83724d33f
parent9dffb5b69353cd041027b334a9c5aadf4163ec2d (diff)
downloademacs-f38cd76e55fd04f0386859cede6f876c1bd1620d.tar.gz
emacs-f38cd76e55fd04f0386859cede6f876c1bd1620d.zip
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.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/textmodes/css-mode.el11
-rw-r--r--lisp/textmodes/sgml-mode.el14
3 files changed, 33 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c7fb5cabe07..c2e5e9fa8ce 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12012-12-01 Jari Aalto <jari.aalto@cante.net>
2
3 * textmodes/css-mode.el (css-current-defun-name): New function.
4 (css-mode): Use it.
5
6 * textmodes/sgml-mode.el (html-current-defun-name): New function.
7 (html-mode): Use it.
8
12012-12-01 Chong Yidong <cyd@gnu.org> 92012-12-01 Chong Yidong <cyd@gnu.org>
2 10
3 Modularize add-log-current-defun (Bug#2224). 11 Modularize add-log-current-defun (Bug#2224).
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index ba104e7b394..7130e1c9cee 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -275,6 +275,7 @@
275 (setq-local parse-sexp-ignore-comments t) 275 (setq-local parse-sexp-ignore-comments t)
276 (setq-local indent-line-function 'css-indent-line) 276 (setq-local indent-line-function 'css-indent-line)
277 (setq-local fill-paragraph-function 'css-fill-paragraph) 277 (setq-local fill-paragraph-function 'css-fill-paragraph)
278 (setq-local add-log-current-defun-function #'css-current-defun-name)
278 (when css-electric-keys 279 (when css-electric-keys
279 (let ((fc (make-char-table 'auto-fill-chars))) 280 (let ((fc (make-char-table 'auto-fill-chars)))
280 (set-char-table-parent fc auto-fill-chars) 281 (set-char-table-parent fc auto-fill-chars)
@@ -480,5 +481,15 @@
480 (save-excursion (indent-line-to indent)) 481 (save-excursion (indent-line-to indent))
481 (indent-line-to indent))))) 482 (indent-line-to indent)))))
482 483
484(defun css-current-defun-name ()
485 "Return the name of the CSS section at point, or nil."
486 (save-excursion
487 (let ((max (max (point-min) (- (point) 1600)))) ; approx 20 lines back
488 (when (search-backward "{" max t)
489 (skip-chars-backward " \t\r\n")
490 (beginning-of-line)
491 (if (looking-at "^[ \t]*\\([^{\r\n]*[^ {\t\r\n]\\)")
492 (match-string-no-properties 1))))))
493
483(provide 'css-mode) 494(provide 'css-mode)
484;;; css-mode.el ends here 495;;; css-mode.el ends here
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 820822222af..97faa3afb36 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -1932,6 +1932,19 @@ This takes effect when first loading the library.")
1932(defvar outline-heading-end-regexp) 1932(defvar outline-heading-end-regexp)
1933(defvar outline-level) 1933(defvar outline-level)
1934 1934
1935(defun html-current-defun-name ()
1936 "Return the name of the last HTML title or heading, or nil."
1937 (save-excursion
1938 (if (re-search-backward
1939 (concat
1940 "<[ \t\r\n]*"
1941 "\\(?:[hH][0-6]\\|title\\|TITLE\\|Title\\)"
1942 "[^>]*>"
1943 "[ \t\r\n]*"
1944 "\\([^<\r\n]*[^ <\t\r\n]+\\)")
1945 nil t)
1946 (match-string-no-properties 1))))
1947
1935 1948
1936;;;###autoload 1949;;;###autoload
1937(define-derived-mode html-mode sgml-mode '(sgml-xml-mode "XHTML" "HTML") 1950(define-derived-mode html-mode sgml-mode '(sgml-xml-mode "XHTML" "HTML")
@@ -1979,6 +1992,7 @@ To work around that, do:
1979 (setq-local outline-heading-end-regexp "</[Hh][1-6]>") 1992 (setq-local outline-heading-end-regexp "</[Hh][1-6]>")
1980 (setq-local outline-level 1993 (setq-local outline-level
1981 (lambda () (char-before (match-end 0)))) 1994 (lambda () (char-before (match-end 0))))
1995 (setq-local add-log-current-defun-function #'html-current-defun-name)
1982 (setq-local sentence-end-base "[.?!][]\"'”)}]*\\(<[^>]*>\\)*") 1996 (setq-local sentence-end-base "[.?!][]\"'”)}]*\\(<[^>]*>\\)*")
1983 1997
1984 (setq imenu-create-index-function 'html-imenu-index) 1998 (setq imenu-create-index-function 'html-imenu-index)