branch: scratch/editorconfig-cc
commit 9fdc9cc689d33d8b5f5c510da80a155361a07fa4
Author: 10sr <8.slas...@gmail.com>
Commit: Stefan Monnier <monn...@iro.umontreal.ca>

    Add variable editorconfig-trim-whitespaces-mode
---
 editorconfig.el | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/editorconfig.el b/editorconfig.el
index a9af423aa4..a3690589ea 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -248,9 +248,12 @@ properties."
   :type '(repeat string)
   :group 'editorconfig)
 
-(defcustom editorconfig-use-ws-butler nil
-  "Use command `ws-butler-mode' for trimming trailing whitespace."
-  :type 'boolean
+(defcustom editorconfig-trim-whitespaces-mode nil
+  "Buffer local minor-mode to use to trim trailing whitespaces.
+
+If set, enable that mode when `trim_trailing_whitespace` is set to true.
+Otherwise, use `delete-trailing-whitespace'."
+  :type 'symbol
   :group 'editorconfig)
 
 (defvar editorconfig-properties-hash nil
@@ -278,11 +281,6 @@ number - `lisp-indent-offset' is not set only if 
indent_size is
   (and (stringp string)
        (string-match-p "\\`[0-9]+\\'" string)))
 
-(defun editorconfig-use-ws-butler-p ()
-  "Return non-nil if `editorconfig-use-ws-butler' is enabled and
-`ws-butler' is available."
-  (and editorconfig-use-ws-butler (fboundp 'ws-butler-mode)))
-
 (defun editorconfig-set-indentation/python-mode (size)
   "Set `python-mode' indent size to SIZE."
   )
@@ -333,12 +331,12 @@ number - `lisp-indent-offset' is not set only if 
indent_size is
                                      nil t))))
 
 (defun editorconfig-set-trailing-ws (trim-trailing-ws)
-    (if (editorconfig-use-ws-butler-p)
-        (ws-butler-mode 1)
+    (if editorconfig-trim-whitespaces-mode
+        (funcall editorconfig-trim-whitespaces-mode 1)
       ...)
-    (if (editorconfig-use-ws-butler-p)
-        (ws-butler-mode 0)
-      ...))
+    (when editorconfig-trim-whitespaces-mode
+      (funcall editorconfig-trim-whitespaces-mode 0))
+    ...)
 
 (defun editorconfig-set-line-length (length)
   "Set the max line length (`fill-column') to LENGTH."

Reply via email to