[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r111054: Add `add-log-current-defun-f
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r111054: Add `add-log-current-defun-function's for CSS and HTML mode. |
Date: |
Sat, 01 Dec 2012 13:51:33 +0800 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 111054
author: Jari Aalto <address@hidden>
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sat 2012-12-01 13:51:33 +0800
message:
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.
modified:
lisp/ChangeLog
lisp/textmodes/css-mode.el
lisp/textmodes/sgml-mode.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-12-01 04:57:07 +0000
+++ b/lisp/ChangeLog 2012-12-01 05:51:33 +0000
@@ -1,3 +1,11 @@
+2012-12-01 Jari Aalto <address@hidden>
+
+ * 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 <address@hidden>
Modularize add-log-current-defun (Bug#2224).
=== modified file 'lisp/textmodes/css-mode.el'
--- a/lisp/textmodes/css-mode.el 2012-12-01 04:09:55 +0000
+++ b/lisp/textmodes/css-mode.el 2012-12-01 05:51:33 +0000
@@ -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
=== modified file 'lisp/textmodes/sgml-mode.el'
--- a/lisp/textmodes/sgml-mode.el 2012-12-01 04:09:55 +0000
+++ b/lisp/textmodes/sgml-mode.el 2012-12-01 05:51:33 +0000
@@ -1932,6 +1932,19 @@
(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 @@
(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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r111054: Add `add-log-current-defun-function's for CSS and HTML mode.,
Chong Yidong <=