X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/1bad168e59601c1c843a38b2962e77b29f497f11..c566235d981eba73c88bbff00b6a1d88360b6e9f:/lisp/textmodes/css-mode.el diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 2359f8ff1a..bfa98e9c36 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1,24 +1,24 @@ ;;; css-mode.el --- Major mode to edit CSS files -;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. +;; Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: Stefan Monnier ;; 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 3, 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 . ;;; Commentary: @@ -92,7 +92,7 @@ ;; vice-versa). (t nil))) elems)) - + (defun css-extract-props-and-vals () (with-temp-buffer @@ -108,7 +108,7 @@ (progn (re-search-forward "[ \t\n]+|[ \t\n]+inherit") (match-beginning 0))))) - ;; + ;; (push (cons prop (css-extract-parse-val-grammar vals-string props)) props))))) props))) @@ -177,6 +177,7 @@ (defcustom css-electric-keys '(?\} ?\;) ;; '() "Self inserting keys which should trigger re-indentation." + :version "22.2" :type '(repeat character) :options '((?\} ?\;)) :group 'css) @@ -211,6 +212,8 @@ (defconst css-nmchar-re (concat "\\(?:[-[:alnum:]]\\|" css-escapes-re "\\)")) (defconst css-nmstart-re (concat "\\(?:[[:alpha:]]\\|" css-escapes-re "\\)")) (defconst css-ident-re (concat css-nmstart-re css-nmchar-re "*")) +(defconst css-proprietary-nmstart-re ;; Vendor-specific properties. + "[-_]\\(?:ms\\|moz\\|o\\|webkit\\|khtml\\)-") (defconst css-name-re (concat css-nmchar-re "+")) (defface css-selector '((t :inherit font-lock-function-name-face)) @@ -219,6 +222,8 @@ (defface css-property '((t :inherit font-lock-variable-name-face)) "Face to use for properties." :group 'css) +(defface css-proprietary-property '((t :inherit (css-property italic))) + "Face to use for vendor-specific properties.") (defvar css-font-lock-keywords `(("!\\s-*important" . font-lock-builtin-face) @@ -250,13 +255,16 @@ ;; No face. nil))) ;; Properties. Again, we don't limit ourselves to css-property-ids. - (,(concat "\\(?:[{;]\\|^\\)[ \t]*\\(" css-ident-re "\\)\\s-*:") - (1 'css-property)))) + (,(concat "\\(?:[{;]\\|^\\)[ \t]*\\(" + "\\(?:\\(" css-proprietary-nmstart-re "\\)\\|" + css-nmstart-re "\\)" css-nmchar-re "*" + "\\)\\s-*:") + (1 (if (match-end 2) 'css-proprietary-property 'css-property))))) (defvar css-font-lock-defaults '(css-font-lock-keywords nil t)) -;;;###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 fundamental-mode "CSS" "Major mode to edit Cascading Style Sheets." @@ -312,7 +320,7 @@ (fill-paragraph justify) ;; Don't try filling again. t))) - + ((and (null (nth 8 ppss)) (or (nth 1 ppss) (and (ignore-errors @@ -372,7 +380,7 @@ (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)) @@ -399,6 +407,7 @@ (defcustom css-indent-offset 4 "Basic size of one indentation step." + :version "22.2" :type 'integer :group 'css) @@ -455,7 +464,7 @@ (if (looking-at "\\s(") (css-indent-calculate) (css-indent-calculate-virtual)))))))))) - + (defun css-indent-line () "Indent current line according to CSS indentation rules."