diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f231cdc9..bcbaeaf7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### New features +* [#1271](https://github.com/clojure-emacs/cider/issues/1271): New possible value (`always-save`) for `cider-prompt-save-file-on-load`. * [#1197](https://github.com/clojure-emacs/cider/issues/1197): Display some indication that we're waiting for a result for long-running evaluations. * [#1127](https://github.com/clojure-emacs/cider/issues/1127): Make it possible to associate a buffer with a connection (via `cider-assoc-buffer-with-connection`). * [#1217](https://github.com/clojure-emacs/cider/issues/1217): Add new command `cider-assoc-project-with-connection` to associate a project directory with a connection. diff --git a/README.md b/README.md index 02448f2fb..ced78a52f 100644 --- a/README.md +++ b/README.md @@ -429,7 +429,10 @@ Buffer name will look like *cider-repl project-name:port*. the buffer being loaded, if it's modified: ```el +;; Don't prompt and don't save (setq cider-prompt-save-file-on-load nil) +;; Just save without prompting +(setq cider-prompt-save-file-on-load 'always-save) ``` * Change the result prefix for REPL evaluation (by default there's no prefix): diff --git a/cider-interaction.el b/cider-interaction.el index eb181a777..b4d9e1cfc 100644 --- a/cider-interaction.el +++ b/cider-interaction.el @@ -97,8 +97,13 @@ which will use the default REPL connection." :group 'cider) (defcustom cider-prompt-save-file-on-load t - "Controls whether to prompt to save the file when loading a buffer." - :type 'boolean + "Controls whether to prompt to save the file when loading a buffer. +If nil, files are not saved. +If t, the user is prompted to save the file if it's been modified. +If the symbol `always-save', save the file without confirmation." + :type '(choice (const t :tag "Prompt to save the file if it's been modified") + (const nil :tag "Don't save the file") + (const always-save :tag "Save the file without confirmation")) :group 'cider :package-version '(cider . "0.6.0")) @@ -2233,7 +2238,8 @@ The heavy lifting is done by `cider-load-file'." (user-error "Buffer %s is not associated with a file" (buffer-name))) (when (and cider-prompt-save-file-on-load (buffer-modified-p) - (y-or-n-p (format "Save file %s? " buffer-file-name))) + (or (eq cider-prompt-save-file-on-load 'always-save) + (y-or-n-p (format "Save file %s? " buffer-file-name)))) (save-buffer)) (cider-load-file buffer-file-name)))