On Mon, Aug 7, 2017 at 3:55 PM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> The proposal is to call (barf-if-buffer-read-only) before attempting to do
> the indent.

No objection here.

Thanks.
 
> change is required? Here's what's will happen: 1. User: Try indentation
> (C-x h M-x indent-region) 2. User: Could take several seconds or few
> minutes (depending on major mode and file size) 3. Emacs: "Bummer, couldn't
> save all that indentation because the buffer is read-only". 4. User: Make

Indentation of a region isn't done by computing the complete result and
then "saving" it into the buffer.  So the error will be signaled as soon
as the indent-region finds a line whose indentation should be changed.
Usually that's almost instantaneous, but indeed in some cases it can
take a while (e.g. in large regions that are already indented except for
the last few lines).

Thanks for explaining the behavior. That explains why the read-only buffer error is not thrown if the buffer is already indented. 
--

Kaushal Modi