[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup 54696b0 124/340: Merge pull request #78 from Fuc
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup 54696b0 124/340: Merge pull request #78 from Fuco1/feature/buttercup-minor-mode |
Date: |
Thu, 16 Dec 2021 14:59:18 -0500 (EST) |
branch: elpa/buttercup
commit 54696b033195b804654e496e1567f54b7232ca55
Merge: 11f072f 2b5f53d
Author: Jorgen Schäfer <Jorgen.Schaefer@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #78 from Fuco1/feature/buttercup-minor-mode
[Fix #72] Add buttercup-minor-mode
---
buttercup.el | 24 ++++++++++++++++++++++++
tests/test-buttercup.el | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+)
diff --git a/buttercup.el b/buttercup.el
index 84414b5..5c6c55a 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -1110,5 +1110,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 5cbd468 084/340: Bump version: 1.2 → 1.3, (continued)
- [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
- [nongnu] elpa/buttercup 07c525e 116/340: Merge pull request #68 from ebpa/report-load-errors, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 11f072f 123/340: Merge pull request #81 from DamienCassou/fix-to-have-same-items-as, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 562cdb0 058/340: The buttercup-suite-full-name function., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d264da3 075/340: Merge pull request #17 from Fuco1/master, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 8c486e6 067/340: Move print settings to the batch reporter where they belong., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0f3eb63 078/340: Show actual function arguments when a spy fails., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 357e73b 085/340: Remove debug message, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 68692d9 113/340: Update Travis configuration instructions, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 54696b0 124/340: Merge pull request #78 from Fuco1/feature/buttercup-minor-mode,
ELPA Syncer <=
- [nongnu] elpa/buttercup 77f0c74 122/340: Fix :to-have-same-items-as (fix #80), ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 20ec520 145/340: Rename functions and arguments for closure manipulation, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 5d1f338 146/340: Move let-binding outside loop for efficiency, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 7fa79c4 048/340: Expand and improve the package commentary., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 4f68f0b 059/340: The buttercup-spec-full-name function., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ef7b730 063/340: Various improvements of the batch reporter., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup a55a638 064/340: More and better tests for the batch reporter., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c7df9f6 069/340: Add 24.5., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0c5cc32 057/340: The buttercup-suites-total-specs-defined function., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ea8effb 095/340: Add the :var argument to describe, ELPA Syncer, 2021/12/16