cucumber.el
cucumber.el copied to clipboard
Keybindings to add/navigate steps
It would be really good if there was a way to add the various gherkin keywords in the feature file and also navigate between features (a la org-mode's navigation between headings).
I added some keybindings to my local emacs for the main keywords, but would it be a good idea to have it as a part of the mode itself?
(defun feature-add-keyword (keyword)
(indent-new-comment-line)
(insert keyword)
(indent-according-to-mode)
)
(defun feature-add-given ()
(interactive)
(feature-add-keyword "Given")
)
(defun feature-add-when ()
(interactive)
(feature-add-keyword "When")
)
(defun feature-add-and ()
(interactive)
(feature-add-keyword "And")
)
(defun feature-add-but ()
(interactive)
(feature-add-keyword "But")
)
(defun feature-add-then ()
(interactive)
(feature-add-keyword "Then")
)
(defun feature-add-scenario ()
(interactive)
(indent-new-comment-line)
(feature-add-keyword "Scenario:")
)
(defun feature-add-feature ()
(interactive)
(feature-add-keyword "Feature:")
)
(defun feature-add-scenario-outline ()
(interactive)
(indent-new-comment-line)
(feature-add-keyword "Scenario Outline:")
)
(defun feature-add-examples ()
(interactive)
(indent-new-comment-line)
(feature-add-keyword "Examples:")
(indent-new-comment-line)
(insert "||")
(backward-char)
)
(add-hook 'feature-mode-hook
(lambda ()
(local-set-key (kbd "C-c i g") 'feature-add-given)
(local-set-key (kbd "C-c i w") 'feature-add-when)
(local-set-key (kbd "C-c i a") 'feature-add-and)
(local-set-key (kbd "C-c i b") 'feature-add-but)
(local-set-key (kbd "C-c i t") 'feature-add-then)
(local-set-key (kbd "C-c i s") 'feature-add-scenario)
(local-set-key (kbd "C-c i f") 'feature-add-feature)
(local-set-key (kbd "C-c i o") 'feature-add-scenario-outline)
(local-set-key (kbd "C-c i e") 'feature-add-examples)
)
)