Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only when there are no existing problems

From: Reuben Thomas <[email-masked]>
Date: Mon, 27 Jan 2014 13:25:01 +0000

On 27 January 2014 01:52, Stefan Monnier <[email-masked]> wrote:

>
> I could be convinced to install it if it's "obviously safe".
> The patch as sent is a large chunk of "new" code plus a large chunk of
> "removed" code, so it's not very appealing.  Diffing while ignoring
> whitespace indicates it's more of a "refactoring", and by introducing an
> "artificial" new function while helps keep the text lines in the
> original order (and hence helps reduce the size of the diff), I get the
> patch below.
>

Thanks very much for trying.

> But it's not obviously safe to me.  Two non-obvious parts are:
> - the removal of "(add-to-list 'whitespace-style (car option))".
>

The removal looks wrong to me too: without that code, the force argument
has no effect. On the other hand, the way it's implemented also seems
wrong, as it permanently changes whitespace-style.

> - the change from has-bogus to bogus-list, where bogus-list will
>   (initially) only be nil if whitespace-report-list is nil.
>

As far as I can see, has-bogus was set whenever an element was added to
bogus-list. Hence, bogus-list is nil when has-bogus was nil. bogus-list is
a list of whichever elements of whitespace-report-list problems are found,
so if no problem is found, it will be nil.

> Another problem is that the docstring of whitespace-test-region does not
> accurately describe its return value.
>

So the return value is currently a list of flags corresponding to elements
of whitespace-report-list.

Two more things:

1. I would like to refactor the description of whitespace problems in
whitespace-report-region to move those which are the same regardless of the
value of indent-tabs-mode into a separate list.

2. Since we're no longer going for getting this into 24.4, can we fold your
"artificial" whitespace--report-report-region back into
whitespace-report-region, which both simplifies the end result slightly,
and avoids the question of whether the new function should be moved down
into "internal functions"?