diff options
| author | Stefan Monnier | 2025-11-19 09:57:29 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2025-11-19 09:58:19 -0500 |
| commit | 5e10b7fe4ebe8ffeb2a6f31886fe524718beb3e9 (patch) | |
| tree | e367b53d707dace2a986c3134b37b11dd5a49a93 | |
| parent | 788b39740a657b6359162ad79cc511b461ee6a27 (diff) | |
| download | emacs-5e10b7fe4ebe8ffeb2a6f31886fe524718beb3e9.tar.gz emacs-5e10b7fe4ebe8ffeb2a6f31886fe524718beb3e9.zip | |
Fix `editorconfig-display-current-properties`
In Emacs-30, `editorconfig-display-current-properties` was
broken in that it displayed only the properties set by
`editorconfig-apply` but not those set in the "normal" way,
i.e. by `hack-local-variables`. Fix that along with a few
docstrings that had misleading old info.
* lisp/editorconfig-tools.el (editorconfig-apply)
(editorconfig-mode-apply): Fix docstring and declare obsolete.
* lisp/editorconfig.el (editorconfig-properties-hash):
(editorconfig-call-get-properties-function): Remove elements of
docstring that aren't true any more.
(editorconfig-call-get-properties-function):
Set `editorconfig-properties-hash`.
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/editorconfig-tools.el | 17 | ||||
| -rw-r--r-- | lisp/editorconfig.el | 14 |
3 files changed, 20 insertions, 17 deletions
| @@ -857,6 +857,12 @@ you could already use 'C-u C-x C-n' to clear the goal column. | |||
| 857 | 857 | ||
| 858 | * Changes in Specialized Modes and Packages in Emacs 31.1 | 858 | * Changes in Specialized Modes and Packages in Emacs 31.1 |
| 859 | 859 | ||
| 860 | ** Editorconfig | ||
| 861 | --- | ||
| 862 | *** 'editorconfig-apply' is declared obsolete. | ||
| 863 | You can now use 'editorconfig-display-current-properties' without having | ||
| 864 | to call 'editorconfig-apply'. | ||
| 865 | |||
| 860 | ** Auth Source | 866 | ** Auth Source |
| 861 | 867 | ||
| 862 | +++ | 868 | +++ |
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 @@ | |||
| 41 | 41 | ||
| 42 | ;;;###autoload | 42 | ;;;###autoload |
| 43 | (defun editorconfig-apply () | 43 | (defun editorconfig-apply () |
| 44 | "Get and apply EditorConfig properties to current buffer. | 44 | "Get and apply EditorConfig properties to current buffer." |
| 45 | 45 | (declare (obsolete hack-local-variables "31.1")) | |
| 46 | This function does not respect the values of `editorconfig-exclude-modes' and | ||
| 47 | `editorconfig-exclude-regexps' and always applies available properties. | ||
| 48 | Use `editorconfig-mode-apply' instead to make use of these variables." | ||
| 49 | (interactive) | 46 | (interactive) |
| 50 | (when buffer-file-name | 47 | (when buffer-file-name |
| 51 | (condition-case err | 48 | (condition-case err |
| @@ -76,14 +73,12 @@ Use `editorconfig-mode-apply' instead to make use of these variables." | |||
| 76 | :error))))) | 73 | :error))))) |
| 77 | 74 | ||
| 78 | (defun editorconfig-mode-apply () | 75 | (defun editorconfig-mode-apply () |
| 79 | "Get and apply EditorConfig properties to current buffer. | 76 | "Get and apply EditorConfig properties to current buffer." |
| 80 | 77 | (declare (obsolete editorconfig-apply "31.1")) | |
| 81 | This function does nothing when the major mode is listed in | ||
| 82 | `editorconfig-exclude-modes', or variable `buffer-file-name' matches | ||
| 83 | any of regexps in `editorconfig-exclude-regexps'." | ||
| 84 | (interactive) | 78 | (interactive) |
| 85 | (when (and major-mode buffer-file-name) | 79 | (when (and major-mode buffer-file-name) |
| 86 | (editorconfig-apply))) | 80 | (with-suppressed-warnings ((obsolete editorconfig-apply)) |
| 81 | (editorconfig-apply)))) | ||
| 87 | 82 | ||
| 88 | 83 | ||
| 89 | ;;;###autoload | 84 | ;;;###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'." | |||
| 251 | :type 'function) | 251 | :type 'function) |
| 252 | 252 | ||
| 253 | (defvar-local editorconfig-properties-hash nil | 253 | (defvar-local editorconfig-properties-hash nil |
| 254 | "Hash object of EditorConfig properties that was enabled for current buffer. | 254 | "Hash object of EditorConfig properties that was enabled for current buffer.") |
| 255 | Set by `editorconfig-apply' and nil if that is not invoked in | ||
| 256 | current buffer yet.") | ||
| 257 | (put 'editorconfig-properties-hash 'permanent-local t) | 255 | (put 'editorconfig-properties-hash 'permanent-local t) |
| 258 | 256 | ||
| 259 | (defvar editorconfig-lisp-use-default-indent nil | 257 | (defvar editorconfig-lisp-use-default-indent nil |
| @@ -527,9 +525,7 @@ This function will revert buffer when the coding-system has been changed." | |||
| 527 | 525 | ||
| 528 | (defun editorconfig-call-get-properties-function (filename) | 526 | (defun editorconfig-call-get-properties-function (filename) |
| 529 | "Call `editorconfig-core-get-properties-hash' with FILENAME and return result. | 527 | "Call `editorconfig-core-get-properties-hash' with FILENAME and return result. |
| 530 | 528 | This function also removes `unset' properties." | |
| 531 | This function also removes `unset' properties and calls | ||
| 532 | `editorconfig-hack-properties-functions'." | ||
| 533 | (if (stringp filename) | 529 | (if (stringp filename) |
| 534 | (setq filename (expand-file-name filename)) | 530 | (setq filename (expand-file-name filename)) |
| 535 | (editorconfig-error "Invalid argument: %S" filename)) | 531 | (editorconfig-error "Invalid argument: %S" filename)) |
| @@ -541,6 +537,12 @@ This function also removes `unset' properties and calls | |||
| 541 | err))) | 537 | err))) |
| 542 | (cl-loop for k being the hash-keys of props using (hash-values v) | 538 | (cl-loop for k being the hash-keys of props using (hash-values v) |
| 543 | when (equal v "unset") do (remhash k props)) | 539 | when (equal v "unset") do (remhash k props)) |
| 540 | ;; E.g. for `editorconfig-display-current-properties'. | ||
| 541 | ;; FIXME: Use it for memoization as well to avoid the duplicate | ||
| 542 | ;; calls to `editorconfig-core-get-properties-hash' (one for | ||
| 543 | ;; `editorconfig--get-coding-system' and one for | ||
| 544 | ;; `editorconfig--get-dir-local-variables')? | ||
| 545 | (setq editorconfig-properties-hash props) | ||
| 544 | props)) | 546 | props)) |
| 545 | 547 | ||
| 546 | (defvar editorconfig-get-local-variables-functions | 548 | (defvar editorconfig-get-local-variables-functions |