Trailing Whitespace Tips (was: Re: starting to review the Extend NOT NULL representation to pg_constraint patch)

From: Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bernd Helmle <mailings(at)oopsware(dot)de>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Geery <andrew(dot)geery(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Trailing Whitespace Tips (was: Re: starting to review the Extend NOT NULL representation to pg_constraint patch)
Date: 2010-10-15 20:45:18
Message-ID: m2sk072nj5.fsf_-_@2ndQuadrant.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> * Lots of bogus trailing whitespace. "git diff --check" can help you
> with that.

This is a repetitive common remark that I think sharing tips to avoid
that problem is a good idea. Here's an emacs setup to have trailing
whitespace hurt the eyes, and more-than-80 columns lines too. This one
is more controversial as we find lots of long lines in the PostgreSQL
sources. Still:

;; display only tails of lines longer than 80 columns, and
;; trailing whitespaces
(require 'whitespace)
(setq whitespace-line-column 80
whitespace-style '(face trailing lines-tail empty))

;; face for tabs long lines' tails
(set-face-attribute 'whitespace-tab nil
:background "red1"
:foreground "yellow"
:weight 'bold)

(set-face-attribute 'whitespace-line nil
:background "red1"
:foreground "yellow"
:weight 'bold)

;; activate minor whitespace mode when in some coding modes
(add-hook 'emacs-lisp-mode-hook 'whitespace-mode)
(add-hook 'python-mode-hook 'whitespace-mode)
(add-hook 'c-mode-hook 'whitespace-mode)

Now, it's easy to find some more about it, including images of how it
looks. You can't miss trailing whitespace any more :

http://ruslanspivak.com/2010/09/27/keep-track-of-whitespaces-and-column-80-overflow/
http://panela.blog-city.com/python_and_emacs_4_whitespace_tabs_tabwidth_visualizi.htm
http://www.emacswiki.org/emacs/WhiteSpace

I suppose people using other editors or tools will come up with other
tricks and tips. Maybe it should go in src/tools/editors/emacs.samples,
too?

Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2010-10-15 20:58:15 Re: [JDBC] Support for JDBC setQueryTimeout, et al.
Previous Message Tom Lane 2010-10-15 20:22:51 Re: [JDBC] Support for JDBC setQueryTimeout, et al.