emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 4bd7fc7 56/79: Make delays configurable at the dispatch le


From: Jackson Ray Hamilton
Subject: [elpa] master 4bd7fc7 56/79: Make delays configurable at the dispatch level.
Date: Sun, 14 Jun 2015 00:05:40 +0000

branch: master
commit 4bd7fc798b0c89df25aad921e898348d3b60d6b1
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    Make delays configurable at the dispatch level.
---
 README.md           |    4 ++--
 context-coloring.el |   37 ++++++++++++++++++++++++-------------
 2 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/README.md b/README.md
index 4643cad..a180a17 100644
--- a/README.md
+++ b/README.md
@@ -85,8 +85,8 @@ Add the following to your init file:
   comments using `font-lock`.
 - `context-coloring-syntactic-strings` (default: `t`): If non-nil, also color
   strings using `font-lock`.
-- `context-coloring-delay` (default: `0.25`; supported modes: `js-mode`,
-  `js3-mode`, `emacs-lisp-mode`): Delay between a buffer update and
+- `context-coloring-default-delay` (default: `0.25`; supported modes: 
`js-mode`,
+  `js3-mode`): Default (sometimes overridden) delay between a buffer update and
   colorization.
 - `context-coloring-js-block-scopes` (default: `nil`; supported modes:
   `js2-mode`): If non-nil, also color block scopes in the scope hierarchy in
diff --git a/context-coloring.el b/context-coloring.el
index ec7ab7a..a343292 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -159,27 +159,34 @@ used.")
 (defvar-local context-coloring-colorize-idle-timer nil
   "The currently-running idle timer.")
 
-(defcustom context-coloring-delay 0.25
-  "Delay between a buffer update and colorization.
+(defcustom context-coloring-default-delay 0.25
+  "Default (sometimes overridden) delay between a buffer update
+and colorization.
 
 Increase this if your machine is high-performing.  Decrease it if
 it ain't.
 
-Supported modes: `js-mode', `js3-mode', `emacs-lisp-mode'"
+Supported modes: `js-mode', `js3-mode'"
   :group 'context-coloring)
 
+(make-obsolete-variable
+ 'context-coloring-delay
+ 'context-coloring-default-delay
+ "6.4.0")
+
 (defun context-coloring-setup-idle-change-detection ()
   "Setup idle change detection."
-  (add-hook
-   'after-change-functions 'context-coloring-change-function nil t)
-  (add-hook
-   'kill-buffer-hook 'context-coloring-teardown-idle-change-detection nil t)
-  (setq context-coloring-colorize-idle-timer
-        (run-with-idle-timer
-         context-coloring-delay
-         t
-         'context-coloring-maybe-colorize
-         (current-buffer))))
+  (let ((dispatch (context-coloring-get-dispatch-for-mode major-mode)))
+    (add-hook
+     'after-change-functions 'context-coloring-change-function nil t)
+    (add-hook
+     'kill-buffer-hook 'context-coloring-teardown-idle-change-detection nil t)
+    (setq context-coloring-colorize-idle-timer
+          (run-with-idle-timer
+           (or (plist-get dispatch :delay) context-coloring-default-delay)
+           t
+           'context-coloring-maybe-colorize
+           (current-buffer)))))
 
 (defun context-coloring-teardown-idle-change-detection ()
   "Teardown idle change detection."
@@ -1128,6 +1135,9 @@ level data returned via stdout.
 
 `:port' - Port number of the scopifier server, e.g. 80, 1337.
 
+`:delay' - Delay between buffer update and colorization, to
+override `context-coloring-default-delay'.
+
 `:version' - Minimum required version that should be printed when
 executing `:command' with a \"--version\" flag.  The version
 should be numeric, e.g. \"2\", \"19700101\", \"1.2.3\",
@@ -1588,6 +1598,7 @@ precedence, i.e. the car of `custom-enabled-themes'."
  'emacs-lisp
  :modes '(emacs-lisp-mode)
  :colorizer 'context-coloring-elisp-colorize
+ :delay 0.016 ;; Thanks to lazy colorization this can be 60 frames per second.
  :setup 'context-coloring-setup-idle-change-detection
  :teardown 'context-coloring-teardown-idle-change-detection)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]