Commits

Peter Szilagyi committed ae64cba

Per jli, only enable rainbow-delimiters-mode in scheme-mode and lisp-mode.

Comments (0)

Files changed (1)

js-micro-features.el

 (defun Jane.rainbow-delimiters ()
   "Color delimiters based on depth, including first atom in sexps.
 
-\\[global-rainbow-delimiters-mode] observes
-`rainbow-delimiters-maximum-size' for individual buffers, but you
-can manually override per buffer with
-\\[rainbow-delimiters-mode].
-
-Because we stick with the Emacs Lisp source, rather than
-compiling, `rainbow-delimiters-mode' is slow, especially when
-disabling in large buffers."
-  ;; pszilagyi: In fact, I turned bharrison's first guess at a limit
-  ;; (10MB) down quite a bit, just in case.
-  (load-library
-   ;;"elisp/contrib/rainbow-delimiters.el"
-   "elisp/contrib/rainbow-sexp.el"      ; jli
-   )
-  (defcustom rainbow-delimiters-maximum-size 1e6
-    "Maximum size of a buffer for `global-rainbow-delimiters-mode'.")
-  ;; pszilagyi: Use advice so we can switch back and forth to the
-  ;; stock distribution without applying patches.  It's not that bad.
-  (defadvice rainbow-delimiters-mode-enable (around maximum-size activate)
-    "Skip buffers larger than `rainbow-delimiters-maximum-size'."
-    (if (<= (buffer-size) rainbow-delimiters-maximum-size) ad-do-it))
-
-  ;; Another approach, taken by jli below in his customizations, is to
-  ;; only use rainbow-delimiters-mode in conjunction with lisp-mode.
+\\[Jane.rainbow-delimiters-mode] observes
+`Jane.rainbow-delimiters-maximum-size' for individual buffers,
+but you can manually override per buffer with
+\\[rainbow-delimiters-mode]."
+  ;; Because we stick with the Emacs Lisp source, rather than
+  ;; compiling, `rainbow-delimiters-mode' is slow, especially when
+  ;; disabling in large buffers.
+  ;;
+  ;; pszilagyi: In fact, I turned bharrison's first suggestion for a
+  ;; limit (10MB) down quite a bit.
+  (defcustom Jane.rainbow-delimiters-maximum-size 1e6
+    "Maximum size of a buffer for `Jane.rainbow-delimiters-mode'.")
+  ;; Actually, we could just have made lisp-mode-hook and
+  ;; scheme-mode-hook conditional, like the mody of
+  ;; Jane.rainbow-delimiters-mode.  Then we still could have
+  ;; overridden the default with \[rainbow-delimiter-mode].
+  (define-minor-mode Jane.rainbow-delimiters-mode
+    "Implement `rainbow-delimiters-mode' modulo `Jane.rainbow-delimiters-maximum-size'."
+    nil nil nil
+    (if (<= (buffer-size) Jane.rainbow-delimiters-maximum-size)
+        (rainbow-delimiters-mode 1)))
   ;;(require 'rainbow-delimiters)
+  ;;(load "elisp/contrib/rainbow-delimiters")
+  (load "elisp/contrib/rainbow-sexp")   ; jli's modified version
   (custom-set-variables
    '(rainbow-delimiters-highlight-first-term-p t))
   (custom-set-faces
    '(rainbow-delimiters-depth-8-face ((((background dark)) (:foreground "#e091b1"))))
    '(rainbow-delimiters-depth-9-face ((((background dark)) (:foreground "#e0217f"))))
    '(rainbow-delimiters-unmatched-face ((((background dark)) (:foreground "red")))))
-  ;;(add-hook 'lisp-mode-hook 'rainbow-delimiters-mode)
-
-  (global-rainbow-delimiters-mode 1))
+  (add-hook 'lisp-mode-hook (lambda () (Jane.rainbow-delimiters-mode 1)))
+  (add-hook 'scheme-mode-hook (lambda () (Jane.rainbow-delimiters-mode 1))))
 
 ;; (Jane.recentf)
 (defun Jane.recentf ()