diff --git a/src/emacs/Cask b/src/emacs/Cask index 82d57d2d4..eebe3d2d8 100644 --- a/src/emacs/Cask +++ b/src/emacs/Cask @@ -10,7 +10,6 @@ (depends-on "flycheck") (depends-on "flymake") (depends-on "fill-column-indicator") - (depends-on "whitespace-cleanup-mode") (depends-on "lua-mode") (depends-on "mmm-mode") (depends-on "s")) diff --git a/src/emacs/README.md b/src/emacs/README.md index dfe8815d3..f688af521 100644 --- a/src/emacs/README.md +++ b/src/emacs/README.md @@ -27,19 +27,17 @@ to use full features of ``lean-mode``. - [fill-column-indicator][fci] - [lua-mode][lua-mode] - [mmm-mode][mmm-mode] - - [whitespace-cleanup-mode][wcm] [company]: http://company-mode.github.io/ [flycheck]: http://flycheck.readthedocs.org/en/latest [fci]: https://github.com/alpaker/Fill-Column-Indicator [lua-mode]: http://immerrr.github.io/lua-mode/ [mmm-mode]: https://github.com/purcell/mmm-mode -[wcm]: https://github.com/purcell/whitespace-cleanup-mode Install ======= -Put the following elisp code on your emacs setup +Put the following elisp code on your emacs setup (e.g. ``.emacs.d/init.el`` [GNU Emacs], ``~/Library/Preferences/Aquamacs Emacs/Preferences.el`` [Aquamacs]) : ```elisp @@ -50,8 +48,8 @@ Put the following elisp code on your emacs setup ;; Install required/optional packages for lean-mode (defvar lean-mode-required-packages - '(company dash dash-functional flycheck whitespace-cleanup-mode - f fill-column-indicator s lua-mode mmm-mode)) + '(company dash dash-functional flycheck f + fill-column-indicator s lua-mode mmm-mode)) (let ((need-to-refresh t)) (dolist (p lean-mode-required-packages) (when (not (package-installed-p p)) diff --git a/src/emacs/lean-mode.el b/src/emacs/lean-mode.el index d875f021c..62d115e8f 100644 --- a/src/emacs/lean-mode.el +++ b/src/emacs/lean-mode.el @@ -127,6 +127,7 @@ (defconst lean-hooks-alist '( ;; Handle events that may start automatic syntax checks + (before-save-hook . lean-whitespace-cleanup) (after-save-hook . lean-server-after-save) ;; ;; Handle events that may triggered pending deferred checks ;; (window-configuration-change-hook . lean-perform-deferred-syntax-check) @@ -169,10 +170,6 @@ enabled and disabled respectively.") (setq fci-rule-column lean-rule-column) (setq fci-rule-color lean-rule-color) (fci-mode t)))) - ;; Delete Trailing Whitespace - (if lean-delete-trailing-whitespace - (progn (require 'whitespace-cleanup-mode) - (whitespace-cleanup-mode t))) ;; eldoc (when lean-eldoc-use (set (make-local-variable 'eldoc-documentation-function) diff --git a/src/emacs/lean-require.el b/src/emacs/lean-require.el index 1b145ee10..506a96dcf 100644 --- a/src/emacs/lean-require.el +++ b/src/emacs/lean-require.el @@ -24,8 +24,7 @@ (lean-mode-check-package 'package) (lean-mode-check-package 'dash) (let ((required-packages '(cl-lib compile dash dash-functional f flymake s)) - (optional-packages '(flycheck whitespace-cleanup-mode fill-column-indicator - lua-mode mmm-mode))) + (optional-packages '(flycheck fill-column-indicator lua-mode mmm-mode))) (-each required-packages 'lean-mode-require-package) (-each optional-packages 'lean-mode-check-package))) diff --git a/src/emacs/lean-util.el b/src/emacs/lean-util.el index e419693ac..f90d7498d 100644 --- a/src/emacs/lean-util.el +++ b/src/emacs/lean-util.el @@ -180,4 +180,8 @@ (pos (point))) (- pos bol-pos))) +(defun lean-whitespace-cleanup () + (when lean-delete-trailing-whitespace + (delete-trailing-whitespace))) + (provide 'lean-util)