[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    for all XEmacs users
From:       "Dirk A. Mueller" <mueller () kde ! org>
Date:       1999-11-25 0:39:45
[Download RAW message or body]

Hi, 

XEmacs (probably also Emacs, don't know) per default can't trim trailing
spaces from lines, like all other editors do. Especially if you reformat
your source using XEmacs and somebody who's using a different editor
commits a change to the file, he also commits many lines that only have a
change in the amount of white space, nothing more. 

The next time a XEmacs user edits the file, there are again many lines with
only changes in the amount of white space. 

You see the problem, it makes reading diffs more difficult and
produces unnecessarily high delta's between revisions on the CVS server. 

A few weeks ago I found a nice elisp hook (.emacs from agulbra@troll.no)
that forces XEmacs to trim the lines while loading. I adopted it to do that
during saving, as it makes more sense there. 

So, please, everybody who uses XEmacs, please add the following lines to
your ~/.emacs: 

(defun agulbra-clean-out-spaces ()
  "Remove spaces at ends of lines"
  (interactive)
  (and ;;(eq major-mode 'c++-mode)
       (not buffer-read-only)
       (save-excursion
         (goto-char (point-min))
         (let ((count 0)
               (bmp (buffer-modified-p)))
           (while (re-search-forward "  *$" nil t)
             (setq count (1+ count))
             (replace-match "" t t))
           (and (> count 0)
                (progn
                  (set-buffer-modified-p bmp)
                  (message "Cleaned %d lines" count)))))) nil)
(add-hook 'write-file-hooks 'agulbra-clean-out-spaces)

(custom-set-variables
 '(require-final-newline t)
) 


Thanks in advance. 

Dirk

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic