Skip to content

Commit

Permalink
Remove editorconfig-mode legacy version (#304)
Browse files Browse the repository at this point in the history
* Remove switch to use legacy version

Remove `editorconfig--lagacy-version` variable.

* Update CHANGELOG
  • Loading branch information
10sr authored May 5, 2024
1 parent e36fd63 commit 2d6690e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Remove editorconfig-mode legacy version ([#304])
- Remove flag `editorconfig--legacy-version`, which was defined in [#263]

### Deprecated

### Removed
Expand Down Expand Up @@ -303,6 +306,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[0.3]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.2...v0.3
[0.2]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.1...v0.2
[0.1]: https://github.com/editorconfig/editorconfig-emacs/releases/tag/v0.1
[#304]: https://github.com/editorconfig/editorconfig-emacs/issues/304
[#306]: https://github.com/editorconfig/editorconfig-emacs/issues/306
[#305]: https://github.com/editorconfig/editorconfig-emacs/issues/305
[#302]: https://github.com/editorconfig/editorconfig-emacs/issues/302
Expand Down
58 changes: 19 additions & 39 deletions editorconfig.el
Original file line number Diff line number Diff line change
Expand Up @@ -861,11 +861,6 @@ F is that function, and FILENAME and ARGS are arguments passed to F."
(format "Error while setting variables from EditorConfig: %S" err))))
ret))

(defvar editorconfig--legacy-version nil
"Use legacy version of editorconfig-mode.
As of 2021/08/30, `editorconfig-mode' uses totally new implementation by
default. This flag disables this and go back to previous version.")

;;;###autoload
(define-minor-mode editorconfig-mode
Expand All @@ -875,41 +870,26 @@ To disable EditorConfig in some buffers, modify
`editorconfig-exclude-modes' or `editorconfig-exclude-regexps'."
:global t
:lighter editorconfig-mode-lighter
(if (not editorconfig--legacy-version)
(let ((modehooks '(prog-mode-hook
text-mode-hook
read-only-mode-hook
;; 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.
rpm-spec-mode-hook)))
(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)
(dolist (hook modehooks)
(add-hook hook
'editorconfig-major-mode-hook
t)))
(advice-remove 'find-file-noselect 'editorconfig--advice-find-file-noselect)
(advice-remove 'insert-file-contents 'editorconfig--advice-insert-file-contents)
(let ((modehooks '(prog-mode-hook
text-mode-hook
read-only-mode-hook
;; 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.
rpm-spec-mode-hook)))
(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)
(dolist (hook modehooks)
(remove-hook hook 'editorconfig-major-mode-hook))))

;; editorconfig--legacy-version is enabled
;; See https://github.com/editorconfig/editorconfig-emacs/issues/141 for why
;; not `after-change-major-mode-hook'
(dolist (hook '(change-major-mode-after-body-hook
read-only-mode-hook
;; 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.
rpm-spec-mode-hook))
(if editorconfig-mode
(add-hook hook 'editorconfig-mode-apply)
(remove-hook hook 'editorconfig-mode-apply)))))
(add-hook hook
'editorconfig-major-mode-hook
t)))
(advice-remove 'find-file-noselect 'editorconfig--advice-find-file-noselect)
(advice-remove 'insert-file-contents 'editorconfig--advice-insert-file-contents)
(dolist (hook modehooks)
(remove-hook hook 'editorconfig-major-mode-hook)))))


;; Tools
Expand Down

0 comments on commit 2d6690e

Please sign in to comment.