doomemacs/modules/defuns/defuns-elisp.el
2016-05-27 15:55:56 -04:00

61 lines
1.6 KiB
EmacsLisp

;;; defuns-elisp.el
;;;###autoload (autoload 'doom:byte-compile "defuns-elisp" nil t)
(evil-define-command doom:byte-compile (&optional bang)
(interactive "<!>")
(if bang (doom-byte-compile) (byte-compile-file buffer-file-name)))
;;;###autoload
(defun doom/elisp-find-function-at-pt ()
(interactive)
(let ((func (function-called-at-point)))
(if func (find-function func))))
;;;###autoload
(defun doom/elisp-find-function-at-pt-other-window ()
(interactive)
(let ((func (function-called-at-point)))
(if func (find-function-other-window func))))
(defsubst doom--ert-pre ()
(save-buffer)
(eval-buffer))
;;;###autoload
(defun doom/ert-run-test ()
(interactive)
(let (case-fold-search)
(doom--ert-pre)
(aif (thing-at-point 'defun t)
(if (string-match "(ert-deftest \\([^ ]+\\)" it)
(ert-run-tests-interactively (substring it (match-beginning 1) (match-end 1)))
(user-error "Invalid test at point"))
(user-error "No test found at point"))))
;;;###autoload
(defun doom/ert-rerun-test ()
(interactive)
(let (case-fold-search)
(doom--ert-pre)
(aif (car-safe ert--selector-history)
(ert-run-tests-interactively it)
(message "No test found in history, looking for test at point")
(doom/ert-run-test))))
;;;###autoload
(defun doom/ert-run-all-tests ()
(interactive)
(ert-delete-all-tests)
(doom--ert-pre)
(ert-run-tests-interactively t))
;;;###autoload
(defun doom/elisp-inf-ielm ()
(ielm)
(let ((buf (current-buffer)))
(bury-buffer)
(pop-to-buffer buf)))
(provide 'defuns-elisp)
;;; defuns-elisp.el ends here