4 ms·
M-q is useful, but something more useful IMO would be the same feature but one that removes unneeded white space within the sexpr between expressions and keep e
by kruhft 10y ago
M-q is useful, but something more useful IMO would be the same feature but one that removes unneeded white space within the sexpr between expressions and keep everything indented. A contrived example:
(defun x ()
(+ x x)) => (defun x ()
(+ x x))
- sedachv 10y agoYou can write an interactive function that runs fill-paragraph (or whatever M-q is bound to in the mode you are using), then deletes multiple spaces (something like http://stackoverflow.com/questions/8674912/how-to-collapse-whitespaces-in-a-region http://stackoverflow.com/questions/8674912/how-to-collapse-w...). That would not be a good default because some people, like me, like to align their code in columns (for example, things like let clauses). What I would like to see come as an Emacs default is just-one-space working on regions with the behavior you describe.
- kruhft 10y agoWhat I've noticed after using paredit is that I'm doing a lot less paren matching (well none) and a lot more white space clean up, so I think such a function would be very useful to run as a hook on insert char. Since the program is always syntactically correct, it might almost work... And @sedachv, thanks for Parenscript. It makes Javascript almost...well, now I can work it it :) Much appreciated.