]> git.eshelyaron.com Git - emacs.git/commitdiff
editorconfig.el: Fix bug#78097
authorStefan Monnier <monnier@iro.umontreal.ca>
Sat, 17 May 2025 18:23:34 +0000 (14:23 -0400)
committerEshel Yaron <me@eshelyaron.com>
Wed, 21 May 2025 06:09:22 +0000 (08:09 +0200)
When there is no `.editorconfig` variable, the
`file-name-directory` call can signal an error, but that can
happen only if `editorconfig-get-local-variables-functions`
added entries "out of thin air".  So just skip running that hook
to avoid this corner case.

* lisp/editorconfig.el (editorconfig--get-dir-local-variables):
Don't run `editorconfig-get-local-variables-functions` when we found no
EditorConfig settings.

(cherry picked from commit 28a8bd6061d99c71ca2ac17868dfc8cf36a1c728)

lisp/editorconfig.el

index 0c219e13e4e0a8497b0b136bae886c858bb53ca0..48e69e6180c3e6f8a1a601d324d2558b809bdcc9 100644 (file)
@@ -703,7 +703,8 @@ Meant to be used on `auto-coding-functions'."
 Meant to be used on `hack-dir-local-get-variables-functions'."
   (when (stringp buffer-file-name)
     (let* ((props (editorconfig-call-get-properties-function buffer-file-name))
-           (alist (editorconfig--get-local-variables props)))
+           (alist (if (< 0 (hash-table-count props))
+                      (editorconfig--get-local-variables props))))
       ;; FIXME: If there's `/foo/.editorconfig', `/foo/bar/.dir-locals.el',
       ;; and `/foo/bar/baz/.editorconfig', it would be nice to return two
       ;; pairs here, so that hack-dir-local can give different priorities