2017-01-16 23:30:11 -05:00
|
|
|
;;; lang/emacs-lisp/autoload.el
|
|
|
|
|
|
|
|
;; ---- emacs-lisp ---------------------------------------------------
|
|
|
|
|
|
|
|
;;;###autoload
|
2017-02-28 12:01:50 -05:00
|
|
|
(defun +emacs-lisp/find-function (&optional arg)
|
|
|
|
"Jump to the definition of the function at point. If ARG (the prefix) is
|
|
|
|
non-nil, the function will be revealed in another window. If ARG is 16 (C-u
|
|
|
|
C-u), then reveal the function in a popup window."
|
|
|
|
(interactive "p")
|
|
|
|
(when-let (func (function-called-at-point))
|
|
|
|
(cond ((= arg 16)
|
|
|
|
(let ((buf (find-function-noselect func t)))
|
|
|
|
(doom-popup-buffer (car buf) :align t :size 30 :select t)
|
|
|
|
(goto-char (cdr buf))))
|
|
|
|
((> arg 1)
|
|
|
|
(find-function-other-window func))
|
|
|
|
(t
|
|
|
|
(find-function func)))))
|
2017-01-16 23:30:11 -05:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +emacs-lisp/repl ()
|
2017-03-04 18:31:18 -05:00
|
|
|
"Open the Emacs Lisp REPL (`ielm')."
|
2017-01-16 23:30:11 -05:00
|
|
|
(interactive)
|
2017-03-04 18:31:18 -05:00
|
|
|
(pop-to-buffer
|
|
|
|
(or (get-buffer "*ielm*")
|
|
|
|
(progn (ielm)
|
|
|
|
(let ((buf (get-buffer "*ielm*")))
|
|
|
|
(bury-buffer buf)
|
|
|
|
buf)))))
|
2017-01-16 23:30:11 -05:00
|
|
|
|
|
|
|
|
|
|
|
;; ---- ert ---------------------------------------------------
|
|
|
|
|
|
|
|
(defsubst +ert--pre ()
|
|
|
|
(save-buffer) (eval-buffer))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +ert/run-test ()
|
|
|
|
(interactive)
|
|
|
|
(let (case-fold-search thing)
|
|
|
|
(+ert--pre)
|
|
|
|
(setq thing (thing-at-point 'defun t))
|
|
|
|
(if thing
|
|
|
|
(if (string-match "(ert-deftest \\([^ ]+\\)" thing)
|
|
|
|
(ert-run-tests-interactively
|
|
|
|
(substring thing (match-beginning 1) (match-end 1)))
|
|
|
|
(user-error "Invalid test at point"))
|
|
|
|
(user-error "No test found at point"))))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +ert/rerun-test ()
|
|
|
|
(interactive)
|
|
|
|
(let (case-fold-search thing)
|
|
|
|
(+ert--pre)
|
|
|
|
(setq thing (car-safe ert--selector-history))
|
|
|
|
(if thing
|
|
|
|
(ert-run-tests-interactively thing)
|
|
|
|
(message "No test found in history, looking for test at point")
|
|
|
|
(+ert-run-test))))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +ert/run-all-tests ()
|
|
|
|
(interactive)
|
|
|
|
(ert-delete-all-tests)
|
|
|
|
(+ert--pre)
|
|
|
|
(ert-run-tests-interactively t))
|
|
|
|
|