Skip to content

Conversation

@pierre-rouleau
Copy link
Contributor

@pierre-rouleau pierre-rouleau commented Oct 6, 2025

  • The gleam-ts--grammar-revision is not meant to be modified. Changed it from defvar to defconst.
  • The gleam-ts--grammar-supports-echo-keyword-p predicate function only depends on gleam-ts--grammar-revision; it can also become a defconst.

Being defconst identify the fact that this is not changeable during an Emacs sessions.

* The `gleam-ts--grammar-revision' is not meant to be modified.
  Changed it from defvar to defconst.
* The `gleam-ts--grammar-supports-echo-keyword-p' predicate function only
  depends on `gleam-ts--grammar-revision'; it can also become a defconst.

Being defconst identify the fact that this is not changeable during an Emacs
sessions.
@pierre-rouleau pierre-rouleau changed the title Use defconst for a defvar and a predicate function. Use defconst for a defvar and a constant predicate function. Oct 6, 2025
@pierre-rouleau
Copy link
Contributor Author

pierre-rouleau commented Oct 6, 2025

Note that this change does not change the way the code works. It makes it explicit that the values should not be changed, and always set the value, even if it was previously bound. It does not (at least with Emacs 30) prevent code from changing the value though.

* Instead of hooking the `gleam-ts-format` to `before-save-hook` when the mode
  is loaded, hook the function `gleam-ts--format-on-save-maybe`.  That
  function performs the formatting only when `gleam-ts-format-on-save` is
  non-nil.
  - Doing it this way means that the user can toggle the value of
    `gleam-ts-format-on-save` at any time, during an Emacs session and the
    change takes effect right away.  That was not possible with the previous
    code: the user had to exit Emacs to activate the change.
* Also minor code format in the `gleam-ts--font-lock-settings` to comply
  with standard Elisp formatting rules.
@pierre-rouleau
Copy link
Contributor Author

The latest change allows users to toggle format on save, a useful feature in various scenarios. This way you can activate or de-activate the mechanism just in the current session without modifying the persistent customizable user-option.

@pierre-rouleau pierre-rouleau changed the title Use defconst for a defvar and a constant predicate function. Use defconst for a defvar & a constant predicate function. Allow toggling format on save. Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant