2

Is there a smart way to keep locally enabled minor modes enabled when changing/restarting major modes without adding it to the mode hook or enable it globally?

For instance, if I usually don't use paredit, but decide one day I want to try it out, but then want to change my major mode from emacs-lisp-mode to lisp-interaction-mode. How can I do this without paredit being disabled?

More specifically I want this to be the case with an extension I am writing for org-mode, where I want a variable to be updated when org-ctrl-c-ctrl-c is run, but because org-mode in some contexts restarts and thus disables my minor mode, it is unable to do this without always being enabled with org-mode.

  • Not sure there's a good way to do what you're asking, since you're fighting the Emacs ecosystem by not turning on the minor modes in the relevant major mode hooks. You might be able to build some machinery into after-change-major-mode-hook. – Dan Apr 29 '16 at 13:18
  • Locally-enabled minor modes are often tied specifically to the major mode. It wouldn't make sense to cause them all to remain enabled after a major mode change. Therefore you would need some specific configuration to say "only retain these specific minor modes for these specific major modes" (if it was for all major modes you'd be using a global minor mode in the first place). And an obvious way to say "use these specific minor modes with these specific major modes" is to use the extremely standard mode-hook approach. So just do that? – phils Apr 29 '16 at 13:46
  • You might be looking for the define-globalized-minor-mode macro, however, to define a controlling function that determines whether a given buffer-local minor mode will be enabled in any given buffer. – phils Apr 29 '16 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.