stuartsierra/component

init.el helper fns

freckletonj opened this issue · 1 comments

Thanks for Component!

I noticed on your Workflow Reloaded blog post that your helper fns no longer work, and since they're immensely useful, I thought I'd contribute these:

Thanks!

;; emacs, init.el

;; find all buffers names which match `reg`, regex
(defun find-buffer-regex (reg)
  (interactive)
  (remove-if-not #'(lambda (x) (string-match reg x))
                 (mapcar #'buffer-name (buffer-list))))

(defun cider-execute (command)
  (interactive)
  (set-buffer (car (find-buffer-regex "cider-repl.*")))
  (goto-char (point-max))
  (insert command)
  (cider-repl-return))

(defun nrepl-reset ()
  (interactive)
  (cider-execute "(reset)"))
(define-key cider-mode-map (kbd "C-c r") 'nrepl-reset)

(defun nrepl-test ()
  (interactive)
  (cider-execute "(test)"))
(define-key cider-mode-map (kbd "C-c t") 'nrepl-test)

Thank you for your contribution, but Emacs functions are not part of the Component library.