aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSimen Heggestøyl2018-05-29 19:14:34 +0200
committerSimen Heggestøyl2018-05-29 21:24:26 +0200
commit58d0642e1ca006fa550bff50fd328bc166c572da (patch)
treea963419d50eac188e629bba7cbb68fcd833a2290 /test
parent5be83e343f9f0f3487793b54ff95bc89ee6b824a (diff)
downloademacs-58d0642e1ca006fa550bff50fd328bc166c572da.tar.gz
emacs-58d0642e1ca006fa550bff50fd328bc166c572da.zip
Add Imenu support to CSS mode and its derivatives
* lisp/textmodes/css-mode.el (css--join-nested-selectors) (css--prev-index-position, css--extract-index-name): New helper functions for supporting Imenu. (css-mode): Set `imenu-space-replacement', `imenu-prev-index-position-function', and `imenu-extract-index-name-function'. (css-current-defun-name): Reuse `css--prev-index-position' and `css--extract-index-name' to support nested selectors. * test/lisp/textmodes/css-mode-tests.el (css-test-current-defun-name): Fix character index. (css-test-join-nested-selectors): New tests for `css--join-nested-selectors'. * etc/NEWS: Add news entry.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/textmodes/css-mode-tests.el15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el
index b0283bfa455..bfae1bf2f75 100644
--- a/test/lisp/textmodes/css-mode-tests.el
+++ b/test/lisp/textmodes/css-mode-tests.el
@@ -85,7 +85,7 @@
85 (insert "body { top: 0; }") 85 (insert "body { top: 0; }")
86 (goto-char 7) 86 (goto-char 7)
87 (should (equal (css-current-defun-name) "body")) 87 (should (equal (css-current-defun-name) "body"))
88 (goto-char 18) 88 (goto-char 15)
89 (should (equal (css-current-defun-name) "body")))) 89 (should (equal (css-current-defun-name) "body"))))
90 90
91(ert-deftest css-test-current-defun-name-nested () 91(ert-deftest css-test-current-defun-name-nested ()
@@ -324,6 +324,19 @@
324 (css-cycle-color-format) 324 (css-cycle-color-format)
325 (should (equal (buffer-string) "black")))) 325 (should (equal (buffer-string) "black"))))
326 326
327(ert-deftest css-test-join-nested-selectors ()
328 (should (equal (css--join-nested-selectors '("div" "&:hover"))
329 "div:hover"))
330 (should
331 (equal (css--join-nested-selectors '("a" "&::before, &::after"))
332 "a::before, a::after"))
333 (should
334 (equal (css--join-nested-selectors
335 '("article" "& > .front-page" "& h1, & h2"))
336 "article > .front-page h1, article > .front-page h2"))
337 (should (equal (css--join-nested-selectors '(".link" "& + &"))
338 ".link + .link")))
339
327(ert-deftest css-mdn-symbol-guessing () 340(ert-deftest css-mdn-symbol-guessing ()
328 (dolist (item '(("@med" "ia" "@media") 341 (dolist (item '(("@med" "ia" "@media")
329 ("@keyframes " "{" "@keyframes") 342 ("@keyframes " "{" "@keyframes")