greghendershott / racket-mode

Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, packages, and more.
https://www.racket-mode.com/
GNU General Public License v3.0
680 stars 93 forks source link

`<f5>` is reserved for users but is bound by racket-mode #714

Closed priime0 closed 2 weeks ago

priime0 commented 3 weeks ago

According to these conventions, <f5> through <f9> are reserved for users. racket-mode and racket-hash-mode seem to use <f5> for themselves:

https://github.com/greghendershott/racket-mode/blob/3cb49c513d56cc615e4b932bb08406dec93471a7/racket-mode.el#L50

https://github.com/greghendershott/racket-mode/blob/3cb49c513d56cc615e4b932bb08406dec93471a7/racket-hash-lang.el#L23

I'm not entirely sure what key this should be replaced with (maybe <f4>?), but it did interfere with my own keybinding.

greghendershott commented 3 weeks ago

Yep; you're correct and I'm aware that f5 is reserved for users.

Why I'm consciously ignoring the convention: To accommodate people who are accustomed to using DrRacket (and not yet too familiar with using Emacs, and customizing its key bindings). Hitting f5 to "run" is a very frequent/basic thing. I want it to "just work" "out of box". I don't want to force new users into some tutorial about customizing keybindings in Emacs.

Furthermore f5 is bound to racket-run-and-switch-to-repl, a flavor of "run" that's more similar to DrRacket. (Compared to the alternative "run" command I prefer personally, racket-run-module-at-point, bound by default to C-c C-c.)

TL;DR: Using f5 as a default key binding here is "wrong" but IMHO also good. I think it's worth it for people coming from DrRacket, brand new to Emacs. For most other people, who already know about customizing key bindings, it's a pretty small nuisance to change one more.

greghendershott commented 3 weeks ago

Having said all that, I'm open to changing this, somehow.

For example perhaps it could bind f5 to racket-run-and-switch-to-repl only if it is not already bound?

I'm not yet sure the best way to implement that, without maybe causing other problems. But I'd be willing to look at it someday soon, if you think it would be worthwhile?

priime0 commented 3 weeks ago

The rationale for having f5 out of the box makes sense.

For example perhaps it could bind f5 to racket-run-and-switch-to-repl only if it is not already bound?

This sounds like a reasonable solution.

I'm not yet sure the best way to implement that, without maybe causing other problems.

My rough idea is to check if the key is bound in the global map and only add it to the racket-mode-map if it isn't present.

But I'd be willing to look at it someday soon, if you think it would be worthwhile?

I consider this to be a fairly low-priority issue, so there's no urgency on my end. I was just raising it in case you weren't aware. I personally haven't used DrRacket in a while, and was unaware of f5's behaviour in it.

Feel free to close this if you don't think it's worth the trouble. :)

greghendershott commented 3 weeks ago

I pushed commit 936c4d8 on a topic branch -- not yet merged to main branch.

I think this might be the right idea. In quick testing, "it works". But I'm not 100% sure what new problems it might create?

So I might sleep on this awhile before merging....