+ "Taylor R. Campbell" campbell@mumble.net:
| Date: Tue, 18 Apr 2006 20:00:50 +0200 (CEST) | From: Harald Hanche-Olsen hanche@math.ntnu.no | | I must disagree. Users aren't supposed to know the name of modes' | keymaps: The recommended method of making your own bindings for a | given mode is precisely to use local-set-key in a mode hook. | | Indeed? I've always just used the modes' key maps. Is this explained | in any part of the Emacs or elisp manuals?
Er, no. I am not sure where I have picked this up from, but evidently not from the info files, I can see that now. I must have been told this in some newsgroup or other. And repeatedly, for I am sure have heard it more than once. But at least, I think it's safe to say this is not uncommon practice, so it pays to make sure you don't break stuff for people who do this.
| Hmmm. Actually, I can't reproduce the behaviour observed by Kelvin | Wu, though I'm using GNU Emacs, not XEmacs. I wonder what C-h c RET | says when in the SLIME REPL.
I could repeat it. But guess what: RET is bound to slime-repl-return initially, after you start slime. But when you start typing some input, THAT is when lisp-mode-hook gets called, and afterwards, RET is bound to newline-and-indent. More precisely, type M-( + space, then slime displays the arglist for +, and the key gets rebound.
I tried adding a function to lisp-mode-hook that calls (error), and it didn't trigger until I started typing. It seems to be slime-fontify-string that is the culprit here. But that makes no sense either: It creates a temporary buffer for the purpose of fontifying some lisp, but that is running pure lisp-mode, so should be the hook will twiddle the wrong keymap.
I just can't figure out what is going on, and it's not for lack of trying: I added a function to lisp-mode-hook that checks whether (current-local-map) is equal to lisp-mode-map and records the answer, and it is always yes. But still, Kelvin Wu's hook rebinds return in lisp-mode-map. Argh.
- Harald