Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edgargoncalves/523802 to your computer and use it in GitHub Desktop.
Save edgargoncalves/523802 to your computer and use it in GitHub Desktop.
(defun slime-update-clojure-namespace (arg)
"Find the namespace in the current buffer and use SLIME's REPL
to switch to it, updating the namespace for all buffers.
Using an universal prefix will ask for the name of the namespace.
The actual namespace switch is done by calling `SLIME-REPL-SET-PACKAGE'."
(interactive "P")
(if arg
(call-interactively 'slime-repl-set-package)
(save-excursion
;; search for this buffer's namespace:
(goto-char 0)
(if (search-forward "(ns " nil t)
(let* ((beg (point))
(end (save-excursion
(forward-sexp 1)
(point)))
(ns (filter-buffer-substring beg end)))
(set-text-properties 0 (length ns) nil ns)
(slime-repl-set-package ns))
;; no package found
(call-interactively 'slime-repl-set-package)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment