emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/editorconfig f7918f5: Use new implementation by default (#


From: ELPA Syncer
Subject: [nongnu] elpa/editorconfig f7918f5: Use new implementation by default (#263)
Date: Mon, 30 Aug 2021 06:57:25 -0400 (EDT)

branch: elpa/editorconfig
commit f7918f52d440784564df39440cbec18a3f30dac3
Author: 10sr <8.slashes@gmail.com>
Commit: GitHub <noreply@github.com>

    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 69f4748..c436e8a 100644
--- a/README.md
+++ b/README.md
@@ -136,26 +136,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 84dd311..7c475cd 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -148,6 +148,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
@@ -162,6 +164,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
@@ -842,11 +849,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
@@ -856,7 +863,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
@@ -880,7 +887,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 782bc89..0000000
--- 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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]