Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

racket-hash-lang-module-language-hook is an abnormal hook #681

Open
usaoc opened this issue Nov 29, 2023 · 1 comment
Open

racket-hash-lang-module-language-hook is an abnormal hook #681

usaoc opened this issue Nov 29, 2023 · 1 comment
Labels
question racket-hash-lang-mode Issues using racket-hash-lang-mode instead of "classic" racket-mode for edit buffers

Comments

@usaoc
Copy link

usaoc commented Nov 29, 2023

In my understanding, abnormal hooks should be named <prefix>-functions as opposed to <prefix>-hook. Would it be better if the name were changed to comply with this convention?

@usaoc usaoc added the question label Nov 29, 2023
@greghendershott
Copy link
Owner

Thanks for the feedback. Good question.

If the naming convention is just strictly about zero vs. more arguments, then yes, the variable should be -functions not -hook.

On the other hand:

In my experience, -function, -functions, -predicate tend to be about supplying alternate behavior in Emacs Lisp programs, similar to Racket parameters, as opposed to end users customizing preferences in their init file?

The spirit here is definitely "hook". It's a kind of "mode hook" run whenever the hash-lang changes. So that users can do the kinds of customization they would otherwise do in racket-hash-lang-mode-hook. From its doc string:

Typically in Emacs each language gets its own major mode. As a
result, the major mode hook is your opportunity to express
preferences. However racket-hash-lang-mode handles radically
different kinds of hash langs in one major mode. And a given
buffer can change langs when you edit the "#lang" line. As a
result, racket-hash-lang-mode-hook is not useful for per-lang
configuration. Instead you need a kind of "sub major mode
hook". This is that hook.

From that POV I think -hook is actually a helpful name. (But naming things is hard.)

I think it's OK to bend the naming convention. This mode is already kind of bending the conventions about major modes and programming languages.

Maybe I'll suggest a new convention, about vars ending in -module-language-hook? 😄


(p.s. If I were to make any change at all, I'd keep it named -hook but change it to take zero arguments; instead add some new buffer-local variable like "racket-hash-lang-module-language". In fact I tried it that way, early on, but it felt silly because nothing else needed this var, and I didn't want users to think setting it would have any effect. So I decided to simply pass the value in as an argument.)

@greghendershott greghendershott added the racket-hash-lang-mode Issues using racket-hash-lang-mode instead of "classic" racket-mode for edit buffers label Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question racket-hash-lang-mode Issues using racket-hash-lang-mode instead of "classic" racket-mode for edit buffers
Projects
None yet
Development

No branches or pull requests

2 participants