Function: clojure-update-ns

clojure-update-ns is an interactive and byte-compiled function defined in clojure-mode.el.

Signature

(clojure-update-ns)

Documentation

Update the namespace of the current buffer.

Useful if a file has been renamed.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/clojure-mode-20260325.811/clojure-mode.el
(defun clojure-update-ns ()
  "Update the namespace of the current buffer.
Useful if a file has been renamed."
  (interactive)
  (let ((nsname (funcall clojure-expected-ns-function)))
    (when nsname
      (save-excursion
        (save-match-data
          (if (clojure-find-ns)
              (progn
                ;; Move to end of the ns/in-ns keyword, then forward
                ;; to the namespace name sexp and replace it.
                (goto-char (match-end 0))
                (clojure-forward-logical-sexp)
                (let ((end (point)))
                  (backward-sexp)
                  ;; Skip past quote in (in-ns 'foo)
                  (skip-chars-forward "'")
                  (delete-region (point) end)
                  (insert nsname))
                (message "ns form updated to `%s'" nsname)
                (setq clojure-cached-ns nsname))
            (user-error "Can't find ns form")))))))