branch: scratch/editorconfig-cc commit 642ff1b62f5ad4cbf78cdf7dcd5759149882dd21 Author: Terje Larsen <ter...@gmail.com> Commit: Stefan Monnier <monn...@iro.umontreal.ca>
Use ws-butler when enabled and available. When having auto-save on and you edit text the cleaning up of white-space is a bit intrusive and removes the space at the end of the line where you are writing. `ws-butler-mode` is an alternative that does take this into account. --- editorconfig.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/editorconfig.el b/editorconfig.el index 857e34e92a..a9af423aa4 100644 --- a/editorconfig.el +++ b/editorconfig.el @@ -248,6 +248,11 @@ properties." :type '(repeat string) :group 'editorconfig) +(defcustom editorconfig-use-ws-butler nil + "Use command `ws-butler-mode' for trimming trailing whitespace." + :type 'boolean + :group 'editorconfig) + (defvar editorconfig-properties-hash nil "Hash object of EditorConfig properties for current buffer. Set by `editorconfig-apply' and nil if that is not invoked in @@ -273,6 +278,11 @@ 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." ) @@ -322,6 +332,14 @@ number - `lisp-indent-offset' is not set only if indent_size is eol) nil t)))) +(defun editorconfig-set-trailing-ws (trim-trailing-ws) + (if (editorconfig-use-ws-butler-p) + (ws-butler-mode 1) + ...) + (if (editorconfig-use-ws-butler-p) + (ws-butler-mode 0) + ...)) + (defun editorconfig-set-line-length (length) "Set the max line length (`fill-column') to LENGTH." (when (and (editorconfig-string-integer-p length)