json-emacs / json-mode

Major mode for editing JSON files with emacs
314 stars 66 forks source link

Use magic-fallback-mode-alist instead of magic-mode-alist #60

Closed kira-bruneau closed 5 years ago

kira-bruneau commented 5 years ago

Currently json-mode uses magic-mode-alist for mode detection. This list is prioritized over auto-mode-alist so it causes problems when a file starts with a either { or [ but isn't actually JSON.

Emacs provides magic-fallback-mode-alist which is essentially the same thing as magic-mode-alist, but is checked after auto-mode-alist. In a fresh install of emacs, it's used for detecting things like html/xml, so this seems like it would be a better fit for json-mode.

See Choosing Modes in the emacs manual for more details.

joshwnj commented 5 years ago

Thanks @MetaDark !