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

Inline and fix syntax table #559

Merged
merged 7 commits into from
Mar 26, 2020
Merged

Conversation

yuhan0
Copy link
Contributor

@yuhan0 yuhan0 commented Mar 26, 2020

In Clojure single quotes ' can be part of a symbol literal anywhere except the head, this is stated explicitly in https://clojure.org/reference/reader and recently confirmed by Alex Miller on the Clojurians Slack.

Changing the syntax of ' in the syntax table affects the output of functions like (thing-at-point 'symbol) which currently does not treat quotes as part of the symbol. This in turn affects cider-symbol-at-point and dependent functions likecider-doc, which currently does not work on vars named eg. foo' or hawai'i

I also took the liberty of inlining the definition of clojure-mode's syntax table rather than inheriting and overriding bits from emacs-lisp-mode (which in turn inherits from lisp-mode), making it simpler to understand it as a whole.

Also added commas as whitespace to the syntax table, this helps with some edge cases where [:space:] is used in a font-lock regex.


Before submitting a PR mark the checkboxes for the items you've done (if you
think a checkbox does not apply, then leave it unchecked):

  • The commits are consistent with our contribution guidelines.
  • You've added tests (if possible) to cover your change(s). Bugfix, indentation, and font-lock tests are extremely important!
  • You've run M-x checkdoc and fixed any warnings in the code you've written.
  • You've updated the changelog (if adding/changing user-visible functionality).
  • You've updated the readme (if adding/changing user-visible functionality).

Thanks!

yuhan0 added 4 commits March 26, 2020 19:21
Define syntax table from scratch instead of inheriting from emacs-lisp-mode.
The code taken from lisp-mode is refactored to use the cons cell range syntax of
modify-syntax-entry instead of while loops.
Unlike other lisps, symbols like x' are syntatically valid in Clojure
@bbatsov
Copy link
Member

bbatsov commented Mar 26, 2020

Great changes!

I also took the liberty of inlining the definition of clojure-mode's syntax table rather than inheriting and overriding bits from emacs-lisp-mode (which in turn inherits from lisp-mode), making it simpler to understand it as a whole.

I've been meaning to this for a very long time, so it's the right move. (see #270)

You'll have to look into the build failures and add some changelog entry.

yuhan0 added 2 commits March 26, 2020 21:41
Caused by leading quotes being detected as part of the symbol
@yuhan0 yuhan0 force-pushed the fix-syntax-table branch from 642b1e8 to 0a75438 Compare March 26, 2020 13:42
@yuhan0
Copy link
Contributor Author

yuhan0 commented Mar 26, 2020

Fixed the emacs-25 build failure, I didn't realise string-trim's optional argument was a new feature in 26. The emacs-master failure was there in previous PRs and seems to be some unrelated checkdoc bug.

I also just realised that this would introduce a breakage in the current cider-symbol-at-point when called on quoted symbols. I could open a PR for Cider with my changes, hopefully users who upgrade packages would do both together?

@bbatsov
Copy link
Member

bbatsov commented Mar 26, 2020

I guess they do, so this shouldn't be a big problem.

@bbatsov bbatsov merged commit 2f8f3ce into clojure-emacs:master Mar 26, 2020
@bbatsov
Copy link
Member

bbatsov commented Mar 26, 2020

Thanks for tackling this!

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