Skip to content

Fix #89 and speed #93

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* [#79](https://github.com/clojure-emacs/inf-clojure/pull/82): Eldoc error when running boot repl.
* [#83](https://github.com/clojure-emacs/inf-clojure/pull/85): No such namespace: complete.core in lumo REPL.
* [#93](https://github.com/clojure-emacs/inf-clojure/pull/93): Slow response from inf-clojure (completions, arglists, ...).

## 2.0.1 (2017-05-18)

Expand Down
17 changes: 10 additions & 7 deletions inf-clojure.el
Original file line number Diff line number Diff line change
Expand Up @@ -958,14 +958,16 @@ Inf-Clojure will create a log file in the project folder named
`inf-clojure--log-file-name' and dump the process activity in it
in case this is not nil." )

(defun inf-clojure--log-string (string &optional type)
(defun inf-clojure--log-string (string &optional tag)
"Log STRING to file, according to `inf-clojure-log-response'.
The optional TYPE will be converted to string and printed before
STRING if present."
(when inf-clojure-log-activity
(write-region (concat "\n"
(when type
(concat (prin1-to-string type) " | "))
(when tag
(if (stringp tag)
(concat tag "\n")
(concat (prin1-to-string tag) "\n")))
(let ((print-escape-newlines t))
(prin1-to-string string)))
nil
Expand All @@ -984,7 +986,7 @@ string will start from (point) in the results buffer. If
END-STRING is nil, the result string will end at (point-max) in
the results buffer. It cuts out the output from and including
the `inf-clojure-prompt`."
(inf-clojure--log-string command :cmd)
(inf-clojure--log-string command "----CMD->")
(let ((work-buffer inf-clojure--redirect-buffer-name))
(save-excursion
(set-buffer (get-buffer-create work-buffer))
Expand All @@ -993,8 +995,9 @@ the `inf-clojure-prompt`."
(inf-clojure--sanitize-command command) work-buffer process nil t)
;; Wait for the process to complete
(set-buffer (process-buffer process))
(while (null comint-redirect-completed)
(accept-process-output nil 1))
(while (and (null comint-redirect-completed)
(accept-process-output process 1 0 t))
(sleep-for 0.01))
;; Collect the output
(set-buffer work-buffer)
(goto-char (point-min))
Expand All @@ -1007,7 +1010,7 @@ the `inf-clojure-prompt`."
(prompt (when (search-forward inf-clojure-prompt nil t)
(match-beginning 0)))
(buffer-string (buffer-substring-no-properties beg (or prompt end))))
(inf-clojure--log-string buffer-string :res)
(inf-clojure--log-string buffer-string "<-RES----")
buffer-string))))

(defun inf-clojure--nil-string-match-p (string)
Expand Down