PythonNut / quark-emacs

:rocket: An incredible wonderland of code
MIT License
137 stars 6 forks source link

font-locking is slow #142

Open PythonNut opened 3 years ago

PythonNut commented 3 years ago

Scrolling tends to lock up. There is evidence that this slowness is caused by

Here is a very dubious piece of code to disable rainbow-delimiters mode JIT.

(defvar quark/rainbow-delimiters-temp-disabled nil)

(defun quark/temp-disable-rainbow-delimiters (_window _pos)
  (unless quark/rainbow-delimiters-temp-disabled
    ;; (font-lock-flush)
    (font-lock-remove-keywords nil rainbow-delimiters--font-lock-keywords)
    (setq quark/rainbow-delimiters-temp-disabled t)))

(defun quark/temp-enable-rainbow-delimiters ()
  (when quark/rainbow-delimiters-temp-disabled
    (font-lock-flush)
    (font-lock-add-keywords nil rainbow-delimiters--font-lock-keywords 'append)
    (setq quark/rainbow-delimiters-temp-disabled nil)))

(add-hook 'window-scroll-functions #'quark/temp-disable-rainbow-delimiters)
(run-with-idle-timer 0.05 t #'quark/temp-enable-rainbow-delimiters)