From xemacs-m  Sun Apr 20 07:22:08 1997
Received: from web2.ndsoft.com (root@web2.ndsoft.com [199.203.68.30])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id HAA29646
	for <xemacs-beta@xemacs.org>; Sun, 20 Apr 1997 07:21:53 -0500 (CDT)
Received: from romeo.ndsoft.com (romeo [194.90.171.61])
	by web2.ndsoft.com (8.8.5/8.8.5) with SMTP id OAA11249
	for <xemacs-beta@xemacs.org>; Sun, 20 Apr 1997 14:16:08 +0300
Received: from ndsoft.com (piccard) by romeo.ndsoft.com (4.1/SMI-4.1)
	id AA19103; Sun, 20 Apr 97 14:21:26 IST
Received: by ndsoft.com (4.1/SMI-4.1)
	id AA19504; Sun, 20 Apr 97 15:21:23 IDT
Date: Sun, 20 Apr 97 15:21:23 IDT
Message-Id: <9704201221.AA19504@ndsoft.com>
From: "Amir J. Katz" <amir@ndsoft.com>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="FSF-Craig_Livingstone-qXmfJ"
Content-Transfer-Encoding: 7bit
To: xemacs-beta@xemacs.org (XEmacs Beta List)
Subject: Nice package - remove trailing spaces
X-Mailer: VM 6.27 under 20.1 XEmacs Lucid
Reply-To: amir@ndsoft.com
X-Face:  ##A>t)R3?k=s5sw'(<v}xy5K8i]2+gl@^A7,ZN.8v5,).3hzG^rRmob&I-^&2m>5K\s3KSk+iIbgHIrS_8k}#}MVff9#>t4r!a>yp<qFqhM>pweVJ!^S<@teMIaDDU(gXk!,)m]o|"X



--FSF-Craig_Livingstone-qXmfJ
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

IMHO, this little gem should go into XE distribution (assuming that
the author is willing to support it).
All it does is to remove all trailing spaces throughout the buffer(s).
Especially useful in C files when you accidentally add a space after 
a continuation character and wonder why the compiler emits 56 error
messages... 

Written by Paul D. Smith <psmith@BayNetworks.com>


--FSF-Craig_Livingstone-qXmfJ
Content-Type: text/plain
Content-Description: rm-tspaces.el
Content-Disposition: inline;
	filename="rm-tspaces.el"
Content-Transfer-Encoding: 7bit

;; rm-tspaces.el: Automatically clean trailing whitespace from buffers.
;;
;; Copyright (C) 1995  Paul D. Smith <psmith@BayNetworks.com>
;;
;; This file requires Emacs 19 or above.  It should work with both Emacs
;; and XEmacs.  Use (require 'rm-tspaces) to load this file (don't
;; autoload it).
;;
;; For user-invoked whitespace cleanup, the function rm-trailing-spaces
;; can be bound to a key or invoked via M-x.
;;
;; The variable rm-trailing-spaces controls behavior when the buffer is
;; saved.  By default nothing is done.  See the documentation of this
;; variable for details.
;;
;; The variable rm-trailing-spaces is buffer-local.  Use setq-default to
;; set the default value for all buffers.  Use setq to override the
;; default value for a particular buffer.  If you're going to put the
;; setq in a hook, use the handy hook functions at the end of this file
;; to avoid having to write your own.
;;
;; For example, to be asked about removal for all buffers, except
;; automatically remove spaces in C files, try something like this:
;;
;;  (require 'rm-tspaces)
;;  (setq-default rm-trailing-spaces 1) ; any non-nil, non-t value
;;
;;  (add-hook 'c-mode-hook 'rm-trailing-spaces-always)
;;
;; Note the user is only queried when there is actually trailing
;; whitespace in the buffer (e.g., the buffer would be modified).
;;
;;  This program is free software; you can redistribute it and/or modify
;;  it under the terms of the GNU General Public License as published by
;;  the Free Software Foundation; either version 2, or (at your option)
;;  any later version.
;;
;; Changes:
;;  1.2 - Add version info.
;;        Add simple functions to make installing in hooks simpler.


(defvar rm-trailing-spaces nil
  "*Value of t says silently remove all trailing spaces when a file is saved.
Non-nil but not t says ask user whether to remove trailing spaces or not.
nil means don't remove trailing spaces.")
(make-variable-buffer-local 'rm-trailing-spaces)


;; What are we?
;;
(defconst rm-tspaces-version (substring "$Revision: 1.2 $" 11 -2)
  "$Id: rm-tspaces.el,v 1.2 1996/05/29 19:16:38 psmith Exp $")


(defun rm-trailing-spaces-internal ()
  "Deletes trailing whitespace from all lines in the current buffer."
  (if (and (not buffer-read-only) rm-trailing-spaces)
      (save-excursion
	(goto-char (point-min))
	(if (or (eq rm-trailing-spaces t)
		(and (re-search-forward "[ \t]$" nil 1)
		     (y-or-n-p
		      (format "Remove trailing spaces in buffer %s? "
			      (buffer-name)))))
	    (while (< (point) (point-max))
	      (end-of-line nil)
	      (delete-horizontal-space)
	      (forward-line 1)))))
  nil) ; indicates buffer-not-saved for write-file-hooks

(defun rm-trailing-spaces ()
  "Deletes trailing whitespace from all lines in the current buffer."
  (interactive "*")
  (message "Deleting trailing spaces... ")
  (let ((rm-trailing-spaces t))
    (rm-trailing-spaces-internal))
  (message "Deleting trailing spaces... done"))


;; Apply this function automatically to all buffers before they're saved.
;;
(add-hook 'write-file-hooks 'rm-trailing-spaces-internal)


;; Provide some simple functions for inclusion in hooks variables
;;
(defun rm-trailing-spaces-never ()
  "Don't automatically delete trailing whitespace in this buffer."
  (setq rm-trailing-spaces nil))

(defun rm-trailing-spaces-ask ()
  "Ask before deleting trailing whitespace in this buffer."
  (setq rm-trailing-spaces 1))

(defun rm-trailing-spaces-always ()
  "Always automatically delete trailing whitespace in this buffer."
  (setq rm-trailing-spaces t))


(provide 'rm-tspaces)

;; rm-tspaces.el ends here

--FSF-Craig_Livingstone-qXmfJ
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


-- 
/* Amir J. Katz  E-mail: amir@ndsoft.com   URL: http://www.ndsoft.com */
/* EagleEye Control Software, LTD., Tel-Aviv, Israel                  */
/* .. I busted a mirror and got seven years bad luck, but my        ..*/
/* .. lawyer thinks he can get me five.        (Steven Wright)      ..*/

--FSF-Craig_Livingstone-qXmfJ--

