;; Test 5 times.
(cond
((= count 5)
- (advice-remove 'context-coloring-colorize advice)
+ (advice-remove #'context-coloring-colorize advice)
(context-coloring-benchmark-log-results
result-file
fixture
:lines (count-lines (point-min) (point-max))
:words (count-words (point-min) (point-max))
:colorization-times colorization-times
- :average-colorization-time (/ (apply '+ colorization-times) 5)))
+ :average-colorization-time (/ (apply #'+ colorization-times) 5)))
(kill-buffer)
(funcall callback))
(t
(setq colorization-start-time (float-time))
- (funcall 'context-coloring-colorize))))))))
- (advice-add 'context-coloring-colorize :around advice)
+ (context-coloring-colorize))))))))
+ (advice-add #'context-coloring-colorize :around advice)
(setq colorization-start-time (float-time))
(find-file fixture)))
(lambda ()
"js-mode"
(lambda ()
"Preparation logic for `js-mode'."
- (add-hook 'js-mode-hook 'context-coloring-mode))
+ (add-hook 'js-mode-hook #'context-coloring-mode))
(lambda ()
"Cleanup logic for `js-mode'."
- (remove-hook 'js-mode-hook 'context-coloring-mode))
+ (remove-hook 'js-mode-hook #'context-coloring-mode))
context-coloring-benchmark-js-fixtures
callback))
(setq js2-mode-show-parse-errors nil)
(setq js2-mode-show-strict-warnings nil)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
- (add-hook 'js2-mode-hook 'context-coloring-mode))
+ (add-hook 'js2-mode-hook #'context-coloring-mode))
(lambda ()
"Cleanup logic for `js2-mode'."
- (remove-hook 'js2-mode-hook 'context-coloring-mode)
+ (remove-hook 'js2-mode-hook #'context-coloring-mode)
(setq auto-mode-alist (delete '("\\.js\\'" . js2-mode)
auto-mode-alist))
(setq js2-mode-show-strict-warnings t)
"emacs-lisp-mode"
(lambda ()
"Preparation logic for `emacs-lisp-mode'."
- (add-hook 'emacs-lisp-mode-hook 'context-coloring-mode))
+ (add-hook 'emacs-lisp-mode-hook #'context-coloring-mode))
(lambda ()
"Cleanup logic for `emacs-lisp-mode'."
- (remove-hook 'emacs-lisp-mode-hook 'context-coloring-mode))
+ (remove-hook 'emacs-lisp-mode-hook #'context-coloring-mode))
context-coloring-benchmark-emacs-lisp-fixtures
callback))
(defun context-coloring-benchmark-run ()
"Benchmark all modes, then exit."
(context-coloring-benchmark-series
- '(context-coloring-benchmark-js-mode-run
- context-coloring-benchmark-js2-mode-run
- context-coloring-benchmark-emacs-lisp-mode-run)
+ (list
+ #'context-coloring-benchmark-js-mode-run
+ #'context-coloring-benchmark-js2-mode-run
+ #'context-coloring-benchmark-emacs-lisp-mode-run)
(lambda ()
(kill-emacs))))
(defun context-coloring-join (strings delimiter)
"Join a list of STRINGS with the string DELIMITER."
- (mapconcat 'identity strings delimiter))
+ (mapconcat #'identity strings delimiter))
(defsubst context-coloring-trim-right (string)
"Remove leading whitespace from STRING."
"Setup idle change detection."
(let ((dispatch (context-coloring-get-dispatch-for-mode major-mode)))
(add-hook
- 'after-change-functions 'context-coloring-change-function nil t)
+ 'after-change-functions #'context-coloring-change-function nil t)
(add-hook
- 'kill-buffer-hook 'context-coloring-teardown-idle-change-detection nil t)
+ '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
+ #'context-coloring-maybe-colorize
(current-buffer)))))
(defun context-coloring-teardown-idle-change-detection ()
(when context-coloring-colorize-idle-timer
(cancel-timer context-coloring-colorize-idle-timer))
(remove-hook
- 'kill-buffer-hook 'context-coloring-teardown-idle-change-detection t)
+ 'kill-buffer-hook #'context-coloring-teardown-idle-change-detection t)
(remove-hook
- 'after-change-functions 'context-coloring-change-function t))
+ 'after-change-functions #'context-coloring-change-function t))
;;; Colorization utilities
(cond
((and context-coloring-syntactic-comments
(not context-coloring-syntactic-strings))
- 'context-coloring-font-lock-syntactic-comment-function)
+ #'context-coloring-font-lock-syntactic-comment-function)
((and context-coloring-syntactic-strings
(not context-coloring-syntactic-comments))
- 'context-coloring-font-lock-syntactic-string-function)
+ #'context-coloring-font-lock-syntactic-string-function)
(t
font-lock-syntactic-face-function))))
(save-excursion
"Color the current buffer using the abstract syntax tree
generated by `js2-mode'."
;; Reset the hash table; the old one could be obsolete.
- (setq context-coloring-js2-scope-level-hash-table (make-hash-table :test 'eq))
+ (setq context-coloring-js2-scope-level-hash-table (make-hash-table :test #'eq))
(setq context-coloring-point-max (point-max))
(with-silent-modifications
(js2-visit-ast
(defsubst context-coloring-exact-or-regexp (words)
"Create a regexp that matches any exact word in WORDS."
(context-coloring-join
- (mapcar 'context-coloring-exact-regexp words) "\\|"))
+ (mapcar #'context-coloring-exact-regexp words) "\\|"))
(defconst context-coloring-elisp-defun-regexp
(context-coloring-exact-or-regexp
the current buffer. Tokens are 3 integers: start, end, level. A
new token occurrs after every 3rd element, and the elements are
separated by commas."
- (let* ((tokens (mapcar 'string-to-number (split-string tokens ","))))
+ (let* ((tokens (mapcar #'string-to-number (split-string tokens ","))))
(while tokens
(context-coloring-colorize-region
(pop tokens)
;;; Dispatch
-(defvar context-coloring-dispatch-hash-table (make-hash-table :test 'eq)
+(defvar context-coloring-dispatch-hash-table (make-hash-table :test #'eq)
"Map dispatch strategy names to their corresponding property
lists, which contain details about the strategies.")
-(defvar context-coloring-mode-hash-table (make-hash-table :test 'eq)
+(defvar context-coloring-mode-hash-table (make-hash-table :test #'eq)
"Map major mode names to dispatch property lists.")
(defun context-coloring-get-dispatch-for-mode (mode)
;;; Themes
-(defvar context-coloring-theme-hash-table (make-hash-table :test 'eq)
+(defvar context-coloring-theme-hash-table (make-hash-table :test #'eq)
"Map theme names to theme properties.")
(defun context-coloring-theme-p (theme)
"Extract a level from a face.")
(defvar context-coloring-originally-set-theme-hash-table
- (make-hash-table :test 'eq)
+ (make-hash-table :test #'eq)
"Cache custom themes who originally set their own
`context-coloring-level-N-face' faces.")
(when (custom-theme-enabled-p theme)
(setq context-coloring-maximum-face (- (length colors) 1)))
(apply
- 'custom-theme-set-faces
+ #'custom-theme-set-faces
theme
(mapcar
(lambda (color)
(context-coloring-define-dispatch
'javascript-js2
:modes '(js2-mode)
- :colorizer 'context-coloring-js2-colorize
+ :colorizer #'context-coloring-js2-colorize
:setup
(lambda ()
- (add-hook 'js2-post-parse-callbacks 'context-coloring-colorize nil t))
+ (add-hook 'js2-post-parse-callbacks #'context-coloring-colorize nil t))
:teardown
(lambda ()
- (remove-hook 'js2-post-parse-callbacks 'context-coloring-colorize t)))
+ (remove-hook 'js2-post-parse-callbacks #'context-coloring-colorize t)))
(context-coloring-define-dispatch
'emacs-lisp
:modes '(emacs-lisp-mode)
- :colorizer 'context-coloring-elisp-colorize
+ :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)
+ :setup #'context-coloring-setup-idle-change-detection
+ :teardown #'context-coloring-teardown-idle-change-detection)
(defun context-coloring-dispatch (&optional callback)
"Determine the optimal track for scopification / coloring of
;; ...but we do use font-lock functions here.
(font-lock-set-defaults)
- ;; Safely change the valye of this function as necessary.
+ ;; Safely change the value of this function as necessary.
(make-local-variable 'font-lock-syntactic-face-function)
(let ((dispatch (context-coloring-get-dispatch-for-mode major-mode)))
(defun context-coloring-coverage-join (strings delimiter)
"Join a list of STRINGS with the string DELIMITER."
- (mapconcat 'identity strings delimiter))
+ (mapconcat #'identity strings delimiter))
(defun context-coloring-coverage-percentage (dividend divisor)
"Get the percentage of DIVIDEND / DIVISOR with precision 2."
"Generate reports for all files in COVERAGE-DATA."
(context-coloring-coverage-join
(mapcar
- 'context-coloring-coverage-format-source-file
+ #'context-coloring-coverage-format-source-file
(cdr (assq 'source_files coverage-data)))
"\n"))
(when ,after-each (apply ,after-each ,args))))))))))))))
(context-coloring-test-define-deftest nil
- :mode 'fundamental-mode
+ :mode #'fundamental-mode
:no-fixture t)
(context-coloring-test-define-deftest async
- :mode 'fundamental-mode
+ :mode #'fundamental-mode
:no-fixture t
:async t)
(context-coloring-test-define-deftest js
- :mode 'js-mode
+ :mode #'js-mode
:extension "js"
:post-colorization t)
(context-coloring-test-define-deftest js2
- :mode 'js2-mode
+ :mode #'js2-mode
:extension "js"
:enable-context-coloring-mode t
:before-each (lambda ()
(context-coloring-test-deftest-js2 ,@args)))
(context-coloring-test-define-deftest emacs-lisp
- :mode 'emacs-lisp-mode
+ :mode #'emacs-lisp-mode
:extension "el"
:enable-context-coloring-mode t)
(context-coloring-test-define-deftest define-theme
- :mode 'fundamental-mode
+ :mode #'fundamental-mode
:no-fixture t
:get-args (lambda ()
(list (context-coloring-test-get-next-theme)))
"but it didn't")
level)))
(setq actual-foreground (face-attribute face :foreground))
- (when (funcall (if negate 'identity 'not)
+ (when (funcall (if negate #'identity #'not)
(string-equal foreground actual-foreground))
(ert-fail (format (concat "Expected face for level `%s' "
"%sto have foreground `%s'; "
"Assert that LEVEL does not have a face with `:foreground'
FOREGROUND. Apply ARGUMENTS to
`context-coloring-test-assert-face', see that function."
- (apply 'context-coloring-test-assert-face
+ (apply #'context-coloring-test-assert-face
(append arguments '(t))))
(defun context-coloring-test-assert-theme-originally-set-p
non-nil."
(let ((theme (context-coloring-test-get-next-theme)))
(put theme 'theme-settings settings)
- (when (funcall (if negate 'identity 'not)
+ (when (funcall (if negate #'identity #'not)
(context-coloring-theme-originally-set-p theme))
(ert-fail (format (concat "Expected theme `%s' with settings `%s' "
"%sto be considered to have defined a level, "
return t for a theme with SETTINGS. Apply ARGUMENTS to
`context-coloring-test-assert-theme-originally-set-p', see that
function."
- (apply 'context-coloring-test-assert-theme-originally-set-p
+ (apply #'context-coloring-test-assert-theme-originally-set-p
(append arguments '(t))))
(context-coloring-test-deftest theme-originally-set-p
"Assert that THEME has the highest level EXPECTED-LEVEL, or the
inverse if NEGATE is non-nil."
(let ((highest-level (context-coloring-theme-highest-level theme)))
- (when (funcall (if negate 'identity 'not) (eq highest-level expected-level))
+ (when (funcall (if negate #'identity #'not) (eq highest-level expected-level))
(ert-fail (format (concat "Expected theme with settings `%s' "
"%sto have a highest level of `%s', "
"but it %s.")
Apply ARGUMENTS to
`context-coloring-test-assert-theme-highest-level', see that
function."
- (apply 'context-coloring-test-assert-theme-highest-level
+ (apply #'context-coloring-test-assert-theme-highest-level
(append arguments '(t))))
(context-coloring-test-deftest theme-highest-level
(defun context-coloring-test-assert-maximum-face (maximum &optional negate)
"Assert that `context-coloring-maximum-face' is MAXIMUM, or the
inverse if NEGATE is non-nil."
- (when (funcall (if negate 'identity 'not)
+ (when (funcall (if negate #'identity #'not)
(eq context-coloring-maximum-face maximum))
(ert-fail (format (concat "Expected `context-coloring-maximum-face' "
"%sto be `%s', "
"Assert that `context-coloring-maximum-face' is not MAXIMUM.
Apply ARGUMENTS to `context-coloring-test-assert-maximum-face',
see that function."
- (apply 'context-coloring-test-assert-maximum-face
+ (apply #'context-coloring-test-assert-maximum-face
(append arguments '(t))))
(context-coloring-test-deftest-define-theme disable-cascade