Skip to content

Commit 6a354dc

Browse files
arichiardibbatsov
authored andcommitted
Add defcustom inf-clojure-prompt-on-set-ns (#46)
The patch allow the user to disable the prompt "Set ns: ..." on `C-c M-n`. The default is to always prompt.
1 parent 3e22747 commit 6a354dc

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### New Features
66

77
* [#34](https://github.com/clojure-emacs/inf-clojure/pull/34): Add support for socket REPL connections.
8+
* [#46](https://github.com/clojure-emacs/inf-clojure/pull/46): Make it possible to disable prompt on `inf-clojure-set-ns`.
89
* New interactive command `inf-clojure-display-version`.
910

1011
### Bugs Fixed

inf-clojure.el

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ This should usually be a combination of `inf-clojure-prompt' and
179179
:type 'regexp
180180
:group 'inf-clojure)
181181

182+
(defcustom inf-clojure-prompt-on-set-ns t
183+
"Controls whether to prompt when switching namespace."
184+
:type '(choice (const :tag "always" t)
185+
(const :tag "never" nil))
186+
:group 'inf-clojure)
187+
182188
(defvar inf-clojure-buffer nil
183189
"The current inf-clojure process buffer.
184190
@@ -620,8 +626,13 @@ See variable `inf-clojure-ns-vars-command'."
620626

621627
(defun inf-clojure-set-ns (ns)
622628
"Set the ns of the inferior Clojure process to NS.
623-
Defaults to the ns of the current buffer."
624-
(interactive (inf-clojure-symprompt "Set ns to" (clojure-find-ns)))
629+
Defaults to the ns of the current buffer, always prompting before
630+
setting, unless `inf-clojure-prompt-on-set-ns` is nil."
631+
(interactive (list (if inf-clojure-prompt-on-set-ns
632+
(inf-clojure-symprompt "Set ns to" (clojure-find-ns))
633+
(clojure-find-ns))))
634+
(when (or (not ns) (equal ns ""))
635+
(user-error "No namespace selected"))
625636
(comint-proc-query (inf-clojure-proc) (format inf-clojure-set-ns-command ns)))
626637

627638
(defun inf-clojure-apropos (var)

0 commit comments

Comments
 (0)