unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [RFC] Do indent-region only on editable buffers
@ 2017-08-07 17:36 Kaushal Modi
  2017-08-07 17:46 ` Drew Adams
  2017-08-07 19:55 ` Stefan Monnier
  0 siblings, 2 replies; 7+ messages in thread
From: Kaushal Modi @ 2017-08-07 17:36 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1824 bytes --]

indent-region is an act of editing a buffer. So before attempting to do
that, it should be checked if the buffer is editable.

Bug#22819[1] raises that point.

The proposal is to call (barf-if-buffer-read-only) before attempting to do
the indent.

Motive for this change:

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
(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
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.

So the motive is to save time and alert user of their pilot error before
attempting to do an operation that would go to waste (in this case, doing
indent, and then waste all those CPU cycles because the changes couldn't
get saved to the file).

Question to the list:

- Are there any objections to doing the buffer read-only check before doing
the indent?

(PS: If user's still want to do indentation on read-only buffers, then can
always do C-x C-q (toggle read-only-mode) and then proceed to indent the
buffer.)

[1]: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22819
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 2729 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-08-07 23:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-07 17:36 [RFC] Do indent-region only on editable buffers Kaushal Modi
2017-08-07 17:46 ` Drew Adams
2017-08-07 17:56   ` Kaushal Modi
2017-08-07 18:13   ` Noam Postavsky
2017-08-07 19:55 ` Stefan Monnier
2017-08-07 20:07   ` Kaushal Modi
2017-08-07 23:03   ` John Wiegley

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).