branch: externals/colorful-mode
commit 590c01d33f5cc2ece617767c751781d8a07e9c53
Author: Elías Gabriel Pérez <eg642...@gmail.com>
Commit: Elías Gabriel Pérez <eg642...@gmail.com>

    Add sample configuration and hack for remove colorful at region.
    
    * README.org: Edited.
---
 README.org | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 52 insertions(+), 6 deletions(-)

diff --git a/README.org b/README.org
index a887035f74..c4127ff29f 100644
--- a/README.org
+++ b/README.org
@@ -172,14 +172,60 @@ Once you have it installed you can activate colorful 
locally in your
 buffer with =M-x colorful-mode=, if want enable it globally without
 using hooks then you can do =M-x global-colorful-mode=
 
-Or if you prefer using =use-package= macro:
+* Configuration ⚙️
+
+Example /(Personal)/ configuration for your =init.el=:
+
 #+begin_src emacs-lisp
+(use-package colorful-mode
+  ;; :diminish
+  ;; :ensure t ; Optional
+  :custom
+  (colorful-use-prefix t)
+  (colorful-only-strings 'only-prog)
+  (css-fontify-colors nil)
+  :config
+  (global-colorful-mode t)
+  (add-to-list 'global-colorful-modes 'helpful-mode))
+#+end_src
 
-  (use-package colorful-mode
-    :ensure t ; Optional
-    :hook (prog-mode text-mode)
-    ;; :config (global-colorful-mode) ; Enable it globally
-    ...)
+** Disable colorful in regions
+
+If you want to disable colorful at region this hack may be useful
+for you:
+
+#+begin_src emacs-lisp
+(add-hook 'post-command-hook
+          (lambda ()
+            "delete colorful overlay on active mark"
+            (when-let (colorful-mode
+                       (beg (region-beginning))
+                       (end (region-end)))
+              (if (use-region-p)
+                  (dolist (ov (overlays-in beg end))
+                    (when (overlay-get ov 'colorful--overlay)
+                      (remove-overlays (overlay-start ov) (overlay-end ov)
+                                       'colorful--overlay t)))
+                (save-excursion
+                  (font-lock-fontify-region beg end)))))
+          nil t)
+
+;; or with use-package syntax:
+
+:hook (post-command
+       . (lambda ()
+           "delete colorful overlay on active mark"
+           (when-let (colorful-mode
+                      (beg (region-beginning))
+                      (end (region-end)))
+             (if (use-region-p)
+                 (dolist (ov (overlays-in beg end))
+                   (when (overlay-get ov 'colorful--overlay)
+                     (remove-overlays (overlay-start ov) (overlay-end ov)
+                                      'colorful--overlay t)))
+               (save-excursion
+                 (font-lock-fontify-region beg end)))))
+       nil t)
 
 #+end_src
 

Reply via email to