From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Kaushal Modi Newsgroups: gmane.emacs.devel Subject: [RFC] Do indent-region only on editable buffers Date: Mon, 07 Aug 2017 17:36:10 +0000 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="f403045fb914fa74a005562d4866" X-Trace: blaine.gmane.org 1502127441 5829 195.159.176.226 (7 Aug 2017 17:37:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 7 Aug 2017 17:37:21 +0000 (UTC) To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 07 19:37:07 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1delxf-0000iN-63 for ged-emacs-devel@m.gmane.org; Mon, 07 Aug 2017 19:37:03 +0200 Original-Received: from localhost ([::1]:38673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1delxl-0002na-BC for ged-emacs-devel@m.gmane.org; Mon, 07 Aug 2017 13:37:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1delx8-0002n2-Bj for emacs-devel@gnu.org; Mon, 07 Aug 2017 13:36:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1delx3-0000lX-5K for emacs-devel@gnu.org; Mon, 07 Aug 2017 13:36:30 -0400 Original-Received: from mail-lf0-x22f.google.com ([2a00:1450:4010:c07::22f]:37568) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1delx2-0000kd-Tj for emacs-devel@gnu.org; Mon, 07 Aug 2017 13:36:25 -0400 Original-Received: by mail-lf0-x22f.google.com with SMTP id m86so4807269lfi.4 for ; Mon, 07 Aug 2017 10:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=s041baFPCWhRMIq9UkFAJ4OBp3tUCSqyZAKNf7bhaM4=; b=Eg7ORuicPuKepxy/U8So+QA8Ix02kX6c8qzqCa8797MvsMCFYcz55yujJwJgo5bwjR Qgq2CwxhkFI5ZIaNoVo7SF9114mYwgtoPRFYc/JgPUm+k/2pkDD0PYCJlxWhbPY7B4mq RNy++u1T06CcA2VKip0A6o5cgkDMbufNM43sLKaO7jdoQVBq8CPRecXaDdpTLemb1BGX jvc1H0XOo2jRkyr4tU+uPiRTCnb7bMtd6VlEjITdKt5mo1VN9Rs+rMbY8Msf+GXJTtOx aYPP2+jQrQj0qOmPjLm+wzV2Us/ZMvlGRf+enHRRy6sMRwJ3llKI84JvXcgVpaQG0tcS copQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=s041baFPCWhRMIq9UkFAJ4OBp3tUCSqyZAKNf7bhaM4=; b=h04Y0o5RG34anPqKICSfudzZ+q7hxpZbB9lBRiU/tEJ94gu16WEG45F+erLWdf2SFE q9HhbEBCGi20J6DJQ7ahY4Tu+6Tu7e1ZyqB5clD5Uuy5ot44pW2NNIyuFV0HHXiBib40 DA4wNyZb1aVyrnp9//iQUzRG1OnKXGsrv7VMQ+kR8h+xGTmH2nLbI/KezTdZVDUX47uk T7dOpzLLyFyIW+OyKcEEdPeu0H71v6EcKW5UyU/pwApp978ETw5P+rT3HiWl9q+3eQOu clsWNFkTmdrFgNjn0+gtg08nBZE5a/IIpzDWOBDp9EorcKDrsbltJ4dw836tiM8wjcqe pKtQ== X-Gm-Message-State: AHYfb5iqSnCTwHBs57nld87BTlhc1jyzbcW8asy8Zk8UZleFuPDjruIe OZE5meNbIoVsLefn55IdAKGXIno0Ng== X-Received: by 10.46.84.16 with SMTP id i16mr385390ljb.121.1502127381441; Mon, 07 Aug 2017 10:36:21 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::22f X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:217360 Archived-At: --f403045fb914fa74a005562d4866 Content-Type: text/plain; charset="UTF-8" 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 --f403045fb914fa74a005562d4866 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
indent-region is an act of editing a buffer. So before att= empting to do that, it should be checked if the buffer is editable.
Bug#22819[1] raises that point.

The pr= oposal is to call=C2=A0(barf-if-buffer-read-only) before attempting to do the i= ndent.

Motive for this change:

The act of indenting is an editing action. So the buffe= r should be checked if it's editable before attempting an indent. If the buffer is read-onl= y 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 ca= se, 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 s= ymlink link with a physical file copy. 5. User: Re-do that several seconds/minutes long indentation.

So the motive is to save time and al= ert user of their pilot error before attempting to do an operation that wou= ld go to waste (in this case, doing indent, and then waste all those CPU cy= cles because the changes couldn't get saved to the file).
<= div>
Question to the list:

- Are there any objections to doing the buffer read-only check b= efore 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.)

--

Kaushal Modi

--f403045fb914fa74a005562d4866--