public

  • Download Gist
slime-update-clojure-namespace.el
Emacs Lisp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
(require 'pc-select)
(defun slime-update-clojure-namespace ()
"Find the namespace in the current buffer and use SLIME's REPL
to switch to it, updating the namespace for all buffers."
(interactive)
(save-excursion
;; search for this buffer's namespace:
(goto-char 0)
(when (search-forward "(ns " nil t)
(let ((beg (point))
(end (save-excursion
(forward-sexp 1)
(point))))
(copy-region-as-kill-nomark beg end))
;; send the in-ns command to slime's repl:
(set-buffer (slime-output-buffer))
(unless (eq (current-buffer) (window-buffer))
(pop-to-buffer (current-buffer) t))
(goto-char (point-max))
(insert "(in-ns '")
(yank)
(insert ")")
(progn
(slime-repl-return)
(other-window 1)))))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.