[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r105890: * lisp/simple.el (delete-tra
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r105890: * lisp/simple.el (delete-trailing-whitespace): Document last change; simplify. |
Date: |
Fri, 23 Sep 2011 11:06:14 -0400 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 105890
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Fri 2011-09-23 11:06:14 -0400
message:
* lisp/simple.el (delete-trailing-whitespace): Document last change; simplify.
modified:
lisp/ChangeLog
lisp/simple.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2011-09-23 14:56:00 +0000
+++ b/lisp/ChangeLog 2011-09-23 15:06:14 +0000
@@ -1,3 +1,8 @@
+2011-09-23 Stefan Monnier <address@hidden>
+
+ * simple.el (delete-trailing-whitespace):
+ Document last change; simplify.
+
2011-09-23 Peter J. Weisberg <address@hidden>
* simple.el (delete-trailing-whitespace): Also delete
=== modified file 'lisp/simple.el'
--- a/lisp/simple.el 2011-09-23 14:56:00 +0000
+++ b/lisp/simple.el 2011-09-23 15:06:14 +0000
@@ -568,6 +568,7 @@
All whitespace after the last non-whitespace character in a line is deleted.
This respects narrowing, created by \\[narrow-to-region] and friends.
A formfeed is not considered whitespace by this function.
+If END is nil, also delete all trailing lines at the end of the buffer.
If the region is active, only delete whitespace within the region."
(interactive (progn
(barf-if-buffer-read-only)
@@ -580,18 +581,18 @@
(start (or start (point-min))))
(goto-char start)
(while (re-search-forward "\\s-$" end-marker t)
- (skip-syntax-backward "-" (save-excursion (forward-line 0) (point)))
+ (skip-syntax-backward "-" (line-beginning-position))
;; Don't delete formfeeds, even if they are considered whitespace.
- (save-match-data
- (if (looking-at ".*\f")
- (goto-char (match-end 0))))
+ (if (looking-at-p ".*\f")
+ (goto-char (match-end 0)))
(delete-region (point) (match-end 0)))
- (save-restriction
- (goto-char end-marker)
- (widen)
- (if (and (eobp)
- (looking-back "\n\n+" nil t))
- (replace-match "\n")))
+ ;; Delete trailing empty lines.
+ (goto-char end-marker)
+ (when (and (not end)
+ (<= (skip-chars-backward "\n") -2)
+ ;; Really the end of buffer.
+ (save-restriction (widen) (eobp)))
+ (delete-region (1+ (point)) end-marker))
(set-marker end-marker nil))))
;; Return nil for the benefit of `write-file-functions'.
nil)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r105890: * lisp/simple.el (delete-trailing-whitespace): Document last change; simplify.,
Stefan Monnier <=