diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f92da69f..282345db7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ * [#1164](https://github.com/clojure-emacs/cider/pull/1164): Fix an error in `cider-browse-ns--doc-at-point`. * [#1189](https://github.com/clojure-emacs/cider/issues/1189): Don't show result from automatic ns form evaluation. +* [#1079](https://github.com/clojure-emacs/cider/issues/1079): Don't try to font-lock very long results. The maximum font-lockable result length is controlled by `cider-font-lock-max-length`. ## 0.9.1 / 2015-06-24 diff --git a/cider-util.el b/cider-util.el index 429e67977..8e7c0b3b7 100644 --- a/cider-util.el +++ b/cider-util.el @@ -34,6 +34,9 @@ (require 'cl-lib) (require 'clojure-mode) +(defconst cider-font-lock-max-length 10000 + "The max length of strings to fontify in `cider-font-lock-as'.") + (defun cider-util--hash-keys (hashtable) "Return a list of keys in HASHTABLE." (let ((keys '())) @@ -83,15 +86,17 @@ PROP is the name of a text property." (defun cider-font-lock-as (mode string) "Use MODE to font-lock the STRING." - (with-temp-buffer - (insert string) - ;; suppress major mode hooks as we care only about their font-locking - ;; otherwise modes like whitespace-mode and paredit might interfere - (setq-local delay-mode-hooks t) - (setq delayed-mode-hooks nil) - (funcall mode) - (font-lock-ensure) - (buffer-string))) + (if (< (length string) cider-font-lock-max-length) + (with-temp-buffer + (insert string) + ;; suppress major mode hooks as we care only about their font-locking + ;; otherwise modes like whitespace-mode and paredit might interfere + (setq-local delay-mode-hooks t) + (setq delayed-mode-hooks nil) + (funcall mode) + (font-lock-ensure) + (buffer-string)) + string)) (defun cider-font-lock-region-as (mode beg end &optional buffer) "Use MODE to font-lock text between BEG and END.