-
-
Notifications
You must be signed in to change notification settings - Fork 645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “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? Sign in to your account
Have a configuration option, so that cider auto-erases the repl buffer when it becomes too large #2527
Comments
see the patch to enable the auto-erase of the cider repl buffer here; |
A good test case for the patch is the following:
You will see in the Messages, that the buffer gets constantly erased and therefore stays in the limits. The behavior of evaluating very long strings is far improved as well, in my view:
Currently there is no way to prevent emacs blocking on this. (as there is no clojure variable such as print-length-string. |
I experimented as well with an other idea, which is to request user confirmation before inserting large content into the repl. The function for this could then look like this: (defun cider--checked-insert-before-markers (response-string buffer-size)
(message "Currrent cider repl buffer size is: %s "(buffer-size))
(message "Length of string to insert: %s " (length response-string))
(let ((max-response-length 10000)
(max-buferer-size 1000)
(response-length (length response-string))
)
(if (> response-length max-response-length)
(let ((choice (read-multiple-choice (format "Large response (%s). Continue ?" response-length)
'((?y "yes")
(?n "no")
)
)))
(if (string-equal "yes" (second choice))
(progn (if (> buffer-size max-buferer-size)
(progn (message "Buffer grew to large -> erase")
(let ((inhibit-read-only t))
(erase-buffer))
)
)
(insert-before-markers response-string))
)
)
(insert-before-markers response-string)
))) This works well, unless the response data structure is a "shortish vector" but each element is large. |
Maybe a good starting point into this direction would be to expose a new function:
which by default has the same behavior as current code. But the user could implement his own logic easily to decide what to do in case of |
The suggestion is reasonable, but I think the default behaviour should be to just delete old parts of the REPL buffer not clear it completely. The most recent output is usually useful. You also need some handling for huge outputs/results to be directed straight to a dedicated popup buffer IMO. One big output and the REPL is dead even with auto-deletion. (or useless if you delete this before the user can see it) |
In any case, this need to be very configurable, I think. So maybe a good quick start could be to have this function as above, which gets called on each insert into the repl. Then we could easily implement and experiment with more advanced truncation behavior. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding! |
Any plans to implement this? |
Same question. |
It's relative easy to implement this (especially now that one can limit the maximum output a single evaluation can produce), I just never got to doing it. PRs welcome! :-) |
Hi @bbatsov Had some issues with this recently due to heavy logging, first time looking into cider code but I'd like to make a pass at implementing this :) Reading the previous discussion, it seems like we can leave the limiting of individual eval output to
Looking at |
As the REPL buffer is just text we can simply check its size after each evaluation and trim the buffer's beginning by some predefined size. We also have to be careful to respect input boundaries not delete partially some input or its results. |
Enables setting a limit to the buffer size of the REPL buffer (off by default), which when exceeded after printing out a result or other output, will clear old repl output from the beginning to ensure it stays within the limit. When clearing it also ensures partial input or output is erased.
Enables setting a limit to the buffer size of the REPL buffer (off by default), which when exceeded after printing out a result or other output, will clear old repl output from the beginning to ensure it stays within the limit. When clearing it also ensures partial input or output is erased.
Enables setting a limit to the buffer size of the REPL buffer (off by default), which when exceeded after printing out a result or other output, will clear old REPL output from the beginning to ensure it stays within the limit. When clearing it also ensures partial input or output is erased.
The well known problem of emacs/cider's behavior on printing long or complex data structures in the repl
is very frustrating.
There are several efforts on going to solve this on the level of truncating the output automatically, in the nrepl for example.
The latest attempt is this:
nrepl/nrepl#75
From my proper experiments, I think it is not enough to limit this it the nrepl allone.
(as a nrepl solution does not solve the problem, that the repl buffer grows and grows over time, and sometimes it fills too quickly for the user to react)
See the reasoning and a potiental, very simple, solution, based on automatically erasing the
repl buffer here:
nrepl/nrepl#75 (comment)
The proposed solution helps as well for #1115
The text was updated successfully, but these errors were encountered: