New proposed function doesn't do what I want

Stephen Eglen stephen at inf.ed.ac.uk
Mon Aug 16 14:08:54 CEST 2004


hi Rodney,

As well as the code that Tom posted, have you seen the function 
delete-blank-lines bound to C-x C-o in Emacs?

Stephen

C-x C-o runs the command delete-blank-lines
   which is an interactive compiled Lisp function in `simple'.
(delete-blank-lines)

On blank line, delete all surrounding blank lines, leaving just one.
On isolated blank line, delete that one.
On nonblank line, delete any immediately following blank lines.

Rodney Sparapani writes:
 > Does anyone know why this function doesn't quite work?  I want to change all 
 > multiple blank lines into one blank line.
 > 
 > (defun ess-delete-blank-lines ()
 > "Convert 2 or more lines of white space into one.  This function
 > works as you might expect, except that it must be terminated by C-g
 > for some reason and it also removes single blank lines?!?"
 >     (interactive)
 > 
 >     (save-excursion
 > 	(goto-char (point-min))
 > 
 > 	(save-match-data
 > 	    (while (search-forward-regexp "^[ \t]*$" nil 'eof 2)
 > 		    (delete-blank-lines)))))
 > 		    
 > Rodney Sparapani              Medical College of Wisconsin
 > Sr. Biostatistician           Patient Care & Outcomes Research
 > rsparapa at mcw.edu              http://www.mcw.edu/pcor
 > Was 'Name That Tune' rigged?  WWLD -- What Would Lombardi Do
 > 
 > ______________________________________________
 > ESS-help at stat.math.ethz.ch mailing list
 > https://stat.ethz.ch/mailman/listinfo/ess-help




More information about the ESS-help mailing list