Skip to content

Improve Swift indentation support#391

Closed
ainame wants to merge 1 commit into
editorconfig:masterfrom
ainame:swift-indent-offsets
Closed

Improve Swift indentation support#391
ainame wants to merge 1 commit into
editorconfig:masterfrom
ainame:swift-indent-offsets

Conversation

@ainame
Copy link
Copy Markdown

@ainame ainame commented May 12, 2026

Summary

This updates Swift indentation support so that indent_size is applied to all relevant swift-mode indentation offsets:

  • swift-mode:basic-offset
  • swift-mode:multiline-statement-offset
  • swift-mode:parenthesized-expression-offset

Previously, editorconfig-emacs only applied indent_size to swift-mode:basic-offset.

Background

This follows the discussion in swift-emacs/swift-mode#202.

Historically swift-mode has three separate indentation settings for Swift code: block indentation, multiline statement indentation, and parenthesized expression indentation. They are all customizable via defcustom in swift-mode:

https://github.com/swift-emacs/swift-mode/blob/5782bb9ab0773b5c6abddc23a14b82e5356cc2db/swift-mode-indent.el#L36-L52

In that discussion, we agreed that swift-mode should move towards using the same indentation value for these offsets by default. This PR applies the same idea on the editorconfig-emacs side: when a project provides indent_size, it should be applied to all three Swift indentation settings instead of only swift-mode:basic-offset.

This makes editorconfig-emacs handle all indentation settings exposed by swift-mode, so that a project-level indent_size can control Swift indentation consistently.

@monnier
Copy link
Copy Markdown
Collaborator

monnier commented May 15, 2026

As the docstring says, editorconfig-indentation-alist is a fallback used for those modes which don't set editorconfig-indent-size-vars. So the better fix is to change swift-mode so it does something like:

(setq-local editorconfig-indent-size-vars
            '(swift-mode:basic-offset
              swift-mode:multiline-statement-offset
              swift-mode:parenthesized-expression-offset))

@ainame
Copy link
Copy Markdown
Author

ainame commented May 17, 2026

I see. I read the docstring and understood the context #383 now. I'll send a patch to swift-mode.el instead. Thank you for your reply!

@ainame ainame closed this May 17, 2026
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