I recently added a modification to my Enter keybinding based on an answer (if you can't see it, this is a link) on this SE. It was good and I liked it. So of course...
Now I want to add MORE dwim behavior. Specifically, while programming, if I'm typing a comment, I'd like to press the Enter key and the next line automatically also be a comment. E.g. in Ruby, if I have
# blah blah| where
| is the cursor, I want to press Enter and see
# blah blah # |
So the question - what is preferred / philosophically correct with emacs?
- Expand my
enter-key-dwimfunction to just check for more things?
- Do I switch to two small functions that work as a local-buffer
post-command-hookand only run if the last command was the Enter key?
- Put an advice around the Enter key behavior?
- Something else?
One comment says that I generally want to avoid
post-command-hook because it gets run after every keystroke as well, which seems to be a vote against option 2.