M-x flush-lines ^$
deletes all blank lines in a buffer. However I only want to delete extra blank lines, that is if there are n consecutive blank lines I want to delete n-1 and keep one.
I know that delete-blank-lines does the job for the blank lines under the point, however I want a simple solution which works for the whole buffer.
Any ideas how to do this? Especially is it possible to modify the regex ^$ from my first example to match only the extra lines?