I'm looking for a command that behaves similiar to fixup-whitespace, but I want it to also remove line breaks between objects around point.

  • Does delete-indentation do what you are looking for?
    – Drew
    Aug 7 '17 at 13:49
  • Yes, but it only deletes one empty line.
    – bertfred
    Aug 8 '17 at 10:11

It's not perfect but this is more or less what I was looking for

(defun fixup-line-breaks ()
  (let ((pos (point)))
       (skip-chars-forward "[^\s\t\n]")
       (constrain-to-field nil pos t))
       (re-search-backward "[^\s\t\n]")
       (constrain-to-field nil pos)))
    (insert "\n")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.