X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/fd1ee6ab8c1ced05a8585fe9699c61c876b779c2..250ca1c395c6f05b733abce69a2d928b6cd31618:/company-css.el diff --git a/company-css.el b/company-css.el index b8bd639c1..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" @@ -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)