Skip to content

Commit 24463b4

Browse files
committed
[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.
1 parent 1d6260a commit 24463b4

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
### Changes
1717

1818
* Display the REPL in a different window by default (it used to be displayed in the current window).
19+
* [#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).
1920

2021
### Bugs Fixed
2122

inf-clojure.el

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -466,17 +466,22 @@ Used by this command to determine defaults."
466466
:type '(repeat symbol)
467467
:group 'inf-clojure)
468468

469-
(defun inf-clojure-load-file (file-name)
470-
"Load a Clojure file FILE-NAME into the inferior Clojure process."
471-
(interactive (comint-get-source "Load Clojure file: " inf-clojure-prev-l/c-dir/file
472-
inf-clojure-source-modes nil)) ; nil because LOAD
473-
; doesn't need an exact name
474-
(comint-check-source file-name) ; Check to see if buffer needs saved.
475-
(setq inf-clojure-prev-l/c-dir/file (cons (file-name-directory file-name)
476-
(file-name-nondirectory file-name)))
477-
(comint-send-string (inf-clojure-proc)
478-
(format inf-clojure-load-command file-name))
479-
(inf-clojure-switch-to-repl t))
469+
(defun inf-clojure-load-file (&optional switch-to-repl file-name)
470+
"Load a Clojure file FILE-NAME into the inferior Clojure process.
471+
472+
The prefix argument SWITCH-TO-REPL controls whether to switch to REPL after the file is loaded or not."
473+
(interactive "P")
474+
(let ((file-name (or file-name
475+
(car (comint-get-source "Load Clojure file: " inf-clojure-prev-l/c-dir/file
476+
;; nil because doesn't need an exact name
477+
inf-clojure-source-modes nil)))))
478+
(comint-check-source file-name) ; Check to see if buffer needs saved.
479+
(setq inf-clojure-prev-l/c-dir/file (cons (file-name-directory file-name)
480+
(file-name-nondirectory file-name)))
481+
(comint-send-string (inf-clojure-proc)
482+
(format inf-clojure-load-command file-name))
483+
(when switch-to-repl
484+
(inf-clojure-switch-to-repl t))))
480485

481486
(defun inf-clojure-connected-p ()
482487
"Return t if inferior Clojure is currently connected, nil otherwise."

0 commit comments

Comments
 (0)