Am 09.06.2011 14:42, schrieb Jeff Sparkes:
I copied the delete-trailing-whitespace from emacs23/lisp/simple.el.
I wrote the documentation entry myself; it needs to be reviewed.
I couldn't find a section on whitespace to reference, so I just said
"spaces and tabs". Pedantically it removes the regexp \s-, skipping
formfeeds. How much detail should I go into?
diff --git a/lisp/simple.el b/lisp/simple.el
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -329,6 +329,23 @@
(insert ? ))
(delete-region (point) (progn (skip-chars-forward " \t") (point))))
+(defun delete-trailing-whitespace ()
+ "Delete all the trailing whitespace across the current buffer.
+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."
+ (interactive "*")
+ (save-match-data
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward "\\s-$" nil t)
+ (skip-syntax-backward "-" (save-excursion (forward-line 0) (point)))
+ ;; Don't delete formfeeds, even if they are considered whitespace.
Hi,
while I'm following that rationale not to delete formfeeds: user might
do still different considerations.
What about a customizable chars-list specifying what as whitespace
should be considered?
Indicating chars in a list is much easier than changing syntax for most
of users IMO.
+ (save-match-data
+ (if (looking-at ".*\f")
+ (goto-char (match-end 0))))
It might mean: whitespaces followed by a formfeed will be preserved.
Seems not reasonable.
Cheers,
Andreas
+ (delete-region (point) (match-end 0))))))
+
(defun delete-blank-lines ()
"On blank line, delete all surrounding blank lines, leaving just one.
On isolated blank line, delete that one.
diff --git a/man/xemacs/killing.texi b/man/xemacs/killing.texi
--- a/man/xemacs/killing.texi
+++ b/man/xemacs/killing.texi
@@ -99,6 +99,12 @@
the next line by deleting a newline and all surrounding spaces, possibly
leaving a single space. @xref{Indentation,M-^}.
+@findex delete-trailing-whitespace
+ @code{delete-trailing-whitespace} deletes spaces and tabs at the end
+of all of the lines in the current buffer or region
+(@pxref{Narrowing}). This command does not remove formfeed
+characters.
+
@subsection Killing by Lines
@table @kbd
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta