Closed liuyinz closed 3 months ago
Hello @liuyinz ,
Is there any methods to make font-lock-add-keywords only take effect in part of current buffer ? I hope colorful-mode disabled in the region so that my multi-cursor willl align on same column, otherwise it appears as follow:
Sorry, i don't think it would be a good idea implement that feature since i find it problematic.
I don't know if the other users that use colorful-mode
agree about integrating this.
However i've made a little hook that you can integrate in your config (i'll documenting in the README file after working on the next release):
(add-hook 'post-command-hook
(defun colorful-delete-color-on-active-mark ()
(when-let (colorful-mode
(beg (region-beginning))
(end (region-end)))
(if mark-active
(dolist (ov (overlays-in beg end))
(when (overlay-get ov 'colorful--overlay)
(colorful--delete-overlay ov)))
(save-excursion
(font-lock-fontify-region beg end)))))
nil t)
Thanks for your advice, my solution for edit-commands meow-grab
as follow:
;; HACK disable colorful-mode in meow-grab command
(with-eval-after-load 'colorful-mode
(defun av/colorful-toggle-on-meow-grab ()
(when (bound-and-true-p colorful-mode)
(when (secondary-selection-exist-p)
(save-excursion
(font-lock-fontify-region (overlay-start mouse-secondary-overlay)
(overlay-end mouse-secondary-overlay))))
(when (region-active-p)
(dolist (ov (overlays-in (region-beginning) (region-end)))
(when (overlay-get ov 'colorful--overlay)
(colorful--delete-overlay ov))))))
(advice-add 'meow-grab :before #'av/colorful-toggle-on-meow-grab))
meow-grab
use secondary-selection overlay for editing.
Thanks for your advice, my solution for edit-commands
meow-grab
as follow:;; HACK disable colorful-mode in meow-grab command (with-eval-after-load 'colorful-mode (defun av/colorful-toggle-on-meow-grab () (when (bound-and-true-p colorful-mode) (when (secondary-selection-exist-p) (save-excursion (font-lock-fontify-region (overlay-start mouse-secondary-overlay) (overlay-end mouse-secondary-overlay)))) (when (region-active-p) (dolist (ov (overlays-in (region-beginning) (region-end))) (when (overlay-get ov 'colorful--overlay) (colorful--delete-overlay ov)))))) (advice-add 'meow-grab :before #'av/colorful-toggle-on-meow-grab))
meow-grab
use secondary-selection overlay for editing.
If your hack works well, then i can close this issue, since i don't use meow
Thanks for your great package ! Is there any methods to make font-lock-add-keywords only take effect in part of current buffer ?
e.g. When I select a region to multi-line edit, I hope colorful-mode disabled in the region so that my multi-cursor willl align on same column, otherwise it appears as follow: