X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/43021afcd34b1e6d27bf4657b2f67b304d5feb4d..e52579348d8529b0cff08a1f0a676cb0cc6f61c3:/company-css.el diff --git a/company-css.el b/company-css.el index 080cb85a5..cf8c683ce 100644 --- a/company-css.el +++ b/company-css.el @@ -1,4 +1,4 @@ -;;; company-css.el --- company-mode completion back-end for css-mode -*- lexical-binding: t -*- +;;; company-css.el --- company-mode completion backend for css-mode -*- lexical-binding: t -*- ;; Copyright (C) 2009, 2011, 2014 Free Software Foundation, Inc. @@ -26,6 +26,8 @@ (require 'company) (require 'cl-lib) +(declare-function web-mode-language-at-pos "web-mode" (&optional pos)) + (defconst company-css-property-alist ;; see http://www.w3.org/TR/CSS21/propidx.html '(("azimuth" angle "left-side" "far-left" "left" "center-left" "center" @@ -86,7 +88,7 @@ ("elevation" angle "below" "level" "above" "higher" "lower") ("empty-cells" "show" "hide") ("float" "left" "right" "none") - ("font" font-style font-variant font-weight font-size "/" line-height + ("font" font-style font-weight font-size "/" line-height font-family "caption" "icon" "menu" "message-box" "small-caption" "status-bar" "normal" "small-caps" ;; CSS3 @@ -345,7 +347,11 @@ (push child results)) (push value results))) (setq results (sort results 'string<)) - (puthash attribute results company-css-property-cache) + (puthash attribute + (if (fboundp 'delete-consecutive-dups) + (delete-consecutive-dups results) + (delete-dups results)) + company-css-property-cache) results))) ;;; bracket detection @@ -402,16 +408,18 @@ Returns \"\" if no property found, but feasible at this position." ;;; values (defconst company-css-property-value-regexp - "\\_<\\([[:alpha:]-]+\\):\\(?:[^};]*[[:space:]]+\\)?\\([^};]*\\_>\\|\\)\\=" + "\\_<\\([[:alpha:]-]+\\):\\(?:[^{};]*[[:space:]]+\\)?\\([^{};]*\\_>\\|\\)\\=" "A regular expression matching CSS tags.") ;;;###autoload (defun company-css (command &optional arg &rest ignored) - "`company-mode' completion back-end for `css-mode'." + "`company-mode' completion backend for `css-mode'." (interactive (list 'interactive)) (cl-case command (interactive (company-begin-backend 'company-css)) - (prefix (and (derived-mode-p 'css-mode) + (prefix (and (or (derived-mode-p 'css-mode) + (and (derived-mode-p 'web-mode) + (string= (web-mode-language-at-pos) "css"))) (or (company-grab company-css-tag-regexp 1) (company-grab company-css-pseudo-regexp 1) (company-grab company-css-property-value-regexp 2)