branch: scratch/editorconfig commit a1edfc24a8ca1a2d26470b77aaf007b1826b7fbe Author: Stefan Monnier <monn...@iro.umontreal.ca> Commit: Stefan Monnier <monn...@iro.umontreal.ca>
Silly fix in `editorconfig--get-local-variables` --- editorconfig.el | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/editorconfig.el b/editorconfig.el index 05c166352d..e06cd32dc4 100644 --- a/editorconfig.el +++ b/editorconfig.el @@ -505,7 +505,7 @@ See `editorconfig-lisp-use-default-indent' for details." (derived-mode-all-parents major-mode))) (parent (if parents (pop parents) major-mode)) (entry ())) - ;; Find the closet parent mode of `major-mode' in + ;; Find the closest parent mode of `major-mode' in ;; `editorconfig-indentation-alist'. ;; FIXME: Rather than keep a central database of all modes and their ;; indent var(s), we should have a buffer-local var and let each @@ -611,6 +611,8 @@ This function will revert buffer when the coding-system has been changed." `((eval . ,(if editorconfig-trim-whitespaces-mode `(,editorconfig-trim-whitespaces-mode 1) + ;; Don't use #' because this specific form is recognized + ;; by Emacs's `safe-local-eval-forms'. '(add-hook 'before-save-hook 'delete-trailing-whitespace nil t))))) ,@(when (or (equal trim-trailing-ws "false") buffer-read-only) @@ -712,12 +714,13 @@ This function also removes `unset' properties and calls (defun editorconfig--get-local-variables (props) "Get variables settings according to EditorConfig PROPS." - (editorconfig--get-indentation (gethash 'indent_style props) - (gethash 'indent_size props) - (gethash 'tab_width props)) - (editorconfig--get-trailing-nl (gethash 'insert_final_newline props)) - (editorconfig--get-trailing-ws (gethash 'trim_trailing_whitespace props)) - (editorconfig--get-line-length (gethash 'max_line_length props))) + (append + (editorconfig--get-indentation (gethash 'indent_style props) + (gethash 'indent_size props) + (gethash 'tab_width props)) + (editorconfig--get-trailing-nl (gethash 'insert_final_newline props)) + (editorconfig--get-trailing-ws (gethash 'trim_trailing_whitespace props)) + (editorconfig--get-line-length (gethash 'max_line_length props)))) (defun editorconfig-set-local-variables (props) "Set buffer variables according to EditorConfig PROPS." @@ -875,10 +878,12 @@ F is that function, and FILENAME and ARGS are arguments passed to F." (alist (editorconfig--get-local-variables props))) ;; FIXME: Actually, we should loop over the "editorconfig-core-handles" ;; since each one comes from a different directory. - (cons - ;; FIXME: This should be the dir where we found the `.editorconfig' file. - (file-name-directory buffer-file-name) - alist)))) + (when alist + (cons + ;; FIXME: This should be the dir where we found the + ;; `.editorconfig' file. + (file-name-directory buffer-file-name) + alist))))) ;;;###autoload (define-minor-mode editorconfig-mode