# HG changeset patch # User Richard M. Stallman # Date 1120861980 0 # Node ID 0b1f11faf0b2fd57b0ddddacda2975d5080aed39 # Parent d1baae4e247f819282824ee3e5c0bb6372ab2fdb (whitespace-buffer-leading-cleanup): Simplify w/ skip-chars-forward. (whitespace-buffer-trailing-cleanup): Simplify w/ skip-chars-backward. diff -r d1baae4e247f -r 0b1f11faf0b2 lisp/whitespace.el --- a/lisp/whitespace.el Fri Jul 08 22:31:32 2005 +0000 +++ b/lisp/whitespace.el Fri Jul 08 22:33:00 2005 +0000 @@ -608,17 +608,9 @@ (defun whitespace-buffer-leading-cleanup () "Remove any empty lines at the top of the file." (save-excursion - (let ((pmin nil) - (pmax nil)) - (goto-char (point-min)) - (beginning-of-line) - (setq pmin (point)) - (end-of-line) - (setq pmax (point)) - (if (equal pmin pmax) - (progn - (kill-line) - (whitespace-buffer-leading-cleanup)))))) + (goto-char (point-min)) + (skip-chars-forward "\n") + (delete-region (point-min) (point)))) (defun whitespace-buffer-trailing () "Check to see if are is more than one empty line at the bottom." @@ -647,26 +639,11 @@ (defun whitespace-buffer-trailing-cleanup () "Delete all the empty lines at the bottom." (save-excursion - (let ((pmin nil) - (pmax nil)) - (goto-char (point-max)) - (beginning-of-line) - (setq pmin (point)) - (end-of-line) - (setq pmax (point)) - (if (equal pmin pmax) - (progn - (goto-char (1- pmin)) - (beginning-of-line) - (setq pmin (point)) - (end-of-line) - (setq pmax (point)) - (if (equal pmin pmax) - (progn - (goto-char (1- (point-max))) - (beginning-of-line) - (kill-line) - (whitespace-buffer-trailing-cleanup)))))))) + (goto-char (point-max)) + (skip-chars-backward "\n") + (if (not (bolp)) + (forward-char 1)) + (delete-region (point) (point-max)))) (defun whitespace-buffer-search (regexp) "Search for any given whitespace REGEXP."