all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Is it possible to have a global minor mode disabled whenever a  certain major mode is enabled?
@ 2010-07-14 11:06 James Gregory
  2010-07-19 18:42 ` Aidan Gauland
  0 siblings, 1 reply; 2+ messages in thread
From: James Gregory @ 2010-07-14 11:06 UTC (permalink / raw
  To: help-gnu-emacs

I have a global minor mode (highlight-symbol) that conflicts with a
major mode (js2-mode). I have seen an alternative implementation of
highlight symbol that doesn't conflict, but it has some issues of its
own. I would rather just disable highlight-symbol whenever js2-mode is
loaded, but I can't work out how to do this.

I have some code like this in my init files:

;make it a global mode, and switch it on
(defun highlight-symbol-mode-on ()
  "Turn on function `highlight-symbol-mode'."
  (highlight-symbol-mode 1))

(defun highlight-symbol-mode-off ()
  "Turn off function `highlight-symbol-mode'."
  (highlight-symbol-mode -1))

(define-globalized-minor-mode global-highlight-symbol-mode
highlight-symbol-mode highlight-symbol-mode-on)
(global-highlight-symbol-mode 1)

(add-hook 'js2-mode-hook 'highlight-symbol-mode-off)

///

But though the hook at the end is called, highlight-symbol is still
switched on in js2-mode buffers. I guess this might be because the
global minor mode is enabled after js2-mode has already loaded? Or
some other load-order issue.

Thanks,

James



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Is it possible to have a global minor mode disabled whenever a  certain major mode is enabled?
  2010-07-14 11:06 Is it possible to have a global minor mode disabled whenever a certain major mode is enabled? James Gregory
@ 2010-07-19 18:42 ` Aidan Gauland
  0 siblings, 0 replies; 2+ messages in thread
From: Aidan Gauland @ 2010-07-19 18:42 UTC (permalink / raw
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1160 bytes --]

James Gregory wrote:
> I have a global minor mode (highlight-symbol) that conflicts with a
> major mode (js2-mode). I have seen an alternative implementation of
> highlight symbol that doesn't conflict, but it has some issues of its
> own. I would rather just disable highlight-symbol whenever js2-mode is
> loaded, but I can't work out how to do this.
> 
> I have some code like this in my init files:
> 
> [snip]
> 
> But though the hook at the end is called, highlight-symbol is still
> switched on in js2-mode buffers. I guess this might be because the
> global minor mode is enabled after js2-mode has already loaded? Or
> some other load-order issue.

According to the Emacs manual, major-mode hooks are run as the *last* step of
initialisation, so I'm not sure why this isn't working for you.  I have an
idea that may or may not be helpful: if highlight-symbol can run hooks, have
it detect the major mode of the current buffer and disable itself.  If that
doesn't work, then, as a rather crude hack, you could have your js2-mode hook
run after a short delay, but that would be unreliable, as it's time dependent.

HTH,
Aidan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 261 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-07-19 18:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-14 11:06 Is it possible to have a global minor mode disabled whenever a certain major mode is enabled? James Gregory
2010-07-19 18:42 ` Aidan Gauland

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.