Subject: Re: bug#22819: 25.0.91; Don't try to indent region if the buffer is read-only

From: Kaushal Modi <[email-masked]>
Date: Mon, 07 Aug 2017 17:45:36 +0000

On Sat, Aug 5, 2017 at 7:50 AM Kaushal Modi <[email-masked]> wrote:

>
> Thanks Noam for reviewing this. I am away from PC for a few days. I'll
> review your patch next week on Tuesday.
>

Hi Noam,

I was able to try the patch sooner.

I use verilog-mode and tried out your patch on a huge SystemVerilog file,
which usually takes a tangible amount of time (10's of seconds) to indent
the whole file -- C-x h C-M-\

When using (barf-if-buffer-read-only):
- The failure due to a buffer being read-only is instantaneous.
- As soon as I do C-x h C-M-\, I get:

== *Messages* ==
Buffer is read-only: #<buffer file.sv>
=====

When using (interactive "*r\nP"):
- The failure happens soon, but not instantaneously.. I start seeing the
progress percentage of the indentation happening, and then the read-only
error shows.
- After I do C-x h C-M-\, I get the below after a second or two:

== *Messages* ==
indent-region
Indenting region...45%
verilog-do-indent: Buffer is read-only: #<buffer file.sv>
=====

So looks like the read-only check based on interactive form is kicked in
some time after the user calls indent-region.. I tried looking at
verilog-do-indent code in verilog-mode.el[1], but I couldn't understand why
interactive * based error is delayed.

[1]:
http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/verilog-mode.el
-- 

Kaushal Modi