[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] scratch/editorconfig-cc cf012776b4 306/351: Use new implementat
From: |
Stefan Monnier |
Subject: |
[nongnu] scratch/editorconfig-cc cf012776b4 306/351: Use new implementation by default (#263) |
Date: |
Thu, 13 Jun 2024 18:39:05 -0400 (EDT) |
branch: scratch/editorconfig-cc
commit cf012776b4a7cb14cc1a3b870f1f88fedefcc8f8
Author: 10sr <8.slashes@gmail.com>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
Use new implementation by default (#263)
* Use new implementation by default
* Remove old test
* Make editorconfig-hack-properties-functions deprecated
---
README.md | 20 -------
editorconfig.el | 19 +++++--
ert-tests/editorconfig-2.el | 130 --------------------------------------------
3 files changed, 13 insertions(+), 156 deletions(-)
diff --git a/README.md b/README.md
index 9d8c9cf61d..ef1a603f70 100644
--- a/README.md
+++ b/README.md
@@ -99,26 +99,6 @@ only blocks of `web-mode` by adding following to your
init.el:
```
-### `editorconfig-hack-properties-functions`
-
-A list of functions to alter property values before applying them.
-
-These functions will be run after loading \".editorconfig\" files and before
-applying them to current buffer, so that you can alter some properties from
-\".editorconfig\" before they take effect.
-
-For example, Makefile files always use tab characters for indentation: you can
-overwrite \"indent_style\" property when current `major-mode` is
-`makefile-mode`:
-
-``` emacs-lisp
-(add-hook 'editorconfig-hack-properties-functions
- '(lambda (props)
- (when (derived-mode-p 'makefile-mode)
- (puthash 'indent_style "tab" props))))
-
-```
-
## Troubleshooting
diff --git a/editorconfig.el b/editorconfig.el
index 92c105b235..5d51b76a69 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -143,6 +143,8 @@ This hook will be run even when there are no matching
sections in
These functions will be run after loading \".editorconfig\" files and before
applying them to current buffer, so that you can alter some properties from
\".editorconfig\" before they take effect.
+(Since 2021/08/30 (v0.9.0): Buffer coding-systems are set before running
+this functions, so this variable cannot be used to change coding-systems.)
For example, Makefiles always use tab characters for indentation: you can
overwrite \"indent_style\" property when current `major-mode' is a
@@ -157,6 +159,11 @@ This hook will be run even when there are no matching
sections in
\".editorconfig\", or no \".editorconfig\" file was found at all."
:type 'hook
:group 'editorconfig)
+(make-obsolete-variable 'editorconfig-hack-properties-functions
+ "Using `editorconfig-after-apply-functions' instead is
recommended,
+ because since 2021/08/30 (v0.9.0) this variable cannot support all
properties:
+ charset values will be referenced before running this hook."
+ "v0.9.0")
(define-obsolete-variable-alias
'edconf-indentation-alist
@@ -715,11 +722,11 @@ 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--enable-20210221-testing nil
- "Enable testing version of `editorconfig-mode'.
+(defvar editorconfig--legacy-version nil
+ "Use legacy version of editorconfig-mode.
-Currently this mode is not well tested yet and can cause unexpected behaviors
-like killing Emacs process or not able to visit files at all.")
+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
@@ -729,7 +736,7 @@ To disable EditorConfig in some buffers, modify
`editorconfig-exclude-modes' or `editorconfig-exclude-regexps'."
:global t
:lighter editorconfig-mode-lighter
- (if editorconfig--enable-20210221-testing
+ (if (not editorconfig--legacy-version)
(let ((modehooks '(prog-mode-hook
text-mode-hook
read-only-mode-hook
@@ -753,7 +760,7 @@ To disable EditorConfig in some buffers, modify
(remove-hook hook
'editorconfig-major-mode-hook))))
- ;; editorconfig--enable-20210221-testing is disabled
+ ;; 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
diff --git a/ert-tests/editorconfig-2.el b/ert-tests/editorconfig-2.el
deleted file mode 100644
index 782bc89aa5..0000000000
--- a/ert-tests/editorconfig-2.el
+++ /dev/null
@@ -1,130 +0,0 @@
-(require 'editorconfig)
-
-(defun display-warning (type message &optional level buffer-name)
- "When testing overwrite this function to throw error when called."
- (unless (eq level :debug)
- (error "display-warning called: %S %S %S %S"
- type
- message
- level
- buffer-name)))
-
-(defmacro with-visit-file (path &rest body)
- "Visit PATH and evaluate BODY."
- (declare (indent 1) (debug t))
- `(let ((buf (find-file-noselect ,path)))
- (unwind-protect
- (with-current-buffer buf
- ,@body)
- (kill-buffer buf))))
-
-;;; interactive
-
-(ert-deftest interactive-test-01 nil
- "This test should not run on Travis"
- :tags '(:interactive)
- (should t))
-
-;;; noninteractive, will run on Travis
-
-(ert-deftest has-feature-01 nil
- "minimally working - provides 'editorconfig"
- (should (featurep 'editorconfig)))
-
-(defvar editorconfig-ert-dir
- (concat default-directory
- "ert-tests/plugin-tests/test_files/"))
-
-(defvar editorconfig-secondary-ert-dir
- (concat default-directory
- "ert-tests/test_files_secondary/"))
-
-(ert-deftest test-editorconfig-2 nil
- "Check if properties are applied."
- (let ((editorconfig--enable-20210221-testing t))
- (editorconfig-mode 1)
-
- (with-visit-file (concat editorconfig-ert-dir
- "3_space.txt")
- (should (eq tab-width 3))
- (should (eq indent-tabs-mode nil)))
-
- (with-visit-file (concat editorconfig-ert-dir
- "4_space.py")
- (should (eq python-indent-offset 4))
- (should (eq tab-width 8))
- (should (eq indent-tabs-mode nil)))
- (editorconfig-mode -1)))
-
-(ert-deftest test-lisp-use-default-indent-2 nil
- (let ((editorconfig--enable-20210221-testing t))
- (editorconfig-mode 1)
-
- (with-visit-file (concat editorconfig-secondary-ert-dir
- "2_space.el")
- (should (eq lisp-indent-offset 2)))
-
- (let ((editorconfig-lisp-use-default-indent t))
- (with-visit-file (concat editorconfig-secondary-ert-dir
- "2_space.el")
- (should (eq lisp-indent-offset nil))))
-
- (let ((editorconfig-lisp-use-default-indent 2))
- (with-visit-file (concat editorconfig-secondary-ert-dir
- "2_space.el")
- (should (eq lisp-indent-offset nil))))
-
- (let ((editorconfig-lisp-use-default-indent 4))
- (with-visit-file (concat editorconfig-secondary-ert-dir
- "2_space.el")
- (should (eq lisp-indent-offset 2))))
- (editorconfig-mode -1)))
-
-(ert-deftest test-trim-trailing-ws-2 nil
- (let ((editorconfig--enable-20210221-testing t))
- (editorconfig-mode 1)
- (with-visit-file (concat editorconfig-ert-dir
- "trim.txt")
- (should (memq 'delete-trailing-whitespace
- write-file-functions)))
- (with-visit-file (concat editorconfig-ert-dir
- "trim.txt")
- (read-only-mode 1)
- (should (not (memq 'delete-trailing-whitespace
- write-file-functions))))
- (editorconfig-mode -1)))
-
-(ert-deftest test-file-type-emacs-2 nil
- :expected-result t ;; Ignore failure
- (let ((editorconfig--enable-20210221-testing t))
- (editorconfig-mode 1)
- (with-visit-file (concat editorconfig-secondary-ert-dir
- "c.txt")
- (should (eq major-mode 'conf-unix-mode)))
- (editorconfig-mode -1)))
-
-(ert-deftest test-file-type-ext-2 nil
- :expected-result t ;; Ignore failure
- (let ((editorconfig--enable-20210221-testing t))
- (editorconfig-mode 1)
- (with-visit-file (concat editorconfig-secondary-ert-dir
- "a.txt")
- (should (eq major-mode 'conf-unix-mode)))
-
- (with-visit-file (concat editorconfig-secondary-ert-dir
- "bin/perlscript")
- (should (eq major-mode 'perl-mode))
- (should (eq perl-indent-level 5)))
- (editorconfig-mode -1)))
-
-(ert-deftest test-hack-properties-functions-2 nil
- (let ((editorconfig--enable-20210221-testing t))
- (editorconfig-mode 1)
- (add-hook 'editorconfig-hack-properties-functions
- (lambda (props)
- (puthash 'indent_size "5" props)))
- (with-visit-file (concat editorconfig-ert-dir
- "4_space.py")
- (should (eq python-indent-offset 5)))
- (setq editorconfig-hack-properties-functions nil)
- (editorconfig-mode -1)))
- [nongnu] scratch/editorconfig-cc 2cfbec79f9 216/351: Update core-test submodule, (continued)
- [nongnu] scratch/editorconfig-cc 2cfbec79f9 216/351: Update core-test submodule, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 2ba007601a 219/351: Add document for editorconfig-trim-whitespaces-mode, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc f2d4539bae 228/351: Refactor handle lib, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc b303bfd220 211/351: Add test for -hack-properties-functions, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 8688e1d3bf 230/351: Revert "Add support for Emacs24.5", Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 5f5a7bf03d 237/351: Update commentary section, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 8cf419254d 246/351: Do not update submodule when running tests, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc be0973c580 291/351: Fix for coding-system set when remote files do not exist (#250), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 9bfade9437 257/351: Use dist: trusty, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 0e299b7528 278/351: Silence byte-compiler warnings (#235), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc cf012776b4 306/351: Use new implementation by default (#263),
Stefan Monnier <=
- [nongnu] scratch/editorconfig-cc 0f2c33d11a 282/351: Update README 2 (#225), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 1969dd74da 271/351: Add conf-mode abbrev-table definitions (#220), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 4b25e6b404 275/351: Update CHANGELOG, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 1ff99f3eff 310/351: tests(build.yml): Use latest minor version number (#274), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 06b57e1fb7 309/351: Add emacs 28.1 to test target (#270), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 0f54515c82 325/351: Load subr-x when compiling (#302), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 217ede58d6 328/351: Revert "Update version string", Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 2458fb6f90 327/351: Update version string, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 24c8272763 321/351: Add bash-ts-mode to editorconfig-indentation-alist (#296), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc b8d1335701 324/351: Add support for gdscript-mode (#300), Stefan Monnier, 2024/06/13