[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] scratch/editorconfig-cc 3305825fd3 298/351: Make new impl work
From: |
Stefan Monnier |
Subject: |
[nongnu] scratch/editorconfig-cc 3305825fd3 298/351: Make new impl work when changing major-mode (#255) |
Date: |
Thu, 13 Jun 2024 18:39:04 -0400 (EDT) |
branch: scratch/editorconfig-cc
commit 3305825fd3b6364ef7ab147027c9309ad30056eb
Author: 10sr <8.slashes@gmail.com>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
Make new impl work when changing major-mode (#255)
---
editorconfig.el | 37 +++++++++++++++++++++++++++++++------
1 file changed, 31 insertions(+), 6 deletions(-)
diff --git a/editorconfig.el b/editorconfig.el
index 25e220038f..f3f5b43d71 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -583,6 +583,17 @@ any of regexps in `editorconfig-exclude-regexps'."
(not (editorconfig--disabled-for-filename buffer-file-name)))
(editorconfig-apply)))
+(defun editorconfig-local-major-mode-hook ()
+ "Function to run when major-mode has been changed."
+ (display-warning '(editorconfig editorconfig-local-major-mode-hook)
+ (format "editorconfig-mode: %S -properties-hash: %S"
+ editorconfig-mode
+ editorconfig-properties-hash)
+ :debug)
+ (when (and editorconfig-mode
+ editorconfig-properties-hash)
+ (editorconfig-set-variables editorconfig-properties-hash)))
+
(defvar editorconfig--cons-filename-codingsystem nil
"Used interally.")
@@ -665,6 +676,24 @@ F is that function, and FILENAME and ARGS are arguments
passed to F."
:warning)))
(setq editorconfig-properties-hash props)
(editorconfig-set-variables props)
+
+ (add-hook 'prog-mode-hook
+ 'editorconfig-local-major-mode-hook
+ t t)
+ (add-hook 'text-mode-hook
+ 'editorconfig-local-major-mode-hook
+ t t)
+ (add-hook 'read-only-mode-hook
+ 'editorconfig-local-major-mode-hook
+ t t)
+ ;; Some modes call `kill-all-local-variables' in their init
+ ;; code, which clears some values set by editorconfig.
+ ;; For those modes, editorconfig-apply need to be called
+ ;; explicitly through their hooks.
+ (add-hook 'rpm-spec-mode-hook
+ 'editorconfig-local-major-mode-hook
+ t t)
+
(condition-case err
(run-hook-with-args 'editorconfig-after-apply-functions props)
(error
@@ -694,13 +723,9 @@ To disable EditorConfig in some buffers, modify
(if editorconfig-mode
(progn
(advice-add 'find-file-noselect :around
'editorconfig--advice-find-file-noselect)
- (advice-add 'insert-file-contents :around
'editorconfig--advice-insert-file-contents)
- (add-hook 'read-only-mode-hook
- 'editorconfig-mode-apply))
+ (advice-add 'insert-file-contents :around
'editorconfig--advice-insert-file-contents))
(advice-remove 'find-file-noselect
'editorconfig--advice-find-file-noselect)
- (advice-remove 'insert-file-contents
'editorconfig--advice-insert-file-contents)
- (remove-hook 'read-only-mode-hook
- 'editorconfig-mode-apply))
+ (advice-remove 'insert-file-contents
'editorconfig--advice-insert-file-contents))
;; editorconfig--enable-20210221-testing is disabled
;; See https://github.com/editorconfig/editorconfig-emacs/issues/141 for
why
- [nongnu] scratch/editorconfig-cc d5473b369e 236/351: Remove comment, (continued)
- [nongnu] scratch/editorconfig-cc d5473b369e 236/351: Remove comment, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 023a221d87 239/351: Add fixes for package-lint, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 8271234c27 241/351: Use -*- lexical-binding: t -*-, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 876e476ded 238/351: Update README, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc c6d823b8a7 242/351: Separate tool functions, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 882e7f5fa0 249/351: Use API to get version info (#193), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc ace446e357 261/351: Bump version to v0.8.1, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 0644119b21 272/351: Keep a CHANGELOG (#221), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 39eca13316 279/351: Add Github Actions build.yaml, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 26c875d609 269/351: Define -mode-apply as an interactive command (#216), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 3305825fd3 298/351: Make new impl work when changing major-mode (#255),
Stefan Monnier <=
- [nongnu] scratch/editorconfig-cc 2e55840057 266/351: Use elisp core by default, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 8d0e609420 277/351: Add Emacs 27.1 to test target (#228), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc d11d5e0078 305/351: Prepare v0.8.2 (#262), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 49c0563f03 285/351: Do not run editorconfig-apply on recentf-save-file (#241), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 28e411023c 283/351: Remove travis.yml (#238), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 153013ff48 297/351: Return early when expecting coding-system has been already set, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 6aa944ce1e 262/351: Update core-test, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 8ca0b6e042 265/351: Remove a trailing whitespace, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc b70f3c7a93 255/351: Add support for bpftrace-mode (#199), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 44876b2cfa 256/351: Update travis Emacs26 version, Stefan Monnier, 2024/06/13