Skip to content

fix: ensure emacs users can easily format in the editor#2470

Open
wdconinc wants to merge 2 commits intomainfrom
emacs-clang-format
Open

fix: ensure emacs users can easily format in the editor#2470
wdconinc wants to merge 2 commits intomainfrom
emacs-clang-format

Conversation

@wdconinc
Copy link
Contributor

Briefly, what does this PR introduce?

This PR adds a local emacs configuration and key binding for clang-format. The key bindings C-c i (clang-format-region) and C-c u (clang-format-buffer) are defined.

When first starting up emacs on a C++ file inside this repository, this configuration will as you to accept this configuration with ! (and you won't be asked again).

You will need to have the clang-format emacs package installed (in addition to the command clang-format provided by a system package).

The clang-format emacs package is on the MELPA package archive, which you will need to enable in your configuration if it isn't already.

This PR removes .dir-locals.el from .gitignore (and adds .dir-locals-2.el), and this PR may therefore overwrite local .dir-locals.el files (after warning about this). The standard approach is for .dir-locals.el to be tracked in git, and for personal additions that are not tracked to be added to .dir-locals-2.el.

What kind of change does this PR introduce?

  • Bug fix (issue: formatting code inside emacs is hard)
  • New feature (issue #__)
  • Documentation update
  • Other: __

Please check if this PR fulfills the following:

  • Tests for the changes have been added
  • Documentation has been added / updated
  • Changes have been communicated to collaborators

Does this PR introduce breaking changes? What changes might users need to make to their code?

No.

Does this PR change default behavior?

No.

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 PR adds Emacs editor support for automatic code formatting using clang-format. It introduces a repository-tracked .dir-locals.el file that configures key bindings for clang-format commands in C++ mode, making it easier for Emacs users to format code consistently with the project's .clang-format configuration.

Changes:

  • Added .dir-locals.el with clang-format key bindings (C-c i for region, C-c u for buffer) in c++-mode
  • Modified .gitignore to track .dir-locals.el and ignore .dir-locals-2.el for personal customizations

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
.gitignore Updated to track .dir-locals.el and ignore .dir-locals-2.el (contains typo)
.dir-locals.el New Emacs configuration file with clang-format key bindings and package loading logic

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

@wdconinc wdconinc enabled auto-merge February 16, 2026 10:30
Copilot AI review requested due to automatic review settings February 16, 2026 14:56

This comment was marked as resolved.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants