diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/read-only-buffers.html | |
new repository
Diffstat (limited to 'devdocs/elisp/read-only-buffers.html')
| -rw-r--r-- | devdocs/elisp/read-only-buffers.html | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/devdocs/elisp/read-only-buffers.html b/devdocs/elisp/read-only-buffers.html new file mode 100644 index 00000000..f966638f --- /dev/null +++ b/devdocs/elisp/read-only-buffers.html @@ -0,0 +1,23 @@ + <h3 class="section">Read-Only Buffers</h3> <p>If a buffer is <em>read-only</em>, then you cannot change its contents, although you may change your view of the contents by scrolling and narrowing. </p> <p>Read-only buffers are used in two kinds of situations: </p> <ul> <li> A buffer visiting a write-protected file is normally read-only. <p>Here, the purpose is to inform the user that editing the buffer with the aim of saving it in the file may be futile or undesirable. The user who wants to change the buffer text despite this can do so after clearing the read-only flag with <kbd>C-x C-q</kbd>. </p> </li> +<li> Modes such as Dired and Rmail make buffers read-only when altering the contents with the usual editing commands would probably be a mistake. <p>The special commands of these modes bind <code>buffer-read-only</code> to <code>nil</code> (with <code>let</code>) or bind <code>inhibit-read-only</code> to <code>t</code> around the places where they themselves change the text. </p> +</li> +</ul> <dl> <dt id="buffer-read-only">Variable: <strong>buffer-read-only</strong> +</dt> <dd><p>This buffer-local variable specifies whether the buffer is read-only. The buffer is read-only if this variable is non-<code>nil</code>. However, characters that have the <code>inhibit-read-only</code> text property can still be modified. See <a href="special-properties">inhibit-read-only</a>. </p></dd> +</dl> <dl> <dt id="inhibit-read-only">Variable: <strong>inhibit-read-only</strong> +</dt> <dd> +<p>If this variable is non-<code>nil</code>, then read-only buffers and, depending on the actual value, some or all read-only characters may be modified. Read-only characters in a buffer are those that have a non-<code>nil</code> <code>read-only</code> text property. See <a href="special-properties">Special Properties</a>, for more information about text properties. </p> <p>If <code>inhibit-read-only</code> is <code>t</code>, all <code>read-only</code> character properties have no effect. If <code>inhibit-read-only</code> is a list, then <code>read-only</code> character properties have no effect if they are members of the list (comparison is done with <code>eq</code>). </p> +</dd> +</dl> <dl> <dt id="read-only-mode">Command: <strong>read-only-mode</strong> <em>&optional arg</em> +</dt> <dd> +<p>This is the mode command for Read Only minor mode, a buffer-local minor mode. When the mode is enabled, <code>buffer-read-only</code> is non-<code>nil</code> in the buffer; when disabled, <code>buffer-read-only</code> is <code>nil</code> in the buffer. The calling convention is the same as for other minor mode commands (see <a href="minor-mode-conventions">Minor Mode Conventions</a>). </p> <p>This minor mode mainly serves as a wrapper for <code>buffer-read-only</code>; unlike most minor modes, there is no separate <code>read-only-mode</code> variable. Even when Read Only mode is disabled, characters with non-<code>nil</code> <code>read-only</code> text properties remain read-only. To temporarily ignore all read-only states, bind <code>inhibit-read-only</code>, as described above. </p> <p>When enabling Read Only mode, this mode command also enables View mode if the option <code>view-read-only</code> is non-<code>nil</code>. See <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Misc-Buffer.html#Misc-Buffer">Miscellaneous Buffer Operations</a> in <cite>The GNU Emacs Manual</cite>. When disabling Read Only mode, it disables View mode if View mode was enabled. </p> +</dd> +</dl> <dl> <dt id="barf-if-buffer-read-only">Function: <strong>barf-if-buffer-read-only</strong> <em>&optional position</em> +</dt> <dd> +<p>This function signals a <code>buffer-read-only</code> error if the current buffer is read-only. If the text at <var>position</var> (which defaults to point) has the <code>inhibit-read-only</code> text property set, the error will not be raised. </p> <p>See <a href="using-interactive">Using Interactive</a>, for another way to signal an error if the current buffer is read-only. </p> +</dd> +</dl><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br> + <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Read-Only-Buffers.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Read-Only-Buffers.html</a> + </p> +</div> |
