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

Dedicated lightweight edn-mode? #650

Open
yuhan0 opened this issue May 21, 2023 · 1 comment
Open

Dedicated lightweight edn-mode? #650

yuhan0 opened this issue May 21, 2023 · 1 comment

Comments

@yuhan0
Copy link
Contributor

yuhan0 commented May 21, 2023

Expected behavior

EDN is a plain data format, and its syntax is a subset of Clojure's (eg. no regex / #() function literals).

Should we have a lightweight edn-mode that derives from clojure-mode? That would allow for simpler and faster font-locking and indentation rules - see also #610.
json-mode derives similarly from javascript-mode, it retains all user config on the parent mode hook and keymap, while allowing tools to use the major-mode as an easy indication of what features to enable.

I would open this as a GH Discussion but it hasn't been enabled on the repo, feel free to convert it to one.

Actual behavior

EDN files are fontified and treated as Clojure source code.

A large majority of clojure-mode's font-lock rules are incorrect in this context. Eg. (defn f) in an EDN file is /not code/ but just a list of symbols, however much the line between code/data is blurred in Clojure. Cider goes further by mapping to it the default user ns, allowing for code evaluation, applying complex indentation rules and dynamically highlighting symbols corresponding to clojure.core vars.

The combined weight of so much regex can be significant for large programmatically-generated data files, where I've had to switch off font-lock-mode before due to Emacs choking on long lines.

Additional context

Sometimes the data in EDN actually is code.
In bb.edn files the :tasks contain representations of Clojure code to be interpreted by SCI. https://book.babashka.org/#tasks But these are ad-hoc semantics imposed by Babashka, eg. extra vars aliased for convenience, :requires syntax etc. We could always add an exception in auto-mode-alist to specify "^bb.edn$" files in particular to be opened in clojure-mode, for code-like indentation and cider-eval support.

Environment & Version information

clojure-mode version

clojure-mode (version 5.16.0)

Emacs version

29.0.91

Operating system

macOS 12.5.1

@bbatsov
Copy link
Member

bbatsov commented May 22, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants