[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master ed870d8 68/79: Refactor minor mode definition.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master ed870d8 68/79: Refactor minor mode definition. |
Date: |
Sun, 14 Jun 2015 00:05:45 +0000 |
branch: master
commit ed870d80914b0102a0739e0418b22f07a8fcb5da
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Refactor minor mode definition.
---
context-coloring.el | 123 ++++++++++++++++++++++++++++++---------------------
1 files changed, 72 insertions(+), 51 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index b36e69a..3329238 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -1713,66 +1713,87 @@ elisp tracks, and asynchronously for shell command
tracks."
;;;###autoload
(define-minor-mode context-coloring-mode
- "Context-based code coloring, inspired by Douglas Crockford."
+ "Toggle contextual code coloring.
+With a prefix argument ARG, enable Context Coloring mode if ARG
+is positive, and disable it otherwise. If called from Lisp,
+enable the mode if ARG is omitted or nil.
+
+Context Coloring mode is a buffer-local minor mode. When
+enabled, code is colored by scope. Scopes are colored
+hierarchically. Variables referenced from nested scopes retain
+the color of their defining scopes. Certain syntax, like
+comments and strings, is still colored with `font-lock'.
+
+The entire buffer is colored initially. Changes to the buffer
+trigger recoloring.
+
+Certain custom themes have predefined colors from their palettes
+to use for coloring. See `context-coloring-theme-hash-table' for
+the supported themes. If the currently-enabled custom theme is
+not among these, you can define colors for it with
+`context-coloring-define-theme', which see.
+
+New language / major mode support can be added with
+`context-coloring-define-dispatch', which see.
+
+Feature inspired by Douglas Crockford."
nil " Context" nil
- (if (not context-coloring-mode)
- (progn
- (let ((dispatch (context-coloring-get-dispatch-for-mode major-mode)))
- (when dispatch
- (let ((command (plist-get dispatch :command))
- (teardown (plist-get dispatch :teardown)))
- (when command
- (context-coloring-teardown-idle-change-detection))
- (when teardown
- (funcall teardown)))))
- (font-lock-mode)
- (jit-lock-mode t))
-
+ (cond
+ (context-coloring-mode
;; Font lock is incompatible with this mode; the converse is also true.
(font-lock-mode 0)
(jit-lock-mode nil)
-
;; ...but we do use font-lock functions here.
(font-lock-set-defaults)
-
;; 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)))
- (if dispatch
- (progn
- (let ((command (plist-get dispatch :command))
- (version (plist-get dispatch :version))
- (executable (plist-get dispatch :executable))
- (setup (plist-get dispatch :setup))
- (colorize-initially-p t))
- (when command
- ;; Shell commands recolor on change, idly.
- (cond
- ((and executable
- (null (executable-find executable)))
- (message "Executable \"%s\" not found" executable)
- (setq colorize-initially-p nil))
- (version
- (context-coloring-check-scopifier-version
- (lambda (sufficient-p)
- (if sufficient-p
- (progn
- (context-coloring-setup-idle-change-detection)
- (context-coloring-colorize))
- (message "Update to the minimum version of \"%s\" (%s)"
- executable version))))
- (setq colorize-initially-p nil))
- (t
- (context-coloring-setup-idle-change-detection))))
- (when setup
- (funcall setup))
- ;; Colorize once initially.
- (when colorize-initially-p
- (let ((context-coloring-parse-interruptable-p nil))
- (context-coloring-colorize)))))
- (when (null dispatch)
- (message "Context coloring is not available for this major
mode"))))))
+ (cond
+ (dispatch
+ (let ((command (plist-get dispatch :command))
+ (version (plist-get dispatch :version))
+ (executable (plist-get dispatch :executable))
+ (setup (plist-get dispatch :setup))
+ (colorize-initially-p t))
+ (when command
+ ;; Shell commands recolor on change, idly.
+ (cond
+ ((and executable
+ (null (executable-find executable)))
+ (message "Executable \"%s\" not found" executable)
+ (setq colorize-initially-p nil))
+ (version
+ (context-coloring-check-scopifier-version
+ (lambda (sufficient-p)
+ (cond
+ (sufficient-p
+ (context-coloring-setup-idle-change-detection)
+ (context-coloring-colorize))
+ (t
+ (message "Update to the minimum version of \"%s\" (%s)"
+ executable version)))))
+ (setq colorize-initially-p nil))
+ (t
+ (context-coloring-setup-idle-change-detection))))
+ (when setup
+ (funcall setup))
+ ;; Colorize once initially.
+ (when colorize-initially-p
+ (let ((context-coloring-parse-interruptable-p nil))
+ (context-coloring-colorize)))))
+ (t
+ (message "Context coloring is not available for this major mode")))))
+ (t
+ (let ((dispatch (context-coloring-get-dispatch-for-mode major-mode)))
+ (when dispatch
+ (let ((command (plist-get dispatch :command))
+ (teardown (plist-get dispatch :teardown)))
+ (when command
+ (context-coloring-teardown-idle-change-detection))
+ (when teardown
+ (funcall teardown)))))
+ (font-lock-mode)
+ (jit-lock-mode t))))
(provide 'context-coloring)
- [elpa] master ec9f04d 64/79: Update emacs lisp support in readme., (continued)
- [elpa] master ec9f04d 64/79: Update emacs lisp support in readme., Jackson Ray Hamilton, 2015/06/13
- [elpa] master d2e08e8 62/79: Improve and test lazy coloring., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 46a9193 65/79: Find the edges of the screen more efficiently., Jackson Ray Hamilton, 2015/06/13
- [elpa] master fd4bc95 66/79: Add dolist support., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 9edc6c3 69/79: Checkdoc cleanup., Jackson Ray Hamilton, 2015/06/13
- [elpa] master e2ceef9 57/79: Prepend function symbols with octothorpes., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 22403b7 61/79: Cover parsing edge cases., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 67576b5 72/79: Skip all insignificant expression prefixes., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 306335e 71/79: Add defadvice support., Jackson Ray Hamilton, 2015/06/13
- [elpa] master acf15ae 70/79: Remove if., Jackson Ray Hamilton, 2015/06/13
- [elpa] master ed870d8 68/79: Refactor minor mode definition.,
Jackson Ray Hamilton <=
- [elpa] master 72a0998 73/79: Add quote and backquote function support., Jackson Ray Hamilton, 2015/06/13
- [elpa] master a4a136c 74/79: Refactor defun / defadvice name handling., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 69ea835 67/79: Refactor elisp parsers using helper functions., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 9b436c0 76/79: Fully recolor later after a fast recolor., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 40f67bf 78/79: Version 6.4.0., Jackson Ray Hamilton, 2015/06/13
- [elpa] master c81eecb 58/79: Update function names and docstrings., Jackson Ray Hamilton, 2015/06/13
- [elpa] master f7c6dcb 75/79: Refactor callee dispatching., Jackson Ray Hamilton, 2015/06/13
- [elpa] master fff08de 36/79: Add elisp benchmarks., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 2d96f10 77/79: Merge branch 'elisp', Jackson Ray Hamilton, 2015/06/13
- [elpa] master e2f402c 79/79: Merge commit '40f67bf039c143758ac070f9693bb0af87b98aba' from context-coloring, Jackson Ray Hamilton, 2015/06/13