Skip to content

Fix/paredit config config per doc#2730

Open
whitphx wants to merge 11 commits intomainfrom
fix/paredit-config-config-per-doc
Open

Fix/paredit config config per doc#2730
whitphx wants to merge 11 commits intomainfrom
fix/paredit-config-config-per-doc

Conversation

@whitphx
Copy link
Owner

@whitphx whitphx commented Feb 4, 2026

Summary by CodeRabbit

  • New Features

    • Paredit configuration is now applied per‑document.
    • Users can define custom parentheses pairs that merge with defaults; set a pair to null to disable a default.
  • Bug Fixes

    • Improved handling of line-comment characters in non‑Lisp files.
  • Documentation

    • Clarified description and added examples showing merged/nullable parentheses configuration.
  • Tests

    • Tests updated to use per‑document configuration access.
  • Chores

    • Added a changeset and schema updates to accept null values for pairs.

Copilot AI review requested due to automatic review settings February 4, 2026 07:59
@changeset-bot
Copy link

changeset-bot bot commented Feb 4, 2026

🦋 Changeset detected

Latest commit: 143990f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
emacs-mcx Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

Walkthrough

Paredit configuration moved from a global/static field to per-document runtime reads; package schema and README updated to allow null to disable defaults; paredit-related interfaces and class field removed; paredit command now reads, filters, logs, and applies parentheses per document.

Changes

Cohort / File(s) Summary
Configuration API removal
src/configuration/iconfiguration.ts, src/configuration/configuration.ts
Removed IPareditConfiguration and the paredit field from IConfiguration/Configuration; removed imports and global paredit init/update logic.
Runtime paredit application
src/commands/paredit.ts
Added getPareditParenthesesConfig(document) to read emacs-mcx.paredit.parentheses, filter out null entries, log the active mapping, call paredit.reader.setParentheses, and switched semicolon handling to replaceAll; added vscode document/config access and logger use.
Schema & docs
package.json, README.md
Schema updated to allow null values for parentheses map entries and added description and scope: "language-overridable"; README documents merge-with-defaults behavior, null-disabling, and shows examples.
Tests
src/test/suite/extension.native.test.ts, src/test/suite/commands/paredit.test.ts
Native test now treats "paredit" as a consumed config key; paredit tests replaced global Configuration.reload flow with per-call vscode.workspace.getConfiguration(..., document) stubs.
Release notes
.changeset/slick-owls-watch.md
Added changeset noting patch update and that Paredit configuration is applied per-document.
Misc
cspell.json
Added "iconfiguration" to the cspell word list.

Sequence Diagram(s)

sequenceDiagram
    participant Editor as "VSCode Editor (Document)"
    participant Command as "Paredit Command Handler"
    participant Config as "VSCode Config (emacs-mcx)"
    participant Paredit as "paredit.reader"
    participant Logger as "Logger"

    Editor->>Command: invoke paredit action (with Document)
    Command->>Config: getConfiguration("emacs-mcx", Document) -> get("paredit.parentheses")
    Config-->>Command: returns mapping (may include nulls)
    Command->>Logger: log active parentheses mapping
    Command->>Paredit: setParentheses(filteredMapping)
    Command->>Paredit: perform sexp-travel / edits
    Paredit-->>Editor: apply edits
    Paredit->>Logger: emit operation logs
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Per-doc hops, no global chain,
Parentheses set for each terrain.
Nulls tuck defaults out of sight,
Each buffer sings its own delight.
I nibble changes — soft and light. 🌿

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Fix/paredit config config per doc' is vague and contains awkward phrasing ('config config') that obscures the actual change, making it difficult to understand the primary change at a glance. Consider rewording to something clearer like 'Apply paredit configuration per document instead of globally' to better convey the main change without awkward repetition.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/paredit-config-config-per-doc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a bug where the emacs-mcx.paredit.parentheses configuration option was defined in the schema but never actually read and applied. The PR refactors the paredit configuration to be effective per document rather than globally, enabling language-specific parentheses configuration.

Changes:

  • Removed global paredit configuration from the Configuration class
  • Added per-document configuration retrieval in paredit commands
  • Enhanced package.json schema to support null values for disabling specific pairs and added scope: "language-overridable"
  • Updated documentation to describe the new configuration behavior

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/configuration/iconfiguration.ts Removed IPareditConfiguration interface and paredit property from IConfiguration interface
src/configuration/configuration.ts Removed paredit configuration property and related imports, eliminating global paredit.js setup
src/commands/paredit.ts Added getPareditParenthesesConfig() function to retrieve per-document configuration, integrated it into makeSexpTravelFunc(), added debug logging, and improved code style with replaceAll()
package.json Modified schema to allow null values for parentheses pairs and added scope: "language-overridable" for per-language configuration
README.md Updated documentation with examples showing how to add new pairs and disable default pairs
.changeset/slick-owls-watch.md Added changeset describing the fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@src/commands/paredit.ts`:
- Around line 42-45: The code is calling an undocumented internal API
paredit.reader.setParentheses from the getPareditParenthesesConfig flow; locate
the call site around getPareditParenthesesConfig and
paredit.reader.setParentheses and either (a) confirm and use a local wrapper
(e.g., implement and export a stable setParentheses function in
vendor/paredit.js and call that), (b) confirm the method is part of paredit's
documented public API and replace the current access with the documented
accessor, or (c) refactor to configure parentheses via paredit's supported
public API (e.g., initialization/options or a documented setter) instead of
touching paredit.reader directly; ensure logger.debug still logs the resolved
parentheses and remove direct references to paredit.reader.setParentheses unless
the API is proven stable or wrapped locally.

In `@src/configuration/configuration.ts`:
- Line 7: The import line referencing the module name "iconfiguration" triggers
a cspell failure; update the import comment or dictionary so CI passes by either
adding a cspell ignore comment above the import or adding "iconfiguration" to
the project's cspell dictionary. Locate the import statement that brings in
IConfiguration and IDebugConfiguration (the line importing from
"./iconfiguration") and either prepend a cspell:disable/enable comment for that
word or add "iconfiguration" to cspell.json/words to whitelist it.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/test/suite/extension.native.test.ts`:
- Around line 70-73: Update the inline comment that currently reads it only
handles "subwordMode" to also mention "paredit" and explain the different
handling: note that "subwordMode" is handled by wordSeparators.ts while
"paredit" is excluded because it is applied per-document at runtime in the
paredit command handler; update the comment adjacent to the if statement
checking keyFirstSegment and the array ["subwordMode", "paredit"] to reflect
both behaviours and their handlers.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

VSIX File Tree

Archive:  /home/runner/work/_temp/emacs-mcx/emacs-mcx-2d0504a5d01697830b2a825e7f210cbafff8e206-21684590631-854.vsix
  Length      Date    Time    Name
---------  ---------- -----   ----
     3038  2026-02-04 19:10   extension.vsixmanifest
      517  2026-02-04 19:10   [Content_Types].xml
   301249  2026-02-04 19:10   extension/package.json
    48128  2026-02-04 19:10   extension/readme.md
    15443  2026-02-04 19:09   extension/LICENSE.txt
    55999  2026-02-04 19:10   extension/changelog.md
    12664  2026-02-04 19:09   extension/images/icon.svg
    23256  2026-02-04 19:09   extension/images/icon.png
   283224  2026-02-04 19:10   extension/dist/extension.js
   133401  2026-02-04 19:10   extension/dist/web/extension.js
---------                     -------
   876919                     10 files

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


const parentheses = getPareditParenthesesConfig(doc);
logger.debug(`Using paredit parentheses: ${JSON.stringify(parentheses)}`);
paredit.reader.setParentheses(parentheses);
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The call to paredit.reader.setParentheses modifies global state in the paredit.js library. If multiple paredit commands are executed concurrently on different documents with different configurations, they could interfere with each other. For example, if command A sets parentheses for document A, then command B sets different parentheses for document B before command A calls paredit.parse, command A will use the wrong configuration.

While this is likely a pre-existing architectural limitation of paredit.js rather than a new issue introduced by this PR, it's worth noting. A potential mitigation would be to ensure paredit operations are serialized, though this may be complex to implement correctly.

Copilot uses AI. Check for mistakes.
whitphx and others added 3 commits February 5, 2026 15:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@whitphx
Copy link
Owner Author

whitphx commented Feb 5, 2026

Looks like the web test fails due to the error on the VSCode upstream that seems to be fixed by microsoft/vscode#292948
Wait for it to be released...

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.

1 participant