Created
November 2, 2015 15:22
-
-
Save dacap/ec4aea989603ebf26857 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun slick-shrink-whitespace () | |
"Replaces three Emacs functions in just one: | |
- Calls `delete-blank-lines' when used in a blank line | |
- Calls `just-one-space' when used in a sequence of whitespaces | |
- Calls `delete-horizontal-space' when used in one whitespace | |
" | |
(interactive) | |
(skip-chars-forward " \t") | |
(let ((endcol (current-column)) | |
(iseol (eolp))) | |
(skip-chars-backward " \t") | |
(let ((isbol (bolp))) | |
(if (and iseol isbol) | |
(delete-blank-lines) | |
(if (> (- endcol (current-column)) 1) | |
(just-one-space) | |
(delete-horizontal-space)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment