diff options
| author | Simen Heggestøyl | 2016-04-26 20:37:56 +0200 |
|---|---|---|
| committer | Simen Heggestøyl | 2016-04-26 20:41:04 +0200 |
| commit | 07d729130e5774fc484ba324d9149d4c6f008260 (patch) | |
| tree | 21927947ef5fb41df1b1359bf27b5085e41aa0c6 | |
| parent | 40a03df45353692f73364e488c962f1a7cf2e8bc (diff) | |
| download | emacs-07d729130e5774fc484ba324d9149d4c6f008260.tar.gz emacs-07d729130e5774fc484ba324d9149d4c6f008260.zip | |
Add completion of `calc()' in CSS mode
* lisp/textmodes/css-mode.el (css-value-class-alist): Add `calc()' as
a completion candidate for several value classes.
(css--value-class-lookup): Return only unique results.
* test/lisp/textmodes/css-mode-tests.el
(css-test-property-values-no-duplicates)
(css-test-value-class-lookup): Update to reflect the above changes.
| -rw-r--r-- | lisp/textmodes/css-mode.el | 25 | ||||
| -rw-r--r-- | test/lisp/textmodes/css-mode-tests.el | 4 |
2 files changed, 17 insertions, 12 deletions
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 608462b36a6..e30fb3e6d14 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el | |||
| @@ -454,6 +454,7 @@ further value candidates, since that list would be infinite.") | |||
| 454 | "xx-small" "x-small" "small" "medium" "large" "x-large" | 454 | "xx-small" "x-small" "small" "medium" "large" "x-large" |
| 455 | "xx-large") | 455 | "xx-large") |
| 456 | (alphavalue number) | 456 | (alphavalue number) |
| 457 | (angle "calc()") | ||
| 457 | (attachment "scroll" "fixed" "local") | 458 | (attachment "scroll" "fixed" "local") |
| 458 | (bg-image image "none") | 459 | (bg-image image "none") |
| 459 | (bg-layer bg-image position repeat-style attachment box) | 460 | (bg-layer bg-image position repeat-style attachment box) |
| @@ -481,6 +482,7 @@ further value candidates, since that list would be infinite.") | |||
| 481 | (final-bg-layer | 482 | (final-bg-layer |
| 482 | bg-image position repeat-style attachment box color) | 483 | bg-image position repeat-style attachment box color) |
| 483 | (font-variant-css21 "normal" "small-caps") | 484 | (font-variant-css21 "normal" "small-caps") |
| 485 | (frequency "calc()") | ||
| 484 | (generic-family | 486 | (generic-family |
| 485 | "serif" "sans-serif" "cursive" "fantasy" "monospace") | 487 | "serif" "sans-serif" "cursive" "fantasy" "monospace") |
| 486 | (generic-voice "male" "female" "child") | 488 | (generic-voice "male" "female" "child") |
| @@ -491,7 +493,8 @@ further value candidates, since that list would be infinite.") | |||
| 491 | "historical-ligatures" "no-historical-ligatures") | 493 | "historical-ligatures" "no-historical-ligatures") |
| 492 | (image uri image-list element-reference gradient) | 494 | (image uri image-list element-reference gradient) |
| 493 | (image-list "image()") | 495 | (image-list "image()") |
| 494 | (length number) | 496 | (integer "calc()") |
| 497 | (length "calc()" number) | ||
| 495 | (line-height "normal" number length percentage) | 498 | (line-height "normal" number length percentage) |
| 496 | (line-style | 499 | (line-style |
| 497 | "none" "hidden" "dotted" "dashed" "solid" "double" "groove" | 500 | "none" "hidden" "dotted" "dashed" "solid" "double" "groove" |
| @@ -499,6 +502,7 @@ further value candidates, since that list would be infinite.") | |||
| 499 | (line-width length "thin" "medium" "thick") | 502 | (line-width length "thin" "medium" "thick") |
| 500 | (linear-gradient "linear-gradient()") | 503 | (linear-gradient "linear-gradient()") |
| 501 | (margin-width "auto" length percentage) | 504 | (margin-width "auto" length percentage) |
| 505 | (number "calc()") | ||
| 502 | (numeric-figure-values "lining-nums" "oldstyle-nums") | 506 | (numeric-figure-values "lining-nums" "oldstyle-nums") |
| 503 | (numeric-fraction-values "diagonal-fractions" "stacked-fractions") | 507 | (numeric-fraction-values "diagonal-fractions" "stacked-fractions") |
| 504 | (numeric-spacing-values "proportional-nums" "tabular-nums") | 508 | (numeric-spacing-values "proportional-nums" "tabular-nums") |
| @@ -529,6 +533,7 @@ further value candidates, since that list would be infinite.") | |||
| 529 | "step-end" "steps()" "cubic-bezier()") | 533 | "step-end" "steps()" "cubic-bezier()") |
| 530 | (specific-voice identifier) | 534 | (specific-voice identifier) |
| 531 | (target-name string) | 535 | (target-name string) |
| 536 | (time "calc()") | ||
| 532 | (transform-list | 537 | (transform-list |
| 533 | "matrix()" "translate()" "translateX()" "translateY()" "scale()" | 538 | "matrix()" "translate()" "translateX()" "translateY()" "scale()" |
| 534 | "scaleX()" "scaleY()" "rotate()" "skew()" "skewX()" "skewY()" | 539 | "scaleX()" "scaleY()" "rotate()" "skew()" "skewX()" "skewY()" |
| @@ -546,9 +551,8 @@ a class of values, and that symbols in the CDRs always refer to | |||
| 546 | other entries in this list, not to properties. | 551 | other entries in this list, not to properties. |
| 547 | 552 | ||
| 548 | The following classes have been left out above because they | 553 | The following classes have been left out above because they |
| 549 | cannot be completed sensibly: `angle', `element-reference', | 554 | cannot be completed sensibly: `element-reference', `id', |
| 550 | `frequency', `id', `identifier', `integer', `number', | 555 | `identifier', `percentage', and `string'.") |
| 551 | `percentage', `string', and `time'.") | ||
| 552 | 556 | ||
| 553 | (defcustom css-electric-keys '(?\} ?\;) ;; '() | 557 | (defcustom css-electric-keys '(?\} ?\;) ;; '() |
| 554 | "Self inserting keys which should trigger re-indentation." | 558 | "Self inserting keys which should trigger re-indentation." |
| @@ -780,12 +784,13 @@ cannot be completed sensibly: `angle', `element-reference', | |||
| 780 | "Return a list of value completion candidates for VALUE-CLASS. | 784 | "Return a list of value completion candidates for VALUE-CLASS. |
| 781 | Completion candidates are looked up in `css-value-class-alist' by | 785 | Completion candidates are looked up in `css-value-class-alist' by |
| 782 | the symbol VALUE-CLASS." | 786 | the symbol VALUE-CLASS." |
| 783 | (seq-mapcat | 787 | (seq-uniq |
| 784 | (lambda (value) | 788 | (seq-mapcat |
| 785 | (if (stringp value) | 789 | (lambda (value) |
| 786 | (list value) | 790 | (if (stringp value) |
| 787 | (css--value-class-lookup value))) | 791 | (list value) |
| 788 | (cdr (assq value-class css-value-class-alist)))) | 792 | (css--value-class-lookup value))) |
| 793 | (cdr (assq value-class css-value-class-alist))))) | ||
| 789 | 794 | ||
| 790 | (defun css--property-values (property) | 795 | (defun css--property-values (property) |
| 791 | "Return a list of value completion candidates for PROPERTY. | 796 | "Return a list of value completion candidates for PROPERTY. |
diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el index 5d5873b301b..4c0a3572b36 100644 --- a/test/lisp/textmodes/css-mode-tests.el +++ b/test/lisp/textmodes/css-mode-tests.el | |||
| @@ -72,12 +72,12 @@ | |||
| 72 | ;; removed, it'll contain at least two instances of `auto'. | 72 | ;; removed, it'll contain at least two instances of `auto'. |
| 73 | (should | 73 | (should |
| 74 | (equal (sort (css--property-values "flex") #'string-lessp) | 74 | (equal (sort (css--property-values "flex") #'string-lessp) |
| 75 | '("auto" "content" "none")))) | 75 | '("auto" "calc()" "content" "none")))) |
| 76 | 76 | ||
| 77 | (ert-deftest css-test-value-class-lookup () | 77 | (ert-deftest css-test-value-class-lookup () |
| 78 | (should | 78 | (should |
| 79 | (equal (sort (css--value-class-lookup 'position) #'string-lessp) | 79 | (equal (sort (css--value-class-lookup 'position) #'string-lessp) |
| 80 | '("bottom" "center" "left" "right" "top")))) | 80 | '("bottom" "calc()" "center" "left" "right" "top")))) |
| 81 | 81 | ||
| 82 | (provide 'css-mode-tests) | 82 | (provide 'css-mode-tests) |
| 83 | ;;; css-mode-tests.el ends here | 83 | ;;; css-mode-tests.el ends here |