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: npostavs
Subject: bug#22819: 25.0.91; Don't try to indent region if the buffer is read-only
Date: Fri, 04 Aug 2017 21:56:11 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux)

Kaushal Modi <kaushal.modi@gmail.com> writes:

> The current behavior of indent-region function is that it will first indent
> the buffer and then throw an error at the end that it couldn't apply the
> indentation. Instead the below patch checks if the buffer if read-only
> first before trying to indent.

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

The patch could be even simpler:

>From 54d1b5cd62572dc35eaed6f07ab9d254313c8a58 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Thu, 6 Jul 2017 20:04:43 -0400
Subject: [PATCH] * lisp/indent.el (indent-region): Fail fast if read-only
 (Bug#22819).

---
 lisp/indent.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/indent.el b/lisp/indent.el
index e7a30b885d..e9ed385faa 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -508,7 +508,7 @@ (defun indent-region (start end &optional column)
 Called from a program, START and END specify the region to indent.
 If the third argument COLUMN is an integer, it specifies the
 column to indent to; if it is nil, use one of the three methods above."
-  (interactive "r\nP")
+  (interactive "*r\nP")
   (cond
    ;; If a numeric prefix is given, indent to that column.
    (column
-- 
2.11.1


reply via email to

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