@@ -305,27 +305,29 @@ It requires a REPL PROC for inspecting the correct type."
305
305
(setq-local inf-clojure-repl-type repl-type))
306
306
inf-clojure-repl-type))
307
307
308
- (defun inf-clojure--single-linify (string )
308
+ (defun inf-clojure--whole-comment-line-p (string )
309
+ " Return true iff STRING is a whole line semicolon comment."
310
+ (string-match-p " ^\s *;" string))
311
+
312
+ (defun inf-clojure--make-single-line (string )
309
313
" Convert a multi-line STRING in a single-line STRING.
310
- It also reduces redundant whitespace for readability."
311
- (thread-last string
312
- (replace-regexp-in-string " [ \\ |\n ]+" " " )
313
- (replace-regexp-in-string " $" " " )))
314
-
315
- (defun inf-clojure--trim-newline-right (string )
316
- " Trim newlines (only) in STRING."
317
- (if (string-match " \n +\\ '" string)
318
- (replace-match " " t t string)
319
- string))
314
+ It also reduces redundant whitespace for readability and removes
315
+ comments."
316
+ (let* ((lines (seq-filter (lambda (s ) (not (inf-clojure--whole-comment-line-p s)))
317
+ (split-string string " [\r\n ]" t ))))
318
+ (mapconcat (lambda (s )
319
+ (if (not (string-match-p " ;" s))
320
+ (replace-regexp-in-string " \s +" " " s)
321
+ (concat s " \n " )))
322
+ lines " " )))
320
323
321
324
(defun inf-clojure--sanitize-command (command )
322
325
" Sanitize COMMAND for sending it to a process.
323
326
An example of things that this function does is to add a final
324
327
newline at the end of the form. Return an empty string if the
325
328
sanitized command is empty."
326
- (let* ((linified (inf-clojure--single-linify command))
327
- (sanitized (inf-clojure--trim-newline-right linified)))
328
- (if (or (string-blank-p linified) (string-blank-p sanitized))
329
+ (let ((sanitized (inf-clojure--make-single-line command)))
330
+ (if (string-blank-p sanitized)
329
331
" "
330
332
(concat sanitized " \n " ))))
331
333
0 commit comments