I'm looking for a command that deletes automatically deletes spaces up to the next parens:
from:
(do |
(do-something)
true)
to:
(do |(do-something)
true)
There is the command just-one-space
which collapses all whitespace around the point down to a single space character. It works in any mode, not just paredit. By default it's bound to M-SPC
, which can be hard to type since most window managers have a keyboard shortcut there that opens a menu. You can instead type Esc SPC
.
For deleting white spaces there are a few commands in Emacs. You can find it all in EmacsWiki DeletingWhiteSpaces
Here are two examples from the wiki:
delete-horizontal-space
M-\
or M-x delete-horizontal-space
will join two word, removing all the white spaces.
delete-horizontal-space-forward
Further down in the wiki page a function for deleting all white spaces forward (essentially what is asked in the example of the question) You can add it to your configuration and bind a key to it.
(defun delete-horizontal-space-forward () ; adapted from `delete-horizontal-space'
"*Delete all spaces and tabs after point."
(interactive "*")
(delete-region (point) (progn (skip-chars-forward " \t") (point))))
Also, package https://github.com/jcpetkovich/shrink-whitespace.el is very convenient as it progressively reduces whitespace around the cursor. This is how I use it:
(use-package shrink-whitespace
:bind ("M-SPC" . shrink-whitespace))
fixup-whitespace
,just-one-space
,delete-horizontal-space
,delete-indentation
,delete-blank-lines
, anddelete-trailing-whitespace
, each of which might be relevant, depending on exactly what you want.