So I've created a major mode for a custom lisp by deriving from the standard Lisp Mode. However, when emacs enters it, it automatically activates slime-mode as well, which overrides most of my bindings. As far as I can tell, this happens because SLIME registers some hooks with Lisp Mode and my mode triggers them as well, but I'm not sure. Is there a way to avoid this?
If you're using define-derived-mode
then the body and mode hook for your parent mode are going to run.
Refer to https://stackoverflow.com/a/19295380 for details.
If you're enabling slime-mode
in lisp-mode-hook
, and your new mode is deriving from lisp-mode
, then the simplest thing would be to disable slime-mode
again in the mode hook for your derived mode.
Edit: Actually I believe you could prevent the mode hooks for the ancestor modes from running by manipulating delayed-mode-hooks
in the body of your mode.
(You can't prevent the bodies of the ancestor modes from running.)
I recommend that you don't do this, though. I think if you find yourself wanting to mess with the derived mode mechanisms (especially if you're planning to share the code), then you shouldn't be using a derived mode at all.
You should probably take a cue from the implementations of lisp-mode
vs emacs-lisp-mode
. Rather than one being derived from the other, they are distinct modes (each derived from prog-mode
). Their (independent) keymaps have a shared parent keymap, however, meaning that a lot of keybindings do the same things.
I suggest using that code as a template for creating a new lisp-ish major mode.