Repository navigation
Proper fix for prog-fill-reindent-defun - #164
Merged
Merged
Conversation
rrudakov
force-pushed
the
fix/indent-defun
branch
3 times, most recently
from
November 1, 2026 14:39
5f5aff7 to
cf263f3
Compare
The fix introduced in clojure-emacs#161 is incorrect, it sets `prog-fill-reindent-defun` to the default implementation which doesn't use Tree-sitter at all. The issue was in the way we used to set `treesit-defun-type-regexp`. Any top-level expression was considered a defun. This commit changes the predicate lambda, so only the direct children of "source" node are considered as defun's and additionally, if `clojure-ts-toplevel-inside-comment-form` is true, the direct children of the rich comment forms.
Emacs-32 introduced setopt-local and added extra validation for defcustoms. If defcustom with :set function is set via .dir-locals.el it must support 3-args arity.
rrudakov
force-pushed
the
fix/indent-defun
branch
from
November 2, 2026 08:16
cf263f3 to
b37c0ea
Compare
Contributor
Author
|
Emacs 32 now refuses setting variables with But I'm not sure why tests pass on main. Another issue was that |
bbatsov
added a commit
that referenced
this pull request
Nov 7, 2026
Since #164 indent-region-function was only set when clojure-ts-align-forms-automatically was on as the mode started, so turning it on later in an open buffer, with setopt or setq-local, left indent-region unaligned. clojure-ts-indent-region checks the option when it runs, which is also what makes a directory-local value work, so it can be set unconditionally again.
bbatsov
added a commit
that referenced
this pull request
Nov 7, 2026
#164 made the setters take the buffer-local argument setopt-local passes, but then they only set the variable: a buffer kept the indentation rules of its old style, and its old faces until something refontified it. A directory-local value worked anyway, because clojure-ts--apply-local-variables runs after it's set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The fix introduced in #161 is incorrect, it sets
prog-fill-reindent-defunto the default implementation which doesn't use Tree-sitter at all. The issue was in the way we used to settreesit-defun-type-regexp. Any top-level expression was considered a defun. This commit changes the predicate lambda, so only the direct children of "source" node are considered as defun's and additionally, ifclojure-ts-toplevel-inside-comment-formis true, the direct children of the rich comment forms.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):
M-x checkdocand fixed any warnings in the code you've written.Thanks!