Skip to content

Refactor to allow setting custom autoload entry #46

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

Merged
merged 5 commits into from
Apr 19, 2017

Conversation

notetiene
Copy link
Contributor

This allows setting custom files to be loaded automatically with json-mode. I saw that some files were added recently, but it doesn't cover much of the file names we can get in web development.

Unless the customization option is set from custom-set-variables, the package is not loaded until an autoload function is called.

* json-mode.el (json-mode-standard-file-ext): Refactor the
  `auto-mode-alist' to extract common JSON extensions.
  (json-mode--update-auto-mode): Add an inline function to set the
  `auto-mode-alist` regexp.
  (json-mode-auto-mode-list): Add the customization option to
  automatically open file names as JSON. Note that each time the
  option is changed, it updates the `auto-mode-alist` entry for
  `json-mode`.
  (json-mode--auto-mode-entry): Add a variable to cache the
  `json-mode` `auto-mode-list` entry.
@notetiene
Copy link
Contributor Author

However, I don't see any reason not to load the package if the user set json-mode-auto-mode-list.

* json-mode.el (json-mode--update-auto-mode): Remove argument that
  appended the new auto-mode-alist JSON entry.
@joshwnj
Copy link
Collaborator

joshwnj commented Apr 19, 2017

This is great @notetiene - something I've wanted for a while but never got around to. Thanks!

@joshwnj joshwnj merged commit c3a7ab3 into json-emacs:master Apr 19, 2017
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.

2 participants