Hi, 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? Damn that would be useful ... I am currently using a function that runs spec --line with the current line number, the problem with this is however that 1.) the specification string is not shown again on the commandline if the spec passed, and 2.) the line number may change when editing the file, and re-running the previous spec commandline (with the very nice emacs command recompile) may hit a different spot. tia, Til
* 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