all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: Emacs developers <emacs-devel@gnu.org>
Subject: [RFC] Do indent-region only on editable buffers
Date: Mon, 07 Aug 2017 17:36:10 +0000	[thread overview]
Message-ID: <CAFyQvY3X69T8n7XGk+43rvjHFGNEzMR4GHRECQmqGmE9AEpESg@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2017-08-07 17:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-07 17:36 Kaushal Modi [this message]
2017-08-07 17:46 ` [RFC] Do indent-region only on editable buffers 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFyQvY3X69T8n7XGk+43rvjHFGNEzMR4GHRECQmqGmE9AEpESg@mail.gmail.com \
    --to=kaushal.modi@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.