[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup 2b5f53d 121/340: [Fix #72] Add buttercup-minor-m
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup 2b5f53d 121/340: [Fix #72] Add buttercup-minor-mode |
Date: |
Thu, 16 Dec 2021 14:59:17 -0500 (EST) |
branch: elpa/buttercup
commit 2b5f53d964b5fb3bc3c4a5e8eb4fe7de68fa97ff
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>
[Fix #72] Add buttercup-minor-mode
With buttercup minor mode active the following is activated:
- `describe` and `it` forms are fontified with
`font-lock-keyword-face`.
- `describe` and `it` forms are available from `imenu` for
quicker access.
---
buttercup.el | 24 ++++++++++++++++++++++++
tests/test-buttercup.el | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+)
diff --git a/buttercup.el b/buttercup.el
index 62f0d98..ceca1bb 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -1109,5 +1109,29 @@ failed -- The second value is the description of the
expectation
frame (backtrace-frame n)))
frame-list))
+;;;###autoload
+(define-minor-mode buttercup-minor-mode
+ "Activate buttercup minor mode.
+
+With buttercup minor mode active the following is activated:
+
+- `describe' and `it' forms are fontified with
+ `font-lock-keyword-face'.
+- `describe' and `it' forms are available from `imenu' for
+ quicker access."
+ :lighter " ❀"
+ (let ((font-lock-form '(("(\\(describe\\|buttercup-define-matcher\\|it\\) "
+ 1 'font-lock-keyword-face)))
+ (imenu-forms '(("Test Suites" "\\((describe\\_>
+\\)\"\\(\\_<.+\\_>\\)\"" 2)
+ ("Spec" "\\((it\\_> +\\)\"\\(\\_<.+\\_>\\)\"" 2))))
+ (if buttercup-minor-mode
+ (progn
+ (font-lock-add-keywords nil font-lock-form)
+ (cl-dolist (form imenu-forms)
+ (add-to-list 'imenu-generic-expression form)))
+ (font-lock-remove-keywords nil font-lock-form)
+ (cl-dolist (form imenu-forms)
+ (setq imenu-generic-expression (delete form
imenu-generic-expression))))))
+
(provide 'buttercup)
;;; buttercup.el ends here
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index fee0b09..b03109f 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -730,3 +730,46 @@
(error "Expected erroring buttercup--funcall not to return %S"
res)))
+;;;;;;;;;;;;;
+;;; Buttercup-minor-mode
+
+(describe "butter-minor-mode"
+
+ (it "should fontify `describe' special form"
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (buttercup-minor-mode 1)
+ (font-lock-mode)
+ (insert "(describe \"A test suite\" (it \"should fontify special
keywords\"))")
+ (font-lock-fontify-region (point-min) (point-max))
+ (expect
+ (text-property-any (point-min) (point-max) 'face
'font-lock-keyword-face)
+ :to-equal 2)))
+
+ (it "should fontify `it' special form"
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (buttercup-minor-mode 1)
+ (font-lock-mode)
+ (insert "(describe \"A test suite\" (it \"should fontify special
keywords\"))")
+ (font-lock-fontify-region (point-min) (point-max))
+ (expect
+ (text-property-any 15 (point-max) 'face 'font-lock-keyword-face)
+ :to-equal 27)))
+
+ (it "should add special forms to `imenu'"
+ (with-temp-buffer
+ (require 'imenu)
+ (emacs-lisp-mode)
+ (buttercup-minor-mode 1)
+ (insert "(describe \"A test suite\"
+ (it \"should fontify special keywords\"))")
+ (imenu--make-index-alist)
+ (let ((suites (assoc "Test Suites" imenu--index-alist))
+ (specs (assoc "Spec" imenu--index-alist)))
+ (expect suites :to-be-truthy)
+ (expect (length (cdr suites)) :to-equal 1)
+ (expect (caadr suites) :to-equal "A test suite")
+ (expect specs :to-be-truthy)
+ (expect (length (cdr specs)) :to-equal 1)
+ (expect (caadr specs) :to-equal "should fontify special keywords")))))
- [nongnu] elpa/buttercup c61a69a 066/340: A rudimentary interactive reporter., (continued)
- [nongnu] elpa/buttercup c61a69a 066/340: A rudimentary interactive reporter., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 182a974 068/340: Pending specs and disabled suites., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b3bb12a 070/340: buttercup-run-discover: Fix regexp., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 26f8117 071/340: Rename buttercup-test.el and move it to the right directory., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup f593486 092/340: Use pattern _ not t in pcase, as t is deprecated, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0a889e2 098/340: Merge pull request #43 from spwhitton/apt-get, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup afbaae1 091/340: Document file names for test discovery, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 25cb350 089/340: Rename docs to be more easily understandable, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 6d96ea3 093/340: Add format specifier to error call with argument, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup cef9988 110/340: Merge pull request #61 from spwhitton/fix-regexp, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 2b5f53d 121/340: [Fix #72] Add buttercup-minor-mode,
ELPA Syncer <=
- [nongnu] elpa/buttercup 5db07c9 112/340: Merge pull request #63 from ebpa/patch-1, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup a05fdcb 117/340: Colorize output, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ed649d7 125/340: Merge pull request #76 from DamienCassou/make-buttercup--with-cleanup-public, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ce75b50 115/340: Report load errors in buttercup-run-discover, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 3deb9a4 053/340: Test discovery: Ignore files in dot directories., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 444716b 079/340: Handle windows better in interactive runs., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 512b82b 077/340: Rework documentation to make the readme more concise., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 238bfa8 082/340: Support --pattern command line argument, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 5cbd468 084/340: Bump version: 1.2 → 1.3, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ba8cd05 106/340: Merge pull request #59 from immerrr/add-other-emacs-params, ELPA Syncer, 2021/12/16