aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2014-11-16 23:36:58 +0100
committerLars Magne Ingebrigtsen2014-11-16 23:41:55 +0100
commitd1b04a9e7ada7070dbd84bb450411c1f169b3739 (patch)
tree8f0e26d1e2154f91364fd1b919df8bd8855604fd
parentc94988f4b740738cbc4660ee9c64637e55ad5d76 (diff)
downloademacs-d1b04a9e7ada7070dbd84bb450411c1f169b3739.tar.gz
emacs-d1b04a9e7ada7070dbd84bb450411c1f169b3739.zip
Implement an `inhibit-read-only' text property
* doc/lispref/text.texi (Special Properties): Mention `inhibit-read-only'. * src/buffer.c (Fbarf_if_buffer_read_only): Don't raise an error if the text at POSITION (new optional argument) has the `inhibit-read-only' text property set. * src/callint.c (Fcall_interactively): Pass in nil as argument to Fbarf_if_buffer_read_only. * src/fileio.c (Finsert_file_contents): Ditto. * src/insdel.c (prepare_to_modify_buffer_1): Pass start region in. * src/intervals.h (INTERVAL_WRITABLE_P): Check the `inhibit-read-only' text property. * src/textprop.c (verify_interval_modification): Check buffer readedness after the last interval.
-rw-r--r--doc/lispref/ChangeLog4
-rw-r--r--doc/lispref/text.texi5
-rw-r--r--etc/NEWS3
-rw-r--r--src/ChangeLog19
-rw-r--r--src/buffer.c16
-rw-r--r--src/callint.c6
-rw-r--r--src/fileio.c2
-rw-r--r--src/insdel.c4
-rw-r--r--src/intervals.h1
-rw-r--r--src/textprop.c5
10 files changed, 56 insertions, 9 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 9772391e483..b7423af07ba 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,7 @@
12014-11-16 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * text.texi (Special Properties): Mention `inhibit-read-only'.
4
12014-11-14 Paul Eggert <eggert@cs.ucla.edu> 52014-11-14 Paul Eggert <eggert@cs.ucla.edu>
2 6
3 * os.texi (Time of Day): 7 * os.texi (Time of Day):
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index f21d2b76656..d1a1e6fa6b9 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -3241,6 +3241,11 @@ possible to remove a @code{read-only} property unless you know the
3241special trick: bind @code{inhibit-read-only} to a non-@code{nil} value 3241special trick: bind @code{inhibit-read-only} to a non-@code{nil} value
3242and then remove the property. @xref{Read Only Buffers}. 3242and then remove the property. @xref{Read Only Buffers}.
3243 3243
3244@item inhibit-read-only
3245@kindex inhibit-read-only @r{(text property)}
3246If a character has the property @code{inhibit-read-only}, and the
3247buffer is read-only, editing the character in question is allowed.
3248
3244@item invisible 3249@item invisible
3245@kindex invisible @r{(text property)} 3250@kindex invisible @r{(text property)}
3246A non-@code{nil} @code{invisible} property can make a character invisible 3251A non-@code{nil} @code{invisible} property can make a character invisible
diff --git a/etc/NEWS b/etc/NEWS
index 2172d078c44..b0e08d46819 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -107,6 +107,9 @@ non-native NS fullscreen. The default is nil. Set to t to enable
107animation when entering and leaving fullscreen. For native OSX fullscreen 107animation when entering and leaving fullscreen. For native OSX fullscreen
108this has no effect. 108this has no effect.
109 109
110*** A new text property `inhibit-read-only' can be used in read-only
111buffers to allow certain parts of the text to be writable.
112
110 113
111* Editing Changes in Emacs 25.1 114* Editing Changes in Emacs 25.1
112 115
diff --git a/src/ChangeLog b/src/ChangeLog
index 7bb16668406..d1888987dbc 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,22 @@
12014-11-16 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * intervals.h (INTERVAL_WRITABLE_P): Check the `inhibit-read-only'
4 text property.
5
6 * callint.c (Fcall_interactively): Pass in nil as argument to
7 Fbarf_if_buffer_read_only.
8
9 * fileio.c (Finsert_file_contents): Ditto.
10
11 * insdel.c (prepare_to_modify_buffer_1): Pass start region in.
12
13 * textprop.c (verify_interval_modification): Check buffer
14 readedness after the last interval.
15
16 * buffer.c (Fbarf_if_buffer_read_only): Don't raise an error if
17 the text at POSITION (new optional argument) has the
18 `inhibit-read-only' text property set.
19
12014-11-16 Eli Zaretskii <eliz@gnu.org> 202014-11-16 Eli Zaretskii <eliz@gnu.org>
2 21
3 * window.c (window_scroll_pixel_based): Avoid truncation/rounding 22 * window.c (window_scroll_pixel_based): Avoid truncation/rounding
diff --git a/src/buffer.c b/src/buffer.c
index 80791a1fdb1..9bdbfb830fd 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2184,12 +2184,20 @@ set_buffer_if_live (Lisp_Object buffer)
2184} 2184}
2185 2185
2186DEFUN ("barf-if-buffer-read-only", Fbarf_if_buffer_read_only, 2186DEFUN ("barf-if-buffer-read-only", Fbarf_if_buffer_read_only,
2187 Sbarf_if_buffer_read_only, 0, 0, 0, 2187 Sbarf_if_buffer_read_only, 0, 1, 0,
2188 doc: /* Signal a `buffer-read-only' error if the current buffer is read-only. */) 2188 doc: /* Signal a `buffer-read-only' error if the current buffer is read-only.
2189 (void) 2189If the text under POSITION (which defaults to point) has the
2190`inhibit-read-only' text property set, the error will not be raised. */)
2191 (Lisp_Object pos)
2190{ 2192{
2193 if (NILP (pos))
2194 XSETFASTINT (pos, PT);
2195 else
2196 CHECK_NUMBER (pos);
2197
2191 if (!NILP (BVAR (current_buffer, read_only)) 2198 if (!NILP (BVAR (current_buffer, read_only))
2192 && NILP (Vinhibit_read_only)) 2199 && NILP (Vinhibit_read_only)
2200 && NILP (Fget_text_property (pos, Qinhibit_read_only, Qnil)))
2193 xsignal1 (Qbuffer_read_only, Fcurrent_buffer ()); 2201 xsignal1 (Qbuffer_read_only, Fcurrent_buffer ());
2194 return Qnil; 2202 return Qnil;
2195} 2203}
diff --git a/src/callint.c b/src/callint.c
index 9a4573c77be..94676952b25 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -448,13 +448,13 @@ invoke it. If KEYS is omitted or nil, the return value of
448 { 448 {
449 if (! (*p == 'r' || *p == 'p' || *p == 'P' 449 if (! (*p == 'r' || *p == 'p' || *p == 'P'
450 || *p == '\n')) 450 || *p == '\n'))
451 Fbarf_if_buffer_read_only (); 451 Fbarf_if_buffer_read_only (Qnil);
452 p++; 452 p++;
453 } 453 }
454 record_then_fail = 1; 454 record_then_fail = 1;
455 } 455 }
456 else 456 else
457 Fbarf_if_buffer_read_only (); 457 Fbarf_if_buffer_read_only (Qnil);
458 } 458 }
459 } 459 }
460 /* Ignore this for semi-compatibility with Lucid. */ 460 /* Ignore this for semi-compatibility with Lucid. */
@@ -865,7 +865,7 @@ invoke it. If KEYS is omitted or nil, the return value of
865 XSETINT (args[i], marker_position (args[i])); 865 XSETINT (args[i], marker_position (args[i]));
866 866
867 if (record_then_fail) 867 if (record_then_fail)
868 Fbarf_if_buffer_read_only (); 868 Fbarf_if_buffer_read_only (Qnil);
869 869
870 Vthis_command = save_this_command; 870 Vthis_command = save_this_command;
871 Vthis_original_command = save_this_original_command; 871 Vthis_original_command = save_this_original_command;
diff --git a/src/fileio.c b/src/fileio.c
index 7d7b0b3148f..b8dec3a2041 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3471,7 +3471,7 @@ by calling `format-decode', which see. */)
3471 error ("Cannot do file visiting in an indirect buffer"); 3471 error ("Cannot do file visiting in an indirect buffer");
3472 3472
3473 if (!NILP (BVAR (current_buffer, read_only))) 3473 if (!NILP (BVAR (current_buffer, read_only)))
3474 Fbarf_if_buffer_read_only (); 3474 Fbarf_if_buffer_read_only (Qnil);
3475 3475
3476 val = Qnil; 3476 val = Qnil;
3477 p = Qnil; 3477 p = Qnil;
diff --git a/src/insdel.c b/src/insdel.c
index 463392dcada..3133ca4bd2c 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1797,9 +1797,11 @@ prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t end,
1797 ptrdiff_t *preserve_ptr) 1797 ptrdiff_t *preserve_ptr)
1798{ 1798{
1799 struct buffer *base_buffer; 1799 struct buffer *base_buffer;
1800 Lisp_Object temp;
1800 1801
1802 XSETFASTINT (temp, start);
1801 if (!NILP (BVAR (current_buffer, read_only))) 1803 if (!NILP (BVAR (current_buffer, read_only)))
1802 Fbarf_if_buffer_read_only (); 1804 Fbarf_if_buffer_read_only (temp);
1803 1805
1804 bset_redisplay (current_buffer); 1806 bset_redisplay (current_buffer);
1805 1807
diff --git a/src/intervals.h b/src/intervals.h
index 4e7a177140e..bd1f49dc383 100644
--- a/src/intervals.h
+++ b/src/intervals.h
@@ -197,6 +197,7 @@ set_interval_plist (INTERVAL i, Lisp_Object plist)
197/* Is this interval writable? Replace later with cache access. */ 197/* Is this interval writable? Replace later with cache access. */
198#define INTERVAL_WRITABLE_P(i) \ 198#define INTERVAL_WRITABLE_P(i) \
199 (i && (NILP (textget ((i)->plist, Qread_only)) \ 199 (i && (NILP (textget ((i)->plist, Qread_only)) \
200 || !NILP (textget ((i)->plist, Qinhibit_read_only)) \
200 || ((CONSP (Vinhibit_read_only) \ 201 || ((CONSP (Vinhibit_read_only) \
201 ? !NILP (Fmemq (textget ((i)->plist, Qread_only), \ 202 ? !NILP (Fmemq (textget ((i)->plist, Qread_only), \
202 Vinhibit_read_only)) \ 203 Vinhibit_read_only)) \
diff --git a/src/textprop.c b/src/textprop.c
index 91ade8ae298..7ecac62be98 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -2298,6 +2298,11 @@ verify_interval_modification (struct buffer *buf,
2298 } 2298 }
2299 } 2299 }
2300 2300
2301 if (i->position + LENGTH (i) < end
2302 && (!NILP (BVAR (current_buffer, read_only))
2303 && NILP (Vinhibit_read_only)))
2304 xsignal1 (Qbuffer_read_only, Fcurrent_buffer ());
2305
2301 i = next_interval (i); 2306 i = next_interval (i);
2302 } 2307 }
2303 /* Keep going thru the interval containing the char before END. */ 2308 /* Keep going thru the interval containing the char before END. */