@@ -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*" )
@@ -1108,6 +1109,17 @@ are going to match those."
1108
1109
(length string))
1109
1110
(or (string-match prompt string) (length string))))
1110
1111
1112
+ (defun inf-clojure--get-redirect-buffer ()
1113
+ " Get the redirection buffer, creating it if necessary.
1114
+
1115
+ It is the buffer used for processing REPL responses, see variable
1116
+ \\ [inf-clojure--redirect-buffer-name]."
1117
+ (or (get-buffer inf-clojure--redirect-buffer-name)
1118
+ (let ((buffer (generate-new-buffer inf-clojure--redirect-buffer-name)))
1119
+ (with-current-buffer buffer
1120
+ (hack-dir-local-variables-non-file-buffer )
1121
+ buffer))))
1122
+
1111
1123
; ; Originally from:
1112
1124
; ; https://github.com/glycerine/lush2/blob/master/lush2/etc/lush.el#L287
1113
1125
(defun inf-clojure--process-response (command process &optional beg-regexp end-regexp )
@@ -1118,31 +1130,29 @@ If BEG-REGEXP is nil, the result string will start from (point)
1118
1130
in the results buffer. If END-REGEXP is nil, the result string
1119
1131
will end at (point-max) in the results buffer. It cuts out the
1120
1132
output from and including the `inf-clojure-prompt`."
1121
- (let ((work -buffer inf-clojure--redirect-buffer-name)
1133
+ (let ((redirect -buffer-name inf-clojure--redirect-buffer-name)
1122
1134
(sanitized-command (inf-clojure--sanitize-command command)))
1123
1135
(when (not (string-empty-p sanitized-command))
1124
1136
(inf-clojure--log-string command " ----CMD->" )
1125
- (with-current-buffer (get-buffer-create work-buffer)
1126
- (erase-buffer )
1127
- (comint-redirect-send-command-to-process sanitized-command work-buffer process nil t )
1128
- ; ; Wait for the process to complete
1129
- (set-buffer (process-buffer process))
1130
- (while (and (null comint-redirect-completed)
1131
- (accept-process-output process 1 0 t ))
1132
- (sleep-for 0.01 ))
1133
- ; ; Collect the output
1134
- (set-buffer work-buffer)
1135
- (goto-char (point-min ))
1136
- (let* ((buffer-string (buffer-substring-no-properties (point-min ) (point-max )))
1137
- (boundaries (inf-clojure--string-boundaries buffer-string inf-clojure-prompt beg-regexp end-regexp))
1138
- (beg-pos (car boundaries))
1139
- (end-pos (car (cdr boundaries)))
1140
- (prompt-pos (car (cdr (cdr boundaries))))
1141
- (response-string (substring buffer-string beg-pos (min end-pos prompt-pos))))
1142
- (inf-clojure--log-string buffer-string " <-BUF----" )
1143
- (inf-clojure--log-string boundaries " <-BND----" )
1144
- (inf-clojure--log-string response-string " <-RES----" )
1145
- response-string)))))
1137
+ (set-buffer (inf-clojure--get-redirect-buffer))
1138
+ (erase-buffer )
1139
+ (comint-redirect-send-command-to-process sanitized-command redirect-buffer-name process nil t )
1140
+ ; ; Wait for the process to complete
1141
+ (set-buffer (process-buffer process))
1142
+ (while (and (null comint-redirect-completed)
1143
+ (accept-process-output process 1 0 t ))
1144
+ (sleep-for 0.01 ))
1145
+ ; ; Collect the output
1146
+ (set-buffer redirect-buffer-name)
1147
+ (goto-char (point-min ))
1148
+ (let* ((buffer-string (buffer-substring-no-properties (point-min ) (point-max )))
1149
+ (boundaries (inf-clojure--string-boundaries buffer-string inf-clojure-prompt beg-regexp end-regexp))
1150
+ (beg-pos (car boundaries))
1151
+ (end-pos (car (cdr boundaries)))
1152
+ (prompt-pos (car (cdr (cdr boundaries))))
1153
+ (response-string (substring buffer-string beg-pos (min end-pos prompt-pos))))
1154
+ (inf-clojure--log-string response-string " <-RES----" )
1155
+ response-string))))
1146
1156
1147
1157
(defun inf-clojure--nil-string-match-p (string )
1148
1158
" Return true iff STRING is not nil.
0 commit comments