Skip to content

Commit 9493bf8

Browse files
committed
Make the expected ns configurable via clojure-expected-ns-function
1 parent 2462fd8 commit 9493bf8

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### New features
1010

1111
* [#370](https://github.com/clojure-emacs/clojure-mode/issues/370): Warn the user if they seem to have activated the wrong major-mode.
12+
* Make the expected ns function configurable via `clojure-expected-ns-function`.
1213

1314
## 5.2.0 (04/02/2016)
1415

clojure-mode.el

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ Inherits from `emacs-lisp-mode-syntax-table'.")
226226
(defconst clojure--prettify-symbols-alist
227227
'(("fn" . )))
228228

229+
(defvar-local clojure-expected-ns-function nil
230+
"The function used to determine the expected namespace of a file.
231+
`clojure-mode' ships a basic function named `clojure-expected-ns'
232+
that does basic heuristics to figure this out.
233+
CIDER provides a more complex version which does classpath analysis.")
234+
229235
(defun clojure-mode-display-version ()
230236
"Display the current `clojure-mode-version' in the minibuffer."
231237
(interactive)
@@ -318,6 +324,7 @@ instead of to `clojure-mode-map'."
318324
(setq-local indent-region-function #'clojure-indent-region)
319325
(setq-local lisp-indent-function #'clojure-indent-function)
320326
(setq-local lisp-doc-string-elt-property 'clojure-doc-string-elt)
327+
(setq-local clojure-expected-ns-function #'clojure-expected-ns)
321328
(setq-local parse-sexp-ignore-comments t)
322329
(setq-local prettify-symbols-alist clojure--prettify-symbols-alist)
323330
(setq-local open-paren-in-column-0-is-defun-start nil))
@@ -1370,7 +1377,7 @@ If PATH is nil, use the path to the file backing the current buffer."
13701377
(defun clojure-insert-ns-form-at-point ()
13711378
"Insert a namespace form at point."
13721379
(interactive)
1373-
(insert (format "(ns %s)" (clojure-expected-ns))))
1380+
(insert (format "(ns %s)" (funcall clojure-expected-ns-function))))
13741381

13751382
(defun clojure-insert-ns-form ()
13761383
"Insert a namespace form at the beginning of the buffer."
@@ -1383,7 +1390,7 @@ If PATH is nil, use the path to the file backing the current buffer."
13831390
"Update the namespace of the current buffer.
13841391
Useful if a file has been renamed."
13851392
(interactive)
1386-
(let ((nsname (clojure-expected-ns)))
1393+
(let ((nsname (funcall clojure-expected-ns-function)))
13871394
(when nsname
13881395
(save-excursion
13891396
(save-match-data

0 commit comments

Comments
 (0)