[Python-Dev] whitespace normalization

skip at pobox.com skip at pobox.com
Thu Apr 26 04:53:01 CEST 2007


    >> Just a little FYI, python-mode (the one Barry and I manage - dunno
    >> about the one distributed w/ GNU Emacs these days) is one of those
    >> tools that leaves trailing whitespace behind when advancing to the
    >> next line..

(See my earlier retraction...)

    Greg> I get extremely annoyed with editors that *don't* leave whitespace
    Greg> at the end of lines alone, at least while you're working on the
    Greg> file. You type part of a line, leave a space, go to copy something
    Greg> from somewhere else to put on the end, and when you get back, the
    Greg> space you deliberately left there is gone.

That's not the way python-mode works.  If I enter this:

    def f(a):
        b = a * a
        @
        %
then hit LF or RET after the statement, it inserts a newline and inserts
enough spaces to leave the cursor where I placed the @ sign.  If I hit
another LF or RET it removes the "trailing" whitespace on the current line,
enters a newline and inserts enough spaces to leave the cursor where I
placed the % sign.

    Greg> Stripping trailing whitespace on saving wouldn't be
    Greg> so bad, though. Is there an option for that in python-mode?

Not by default.  You could add a hook to write-file-hooks though.

Skip


More information about the Python-Dev mailing list