@@ -575,9 +575,10 @@ run).
575
575
(list cmd)
576
576
(split-string cmd))))
577
577
(message " Starting Clojure REPL via `%s' ... " cmd)
578
- (set-buffer (apply #'make-comint
579
- " inf-clojure" (car cmdlist) nil (cdr cmdlist)))
580
- (inf-clojure-mode)))
578
+ (with-current-buffer (apply #'make-comint
579
+ " inf-clojure" (car cmdlist) nil (cdr cmdlist))
580
+ (inf-clojure-mode)
581
+ (hack-dir-local-variables-non-file-buffer ))))
581
582
(setq inf-clojure-buffer " *inf-clojure*" )
582
583
(if inf-clojure-repl-use-same-window
583
584
(pop-to-buffer-same-window " *inf-clojure*" )
@@ -1124,6 +1125,17 @@ are going to match those."
1124
1125
(length string))
1125
1126
(or (string-match prompt string) (length string))))
1126
1127
1128
+ (defun inf-clojure--get-redirect-buffer ()
1129
+ " Get the redirection buffer, creating it if necessary.
1130
+
1131
+ It is the buffer used for processing REPL responses, see variable
1132
+ \\ [inf-clojure--redirect-buffer-name]."
1133
+ (or (get-buffer inf-clojure--redirect-buffer-name)
1134
+ (let ((buffer (generate-new-buffer inf-clojure--redirect-buffer-name)))
1135
+ (with-current-buffer buffer
1136
+ (hack-dir-local-variables-non-file-buffer )
1137
+ buffer))))
1138
+
1127
1139
; ; Originally from:
1128
1140
; ; https://github.com/glycerine/lush2/blob/master/lush2/etc/lush.el#L287
1129
1141
(defun inf-clojure--process-response (command process &optional beg-regexp end-regexp )
@@ -1134,31 +1146,29 @@ If BEG-REGEXP is nil, the result string will start from (point)
1134
1146
in the results buffer. If END-REGEXP is nil, the result string
1135
1147
will end at (point-max) in the results buffer. It cuts out the
1136
1148
output from and including the `inf-clojure-prompt`."
1137
- (let ((work -buffer inf-clojure--redirect-buffer-name)
1149
+ (let ((redirect -buffer-name inf-clojure--redirect-buffer-name)
1138
1150
(sanitized-command (inf-clojure--sanitize-command command)))
1139
1151
(when (not (string-empty-p sanitized-command))
1140
1152
(inf-clojure--log-string command " ----CMD->" )
1141
- (with-current-buffer (get-buffer-create work-buffer)
1142
- (erase-buffer )
1143
- (comint-redirect-send-command-to-process sanitized-command work-buffer process nil t )
1144
- ; ; Wait for the process to complete
1145
- (set-buffer (process-buffer process))
1146
- (while (and (null comint-redirect-completed)
1147
- (accept-process-output process 1 0 t ))
1148
- (sleep-for 0.01 ))
1149
- ; ; Collect the output
1150
- (set-buffer work-buffer)
1151
- (goto-char (point-min ))
1152
- (let* ((buffer-string (buffer-substring-no-properties (point-min ) (point-max )))
1153
- (boundaries (inf-clojure--string-boundaries buffer-string inf-clojure-prompt beg-regexp end-regexp))
1154
- (beg-pos (car boundaries))
1155
- (end-pos (car (cdr boundaries)))
1156
- (prompt-pos (car (cdr (cdr boundaries))))
1157
- (response-string (substring buffer-string beg-pos (min end-pos prompt-pos))))
1158
- (inf-clojure--log-string buffer-string " <-BUF----" )
1159
- (inf-clojure--log-string boundaries " <-BND----" )
1160
- (inf-clojure--log-string response-string " <-RES----" )
1161
- response-string)))))
1153
+ (set-buffer (inf-clojure--get-redirect-buffer))
1154
+ (erase-buffer )
1155
+ (comint-redirect-send-command-to-process sanitized-command redirect-buffer-name process nil t )
1156
+ ; ; Wait for the process to complete
1157
+ (set-buffer (process-buffer process))
1158
+ (while (and (null comint-redirect-completed)
1159
+ (accept-process-output process 1 0 t ))
1160
+ (sleep-for 0.01 ))
1161
+ ; ; Collect the output
1162
+ (set-buffer redirect-buffer-name)
1163
+ (goto-char (point-min ))
1164
+ (let* ((buffer-string (buffer-substring-no-properties (point-min ) (point-max )))
1165
+ (boundaries (inf-clojure--string-boundaries buffer-string inf-clojure-prompt beg-regexp end-regexp))
1166
+ (beg-pos (car boundaries))
1167
+ (end-pos (car (cdr boundaries)))
1168
+ (prompt-pos (car (cdr (cdr boundaries))))
1169
+ (response-string (substring buffer-string beg-pos (min end-pos prompt-pos))))
1170
+ (inf-clojure--log-string buffer-string " <-RES----" )
1171
+ response-string))))
1162
1172
1163
1173
(defun inf-clojure--nil-string-match-p (string )
1164
1174
" Return true iff STRING is not nil.
0 commit comments