Skip to content

Instantly share code, notes, and snippets.

@dacap
Created November 2, 2015 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacap/ec4aea989603ebf26857 to your computer and use it in GitHub Desktop.
Save dacap/ec4aea989603ebf26857 to your computer and use it in GitHub Desktop.
(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