zenspider / enhanced-ruby-mode

An enhanced ruby-mode for Emacs that uses Ripper in ruby 1.9+ to highlight and indent the source code
Other
217 stars 58 forks source link

Rework sexp behaviour #168

Open fredefox opened 4 years ago

fredefox commented 4 years ago

enh-ruby-mode rebinds C-M-f to enh-ruby-forward-sexp. That key is bound to forward-sexp by default. Similarly C-M-n is rebound to enh-ruby-end-of-block in stead of forward-list etc..

This means that the behaviour is inconsistent with the built-in functions. That works fine for those particular commands that have had their keys re-bound. However enh-ruby-mode does not rebind e.g. C-M-SPC which is bound to mark-sexp. This means that the sexp that you can mark is not the same as the one you can navigate.

To fix this problem we could do one of two things

The first solution might be the quick fix. It may have the downside of duplicating some functionality that Emacs already ships with. The second solution might require some more work. It could be that it's simply a matter of locally redefining forward-sexp as I can see that e.g. mark-sexp calls this internally. More investigation is required. The second solution might also fix other problems I haven't identified yet.

Thoughts?

fredefox commented 4 years ago

Section 26.4 of the Emacs manual says that

The major mode controls which delimiters are significant, through the syntax table (*note Syntax Tables: (elisp)Syntax Tables.).

So I suppose that's the recommended way to get the desired behaviour from forward-sexp and friends.

zenspider commented 3 years ago

Sorry for dropping the ball on this one. If you want to rework it, go for it. I'd rather fix up the bound keys to be consistent to emacs for old-school emacs users & programs alike. The notion of a sexp in ruby is a bit messier... I'm not sure if the parser mechanics give that info back up to emacs well enough to navigate via the actual parse tree, but we can at least get as close as ruby-mode does (or change the protocol to get that info as well)