el-expectations.elを使ったテストまで移動する関数
el-expectationsを使ったテストに直ぐに移動するための関数です。
つい癖でanything-c-moccurなどを使ってテストの位置まで移動していましたが、コマンドにしたら凄く便利になって気持ちがスッキリしました。14行程コードを書けば世界が変わりますね。まあ名前決め打ちな所もあるのですが。
やってる事
- 編集中のバッファのクローンを作り、popさせる(バッファ名<2>があればそれを選択します)
- (expectations まで移動
- ポイントの位置のシンボルがあれば、さらに移動
(defun my-goto-test () (interactive) (let* ((bname (buffer-name)) (cur-word (regexp-quote (or (thing-at-point 'symbol) ""))) (pop-buffer (lambda () (cond ((and (stringp bname) (get-buffer (concat bname "<2>"))) (pop-to-buffer (concat bname "<2>"))) (t (call-interactively 'clone-indirect-buffer)))))) (funcall pop-buffer) (goto-char (point-min)) (re-search-forward "(expectations" nil t) (re-search-forward cur-word nil t)))