branch: master commit c125d9fc9e6eeb8ba5a315dd7a061e6b32f17f4d Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com> Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
Reorganize defvars and defcustoms. --- context-coloring.el | 83 ++++++++++++++++++++++++-------------------------- 1 files changed, 40 insertions(+), 43 deletions(-) diff --git a/context-coloring.el b/context-coloring.el index aa9e4ca..5d18157 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -56,54 +56,11 @@ (require 'js2-mode) -;;; Customizable options - -(defcustom context-coloring-delay 0.25 - "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'" - :group 'context-coloring) - -(defcustom context-coloring-comments-and-strings t - "If non-nil, also color comments and strings using `font-lock'." - :group 'context-coloring) - -(defcustom context-coloring-js-block-scopes nil - "If non-nil, also color block scopes in the scope hierarchy in JavaScript. - -The block-scoped `let' and `const' are introduced in ES6. If you -are writing ES6 code, enable this; otherwise, don't. - -Supported modes: `js2-mode'" - :group 'context-coloring) - -(defcustom context-coloring-benchmark-colorization nil - "If non-nil, track how long colorization takes and print -messages with the colorization duration." - :group 'context-coloring) - - ;;; Local variables (defvar-local context-coloring-buffer nil "Reference to this buffer (for timers).") -(defvar-local context-coloring-scopifier-process nil - "Reference to the single scopifier process that can be - running.") - -(defvar-local context-coloring-colorize-idle-timer nil - "Reference to the currently-running idle timer.") - -(defvar-local context-coloring-changed nil - "Indication that the buffer has changed recently, which would -imply that it should be colorized again by -`context-coloring-colorize-idle-timer' if that timer is being -used.") - ;;; Faces @@ -186,6 +143,10 @@ END (exclusive) with the face corresponding to LEVEL." end `(face ,(context-coloring-level-face level)))) +(defcustom context-coloring-comments-and-strings t + "If non-nil, also color comments and strings using `font-lock'." + :group 'context-coloring) + (defsubst context-coloring-maybe-colorize-comments-and-strings () "Colorizes the current buffer's comments and strings if `context-coloring-comments-and-strings' is non-nil." @@ -200,6 +161,15 @@ END (exclusive) with the face corresponding to LEVEL." "Associates `js2-scope' structures and with their scope levels.") +(defcustom context-coloring-js-block-scopes nil + "If non-nil, also color block scopes in the scope hierarchy in JavaScript. + +The block-scoped `let' and `const' are introduced in ES6. If you +are writing ES6 code, enable this; otherwise, don't. + +Supported modes: `js2-mode'" + :group 'context-coloring) + (defsubst context-coloring-js2-scope-level (scope) "Gets the level of SCOPE." (cond ((gethash scope context-coloring-js2-scope-level-hash-table)) @@ -296,6 +266,10 @@ element." (vconcat (mapcar 'string-to-number (split-string (substring input 1 -1) ",")))) +(defvar-local context-coloring-scopifier-process nil + "Reference to the single scopifier process that can be + running.") + (defun context-coloring-kill-scopifier () "Kills the currently-running scopifier process for this buffer." @@ -451,6 +425,11 @@ elisp tracks, and asynchronously for shell command tracks." ;;; Colorization +(defcustom context-coloring-benchmark-colorization nil + "If non-nil, track how long colorization takes and print +messages with the colorization duration." + :group 'context-coloring) + (defun context-coloring-colorize (&optional callback) "Colors the current buffer by function context. @@ -463,6 +442,12 @@ Invokes CALLBACK when complete; see `context-coloring-dispatch'." (message "Colorization took %.3f seconds" (- (float-time) start-time))) (when callback (funcall callback)))))) +(defvar-local context-coloring-changed nil + "Indication that the buffer has changed recently, which would +imply that it should be colorized again by +`context-coloring-colorize-idle-timer' if that timer is being +used.") + (defun context-coloring-change-function (_start _end _length) "Registers a change so that a buffer can be colorized soon." ;; Tokenization is obsolete if there was a change. @@ -829,6 +814,18 @@ faces for custom themes that might not exist yet." ;;; Minor mode +(defvar-local context-coloring-colorize-idle-timer nil + "Reference to the currently-running idle timer.") + +(defcustom context-coloring-delay 0.25 + "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'" + :group 'context-coloring) + ;;;###autoload (define-minor-mode context-coloring-mode "Context-based code coloring, inspired by Douglas Crockford."