sanel / monroe

Clojure nREPL client for Emacs
161 stars 21 forks source link

Mode hooks #21

Closed danielsz closed 7 years ago

danielsz commented 7 years ago

I'd love to be able to add custom elisp via the standard Emacs mode hook facility.

With Cider, for example, I have the following:

(add-hook 'cider-repl-mode-hook (lambda () (abbrev-mode 1)))

Thanks for listening!

sanel commented 7 years ago

Will monroe-mode-hook and monroe-interaction-mode-hook be suitable for you?

monroe-mode-hook is called when new connection is made in REPL buffer and monroe-interaction-mode-hook is called when you open anything that invokes "Monroe" mode (like .clj/.cljs files and so on).

sanel commented 7 years ago

These aren't documented in README, which should be changed...

danielsz commented 7 years ago

Yes, it's perfect, actually. Thank you so much! (I should have looked more closely at the source code)

(add-hook 'monroe-mode-hook (lambda () (abbrev-mode 1)))
sanel commented 7 years ago

Glad this solved your problem.

The thing is that you won't find it in source code directly: elisp's define-minor-mode and define-derived-mode macros (used to define monroe modes) will implicitly create these hooks and call them when mode is enabled.

danielsz commented 7 years ago

Oh, right!

I actually looked at the code a while back and indeed couldn't find it. Thank you for explaining! :+1: