bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Kaushal Modi
Subject: bug#22819: 25.0.91; Don't try to indent region if the buffer is read-only
Date: Sat, 05 Aug 2017 11:50:59 +0000

On Sat, Aug 5, 2017, 2:53 AM Eli Zaretskii <eliz@gnu.org> wrote:
> From: npostavs@users.sourceforge.net
> Date: Fri, 04 Aug 2017 21:56:11 -0400
> Cc: 22819@debbugs.gnu.org
>
> I wonder if someone will complain that they were relying on this
> behaviour to check indentation in read-only buffers (currently if the
> indentation is already correct there is no error).

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

The act of indenting is an editing action. So the buffer should be checked if it's editable before attempting an indent. If the buffer is read-only and no indentation change is required, then good. But what if indentation change is required? Here's what's will happen:

1. User: Try indentation
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 buffer editable. It's not a simple act of chmod. In my case, the buffer was read-only because the file is part of a centralized version control system (Cliosoft SOS). In "checked in" state, the file is just a symlink to the cached version in server, and thus read-only. To make it editable, I need to "check out" the file. That act replaces the symlink link with a physical file copy. 
5. User: Re-do that several seconds/minutes long indentation.

My commit saves the user from wasting that time in Step 2 above. 

The original submission provided no rationale for the change, so it's
hard to reason about its advantages.

Please consider the above use case. 

The
clear disadvantage is that
this goes 

I am failing to see the disadvantage.  

Before: Do indent > Attempt to write that indent to buffer

After (my patch): Check if buffer is writable > Do indent > Attempt to write that indent. 

Isn't it just logical that if you need to do an expensive indentation, the buffer should be checked if it's editable to prevent spending that time twice?

>against veteran Emacs behavior regarding read->only text,
>behavior that is present in several other >commands, and that AFAIR
>resulted from some past discussions.

This is the only one that provided me this surprise in about a decade of Emacs use. Which other commands do the text manipulation, and then check the buffer read-only status? 

If
 the rationale is user surprise, then I'd suggest to leave the
current behavior unchanged.

The flip question is: How common is a workflow, where a buffer is read-only, user does indentation, and is fine with seeing that error after the fact?
--

Kaushal Modi


reply via email to

[Prev in Thread] Current Thread [Next in Thread]