Re: [PATCH] Trim trailing whitespace in vim and emacs

From: David Fetter <david(at)fetter(dot)org>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Trim trailing whitespace in vim and emacs
Date: 2018-06-05 17:51:14
Message-ID: 20180605175113.GE10899@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jun 05, 2018 at 01:28:54PM -0400, Alvaro Herrera wrote:
> On 2018-Jun-05, David Fetter wrote:
> Hi David
>
> > Here's my attempt to $subject. I've tested with vim, but I'm much less
> > certain I got the EMACS code right.
> >
> > Is there any interest in such a feature?
>
> I'd rather have the editor warn me (highlight) such things rather than
> fix them silently (I wonder if it'd cause a mess with regression .out
> files for example, which I do edit on occasion).

For what it's worth, the patch trims trailing whitespace only on
certain types of files in vim and just one (C) in emacs for just this
reason.

> I once tried to have vim highlight trailing whitespace, spaces before
> tabs, and overlength lines (>80 chars), and while I could do each thing
> in isolation, I wasn't able to get it to highlight the three of them at
> the same time. If you have a recipe for that, I welcome it.

In vim, one way to do it is:

highlight link sensibleWhitespaceError Error
autocmd Syntax * syntax match sensibleWhitespaceError excludenl /\s\+\%#\@<!$\| \+\ze\t|^.\{81,}/ display containedin=ALL

I'm sure there's something more elegant in emacs, but I'm not sure
what it is.

Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-06-05 17:52:09 Re: Spilling hashed SetOps and aggregates to disk
Previous Message Jeff Davis 2018-06-05 17:47:49 Re: Spilling hashed SetOps and aggregates to disk