summaryrefslogtreecommitdiff
path: root/devdocs/elisp/registers.html
blob: 53f843d31d5be77eb863afb354021587dd535b8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 <h3 class="section">Registers</h3>  <p>A register is a sort of variable used in Emacs editing that can hold a variety of different kinds of values. Each register is named by a single character. All <acronym>ASCII</acronym> characters and their meta variants (but with the exception of <kbd>C-g</kbd>) can be used to name registers. Thus, there are 255 possible registers. A register is designated in Emacs Lisp by the character that is its name. </p> <dl> <dt id="register-alist">Variable: <strong>register-alist</strong>
</dt> <dd>
<p>This variable is an alist of elements of the form <code>(<var>name</var> .
<var>contents</var>)</code>. Normally, there is one element for each Emacs register that has been used. </p> <p>The object <var>name</var> is a character (an integer) identifying the register. </p>
</dd>
</dl> <p>The <var>contents</var> of a register can have several possible types: </p> <dl compact> <dt>a number</dt> <dd>
<p>A number stands for itself. If <code>insert-register</code> finds a number in the register, it converts the number to decimal. </p> </dd> <dt>a marker</dt> <dd>
<p>A marker represents a buffer position to jump to. </p> </dd> <dt>a string</dt> <dd>
<p>A string is text saved in the register. </p> </dd> <dt>a rectangle</dt> <dd>
 <p>A rectangle is represented by a list of strings. </p> </dd> <dt><code>(<var>window-configuration</var> <var>position</var>)</code></dt> <dd>
<p>This represents a window configuration to restore in one frame, and a position to jump to in the current buffer. </p> </dd> <dt><code>(<var>frame-configuration</var> <var>position</var>)</code></dt> <dd>
<p>This represents a frame configuration to restore, and a position to jump to in the current buffer. </p> </dd> <dt>(file <var>filename</var>)</dt> <dd>
<p>This represents a file to visit; jumping to this value visits file <var>filename</var>. </p> </dd> <dt>(file-query <var>filename</var> <var>position</var>)</dt> <dd><p>This represents a file to visit and a position in it; jumping to this value visits file <var>filename</var> and goes to buffer position <var>position</var>. Restoring this type of position asks the user for confirmation first. </p></dd> </dl> <p>The functions in this section return unpredictable values unless otherwise stated. </p> <dl> <dt id="get-register">Function: <strong>get-register</strong> <em>reg</em>
</dt> <dd><p>This function returns the contents of the register <var>reg</var>, or <code>nil</code> if it has no contents. </p></dd>
</dl> <dl> <dt id="set-register">Function: <strong>set-register</strong> <em>reg value</em>
</dt> <dd><p>This function sets the contents of register <var>reg</var> to <var>value</var>. A register can be set to any value, but the other register functions expect only certain data types. The return value is <var>value</var>. </p></dd>
</dl> <dl> <dt id="view-register">Command: <strong>view-register</strong> <em>reg</em>
</dt> <dd><p>This command displays what is contained in register <var>reg</var>. </p></dd>
</dl> <dl> <dt id="insert-register">Command: <strong>insert-register</strong> <em>reg &amp;optional beforep</em>
</dt> <dd>
<p>This command inserts contents of register <var>reg</var> into the current buffer. </p> <p>Normally, this command puts point before the inserted text, and the mark after it. However, if the optional second argument <var>beforep</var> is non-<code>nil</code>, it puts the mark before and point after. </p> <p>When called interactively, the command defaults to putting point after text, and a prefix argument inverts this behavior. </p> <p>If the register contains a rectangle, then the rectangle is inserted with its upper left corner at point. This means that text is inserted in the current line and underneath it on successive lines. </p> <p>If the register contains something other than saved text (a string) or a rectangle (a list), currently useless things happen. This may be changed in the future. </p>
</dd>
</dl> <dl> <dt id="register-read-with-preview">Function: <strong>register-read-with-preview</strong> <em>prompt</em>
</dt> <dd>
 <p>This function reads and returns a register name, prompting with <var>prompt</var> and possibly showing a preview of the existing registers and their contents. The preview is shown in a temporary window, after the delay specified by the user option <code>register-preview-delay</code>, if its value and <code>register-alist</code> are both non-<code>nil</code>. The preview is also shown if the user requests help (e.g., by typing the help character). We recommend that all interactive commands which read register names use this function. </p>
</dd>
</dl><div class="_attribution">
  <p class="_attribution-p">
    Copyright &copy; 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/Registers.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Registers.html</a>
  </p>
</div>