Merge pull request #285 from nathanstitt/clean-whitespace-on-save
Make cleaning white space on save an option
This commit is contained in:
commit
75a6769019
2 changed files with 23 additions and 1 deletions
13
README.md
13
README.md
|
@ -312,6 +312,19 @@ personal config with the following bit of code:
|
||||||
(setq prelude-whitespace nil)
|
(setq prelude-whitespace nil)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you like `whitespace-mode` but prefer it to not automatically
|
||||||
|
cleanup your file on save, you can disable that behavior by setting
|
||||||
|
prelude-clean-whitespace-on-save to nil in your config file with:
|
||||||
|
|
||||||
|
```lisp
|
||||||
|
(setq prelude-clean-whitespace-on-save nil)
|
||||||
|
```
|
||||||
|
|
||||||
|
The prelude-clean-whitespace-on-save setting can also be set on a
|
||||||
|
per-file or directory basis by using a file variable or a
|
||||||
|
.dir-locals.el file.
|
||||||
|
|
||||||
|
|
||||||
#### Disable flyspell-mode
|
#### Disable flyspell-mode
|
||||||
|
|
||||||
If you're not fond of spellchecking on the fly:
|
If you're not fond of spellchecking on the fly:
|
||||||
|
|
|
@ -53,6 +53,12 @@
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:group 'prelude)
|
:group 'prelude)
|
||||||
|
|
||||||
|
(defcustom prelude-clean-whitespace-on-save t
|
||||||
|
"Cleanup whitespace from file before it's saved. Will only occur if prelude-whitespace is also enabled"
|
||||||
|
:type 'boolean
|
||||||
|
:group 'prelude
|
||||||
|
)
|
||||||
|
|
||||||
(defcustom prelude-flyspell t
|
(defcustom prelude-flyspell t
|
||||||
"Non-nil values enable Prelude's flyspell support."
|
"Non-nil values enable Prelude's flyspell support."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
|
@ -218,10 +224,13 @@
|
||||||
(when (and prelude-flyspell (executable-find ispell-program-name))
|
(when (and prelude-flyspell (executable-find ispell-program-name))
|
||||||
(flyspell-mode +1)))
|
(flyspell-mode +1)))
|
||||||
|
|
||||||
|
(defun prelude-cleanup-maybe ()
|
||||||
|
(when prelude-clean-whitespace-on-save (whitespace-cleanup)))
|
||||||
|
|
||||||
(defun prelude-enable-whitespace ()
|
(defun prelude-enable-whitespace ()
|
||||||
(when prelude-whitespace
|
(when prelude-whitespace
|
||||||
;; keep the whitespace decent all the time (in this buffer)
|
;; keep the whitespace decent all the time (in this buffer)
|
||||||
(add-hook 'before-save-hook 'whitespace-cleanup nil t)
|
(add-hook 'before-save-hook 'prelude-cleanup-maybe nil t)
|
||||||
(whitespace-mode +1)))
|
(whitespace-mode +1)))
|
||||||
|
|
||||||
(add-hook 'text-mode-hook 'prelude-enable-flyspell)
|
(add-hook 'text-mode-hook 'prelude-enable-flyspell)
|
||||||
|
|
Loading…
Reference in a new issue