[rspec-users] Emacs spec parsing?
Tilmann Singer
tils-rspec at tils.net
Wed Feb 14 07:39:17 EST 2007
* Tilmann Singer <tils-rspec at tils.net> [20070130 16:56]:
> Did anyone with better emacs lisp knowledge than me already come up
> with a function like spec-at-point which finds the specify and context
> declaration for the current cursor position and returns a string which
> can be used to be passed to the --spec option of the spec runner?
Answering my own question, in case someone else is interested in this:
below is the relevant part of my .emacs with a function that finds and
runs the spec under the current cursor position.
(defun spec-at-point ()
"Run specification at point"
(interactive)
(let (
(old_point (point))
(specify (progn (move-end-of-line nil) (re-search-backward "^ *specify +\"\\(.*\\)\" +do") (match-string 1)))
(context (progn (re-search-backward "^ *context +\"\\(.*\\)\" +do") (match-string 1))))
(goto-char old_point)
(compile (concat "spec -s \"" context " " specify "\" " (buffer-file-name)))
)
)
(global-set-key "\C-cs" 'spec-at-point)
(defun spec-file()
"Run current spec file"
(interactive)
(compile (concat "spec " (buffer-file-name)))
)
(defun save-and-recompile () "Save and recompile" (interactive)
(save-buffer)
(recompile)
)
(define-key global-map "\C-x\C-y" 'save-and-recompile)
Til
More information about the rspec-users
mailing list