diff options
| author | Chong Yidong | 2012-07-28 18:38:55 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-07-28 18:38:55 +0800 |
| commit | 345a2258671ec587a32129daf37fb53b3eea903e (patch) | |
| tree | d56dcdb70927a4cf7855ce14484a050846975279 | |
| parent | 049a0936caca462a2f12107813a24b70eeb97c3e (diff) | |
| download | emacs-345a2258671ec587a32129daf37fb53b3eea903e.tar.gz emacs-345a2258671ec587a32129daf37fb53b3eea903e.zip | |
* simple.el (delete-trailing-lines): New option.
(delete-trailing-whitespace): Obey it.
Fixes: debbugs:11879
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/simple.el | 28 |
3 files changed, 31 insertions, 6 deletions
| @@ -147,6 +147,10 @@ for it. | |||
| 147 | 147 | ||
| 148 | * Editing Changes in Emacs 24.2 | 148 | * Editing Changes in Emacs 24.2 |
| 149 | 149 | ||
| 150 | ** New option `delete-trailing-lines' specifies whether the | ||
| 151 | M-x delete-trailing-lines command should delete trailing lines at the | ||
| 152 | end of the buffer. It defaults to t. | ||
| 153 | |||
| 150 | ** Search changes | 154 | ** Search changes |
| 151 | 155 | ||
| 152 | *** Global `M-s _' starts a symbol (identifier) incremental search, | 156 | *** Global `M-s _' starts a symbol (identifier) incremental search, |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a158e4f347a..410a23592df 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-07-28 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * simple.el (delete-trailing-lines): New option. | ||
| 4 | (delete-trailing-whitespace): Obey it (Bug#11879). | ||
| 5 | |||
| 1 | 2012-07-28 David Engster <deng@randomsample.de> | 6 | 2012-07-28 David Engster <deng@randomsample.de> |
| 2 | 7 | ||
| 3 | * xml.el (xml-node-name, xml-parse-file, xml-parse-region): | 8 | * xml.el (xml-node-name, xml-parse-file, xml-parse-region): |
diff --git a/lisp/simple.el b/lisp/simple.el index 3240ede0299..2011ff2b1bb 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -564,13 +564,28 @@ On nonblank line, delete any immediately following blank lines." | |||
| 564 | (if (looking-at "^[ \t]*\n\\'") | 564 | (if (looking-at "^[ \t]*\n\\'") |
| 565 | (delete-region (point) (point-max))))) | 565 | (delete-region (point) (point-max))))) |
| 566 | 566 | ||
| 567 | (defcustom delete-trailing-lines t | ||
| 568 | "If non-nil, \\[delete-trailing-whitespace] deletes trailing lines. | ||
| 569 | Trailing lines are deleted only if `delete-trailing-whitespace' | ||
| 570 | is called on the entire buffer (rather than an active region)." | ||
| 571 | :type 'boolean | ||
| 572 | :group 'editing | ||
| 573 | :version "24.2") | ||
| 574 | |||
| 567 | (defun delete-trailing-whitespace (&optional start end) | 575 | (defun delete-trailing-whitespace (&optional start end) |
| 568 | "Delete all the trailing whitespace across the current buffer. | 576 | "Delete trailing whitespace between START and END. |
| 569 | All whitespace after the last non-whitespace character in a line is deleted. | 577 | If called interactively, START and END are the start/end of the |
| 570 | This respects narrowing, created by \\[narrow-to-region] and friends. | 578 | region if the mark is active, or of the buffer's accessible |
| 571 | A formfeed is not considered whitespace by this function. | 579 | portion if the mark is inactive. |
| 572 | If END is nil, also delete all trailing lines at the end of the buffer. | 580 | |
| 573 | If the region is active, only delete whitespace within the region." | 581 | This command deletes whitespace characters after the last |
| 582 | non-whitespace character in each line between START and END. It | ||
| 583 | does not consider formfeed characters to be whitespace. | ||
| 584 | |||
| 585 | If this command acts on the entire buffer (i.e. if called | ||
| 586 | interactively with the mark inactive, or called from Lisp with | ||
| 587 | END nil), it also deletes all trailing lines at the end of the | ||
| 588 | buffer if the variable `delete-trailing-lines' is non-nil." | ||
| 574 | (interactive (progn | 589 | (interactive (progn |
| 575 | (barf-if-buffer-read-only) | 590 | (barf-if-buffer-read-only) |
| 576 | (if (use-region-p) | 591 | (if (use-region-p) |
| @@ -590,6 +605,7 @@ If the region is active, only delete whitespace within the region." | |||
| 590 | ;; Delete trailing empty lines. | 605 | ;; Delete trailing empty lines. |
| 591 | (goto-char end-marker) | 606 | (goto-char end-marker) |
| 592 | (when (and (not end) | 607 | (when (and (not end) |
| 608 | delete-trailing-lines | ||
| 593 | ;; Really the end of buffer. | 609 | ;; Really the end of buffer. |
| 594 | (save-restriction (widen) (eobp)) | 610 | (save-restriction (widen) (eobp)) |
| 595 | (<= (skip-chars-backward "\n") -2)) | 611 | (<= (skip-chars-backward "\n") -2)) |