Skip to content

Instantly share code, notes, and snippets.

@behrica
Last active November 22, 2018 14:37
Show Gist options
  • Save behrica/387e5838d8f933f6eb239f27b17577fc to your computer and use it in GitHub Desktop.
Save behrica/387e5838d8f933f6eb239f27b17577fc to your computer and use it in GitHub Desktop.
cider-nrepl-auto-erase patch
--- a/cider-repl.el
+++ b/cider-repl.el
@@ -396,6 +396,21 @@ client process connection. Unless NO-BANNER is non-nil, insert a banner."
;;; REPL interaction
+(defun cider--checked-insert-before-markers (string)
+
+ (message "Currrent cider repl buffer size is: %s "(buffer-size))
+ (message "Length of string to insert: %s " (length string))
+ (if (> (buffer-size) 100000)
+ (progn (message "Buffer grew to large -> erase")
+
+ (let ((inhibit-read-only t))
+ (erase-buffer))
+ )
+ )
+
+ (insert-before-markers string)
+ )
+
(defun cider-repl--in-input-area-p ()
"Return t if in input area."
(<= cider-repl-input-start-mark (point)))
@@ -666,7 +681,7 @@ If BOL is non-nil insert at the beginning of line. Run
'font-lock-face output-face
'rear-nonsticky '(font-lock-face)))
(setq string (cider-run-chained-hook 'cider-repl-preoutput-hook string))
- (insert-before-markers string)
+ (cider--checked-insert-before-markers string)
(cider-repl--flush-ansi-color-context)
(when (and (= (point) cider-repl-prompt-start-mark)
(not (bolp)))
@@ -726,10 +741,10 @@ of the line. If BOL is non-nil insert at the beginning of the line."
(when show-prefix
(insert-before-markers (propertize cider-repl-result-prefix 'font-lock-face 'font-lock-comment-face)))
(if cider-repl-use-clojure-font-lock
- (insert-before-markers (cider-font-lock-as-clojure string))
+ (cider--checked-insert-before-markers (cider-font-lock-as-clojure string))
(cider-propertize-region
'(font-lock-face cider-repl-result-face rear-nonsticky (font-lock-face))
- (insert-before-markers string))))))
+ (cider--checked-insert-before-markers string))))))
(cider-repl--show-maximum-output)))
(defun cider-repl-newline-and-indent ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment