From 64b085b3816f557a6d66579532e90708e5b5f14f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 18 Sep 2025 00:21:01 -0400 Subject: [PATCH] fix(editorconfig): default to native binary, if available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default editorconfig implementation was changed upstream to the elisp one, but — for the principle of least surprise — I believe it should be the other way around: if the user has the native binary installed, they're likely expecting it to be used; it will fall back to the elisp implementation otherwise. Also updates documentation to reflect these changes and removes the doctor warning about a missing binary. Ref: editorconfig/editorconfig-emacs#209 --- modules/tools/editorconfig/README.org | 16 ++++++++-------- modules/tools/editorconfig/config.el | 7 +++++++ modules/tools/editorconfig/doctor.el | 5 ----- 3 files changed, 15 insertions(+), 13 deletions(-) delete mode 100644 modules/tools/editorconfig/doctor.el diff --git a/modules/tools/editorconfig/README.org b/modules/tools/editorconfig/README.org index b7f2d0a38..432ceb52e 100644 --- a/modules/tools/editorconfig/README.org +++ b/modules/tools/editorconfig/README.org @@ -4,9 +4,9 @@ #+since: 0.9 * Description :unfold: -This module integrates [[https://editorconfig.org/][EditorConfig]] into Emacs, allowing users to dictate code -style on a per-project basis with an =.editorconfig= file ([[https://editorconfig-specification.readthedocs.io/][formal -specification]]). +This module adds [[https://editorconfig.org/][EditorConfig]] support to Emacs, allowing users to dictate code +style on a per-project basis with =.editorconfig= files ([[https://editorconfig-specification.readthedocs.io/][formal specification]]), +with or without the native editorconfig binary. ** Maintainers - [[doom-user:][@hlissner]] @@ -33,12 +33,12 @@ specification]]). * Installation [[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]] -This module has one optional dependency: the ~editorconfig~ native binary. -Without it, a built-in elisp implementation will be used, but it has fewer -features and can be a bit slower. +This module has one optional dependency: the native ~editorconfig~ binary. +Without it, a built-in elisp implementation will be used, which is claimed to be +faster and more secure. -The editorconfig binary has [[https://github.com/editorconfig#contributing][many implementations]] you can choose from, typically -available through your OS package manager (or build it yourself). +If you choose to install the binary, [[https://github.com/editorconfig#contributing][many implementations]] are available, usually +through your OS package manager (if not built from source yourself). * Usage You will need to write an ~.editorconfig~ file in your project (this is usually diff --git a/modules/tools/editorconfig/config.el b/modules/tools/editorconfig/config.el index 1d2d65817..7cce161eb 100644 --- a/modules/tools/editorconfig/config.el +++ b/modules/tools/editorconfig/config.el @@ -6,6 +6,13 @@ (use-package! editorconfig :hook (doom-first-buffer . editorconfig-mode) :config + ;; The elisp implementation is the default (rather than the external, + ;; editorconfig binary), because upstream claims it's "faster and more + ;; secure". Whether that's true or not, I argue the principle of least + ;; surprise: if the user has the editorconfig binary installed, they're likely + ;; expecting it to be used. + (setq editorconfig-get-properties-function #'editorconfig-get-properties) + (when (require 'ws-butler nil t) (setq editorconfig-trim-whitespaces-mode 'ws-butler-mode)) diff --git a/modules/tools/editorconfig/doctor.el b/modules/tools/editorconfig/doctor.el deleted file mode 100644 index 2ad8898e8..000000000 --- a/modules/tools/editorconfig/doctor.el +++ /dev/null @@ -1,5 +0,0 @@ -;; -*- lexical-binding: t; no-byte-compile: t; -*- -;;; tools/editorconfig/doctor.el - -(unless (executable-find "editorconfig") - (warn! "Couldn't find the editorconfig binary. Using native elisp version (slower)"))