]> code.delx.au - gnu-emacs/blobdiff - lisp/textmodes/css-mode.el
Add 2010 to copyright years.
[gnu-emacs] / lisp / textmodes / css-mode.el
index 00a438a3e95002307dfb61dae1a4521c113cda70..6e80b737284834d530a2fdf45f79962593d59963 100644 (file)
@@ -1,24 +1,24 @@
 ;;; css-mode.el --- Major mode to edit CSS files
 
-;; Copyright (C) 2006, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
 ;; Keywords: hypermedia
 
-;; This file is free software; you can redistribute it and/or modify
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
-;; This file is distributed in the hope that it will be useful,
+;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 
 ;;; Code:
 
+(defgroup css nil
+  "Cascading Style Sheets (CSS) editing mode."
+  :group 'languages)
+
+(eval-when-compile (require 'cl))
+
 (defun css-extract-keyword-list (res)
   (with-temp-buffer
     (url-insert-file-contents "http://www.w3.org/TR/REC-CSS2/css2.txt")
@@ -86,7 +92,7 @@
        ;; vice-versa).
        (t nil)))
     elems))
-        
+
 
 (defun css-extract-props-and-vals ()
   (with-temp-buffer
                                                  (progn
                                                    (re-search-forward "[ \t\n]+|[ \t\n]+<a href=\"cascade.html#value-def-inherit\" class=\"noxref\"><span class=\"value-inst-inherit\">inherit</span></a>")
                                                    (match-beginning 0)))))
-              ;; 
+              ;;
               (push (cons prop (css-extract-parse-val-grammar vals-string props))
                     props)))))
       props)))
     "word-spacing" "z-index")
   "Identifiers for properties.")
 
-(defcustom css-electrick-keys '(?\} ?\;) ;; '()
+(defcustom css-electric-keys '(?\} ?\;) ;; '()
   "Self inserting keys which should trigger re-indentation."
+  :version "22.2"
   :type '(repeat character)
-  :options '((?\} ?\;)))
+  :options '((?\} ?\;))
+  :group 'css)
 
 (defvar css-mode-syntax-table
   (let ((st (make-syntax-table)))
 (defconst css-name-re (concat css-nmchar-re "+"))
 
 (defface css-selector '((t :inherit font-lock-function-name-face))
-  "Face to use for selectors.")
+  "Face to use for selectors."
+  :group 'css)
 (defface css-property '((t :inherit font-lock-variable-name-face))
-  "Face to use for properties.")
+  "Face to use for properties."
+  :group 'css)
 
 (defvar css-font-lock-keywords
   `(("!\\s-*important" . font-lock-builtin-face)
 (defvar css-font-lock-defaults
   '(css-font-lock-keywords nil t))
 
-(unless (fboundp 'prog-mode) (defalias 'prog-mode 'fundamental-mode))
-
-;;;###autoload (add-to-list 'auto-mode-alist '("\\.css\\'" . css-mode))
+;;;###autoload (add-to-list 'auto-mode-alist (cons (purecopy "\\.css\\'") 'css-mode))
 ;;;###autoload
-(define-derived-mode css-mode prog-mode "CSS"
+(define-derived-mode css-mode fundamental-mode "CSS"
   "Major mode to edit Cascading Style Sheets."
   (set (make-local-variable 'font-lock-defaults) css-font-lock-defaults)
   (set (make-local-variable 'comment-start) "/*")
   (set (make-local-variable 'indent-line-function) 'css-indent-line)
   (set (make-local-variable 'fill-paragraph-function)
        'css-fill-paragraph)
-  (when css-electrick-keys
+  (when css-electric-keys
     (let ((fc (make-char-table 'auto-fill-chars)))
       (set-char-table-parent fc auto-fill-chars)
-      (dolist (c css-electrick-keys)
+      (dolist (c css-electric-keys)
         (aset fc c 'indent-according-to-mode))
       (set (make-local-variable 'auto-fill-chars) fc))))
 
+(defvar comment-continue)
+
 (defun css-fill-paragraph (&optional justify)
   (save-excursion
     (let ((ppss (syntax-ppss))
         ;; css-mode but for all modes.
         (save-restriction
           (narrow-to-region (nth 8 ppss) eol)
-          (comment-normalize-vars)
+          (comment-normalize-vars)      ;Will define comment-continue.
           (let ((fill-paragraph-function nil)
                 (paragraph-separate
                  (if (and comment-continue
             (fill-paragraph justify)
             ;; Don't try filling again.
             t)))
-        
+
        ((and (null (nth 8 ppss))
              (or (nth 1 ppss)
                  (and (ignore-errors
                         (save-excursion
                           (forward-comment (- (point-max)))
                           ;; FIXME: We should also skip punctuation.
-                          (not (memq (char-before) '(?\; ?\{)))))))))))
+                          (not (or (bobp) (memq (char-before) '(?\; ?\{))))))))))))
 
 (defun css-forward-sexp (n)
   (let ((forward-sexp-function nil))
 
 (defcustom css-indent-offset 4
   "Basic size of one indentation step."
-  :type 'integer)
+  :version "22.2"
+  :type 'integer
+  :group 'css)
 
 (defun css-indent-calculate ()
   (let ((ppss (syntax-ppss))
              (if (looking-at "\\s(")
                  (css-indent-calculate)
                (css-indent-calculate-virtual))))))))))
-     
+
 
 (defun css-indent-line ()
   "Indent current line according to CSS indentation rules."