From ddad0330ea4afaf8ac4059d4bf279c5b3724035d Mon Sep 17 00:00:00 2001 From: Andrea Richiardi Date: Fri, 3 Mar 2017 11:22:19 -0800 Subject: [PATCH] Add defcustom `inf-clojure-prompt-when-set-ns` The patch allow the user to disable the request "Set ns: ..." on C-c M-n. The default is to always prompt. --- CHANGELOG.md | 1 + inf-clojure.el | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99009ea..b5e8134 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### New Features * [#34](https://github.com/clojure-emacs/inf-clojure/pull/34): Add support for socket REPL connections. +* [#46](https://github.com/clojure-emacs/inf-clojure/pull/46): Make it possible to disable prompt on `inf-clojure-set-ns`. * New interactive command `inf-clojure-display-version`. ### Bugs Fixed diff --git a/inf-clojure.el b/inf-clojure.el index 13bfeb4..3a445f1 100644 --- a/inf-clojure.el +++ b/inf-clojure.el @@ -179,6 +179,12 @@ This should usually be a combination of `inf-clojure-prompt' and :type 'regexp :group 'inf-clojure) +(defcustom inf-clojure-prompt-on-set-ns t + "Controls whether to prompt when switching namespace." + :type '(choice (const :tag "always" t) + (const :tag "never" nil)) + :group 'inf-clojure) + (defvar inf-clojure-buffer nil "The current inf-clojure process buffer. @@ -620,8 +626,13 @@ See variable `inf-clojure-ns-vars-command'." (defun inf-clojure-set-ns (ns) "Set the ns of the inferior Clojure process to NS. -Defaults to the ns of the current buffer." - (interactive (inf-clojure-symprompt "Set ns to" (clojure-find-ns))) +Defaults to the ns of the current buffer, always prompting before +setting, unless `inf-clojure-prompt-on-set-ns` is nil." + (interactive (list (if inf-clojure-prompt-on-set-ns + (inf-clojure-symprompt "Set ns to" (clojure-find-ns)) + (clojure-find-ns)))) + (when (or (not ns) (equal ns "")) + (user-error "No namespace selected")) (comint-proc-query (inf-clojure-proc) (format inf-clojure-set-ns-command ns))) (defun inf-clojure-apropos (var)