branch: scratch/editorconfig-cc commit 8caddd3d40beaefe3af07c096e07fb36374489f6 Author: 10sr <8.slas...@gmail.com> Commit: Stefan Monnier <monn...@iro.umontreal.ca>
Move hack-properties-function run --- editorconfig.el | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/editorconfig.el b/editorconfig.el index 9235eba96a..030802304f 100644 --- a/editorconfig.el +++ b/editorconfig.el @@ -511,13 +511,6 @@ This function also removes 'unset'ted properties and calls err))) (cl-loop for k being the hash-keys of props using (hash-values v) when (equal v "unset") do (remhash k props)) - (condition-case err - (run-hook-with-args 'editorconfig-hack-properties-functions props) - (error - (display-warning '(editorconfig editorconfig-hack-properties-functions) - (format "Error while running editorconfig-hack-properties-functions, abort running hook: %S" - err) - :warning))) props)) (defun editorconfig-set-variables (props) @@ -541,6 +534,13 @@ Use `editorconfig-mode-apply' instead to make use of these variables." (condition-case err (progn (let ((props (editorconfig-call-get-properties-function buffer-file-name))) + (condition-case err + (run-hook-with-args 'editorconfig-hack-properties-functions props) + (error + (display-warning '(editorconfig editorconfig-hack-properties-functions) + (format "Error while running editorconfig-hack-properties-functions, abort running hook: %S" + err) + :warning))) (setq editorconfig-properties-hash props) (editorconfig-set-variables props) (editorconfig-set-coding-system @@ -641,6 +641,16 @@ F is that function, and FILENAME and ARGS are arguments passed to F." ;; For that case, explicitly set this value so that saving will be done ;; with expected coding system. (set-buffer-file-coding-system coding-system)) + + ;; When using editorconfig-2-mode, hack-properties-functions cannot affect coding-system value, + ;; because it has to be set before initializing buffers. + (condition-case err + (run-hook-with-args 'editorconfig-hack-properties-functions props) + (error + (display-warning '(editorconfig editorconfig-hack-properties-functions) + (format "Error while running editorconfig-hack-properties-functions, abort running hook: %S" + err) + :warning))) (setq editorconfig-properties-hash props) (editorconfig-set-variables props) (condition-case err