Skip to content

Commit dda0a43

Browse files
arichiardibbatsov
authored andcommitted
Fix newline append on eval functions
A fix was necessary for a regression caused by the fact that now `inf-clojure--send-string` adds a newline at the end of the string it sends to the process.
1 parent ce0510b commit dda0a43

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

inf-clojure.el

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,16 @@ It requires a REPL PROC for inspecting the correct type."
216216

217217
(defun inf-clojure--send-string (proc string)
218218
"A custom `comint-input-sender` / `comint-send-string`.
219-
Perform the required side effects on every send for PROC and
219+
It performs the required side effects on every send for PROC and
220220
STRING (for example set the buffer local REPL type). It should
221-
be used instead of `comint-send-string`."
221+
always be preferred over `comint-send-string`. It delegates to
222+
`comint-simple-send` so it always appends a newline at the end of
223+
the string for evaluation. Refer to `comint-simple-send` for
224+
customizations. "
222225
(inf-clojure--set-repl-type proc)
223226
(comint-simple-send proc string))
224227

225-
(defcustom inf-clojure-load-form "(clojure.core/load-file \"%s\")\n"
228+
(defcustom inf-clojure-load-form "(clojure.core/load-file \"%s\")"
226229
"Format-string for building a Clojure expression to load a file.
227230
This format string should use `%s' to substitute a file name and
228231
should result in a Clojure form that will be sent to the inferior
@@ -458,17 +461,16 @@ of `inf-clojure-*-cmd'). Runs the hooks from
458461
"Send the current region to the inferior Clojure process.
459462
Prefix argument AND-GO means switch to the Clojure buffer afterwards."
460463
(interactive "r\nP")
461-
;; replace multiple newlines at the end of the region by a single one
462-
;; or add one if there was no newline
464+
;; drops newlines at the end of the region
463465
(let ((str (replace-regexp-in-string
464-
"[\n]*\\'" "\n"
466+
"[\n]+\\'" ""
465467
(buffer-substring-no-properties start end))))
466468
(inf-clojure--send-string (inf-clojure-proc) str))
467-
(if and-go (inf-clojure-switch-to-repl t)))
469+
(when and-go (inf-clojure-switch-to-repl t)))
468470

469471
(defun inf-clojure-eval-string (code)
470472
"Send the string CODE to the inferior Clojure process to be executed."
471-
(inf-clojure--send-string (inf-clojure-proc) (concat code "\n")))
473+
(inf-clojure--send-string (inf-clojure-proc) code))
472474

473475
(defun inf-clojure-eval-defun (&optional and-go)
474476
"Send the current defun to the inferior Clojure process.

0 commit comments

Comments
 (0)