disabling global-hl-mode in visual-mode
Hey I want to disable global-hl-line-mode in visual mode, but adding global-hl-mode to vimpulse-visual-local-vars didn't help. Any ideas? (latest git version of vimpulse) Regards Tom
Hi Thomas, One approach is to use the provided hooks to toggle it on and off when visual mode is entered / left. viper vi-mode is entered again when vimpulse visual mode is left. (setq vimtest-var 0) (defun vimtest () (interactive) (setq vimtest-var (+ 1 vimtest-var))) (defun vimtest-deactivate () (interactive) (setq vimtest-var (- vimtest-var 1))) (add-hook 'vimpulse-visual-state-hook 'vimtest) (add-hook 'viper-vi-state-hook 'vimtest-deactivate) Tim On Jun 17, 2011, at 11:08 , Thomas Hisch wrote:
Hey
I want to disable global-hl-line-mode in visual mode, but adding global-hl-mode to vimpulse-visual-local-vars didn't help.
Any ideas?
(latest git version of vimpulse)
Regards Tom _______________________________________________ implementations-list mailing list [email protected] https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
Thx for the example, but it does't work as expected, just consider multiple buffers, vi state hook is also executed when i switch for example from emacs state to vi state,.. All this leads to negative values of vimtest-var. I thought of using vimpulse-visual-local-vars because, when looking at its definition I looks like exactly what I want: (viper-deflocalvar vimpulse-visual-local-vars '(cua-mode mark-active transient-mark-mode zmacs-regions) "System variables that are reset for each Visual session.") Or am I wrong ? Regards Thomas On Fri, Jun 17, 2011 at 7:35 PM, Tim Harper <[email protected]> wrote:
Hi Thomas,
One approach is to use the provided hooks to toggle it on and off when visual mode is entered / left. viper vi-mode is entered again when vimpulse visual mode is left.
(setq vimtest-var 0) (defun vimtest () (interactive) (setq vimtest-var (+ 1 vimtest-var)))
(defun vimtest-deactivate () (interactive) (setq vimtest-var (- vimtest-var 1)))
(add-hook 'vimpulse-visual-state-hook 'vimtest) (add-hook 'viper-vi-state-hook 'vimtest-deactivate)
Tim
On Jun 17, 2011, at 11:08 , Thomas Hisch wrote:
Hey
I want to disable global-hl-line-mode in visual mode, but adding global-hl-mode to vimpulse-visual-local-vars didn't help.
Any ideas?
(latest git version of vimpulse)
Regards Tom _______________________________________________ implementations-list mailing list [email protected]
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
_______________________________________________ implementations-list mailing list [email protected] https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
On Jun 17, 2011, at 12:05 , Thomas Hisch wrote:
Thx for the example, but it does't work as expected, just consider multiple buffers, vi state hook is also executed when i switch for example from emacs state to vi state,.. All this leads to negative values of vimtest-var.
I thought of using vimpulse-visual-local-vars because, when looking at its definition I looks like exactly what I want:
(viper-deflocalvar vimpulse-visual-local-vars '(cua-mode mark-active transient-mark-mode zmacs-regions) "System variables that are reset for each Visual session.")
Or am I wrong ?
Well aware of vi-state-hooks behavior. I was just giving you a tidbit to send you in potentially a workable direction. :) You could try using a buffer-local variable to test if you've applied your change, or wait for a better solution. I don't see a really clean way to hook into impulse visual mode deactivation without adding an additional hook to impulse. You could maybe use deactivate-mark-hook, and check if vimpulse-visual-mode is true, but you'd have to be sure that your function came before vimpulse-visual-deactivate-hook in the hook. Tim
What's wrong with this solution: (add-hook 'vimpulse-visual-state-hook (lambda () (interactive) (hl-line-mode))) (add-hook 'viper-vi-state-hook (lambda () (interactive) (hl-line-mode 1))) Titus
yes that works! ( (interactive) is not needed there ) The problem is still that i have some modes, in which hl-mode is disabled by default, which means that i have to introduce a buffer local (or "mode-local" - don't know if this exists in elisp) variable and only turn hl-line-mode on if this var is non nil. Better ideas ? Thomas On Fri, Jun 17, 2011 at 8:43 PM, Titus von der Malsburg <[email protected]>wrote:
What's wrong with this solution:
(add-hook 'vimpulse-visual-state-hook (lambda () (interactive) (hl-line-mode))) (add-hook 'viper-vi-state-hook (lambda () (interactive) (hl-line-mode 1)))
Titus
_______________________________________________ implementations-list mailing list [email protected] https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
Can't you modify the functions that turn hl-line-mode on and off to check what the current mode is and if it's included in your list of modes for which you don't want hl-line-mode? I'm thinking of something like this: (add-hook 'viper-vi-state-hook (lambda () (if (not (memq major-mode '(emacs-lisp-mode))) (hl-line-mode 1)))) On Fri, Jun 17, 2011 at 9:16 PM, Thomas Hisch <[email protected]> wrote:
yes that works! ( (interactive) is not needed there ) The problem is still that i have some modes, in which hl-mode is disabled by
Thx - works! This works only if global-hl-line-mode is not activated! (setq hl-line-disabled-modes-list '(org-mode)) (defun thi-turn-hl-line-mode-on () (interactive) (if (not (member major-mode hl-line-disabled-modes-list)) (hl-line-mode 1))) (defun thi-turn-hl-line-mode-off () (interactive) (if (not (member major-mode hl-line-disabled-modes-list)) (hl-line-mode -1))) (add-hook 'vimpulse-visual-state-hook 'thi-turn-hl-line-mode-off) (add-hook 'viper-vi-state-hook 'thi-turn-hl-line-mode-on) regards thomas On Fri, Jun 17, 2011 at 10:02 PM, Titus von der Malsburg <[email protected]
wrote:
Can't you modify the functions that turn hl-line-mode on and off to check what the current mode is and if it's included in your list of modes for which you don't want hl-line-mode? I'm thinking of something like this:
(add-hook 'viper-vi-state-hook (lambda () (if (not (memq major-mode '(emacs-lisp-mode))) (hl-line-mode 1))))
On Fri, Jun 17, 2011 at 9:16 PM, Thomas Hisch <[email protected]> wrote:
yes that works! ( (interactive) is not needed there ) The problem is still that i have some modes, in which hl-mode is disabled by
_______________________________________________ implementations-list mailing list [email protected] https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
participants (3)
-
Thomas Hisch -
Tim Harper -
Titus von der Malsburg