[Fwd: Nabble - War on trailing whitespace]

All,

Trailing whitespace introduces noise--sometimes a *lot* of noise--into svn changesets. I would very much appreciate it if everyone would try to eliminate trailing whitespace before committing any changes to svn. (And also eliminate hard tabs--I haven't seen many new ones creeping in, but continuing vigilence is appreciated.)

Thank you.

Eric

Nabble - War on trailing whitespace (602 Bytes)

Hey Eric,

You probably already know about reindent.py; but since I would rather
not assume and run the risk that you aren't familiar with it, here it
is: http://svn.python.org/view/python/trunk/Tools/scripts/reindent.py?rev=55804&view=markup

It is part of the Python developer's tools and cleans up trailing
whitespace as well as fixing tabs. Ideally everyone should be mindful
as you request, but this is a useful script to occasionally run
anyway.

Thanks for all the great work,

···

On Nov 18, 2007 11:33 AM, Eric Firing <efiring@...229...> wrote:

Trailing whitespace introduces noise--sometimes a *lot* of noise--into
svn changesets. I would very much appreciate it if everyone would try
to eliminate trailing whitespace before committing any changes to svn.
(And also eliminate hard tabs--I haven't seen many new ones creeping in,
but continuing vigilence is appreciated.)

--
Jarrod Millman
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/

While I'm happy to play along ( I configured my emacs to detect
whitespace) and suspect I may have been a trailing whitespace
contributer, I fear this may be a case where the cure is worse than
the disease. As we all make commits to fix the trailing whitespaces,
since they are now glaringly ugly in my emacs buffer, I fear we will
see significantly more changesets which are whitespace only, than if
we simply configured our editors to ignore them.

JDH

···

On Nov 18, 2007 10:10 PM, Jarrod Millman <millman@...453...> wrote:

On Nov 18, 2007 11:33 AM, Eric Firing <efiring@...229...> wrote:
> Trailing whitespace introduces noise--sometimes a *lot* of noise--into
> svn changesets. I would very much appreciate it if everyone would try
> to eliminate trailing whitespace before committing any changes to svn.
> (And also eliminate hard tabs--I haven't seen many new ones creeping in,
> but continuing vigilence is appreciated.)

It made my merge from trunk to branch a little harder than it had to be, too.

I understand the drive for this, but there is that downside as well.

Cheers,
Mike

John Hunter wrote:

···

On Nov 18, 2007 10:10 PM, Jarrod Millman <millman@...453...> wrote:

On Nov 18, 2007 11:33 AM, Eric Firing <efiring@...229...> wrote:

Trailing whitespace introduces noise--sometimes a *lot* of noise--into
svn changesets. I would very much appreciate it if everyone would try
to eliminate trailing whitespace before committing any changes to svn.
(And also eliminate hard tabs--I haven't seen many new ones creeping in,
but continuing vigilence is appreciated.)

While I'm happy to play along ( I configured my emacs to detect
whitespace) and suspect I may have been a trailing whitespace
contributer, I fear this may be a case where the cure is worse than
the disease. As we all make commits to fix the trailing whitespaces,
since they are now glaringly ugly in my emacs buffer, I fear we will
see significantly more changesets which are whitespace only, than if
we simply configured our editors to ignore them.

JDH

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Michael Droettboom wrote:

It made my merge from trunk to branch a little harder than it had to be, too.

I understand the drive for this, but there is that downside as well.

John, Mike,

Yes, I understand, and I am sorry--but I hope it is one-time pain to avoid continuing pin-pricks. If svn ignored trailing whitespace, then there would be no problem; I could continue to use an editor that removes it, and you could continue to use editors that gratuitously add it, and usually it would make no difference. This is not the case, however. As it is now, if a file comes into svn without any trailing whitespace, and one of you loads it up, maybe makes a trivial change after running your cursor through it, and saves it--it will end up with a big changeset--lots of trailing whitespace. This is just plain bad. All downside, no upside.

Eric

···

Cheers,
Mike

John Hunter wrote:

On Nov 18, 2007 10:10 PM, Jarrod Millman <millman@...453...> wrote:

On Nov 18, 2007 11:33 AM, Eric Firing <efiring@...229...> wrote:

Trailing whitespace introduces noise--sometimes a *lot* of noise--into
svn changesets. I would very much appreciate it if everyone would try
to eliminate trailing whitespace before committing any changes to svn.
(And also eliminate hard tabs--I haven't seen many new ones creeping in,
but continuing vigilence is appreciated.)

While I'm happy to play along ( I configured my emacs to detect
whitespace) and suspect I may have been a trailing whitespace
contributer, I fear this may be a case where the cure is worse than
the disease. As we all make commits to fix the trailing whitespaces,
since they are now glaringly ugly in my emacs buffer, I fear we will
see significantly more changesets which are whitespace only, than if
we simply configured our editors to ignore them.

JDH

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

John Hunter wrote:

( I configured my emacs to detect
whitespace) and suspect I may have been a trailing whitespace
contributer,

Can you give me a pointer about what exactly you did? Just now, I just
discovered a whitespace-cleanup and a whitespace-visual-mode. It'd be
nice if there was something that automatically showed just tabs and
end-of-line whitespace. As it is, I found
whitespace-visual-set-whitespace-chars doesn't seem to have quite that
level of granularity. Have you configured anything beyond this?

Thanks,
Andrew

I ended up adding both of these to .emacs and restarting. Probably
one or the other would work. For some reason I had to restart, and
not just eval them in .emacs (??)

(add-hook 'python-mode-hook
          (lambda ()
      (setq show-trailing-whitespace t)
      ))

(mapc (lambda (hook)
      (add-hook hook (lambda ()
           (setq show-trailing-whitespace t))))
      '(python-mode-hook))

···

On Nov 21, 2007 1:37 PM, Andrew Straw <strawman@...36...> wrote:

Can you give me a pointer about what exactly you did? Just now, I just
discovered a whitespace-cleanup and a whitespace-visual-mode. It'd be
nice if there was something that automatically showed just tabs and
end-of-line whitespace. As it is, I found
whitespace-visual-set-whitespace-chars doesn't seem to have quite that
level of granularity. Have you configured anything beyond this?

Thanks, that works, but unforunately only on emacs21 but not xemacs 21.
Looks like I'll now have to find a way to do the one thing in emacs that
keeps me using xemacs: goto-line bound to M-g. (Any quick tips appreciated.)

-Andrew

John Hunter wrote:

···

On Nov 21, 2007 1:37 PM, Andrew Straw <strawman@...36...> wrote:

Can you give me a pointer about what exactly you did? Just now, I just
discovered a whitespace-cleanup and a whitespace-visual-mode. It'd be
nice if there was something that automatically showed just tabs and
end-of-line whitespace. As it is, I found
whitespace-visual-set-whitespace-chars doesn't seem to have quite that
level of granularity. Have you configured anything beyond this?

I ended up adding both of these to .emacs and restarting. Probably
one or the other would work. For some reason I had to restart, and
not just eval them in .emacs (??)

(add-hook 'python-mode-hook
          (lambda ()
      (setq show-trailing-whitespace t)
      ))

(mapc (lambda (hook)
      (add-hook hook (lambda ()
           (setq show-trailing-whitespace t))))
      '(python-mode-hook))

[oops, meant on-list ]

Thanks, that works, but unforunately only on emacs21 but not xemacs 21.
Looks like I'll now have to find a way to do the one thing in emacs that
keeps me using xemacs: goto-line bound to M-g. (Any quick tips appreciated.)

I recently switched to the 'pretty emacs' from

http://peadrop.com/blog/2007/09/17/pretty-emacs-reloaded/

so I could get decent fonts in emacs. I had to tweak my config a bit,
and for M-g I put this by hand in my config file:

(global-set-key "\M-g" 'goto-line) ; standard XEmacs

I can send you my configs which allow me to start this emacs (with
"emacs-snapshot-gtk --enable-font-backend") or plain xemacs in a
reasonably functional state for both.

Cheers,

f

···

On Nov 21, 2007 12:52 PM, Andrew Straw <strawman@...36...> wrote:

Eric Firing wrote:

Yes, I understand, and I am sorry--but I hope it is one-time pain to
avoid continuing pin-pricks. If svn ignored trailing whitespace, then
there would be no problem; I could continue to use an editor that
removes it, and you could continue to use editors that gratuitously add
it, and usually it would make no difference. This is not the case,
however. As it is now, if a file comes into svn without any trailing
whitespace, and one of you loads it up, maybe makes a trivial change
after running your cursor through it, and saves it--it will end up with
a big changeset--lots of trailing whitespace. This is just plain bad.
All downside, no upside.
  

FWIW, you can get svn diff to ignore (trailing whitespace) -- by not
using svn diff.

svn diff --diff-cmd diff -x -uw path/to/file.py

With apologies for previously hijacking your thread into an emacs
configure-a-thon, :slight_smile:
Andrew

Andrew Straw wrote:

Eric Firing wrote:

Yes, I understand, and I am sorry--but I hope it is one-time pain to avoid continuing pin-pricks. If svn ignored trailing whitespace, then there would be no problem; I could continue to use an editor that removes it, and you could continue to use editors that gratuitously add it, and usually it would make no difference. This is not the case, however. As it is now, if a file comes into svn without any trailing whitespace, and one of you loads it up, maybe makes a trivial change after running your cursor through it, and saves it--it will end up with a big changeset--lots of trailing whitespace. This is just plain bad. All downside, no upside.
  

FWIW, you can get svn diff to ignore (trailing whitespace) -- by not
using svn diff.

svn diff --diff-cmd diff -x -uw path/to/file.py

Almost. Quotes are needed for the diff options:

svn diff -x '-uw' path/to/file.py

This is useful, but doesn't help with the problem of noise in changesets.

With apologies for previously hijacking your thread into an emacs
configure-a-thon, :slight_smile:

No problem--everyone but me uses emacs or vi, it seems, so figuring out how to configure emacs is what it takes to address the problem.

Eric

Not that I've used one myself, but wouldn't this be most easily accomplished with a SVN commit hook -- i.e. whitespace would be stripped on every commit, rather than trying to enforce all developers setting up their editors correctly?

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...236...

Christopher Barker wrote:

Not that I've used one myself, but wouldn't this be most easily accomplished with a SVN commit hook -- i.e. whitespace would be stripped on every commit, rather than trying to enforce all developers setting up their editors correctly?

-Chris

That would be ideal, but it looks like sourceforge doesn't allow this, so we would have to move the project to another host.

http://sourceforge.net/docs/E09#scripts

Eric

Eric Firing wrote:

Christopher Barker wrote:

Not that I've used one myself, but wouldn't this be most easily accomplished with a SVN commit hook

That would be ideal, but it looks like sourceforge doesn't allow this, so we would have to move the project to another host.

http://sourceforge.net/docs/E09#scripts

Well, darn, That's a remarkably small list! Is there a way to petition them to add something else?

oh well,

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...236...

I think I may have found the ultimate emacs solution. It really
annoys me to see the trailing whitespace in my buffer. When I start a
new indented line but end up not adding anything there, it highlights
the region from the left of the to where the cursor was a trailing
whitespace so I have a lot of ugly red blocks in my buffer. My new
solution is not to highlight it, but to add a hook to emacs to delete
it whenever I save my buffer.

(add-hook 'python-mode-hook
          (lambda ()
      (add-hook 'local-write-file-hooks 'delete-trailing-whitespace)
      ))

Now I can be blissfully unaware of trailing whitespace as before, and
my editor will clean it out on save.

JDH

···

On Nov 21, 2007 1:52 PM, Andrew Straw <strawman@...36...> wrote:

Thanks, that works, but unforunately only on emacs21 but not xemacs 21.
Looks like I'll now have to find a way to do the one thing in emacs that
keeps me using xemacs: goto-line bound to M-g. (Any quick tips appreciated.)

For those using emacs-22.1 (apparently local-write-file-hooks is deprecated and didn't work for me) --->

(setq python-mode-hook
       '(lambda ()
          (add-hook 'write-file-functions 'delete-trailing-whitespace)
))

Maybe we should do a big trailing whitespace removal en masse once we move the transforms branch to trunk to get this taken care of once and for all... (?)

Cheers,
Mike

John Hunter wrote:

···

On Nov 21, 2007 1:52 PM, Andrew Straw <strawman@...36...> wrote:

Thanks, that works, but unforunately only on emacs21 but not xemacs 21.
Looks like I'll now have to find a way to do the one thing in emacs that
keeps me using xemacs: goto-line bound to M-g. (Any quick tips appreciated.)

I think I may have found the ultimate emacs solution. It really
annoys me to see the trailing whitespace in my buffer. When I start a
new indented line but end up not adding anything there, it highlights
the region from the left of the to where the cursor was a trailing
whitespace so I have a lot of ugly red blocks in my buffer. My new
solution is not to highlight it, but to add a hook to emacs to delete
it whenever I save my buffer.

(add-hook 'python-mode-hook
          (lambda ()
      (add-hook 'local-write-file-hooks 'delete-trailing-whitespace)
      ))

Now I can be blissfully unaware of trailing whitespace as before, and
my editor will clean it out on save.

JDH

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

John Hunter wrote:

Thanks, that works, but unforunately only on emacs21 but not xemacs 21.
Looks like I'll now have to find a way to do the one thing in emacs that
keeps me using xemacs: goto-line bound to M-g. (Any quick tips appreciated.)

I think I may have found the ultimate emacs solution. It really
annoys me to see the trailing whitespace in my buffer. When I start a
new indented line but end up not adding anything there, it highlights
the region from the left of the to where the cursor was a trailing
whitespace so I have a lot of ugly red blocks in my buffer. My new
solution is not to highlight it, but to add a hook to emacs to delete
it whenever I save my buffer.

(add-hook 'python-mode-hook
          (lambda ()
      (add-hook 'local-write-file-hooks 'delete-trailing-whitespace)
      ))

Now I can be blissfully unaware of trailing whitespace as before, and
my editor will clean it out on save.

John,

Excellent! I always thought that something like this should be the solution--and should be a standard part of python mode (and of other language-specific modes)--but not being an emacs user, I did not know how to do it.

I assume there is also some sort of C and/or C++ mode, and similar hook additions are needed for them--correct? Or is there a hierarchy of modes, in which case a single hook could go at a higher level?

Eric

···

On Nov 21, 2007 1:52 PM, Andrew Straw <strawman@...36...> wrote:

I don't know about a hierarchy, but there is a c++-mode-hook and a
c-mode-hook. I've updated the CODING_GUIDE to advise emacs users to
set these hooks. Soon your nightmare of trailing whitespaces will be
nothing more than a nasty memory ....

JDH

···

On Nov 28, 2007 11:46 AM, Eric Firing <efiring@...229...> wrote:

I assume there is also some sort of C and/or C++ mode, and similar hook
additions are needed for them--correct? Or is there a hierarchy of
modes, in which case a single hook could go at a higher level?

I think the emacs version dependency in the CODING_GUIDE may be backward.

AFAIK, "write-file-functions" is the current one to use for emacs 22
(the latest released version) and beyond. "local-write-file-hooks" is
the old deprecated way.

The docstring for local-write-file-hooks is:

"This variable is obsolete since 22.1; use `write-file-functions' instead."

So, I think perhaps this description in CODING_GUIDE is backward, but
wanted to double check before I fix it.

Cheers,
Mike

···

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

John Hunter wrote:

On Nov 28, 2007 11:46 AM, Eric Firing <efiring@...229...> wrote:

I assume there is also some sort of C and/or C++ mode, and similar hook
additions are needed for them--correct? Or is there a hierarchy of
modes, in which case a single hook could go at a higher level?

I don't know about a hierarchy, but there is a c++-mode-hook and a
c-mode-hook. I've updated the CODING_GUIDE to advise emacs users to
set these hooks. Soon your nightmare of trailing whitespaces will be
nothing more than a nasty memory ....

JDH

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Yep, good catch. I updated the doc. I think I have it this time...

Please do not commit lines with trailing white space, as it causes
noise in svn diffs. If you are an emacs user, the following in your
.emacs will cause emacs to strip trailing white space on save for
python, C and C++

; and similarly for c++-mode-hook and c-mode-hook
(add-hook 'python-mode-hook
          (lambda ()
    (add-hook 'write-file-functions 'delete-trailing-whitespace)))

for older versions of emacs (emacs<22) you need to do

(add-hook 'python-mode-hook
          (lambda ()
          (add-hook 'local-write-file-hooks 'delete-trailing-whitespace)))

···

On Nov 28, 2007 12:22 PM, Michael Droettboom <mdroe@...31...> wrote:

So, I think perhaps this description in CODING_GUIDE is backward, but
wanted to double check before I fix it.