Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Consider all clojure sexps as defuns#32

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bbatsov merged 2 commits intoclojure-emacs:mainfromkommen:all-clj-sexps-are-defuns
Feb 11, 2024

Conversation

@kommen
Copy link
Contributor

Consider this clojure code,| indicating the point position

(nsmy.app)(defnfoo []  (+11))foo|"another sexp"(defnbar []  (+21))

Without this change,beginning-of-defun would move point before the(defn foo,,,) as the symbol literalfoo is not considered as a valid defun.

With this change, all clojure sexps will be considered as defuns, sobeginning-of-defun moves point beforefoo, which I would consider as the expected behavior.

Similar forcider-eval-defun-at-point: At the point position indicated in the example without this change the(defn bar,,,) form is evaluated. With this change,foo is evaluated, which I also would consider the expected behavior.

(setq-local treesit-defun-tactic'top-level)
(setq-local treesit-defun-type-regexp
(cons (rx (or"list_lit""vec_lit""map_lit"))
(cons (regexp-opt clojure-ts--sexp-nodes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'd add some note explaining this, so someone wouldn't fix down the road. :-)

@bbatsov
Copy link
Member

I'm fine with the proposal as it's in line with how most Emacs modes work - defuns are essentially top-level forms in them, not real defuns.

I'd suggest adding a couple of unit tests for this (you can copy something fromclojure-mode) and a changelog entry, though.

@kommen
Copy link
ContributorAuthor

@bbatsov thanks for the review! I added the note and the changelog entry. However, for the tests there is nothing set up yet here and I guess adding some bare-bone tests could conflict with@dannyfreeman's plan outlined in#25 (comment)?

@bbatsov
Copy link
Member

Well, I see those tests as accretive to the tests that we plan to copy, so I don't think that would create any issues. I'm guessing you can just copy all the tests, as this would help set up the infra here and this would actually speed up the compatibility work.

But if you don't want to tackle this, I or Danny can do it down the road.

@kommen
Copy link
ContributorAuthor

@bbatsov I'd rather not tackle setting up the tests here and now, but would be happy to help Danny and you down the road.

@bbatsovbbatsov merged commitf11b680 intoclojure-emacs:mainFeb 11, 2024
@camdez
Copy link

It might be clarifying for the issue title (and more importantly the changelog) if it said "top-level forms" (or even "top-level sexps"). I read the title and thought every (possibly-nested) sexp would be a target forbeginning-of-defun, but that appears not to be the case.

(Please disregard entirely if I've misunderstood—I haven't run this.)

Cheers.

bitti reacted with thumbs up emoji

@bbatsov
Copy link
Member

Yeah, that affects only top-level forms. I'll update the changelog.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@bbatsovbbatsovbbatsov left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@kommen@bbatsov@camdez

[8]ページ先頭

©2009-2025 Movatter.jp