branch: scratch/editorconfig-cc commit ee5b70f1e2c4abba5cdf691b957fec337915f8ba Author: 10sr <8slashes+...@gmail.com> Commit: Stefan Monnier <monn...@iro.umontreal.ca>
editorocnfig-core: Throw error when parsing .editorconfig failed --- editorconfig-core-handle.el | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/editorconfig-core-handle.el b/editorconfig-core-handle.el index 6591772fe9..c175e85d76 100644 --- a/editorconfig-core-handle.el +++ b/editorconfig-core-handle.el @@ -165,26 +165,28 @@ If CONF is not found return nil." (setq props nil)) (setq pattern (match-string 1 line))) - ((string-match-p "=\\|:" - line) - ;; NOTE: Using match-string does not work as expected - (let* ( - (idx (string-match "=\\|:" - line)) - (key (downcase (editorconfig-core-handle--string-trim (substring line - 0 - idx)))) - (value (editorconfig-core-handle--string-trim (substring line - (1+ idx)))) - ) - (when (and (< (length key) 51) - (< (length value) 256)) - (if pattern - (when (< (length pattern) 4097) - (setq props - `(,@props (,key . ,value)))) - (setq top-props - `(,@top-props (,key . ,value))))))) + (t + (let ((idx (string-match "=\\|:" + line))) + (unless idx + (error (format "Failed to parse file: %s" + conf))) + (let ( + (key (downcase (editorconfig-core-handle--string-trim + (substring line + 0 + idx)))) + (value (editorconfig-core-handle--string-trim + (substring line + (1+ idx))))) + (when (and (< (length key) 51) + (< (length value) 256)) + (if pattern + (when (< (length pattern) 4097) + (setq props + `(,@props (,key . ,value)))) + (setq top-props + `(,@top-props (,key . ,value)))))))) ) (forward-line 1)) (when pattern