diff options
author | Richard M. Stallman <rms@gnu.org> | 2005-07-08 22:33:00 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2005-07-08 22:33:00 +0000 |
commit | 185d43ee89e50224fb73b317ee739ac58e6fd6f8 (patch) | |
tree | 187043267a03b24f888d91e3c8c9addec392905e /lisp/whitespace.el | |
parent | c32e5fb00d2866866dea360be788f4b7c4c0b0bf (diff) | |
download | emacs-185d43ee89e50224fb73b317ee739ac58e6fd6f8.tar.gz |
(whitespace-buffer-leading-cleanup): Simplify w/ skip-chars-forward.
(whitespace-buffer-trailing-cleanup): Simplify w/ skip-chars-backward.
Diffstat (limited to 'lisp/whitespace.el')
-rw-r--r-- | lisp/whitespace.el | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/lisp/whitespace.el b/lisp/whitespace.el index f1255df9482..f09113a3690 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el @@ -608,17 +608,9 @@ whitespace problems." (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 @@ whitespace problems." (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." |