diff --git a/etc/NEWS b/etc/NEWS index 0d3c8938139..fdb1ee02819 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -857,6 +857,12 @@ you could already use 'C-u C-x C-n' to clear the goal column. * Changes in Specialized Modes and Packages in Emacs 31.1 +** Editorconfig +--- +*** 'editorconfig-apply' is declared obsolete. +You can now use 'editorconfig-display-current-properties' without having +to call 'editorconfig-apply'. + ** Auth Source +++ diff --git a/lisp/editorconfig-tools.el b/lisp/editorconfig-tools.el index 2fec1a94f8b..474f46b0527 100644 --- a/lisp/editorconfig-tools.el +++ b/lisp/editorconfig-tools.el @@ -41,11 +41,8 @@ ;;;###autoload (defun editorconfig-apply () - "Get and apply EditorConfig properties to current buffer. - -This function does not respect the values of `editorconfig-exclude-modes' and -`editorconfig-exclude-regexps' and always applies available properties. -Use `editorconfig-mode-apply' instead to make use of these variables." + "Get and apply EditorConfig properties to current buffer." + (declare (obsolete hack-local-variables "31.1")) (interactive) (when buffer-file-name (condition-case err @@ -76,14 +73,12 @@ Use `editorconfig-mode-apply' instead to make use of these variables." :error))))) (defun editorconfig-mode-apply () - "Get and apply EditorConfig properties to current buffer. - -This function does nothing when the major mode is listed in -`editorconfig-exclude-modes', or variable `buffer-file-name' matches -any of regexps in `editorconfig-exclude-regexps'." + "Get and apply EditorConfig properties to current buffer." + (declare (obsolete editorconfig-apply "31.1")) (interactive) (when (and major-mode buffer-file-name) - (editorconfig-apply))) + (with-suppressed-warnings ((obsolete editorconfig-apply)) + (editorconfig-apply)))) ;;;###autoload diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index b0888c4377b..04c7314369d 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -251,9 +251,7 @@ Otherwise, use `delete-trailing-whitespace'." :type 'function) (defvar-local editorconfig-properties-hash nil - "Hash object of EditorConfig properties that was enabled for current buffer. -Set by `editorconfig-apply' and nil if that is not invoked in -current buffer yet.") + "Hash object of EditorConfig properties that was enabled for current buffer.") (put 'editorconfig-properties-hash 'permanent-local t) (defvar editorconfig-lisp-use-default-indent nil @@ -527,9 +525,7 @@ This function will revert buffer when the coding-system has been changed." (defun editorconfig-call-get-properties-function (filename) "Call `editorconfig-core-get-properties-hash' with FILENAME and return result. - -This function also removes `unset' properties and calls -`editorconfig-hack-properties-functions'." +This function also removes `unset' properties." (if (stringp filename) (setq filename (expand-file-name filename)) (editorconfig-error "Invalid argument: %S" filename)) @@ -541,6 +537,12 @@ This function also removes `unset' 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)) + ;; E.g. for `editorconfig-display-current-properties'. + ;; FIXME: Use it for memoization as well to avoid the duplicate + ;; calls to `editorconfig-core-get-properties-hash' (one for + ;; `editorconfig--get-coding-system' and one for + ;; `editorconfig--get-dir-local-variables')? + (setq editorconfig-properties-hash props) props)) (defvar editorconfig-get-local-variables-functions