aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/simple.el21
2 files changed, 16 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f17ba200815..fd5cb9bcac7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12011-09-23 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * simple.el (delete-trailing-whitespace):
4 Document last change; simplify.
5
12011-09-23 Peter J. Weisberg <pj@irregularexpressions.net> 62011-09-23 Peter J. Weisberg <pj@irregularexpressions.net>
2 7
3 * simple.el (delete-trailing-whitespace): Also delete 8 * simple.el (delete-trailing-whitespace): Also delete
diff --git a/lisp/simple.el b/lisp/simple.el
index c828584c17f..142270930ca 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -568,6 +568,7 @@ On nonblank line, delete any immediately following blank lines."
568All whitespace after the last non-whitespace character in a line is deleted. 568All whitespace after the last non-whitespace character in a line is deleted.
569This respects narrowing, created by \\[narrow-to-region] and friends. 569This respects narrowing, created by \\[narrow-to-region] and friends.
570A formfeed is not considered whitespace by this function. 570A formfeed is not considered whitespace by this function.
571If END is nil, also delete all trailing lines at the end of the buffer.
571If the region is active, only delete whitespace within the region." 572If the region is active, only delete whitespace within the region."
572 (interactive (progn 573 (interactive (progn
573 (barf-if-buffer-read-only) 574 (barf-if-buffer-read-only)
@@ -580,18 +581,18 @@ If the region is active, only delete whitespace within the region."
580 (start (or start (point-min)))) 581 (start (or start (point-min))))
581 (goto-char start) 582 (goto-char start)
582 (while (re-search-forward "\\s-$" end-marker t) 583 (while (re-search-forward "\\s-$" end-marker t)
583 (skip-syntax-backward "-" (save-excursion (forward-line 0) (point))) 584 (skip-syntax-backward "-" (line-beginning-position))
584 ;; Don't delete formfeeds, even if they are considered whitespace. 585 ;; Don't delete formfeeds, even if they are considered whitespace.
585 (save-match-data 586 (if (looking-at-p ".*\f")
586 (if (looking-at ".*\f") 587 (goto-char (match-end 0)))
587 (goto-char (match-end 0))))
588 (delete-region (point) (match-end 0))) 588 (delete-region (point) (match-end 0)))
589 (save-restriction 589 ;; Delete trailing empty lines.
590 (goto-char end-marker) 590 (goto-char end-marker)
591 (widen) 591 (when (and (not end)
592 (if (and (eobp) 592 (<= (skip-chars-backward "\n") -2)
593 (looking-back "\n\n+" nil t)) 593 ;; Really the end of buffer.
594 (replace-match "\n"))) 594 (save-restriction (widen) (eobp)))
595 (delete-region (1+ (point)) end-marker))
595 (set-marker end-marker nil)))) 596 (set-marker end-marker nil))))
596 ;; Return nil for the benefit of `write-file-functions'. 597 ;; Return nil for the benefit of `write-file-functions'.
597 nil) 598 nil)