branch: elpa/inf-clojure commit 24463b4b6901cb1fa381086320408e1942fd5ca3 Author: Bozhidar Batsov <bozhi...@batsov.com> Commit: Bozhidar Batsov <bozhi...@batsov.com>
[Fix #26] Make switching to the REPL optional on `inf-clojure-load-file' After this change the command doesn't switch to the REPL by default - it does so only when invoked with a prefix argument. --- CHANGELOG.md | 1 + inf-clojure.el | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b537dab..c72e1a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ ### Changes * Display the REPL in a different window by default (it used to be displayed in the current window). +* [#26](https://github.com/clojure-emacs/inf-clojure/issues/26): Make switching to the REPL optional on `inf-clojure-load-file` (it's now controlled via a prefix argument). ### Bugs Fixed diff --git a/inf-clojure.el b/inf-clojure.el index fd4634d..eb512b0 100644 --- a/inf-clojure.el +++ b/inf-clojure.el @@ -466,17 +466,22 @@ Used by this command to determine defaults." :type '(repeat symbol) :group 'inf-clojure) -(defun inf-clojure-load-file (file-name) - "Load a Clojure file FILE-NAME into the inferior Clojure process." - (interactive (comint-get-source "Load Clojure file: " inf-clojure-prev-l/c-dir/file - inf-clojure-source-modes nil)) ; nil because LOAD - ; doesn't need an exact name - (comint-check-source file-name) ; Check to see if buffer needs saved. - (setq inf-clojure-prev-l/c-dir/file (cons (file-name-directory file-name) - (file-name-nondirectory file-name))) - (comint-send-string (inf-clojure-proc) - (format inf-clojure-load-command file-name)) - (inf-clojure-switch-to-repl t)) +(defun inf-clojure-load-file (&optional switch-to-repl file-name) + "Load a Clojure file FILE-NAME into the inferior Clojure process. + +The prefix argument SWITCH-TO-REPL controls whether to switch to REPL after the file is loaded or not." + (interactive "P") + (let ((file-name (or file-name + (car (comint-get-source "Load Clojure file: " inf-clojure-prev-l/c-dir/file + ;; nil because doesn't need an exact name + inf-clojure-source-modes nil))))) + (comint-check-source file-name) ; Check to see if buffer needs saved. + (setq inf-clojure-prev-l/c-dir/file (cons (file-name-directory file-name) + (file-name-nondirectory file-name))) + (comint-send-string (inf-clojure-proc) + (format inf-clojure-load-command file-name)) + (when switch-to-repl + (inf-clojure-switch-to-repl t)))) (defun inf-clojure-connected-p () "Return t if inferior Clojure is currently connected, nil otherwise."