-This is ../info/lispref.info, produced by makeinfo version 3.12s from
+This is ../info/lispref.info, produced by makeinfo version 4.0 from
lispref/lispref.texi.
INFO-DIR-SECTION XEmacs Editor
Foundation instead of in the original English.
\1f
+File: lispref.info, Node: The Selected Console and Device, Next: Console and Device I/O, Prev: Connecting to a Console or Device, Up: Consoles and Devices
+
+The Selected Console and Device
+===============================
+
+ - Function: select-console console
+ This function selects the console CONSOLE. Subsequent editing
+ commands apply to its selected device, selected frame, and selected
+ window. The selection of CONSOLE lasts until the next time the
+ user does something to select a different console, or until the
+ next time this function is called.
+
+ - Function: selected-console
+ This function returns the console which is currently active.
+
+ - Function: select-device device
+ This function selects the device DEVICE.
+
+ - Function: selected-device &optional console
+ This function returns the device which is currently active. If
+ optional CONSOLE is non-`nil', this function returns the device
+ that would be currently active if CONSOLE were the selected
+ console.
+
+\1f
+File: lispref.info, Node: Console and Device I/O, Prev: The Selected Console and Device, Up: Consoles and Devices
+
+Console and Device I/O
+======================
+
+ - Function: console-disable-input console
+ This function disables input on console CONSOLE.
+
+ - Function: console-enable-input console
+ This function enables input on console CONSOLE.
+
+ Each device has a "baud rate" value associated with it. On most
+systems, changing this value will affect the amount of padding and
+other strategic decisions made during redisplay.
+
+ - Function: device-baud-rate &optional device
+ This function returns the output baud rate of DEVICE.
+
+ - Function: set-device-baud-rate device rate
+ This function sets the output baud rate of DEVICE to RATE.
+
+\1f
+File: lispref.info, Node: Positions, Next: Markers, Prev: Consoles and Devices, Up: Top
+
+Positions
+*********
+
+ A "position" is the index of a character in the text of a buffer.
+More precisely, a position identifies the place between two characters
+(or before the first character, or after the last character), so we can
+speak of the character before or after a given position. However, we
+often speak of the character "at" a position, meaning the character
+after that position.
+
+ Positions are usually represented as integers starting from 1, but
+can also be represented as "markers"--special objects that relocate
+automatically when text is inserted or deleted so they stay with the
+surrounding characters. *Note Markers::.
+
+* Menu:
+
+* Point:: The special position where editing takes place.
+* Motion:: Changing point.
+* Excursions:: Temporary motion and buffer changes.
+* Narrowing:: Restricting editing to a portion of the buffer.
+
+\1f
+File: lispref.info, Node: Point, Next: Motion, Up: Positions
+
+Point
+=====
+
+ "Point" is a special buffer position used by many editing commands,
+including the self-inserting typed characters and text insertion
+functions. Other commands move point through the text to allow editing
+and insertion at different places.
+
+ Like other positions, point designates a place between two characters
+(or before the first character, or after the last character), rather
+than a particular character. Usually terminals display the cursor over
+the character that immediately follows point; point is actually before
+the character on which the cursor sits.
+
+ The value of point is a number between 1 and the buffer size plus 1.
+If narrowing is in effect (*note Narrowing::), then point is constrained
+to fall within the accessible portion of the buffer (possibly at one end
+of it).
+
+ Each buffer has its own value of point, which is independent of the
+value of point in other buffers. Each window also has a value of point,
+which is independent of the value of point in other windows on the same
+buffer. This is why point can have different values in various windows
+that display the same buffer. When a buffer appears in only one window,
+the buffer's point and the window's point normally have the same value,
+so the distinction is rarely important. *Note Window Point::, for more
+details.
+
+ - Function: point &optional buffer
+ This function returns the value of point in BUFFER, as an integer.
+ BUFFER defaults to the current buffer if omitted.
+
+ (point)
+ => 175
+
+ - Function: point-min &optional buffer
+ This function returns the minimum accessible value of point in
+ BUFFER. This is normally 1, but if narrowing is in effect, it is
+ the position of the start of the region that you narrowed to.
+ (*Note Narrowing::.) BUFFER defaults to the current buffer if
+ omitted.
+
+ - Function: point-max &optional buffer
+ This function returns the maximum accessible value of point in
+ BUFFER. This is `(1+ (buffer-size buffer))', unless narrowing is
+ in effect, in which case it is the position of the end of the
+ region that you narrowed to. (*note Narrowing::). BUFFER defaults
+ to the current buffer if omitted.
+
+ - Function: buffer-end flag &optional buffer
+ This function returns `(point-min buffer)' if FLAG is less than 1,
+ `(point-max buffer)' otherwise. The argument FLAG must be a
+ number. BUFFER defaults to the current buffer if omitted.
+
+ - Function: buffer-size &optional buffer
+ This function returns the total number of characters in BUFFER.
+ In the absence of any narrowing (*note Narrowing::), `point-max'
+ returns a value one larger than this. BUFFER defaults to the
+ current buffer if omitted.
+
+ (buffer-size)
+ => 35
+ (point-max)
+ => 36
+
+ - Variable: buffer-saved-size
+ The value of this buffer-local variable is the former length of the
+ current buffer, as of the last time it was read in, saved or
+ auto-saved.
+
+\1f
+File: lispref.info, Node: Motion, Next: Excursions, Prev: Point, Up: Positions
+
+Motion
+======
+
+ Motion functions change the value of point, either relative to the
+current value of point, relative to the beginning or end of the buffer,
+or relative to the edges of the selected window. *Note Point::.
+
+* Menu:
+
+* Character Motion:: Moving in terms of characters.
+* Word Motion:: Moving in terms of words.
+* Buffer End Motion:: Moving to the beginning or end of the buffer.
+* Text Lines:: Moving in terms of lines of text.
+* Screen Lines:: Moving in terms of lines as displayed.
+* List Motion:: Moving by parsing lists and sexps.
+* Skipping Characters:: Skipping characters belonging to a certain set.
+
+\1f
+File: lispref.info, Node: Character Motion, Next: Word Motion, Up: Motion
+
+Motion by Characters
+--------------------
+
+ These functions move point based on a count of characters.
+`goto-char' is the fundamental primitive; the other functions use that.
+
+ - Command: goto-char position &optional buffer
+ This function sets point in `buffer' to the value POSITION. If
+ POSITION is less than 1, it moves point to the beginning of the
+ buffer. If POSITION is greater than the length of the buffer, it
+ moves point to the end. BUFFER defaults to the current buffer if
+ omitted.
+
+ If narrowing is in effect, POSITION still counts from the
+ beginning of the buffer, but point cannot go outside the accessible
+ portion. If POSITION is out of range, `goto-char' moves point to
+ the beginning or the end of the accessible portion.
+
+ When this function is called interactively, POSITION is the
+ numeric prefix argument, if provided; otherwise it is read from the
+ minibuffer.
+
+ `goto-char' returns POSITION.
+
+ - Command: forward-char &optional count buffer
+ This function moves point COUNT characters forward, towards the
+ end of the buffer (or backward, towards the beginning of the
+ buffer, if COUNT is negative). If the function attempts to move
+ point past the beginning or end of the buffer (or the limits of
+ the accessible portion, when narrowing is in effect), an error is
+ signaled with error code `beginning-of-buffer' or `end-of-buffer'.
+ BUFFER defaults to the current buffer if omitted.
+
+ In an interactive call, COUNT is the numeric prefix argument.
+
+ - Command: backward-char &optional count buffer
+ This function moves point COUNT characters backward, towards the
+ beginning of the buffer (or forward, towards the end of the
+ buffer, if COUNT is negative). If the function attempts to move
+ point past the beginning or end of the buffer (or the limits of
+ the accessible portion, when narrowing is in effect), an error is
+ signaled with error code `beginning-of-buffer' or `end-of-buffer'.
+ BUFFER defaults to the current buffer if omitted.
+
+ In an interactive call, COUNT is the numeric prefix argument.
+
+\1f
+File: lispref.info, Node: Word Motion, Next: Buffer End Motion, Prev: Character Motion, Up: Motion
+
+Motion by Words
+---------------
+
+ These functions for parsing words use the syntax table to decide
+whether a given character is part of a word. *Note Syntax Tables::.
+
+ - Command: forward-word count &optional buffer
+ This function moves point forward COUNT words (or backward if
+ COUNT is negative). Normally it returns `t'. If this motion
+ encounters the beginning or end of the buffer, or the limits of the
+ accessible portion when narrowing is in effect, point stops there
+ and the value is `nil'. BUFFER defaults to the current buffer if
+ omitted.
+
+ In an interactive call, COUNT is set to the numeric prefix
+ argument.
+
+ - Command: backward-word count &optional buffer
+ This function is just like `forward-word', except that it moves
+ backward until encountering the front of a word, rather than
+ forward. BUFFER defaults to the current buffer if omitted.
+
+ In an interactive call, COUNT is set to the numeric prefix
+ argument.
+
+ This function is rarely used in programs, as it is more efficient
+ to call `forward-word' with a negative argument.
+
+ - Variable: words-include-escapes
+ This variable affects the behavior of `forward-word' and everything
+ that uses it. If it is non-`nil', then characters in the "escape"
+ and "character quote" syntax classes count as part of words.
+ Otherwise, they do not.
+
+\1f
+File: lispref.info, Node: Buffer End Motion, Next: Text Lines, Prev: Word Motion, Up: Motion
+
+Motion to an End of the Buffer
+------------------------------
+
+ To move point to the beginning of the buffer, write:
+
+ (goto-char (point-min))
+
+Likewise, to move to the end of the buffer, use:
+
+ (goto-char (point-max))
+
+ Here are two commands that users use to do these things. They are
+documented here to warn you not to use them in Lisp programs, because
+they set the mark and display messages in the echo area.
+
+ - Command: beginning-of-buffer &optional n
+ This function moves point to the beginning of the buffer (or the
+ limits of the accessible portion, when narrowing is in effect),
+ setting the mark at the previous position. If N is non-`nil',
+ then it puts point N tenths of the way from the beginning of the
+ buffer.
+
+ In an interactive call, N is the numeric prefix argument, if
+ provided; otherwise N defaults to `nil'.
+
+ Don't use this function in Lisp programs!
+
+ - Command: end-of-buffer &optional n
+ This function moves point to the end of the buffer (or the limits
+ of the accessible portion, when narrowing is in effect), setting
+ the mark at the previous position. If N is non-`nil', then it puts
+ point N tenths of the way from the end of the buffer.
+
+ In an interactive call, N is the numeric prefix argument, if
+ provided; otherwise N defaults to `nil'.
+
+ Don't use this function in Lisp programs!
+
+\1f
+File: lispref.info, Node: Text Lines, Next: Screen Lines, Prev: Buffer End Motion, Up: Motion
+
+Motion by Text Lines
+--------------------
+
+ Text lines are portions of the buffer delimited by newline
+characters, which are regarded as part of the previous line. The first
+text line begins at the beginning of the buffer, and the last text line
+ends at the end of the buffer whether or not the last character is a
+newline. The division of the buffer into text lines is not affected by
+the width of the window, by line continuation in display, or by how
+tabs and control characters are displayed.
+
+ - Command: goto-line line
+ This function moves point to the front of the LINEth line,
+ counting from line 1 at beginning of the buffer. If LINE is less
+ than 1, it moves point to the beginning of the buffer. If LINE is
+ greater than the number of lines in the buffer, it moves point to
+ the end of the buffer--that is, the _end of the last line_ of the
+ buffer. This is the only case in which `goto-line' does not
+ necessarily move to the beginning of a line.
+
+ If narrowing is in effect, then LINE still counts from the
+ beginning of the buffer, but point cannot go outside the accessible
+ portion. So `goto-line' moves point to the beginning or end of the
+ accessible portion, if the line number specifies an inaccessible
+ position.
+
+ The return value of `goto-line' is the difference between LINE and
+ the line number of the line to which point actually was able to
+ move (in the full buffer, before taking account of narrowing).
+ Thus, the value is positive if the scan encounters the real end of
+ the buffer. The value is zero if scan encounters the end of the
+ accessible portion but not the real end of the buffer.
+
+ In an interactive call, LINE is the numeric prefix argument if one
+ has been provided. Otherwise LINE is read in the minibuffer.
+
+ - Command: beginning-of-line &optional count buffer
+ This function moves point to the beginning of the current line.
+ With an argument COUNT not `nil' or 1, it moves forward COUNT-1
+ lines and then to the beginning of the line. BUFFER defaults to
+ the current buffer if omitted.
+
+ If this function reaches the end of the buffer (or of the
+ accessible portion, if narrowing is in effect), it positions point
+ there. No error is signaled.
+
+ - Command: end-of-line &optional count buffer
+ This function moves point to the end of the current line. With an
+ argument COUNT not `nil' or 1, it moves forward COUNT-1 lines and
+ then to the end of the line. BUFFER defaults to the current
+ buffer if omitted.
+
+ If this function reaches the end of the buffer (or of the
+ accessible portion, if narrowing is in effect), it positions point
+ there. No error is signaled.
+
+ - Command: forward-line &optional count buffer
+ This function moves point forward COUNT lines, to the beginning of
+ the line. If COUNT is negative, it moves point -COUNT lines
+ backward, to the beginning of a line. If COUNT is zero, it moves
+ point to the beginning of the current line. BUFFER defaults to
+ the current buffer if omitted.
+
+ If `forward-line' encounters the beginning or end of the buffer (or
+ of the accessible portion) before finding that many lines, it sets
+ point there. No error is signaled.
+
+ `forward-line' returns the difference between COUNT and the number
+ of lines actually moved. If you attempt to move down five lines
+ from the beginning of a buffer that has only three lines, point
+ stops at the end of the last line, and the value will be 2.
+
+ In an interactive call, COUNT is the numeric prefix argument.
+
+ - Function: count-lines start end
+ This function returns the number of lines between the positions
+ START and END in the current buffer. If START and END are equal,
+ then it returns 0. Otherwise it returns at least 1, even if START
+ and END are on the same line. This is because the text between
+ them, considered in isolation, must contain at least one line
+ unless it is empty.
+
+ Here is an example of using `count-lines':
+
+ (defun current-line ()
+ "Return the vertical position of point..."
+ (+ (count-lines (window-start) (point))
+ (if (= (current-column) 0) 1 0)
+ -1))
+
+ Also see the functions `bolp' and `eolp' in *Note Near Point::.
+These functions do not move point, but test whether it is already at the
+beginning or end of a line.
+
+\1f
+File: lispref.info, Node: Screen Lines, Next: List Motion, Prev: Text Lines, Up: Motion
+
+Motion by Screen Lines
+----------------------
+
+ The line functions in the previous section count text lines,
+delimited only by newline characters. By contrast, these functions
+count screen lines, which are defined by the way the text appears on
+the screen. A text line is a single screen line if it is short enough
+to fit the width of the selected window, but otherwise it may occupy
+several screen lines.
+
+ In some cases, text lines are truncated on the screen rather than
+continued onto additional screen lines. In these cases,
+`vertical-motion' moves point much like `forward-line'. *Note
+Truncation::.
+
+ Because the width of a given string depends on the flags that control
+the appearance of certain characters, `vertical-motion' behaves
+differently, for a given piece of text, depending on the buffer it is
+in, and even on the selected window (because the width, the truncation
+flag, and display table may vary between windows). *Note Usual
+Display::.
+
+ These functions scan text to determine where screen lines break, and
+thus take time proportional to the distance scanned. If you intend to
+use them heavily, Emacs provides caches which may improve the
+performance of your code. *Note cache-long-line-scans: Text Lines.
+
+ - Function: vertical-motion count &optional window pixels
+ This function moves point to the start of the frame line COUNT
+ frame lines down from the frame line containing point. If COUNT
+ is negative, it moves up instead. The optional second argument
+ WINDOW may be used to specify a window other than the selected
+ window in which to perform the motion.
+
+ Normally, `vertical-motion' returns the number of lines moved. The
+ value may be less in absolute value than COUNT if the beginning or
+ end of the buffer was reached. If the optional third argument,
+ PIXELS is non-`nil', the vertical pixel height of the motion which
+ took place is returned instead of the actual number of lines
+ moved. A motion of zero lines returns the height of the current
+ line.
+
+ Note that `vertical-motion' sets WINDOW's buffer's point, not
+ WINDOW's point. (This differs from FSF Emacs, which buggily always
+ sets current buffer's point, regardless of WINDOW.)
+
+ - Function: vertical-motion-pixels count &optional window how
+ This function moves point to the start of the frame line PIXELS
+ vertical pixels down from the frame line containing point, or up if
+ PIXELS is negative. The optional second argument WINDOW is the
+ window to move in, and defaults to the selected window. The
+ optional third argument HOW specifies the stopping condition. A
+ negative integer indicates that the motion should be no more than
+ PIXELS. A positive value indicates that the motion should be at
+ least PIXELS. Any other value indicates that the motion should be
+ as close as possible to PIXELS.
+
+ - Command: move-to-window-line count &optional window
+ This function moves point with respect to the text currently
+ displayed in WINDOW, which defaults to the selected window. It
+ moves point to the beginning of the screen line COUNT screen lines
+ from the top of the window. If COUNT is negative, that specifies a
+ position -COUNT lines from the bottom (or the last line of the
+ buffer, if the buffer ends above the specified screen position).
+
+ If COUNT is `nil', then point moves to the beginning of the line
+ in the middle of the window. If the absolute value of COUNT is
+ greater than the size of the window, then point moves to the place
+ that would appear on that screen line if the window were tall
+ enough. This will probably cause the next redisplay to scroll to
+ bring that location onto the screen.
+
+ In an interactive call, COUNT is the numeric prefix argument.
+
+ The value returned is the window line number point has moved to,
+ with the top line in the window numbered 0.
+
+\1f
+File: lispref.info, Node: List Motion, Next: Skipping Characters, Prev: Screen Lines, Up: Motion
+
+Moving over Balanced Expressions
+--------------------------------
+
+ Here are several functions concerned with balanced-parenthesis
+expressions (also called "sexps" in connection with moving across them
+in XEmacs). The syntax table controls how these functions interpret
+various characters; see *Note Syntax Tables::. *Note Parsing
+Expressions::, for lower-level primitives for scanning sexps or parts of
+sexps. For user-level commands, see *Note Lists and Sexps:
+(emacs)Lists and Sexps.
+
+ - Command: forward-list &optional arg
+ This function moves forward across ARG balanced groups of
+ parentheses. (Other syntactic entities such as words or paired
+ string quotes are ignored.) ARG defaults to 1 if omitted. If ARG
+ is negative, move backward across that many groups of parentheses.
+
+ - Command: backward-list &optional arg
+ This function moves backward across ARG balanced groups of
+ parentheses. (Other syntactic entities such as words or paired
+ string quotes are ignored.) ARG defaults to 1 if omitted. If ARG
+ is negative, move forward across that many groups of parentheses.
+
+ - Command: up-list arg
+ This function moves forward out of ARG levels of parentheses. A
+ negative argument means move backward but still to a less deep
+ spot.
+
+ - Command: down-list arg
+ This function moves forward into ARG levels of parentheses. A
+ negative argument means move backward but still go deeper in
+ parentheses (-ARG levels).
+
+ - Command: forward-sexp &optional arg
+ This function moves forward across ARG balanced expressions.
+ Balanced expressions include both those delimited by parentheses
+ and other kinds, such as words and string constants. ARG defaults
+ to 1 if omitted. If ARG is negative, move backward across that
+ many balanced expressions. For example,
+
+ ---------- Buffer: foo ----------
+ (concat-!- "foo " (car x) y z)
+ ---------- Buffer: foo ----------
+
+ (forward-sexp 3)
+ => nil
+
+ ---------- Buffer: foo ----------
+ (concat "foo " (car x) y-!- z)
+ ---------- Buffer: foo ----------
+
+ - Command: backward-sexp &optional arg
+ This function moves backward across ARG balanced expressions. ARG
+ defaults to 1 if omitted. If ARG is negative, move forward across
+ that many balanced expressions.
+
+ - Command: beginning-of-defun &optional arg
+ This function moves back to the ARGth beginning of a defun. If
+ ARG is negative, this actually moves forward, but it still moves
+ to the beginning of a defun, not to the end of one. ARG defaults
+ to 1 if omitted.
+
+ - Command: end-of-defun &optional arg
+ This function moves forward to the ARGth end of a defun. If ARG
+ is negative, this actually moves backward, but it still moves to
+ the end of a defun, not to the beginning of one. ARG defaults to
+ 1 if omitted.
+
+ - User Option: defun-prompt-regexp
+ If non-`nil', this variable holds a regular expression that
+ specifies what text can appear before the open-parenthesis that
+ starts a defun. That is to say, a defun begins on a line that
+ starts with a match for this regular expression, followed by a
+ character with open-parenthesis syntax.
+
+\1f
+File: lispref.info, Node: Skipping Characters, Prev: List Motion, Up: Motion
+
+Skipping Characters
+-------------------
+
+ The following two functions move point over a specified set of
+characters. For example, they are often used to skip whitespace. For
+related functions, see *Note Motion and Syntax::.
+
+ - Function: skip-chars-forward character-set &optional limit buffer
+ This function moves point in BUFFER forward, skipping over a given
+ set of characters. It examines the character following point,
+ then advances point if the character matches CHARACTER-SET. This
+ continues until it reaches a character that does not match. The
+ function returns `nil'. BUFFER defaults to the current buffer if
+ omitted.
+
+ The argument CHARACTER-SET is like the inside of a `[...]' in a
+ regular expression except that `]' is never special and `\' quotes
+ `^', `-' or `\'. Thus, `"a-zA-Z"' skips over all letters,
+ stopping before the first non-letter, and `"^a-zA-Z'" skips
+ non-letters stopping before the first letter. *Note Regular
+ Expressions::.
+
+ If LIMIT is supplied (it must be a number or a marker), it
+ specifies the maximum position in the buffer that point can be
+ skipped to. Point will stop at or before LIMIT.
+
+ In the following example, point is initially located directly
+ before the `T'. After the form is evaluated, point is located at
+ the end of that line (between the `t' of `hat' and the newline).
+ The function skips all letters and spaces, but not newlines.
+
+ ---------- Buffer: foo ----------
+ I read "-!-The cat in the hat
+ comes back" twice.
+ ---------- Buffer: foo ----------
+
+ (skip-chars-forward "a-zA-Z ")
+ => nil
+
+ ---------- Buffer: foo ----------
+ I read "The cat in the hat-!-
+ comes back" twice.
+ ---------- Buffer: foo ----------
+
+ - Function: skip-chars-backward character-set &optional limit buffer
+ This function moves point backward, skipping characters that match
+ CHARACTER-SET, until LIMIT. It just like `skip-chars-forward'
+ except for the direction of motion.
+
+\1f
File: lispref.info, Node: Excursions, Next: Narrowing, Prev: Motion, Up: Positions
Excursions
- Function: move-marker marker position &optional buffer
This is another name for `set-marker'.
-\1f
-File: lispref.info, Node: The Mark, Next: The Region, Prev: Changing Markers, Up: Markers
-
-The Mark
-========
-
- One special marker in each buffer is designated "the mark". It
-records a position for the user for the sake of commands such as `C-w'
-and `C-x <TAB>'. Lisp programs should set the mark only to values that
-have a potential use to the user, and never for their own internal
-purposes. For example, the `replace-regexp' command sets the mark to
-the value of point before doing any replacements, because this enables
-the user to move back there conveniently after the replace is finished.
-
- Once the mark "exists" in a buffer, it normally never ceases to
-exist. However, it may become "inactive", and usually does so after
-each command (other than simple motion commands and some commands that
-explicitly activate the mark). When the mark is active, the region
-between point and the mark is called the "active region" and is
-highlighted specially.
-
- Many commands are designed so that when called interactively they
-operate on the text between point and the mark. Such commands work
-only when an active region exists, i.e. when the mark is active. (The
-reason for this is to prevent you from accidentally deleting or
-changing large chunks of your text.) If you are writing such a command,
-don't examine the mark directly; instead, use `interactive' with the
-`r' specification. This provides the values of point and the mark as
-arguments to the command in an interactive call, but permits other Lisp
-programs to specify arguments explicitly, and automatically signals an
-error if the command is called interactively when no active region
-exists. *Note Interactive Codes::.
-
- Each buffer has its own value of the mark that is independent of the
-value of the mark in other buffers. (When a buffer is created, the mark
-exists but does not point anywhere. We consider this state as "the
-absence of a mark in that buffer.") However, only one active region can
-exist at a time. Activating the mark in one buffer automatically
-deactivates an active mark in any other buffer. Note that the user can
-explicitly activate a mark at any time by using the command
-`activate-region' (normally bound to `M-C-z') or by using the command
-`exchange-point-and-mark' (normally bound to `C-x C-x'), which has the
-side effect of activating the mark.
-
- Some people do not like active regions, so they disable this behavior
-by setting the variable `zmacs-regions' to `nil'. This makes the mark
-always active (except when a buffer is just created and the mark points
-nowhere), and turns off the highlighting of the region between point
-and the mark. Commands that explicitly retrieve the value of the mark
-should make sure that they behave correctly and consistently
-irrespective of the setting of `zmacs-regions'; some primitives are
-provided to ensure this behavior.
-
- In addition to the mark, each buffer has a "mark ring" which is a
-list of markers containing previous values of the mark. When editing
-commands change the mark, they should normally save the old value of the
-mark on the mark ring. The variable `mark-ring-max' specifies the
-maximum number of entries in the mark ring; once the list becomes this
-long, adding a new element deletes the last element.
-
- - Function: mark &optional force buffer
- This function returns BUFFER's mark position as an integer.
- BUFFER defaults to the current buffer if omitted.
-
- If the mark is inactive, `mark' normally returns `nil'. However,
- if FORCE is non-`nil', then `mark' returns the mark position
- anyway--or `nil', if the mark is not yet set for the buffer.
-
- (Remember that if ZMACS-REGIONS is `nil', the mark is always
- active as long as it exists, and the FORCE argument will have no
- effect.)
-
- If you are using this in an editing command, you are most likely
- making a mistake; see the documentation of `set-mark' below.
-
- - Function: mark-marker inactive-p buffer
- This function returns BUFFER's mark. BUFFER defaults to the
- current buffer if omitted. This is the very marker that records
- the mark location inside XEmacs, not a copy. Therefore, changing
- this marker's position will directly affect the position of the
- mark. Don't do it unless that is the effect you want.
-
- If the mark is inactive, `mark-marker' normally returns `nil'.
- However, if FORCE is non-`nil', then `mark-marker' returns the
- mark anyway.
- (setq m (mark-marker))
- => #<marker at 3420 in markers.texi>
- (set-marker m 100)
- => #<marker at 100 in markers.texi>
- (mark-marker)
- => #<marker at 100 in markers.texi>
-
- Like any marker, this marker can be set to point at any buffer you
- like. We don't recommend that you make it point at any buffer
- other than the one of which it is the mark. If you do, it will
- yield perfectly consistent, but rather odd, results.
-
- - Function: set-mark position &optional buffer
- This function sets `buffer''s mark to POSITION, and activates the
- mark. BUFFER defaults to the current buffer if omitted. The old
- value of the mark is _not_ pushed onto the mark ring.
-
- *Please note:* Use this function only if you want the user to see
- that the mark has moved, and you want the previous mark position to
- be lost. Normally, when a new mark is set, the old one should go
- on the `mark-ring'. For this reason, most applications should use
- `push-mark' and `pop-mark', not `set-mark'.
-
- Novice XEmacs Lisp programmers often try to use the mark for the
- wrong purposes. The mark saves a location for the user's
- convenience. An editing command should not alter the mark unless
- altering the mark is part of the user-level functionality of the
- command. (And, in that case, this effect should be documented.)
- To remember a location for internal use in the Lisp program, store
- it in a Lisp variable. For example:
-
- (let ((beg (point)))
- (forward-line 1)
- (delete-region beg (point))).
-
- - Command: exchange-point-and-mark &optional dont-activate-region
- This function exchanges the positions of point and the mark. It
- is intended for interactive use. The mark is also activated
- unless DONT-ACTIVATE-REGION is non-`nil'.
-
- - Function: push-mark &optional position nomsg activate buffer
- This function sets BUFFER's mark to POSITION, and pushes a copy of
- the previous mark onto `mark-ring'. BUFFER defaults to the
- current buffer if omitted. If POSITION is `nil', then the value
- of point is used. `push-mark' returns `nil'.
-
- If the last global mark pushed was not in BUFFER, also push
- POSITION on the global mark ring (see below).
-
- The function `push-mark' normally _does not_ activate the mark.
- To do that, specify `t' for the argument ACTIVATE.
-
- A `Mark set' message is displayed unless NOMSG is non-`nil'.
-
- - Function: pop-mark
- This function pops off the top element of `mark-ring' and makes
- that mark become the buffer's actual mark. This does not move
- point in the buffer, and it does nothing if `mark-ring' is empty.
- It deactivates the mark.
-
- The return value is not meaningful.
-
- - Variable: mark-ring
- The value of this buffer-local variable is the list of saved former
- marks of the current buffer, most recent first.
-
- mark-ring
- => (#<marker at 11050 in markers.texi>
- #<marker at 10832 in markers.texi>
- ...)
-
- - User Option: mark-ring-max
- The value of this variable is the maximum size of `mark-ring'. If
- more marks than this are pushed onto the `mark-ring', `push-mark'
- discards an old mark when it adds a new one.
-
- In additional to a per-buffer mark ring, there is a "global mark
-ring". Marks are pushed onto the global mark ring the first time you
-set a mark after switching buffers.
-
- - Variable: global-mark-ring
- The value of this variable is the list of saved former global
- marks, most recent first.
-
- - User Option: mark-ring-max
- The value of this variable is the maximum size of
- `global-mark-ring'. If more marks than this are pushed onto the
- `global-mark-ring', `push-mark' discards an old mark when it adds
- a new one.
-
- - Command: pop-global-mark
- This function pops a mark off the global mark ring and jumps to
- that location.
-
-\1f
-File: lispref.info, Node: The Region, Prev: The Mark, Up: Markers
-
-The Region
-==========
-
- The text between point and the mark is known as "the region".
-Various functions operate on text delimited by point and the mark, but
-only those functions specifically related to the region itself are
-described here.
-
- When `zmacs-regions' is non-`nil' (this is the default), the concept
-of an "active region" exists. The region is active when the
-corresponding mark is active. Note that only one active region at a
-time can exist - i.e. only one buffer's region is active at a time.
-*Note The Mark::, for more information about active regions.
-
- - User Option: zmacs-regions
- If non-`nil' (the default), active regions are used. *Note The
- Mark::, for a detailed explanation of what this means.
-
- A number of functions are provided for explicitly determining the
-bounds of the region and whether it is active. Few programs need to use
-these functions, however. A command designed to operate on a region
-should normally use `interactive' with the `r' specification to find
-the beginning and end of the region. This lets other Lisp programs
-specify the bounds explicitly as arguments and automatically respects
-the user's setting for ZMACS-REGIONS. (*Note Interactive Codes::.)
-
- - Function: region-beginning &optional buffer
- This function returns the position of the beginning of BUFFER's
- region (as an integer). This is the position of either point or
- the mark, whichever is smaller. BUFFER defaults to the current
- buffer if omitted.
-
- If the mark does not point anywhere, an error is signaled. Note
- that this function ignores whether the region is active.
-
- - Function: region-end &optional buffer
- This function returns the position of the end of BUFFER's region
- (as an integer). This is the position of either point or the mark,
- whichever is larger. BUFFER defaults to the current buffer if
- omitted.
-
- If the mark does not point anywhere, an error is signaled. Note
- that this function ignores whether the region is active.
-
- - Function: region-exists-p
- This function is non-`nil' if the region exists. If active regions
- are in use (i.e. `zmacs-regions' is true), this means that the
- region is active. Otherwise, this means that the user has pushed
- a mark in this buffer at some point in the past. If this function
- returns `nil', a function that uses the `r' interactive
- specification will cause an error when called interactively.
-
- - Function: region-active-p
- If `zmacs-regions' is true, this is equivalent to
- `region-exists-p'. Otherwise, this function always returns false.
- This function is used by commands such as
- `fill-paragraph-or-region' and `capitalize-region-or-word', which
- operate either on the active region or on something else (e.g. the
- word or paragraph at point).
-
- - Variable: zmacs-region-stays
- If a command sets this variable to true, the currently active
- region will remain activated when the command finishes. (Normally
- the region is deactivated when each command terminates.) If
- ZMACS-REGIONS is false, however, this has no effect. Under normal
- circumstances, you do not need to set this; use the interactive
- specification `_' instead, if you want the region to remain active.
-
- - Function: zmacs-activate-region
- This function activates the region in the current buffer (this is
- equivalent to activating the current buffer's mark). This will
- normally also highlight the text in the active region and set
- ZMACS-REGION-STAYS to `t'. (If ZMACS-REGIONS is false, however,
- this function has no effect.)
-
- - Function: zmacs-deactivate-region
- This function deactivates the region in the current buffer (this is
- equivalent to deactivating the current buffer's mark). This will
- normally also unhighlight the text in the active region and set
- ZMACS-REGION-STAYS to `nil'. (If ZMACS-REGIONS is false, however,
- this function has no effect.)
-
- - Function: zmacs-update-region
- This function updates the active region, if it's currently active.
- (If there is no active region, this function does nothing.) This
- has the effect of updating the highlighting on the text in the
- region; but you should never need to call this except under rather
- strange circumstances. The command loop automatically calls it
- when appropriate. Calling this function will call the hook
- `zmacs-update-region-hook', if the region is active.
-
- - Variable: zmacs-activate-region-hook
- This normal hook is called when a region becomes active. (Usually
- this happens as a result of a command that activates the region,
- such as `set-mark-command', `activate-region', or
- `exchange-point-and-mark'.) Note that calling
- `zmacs-activate-region' will call this hook, even if the region is
- already active. If ZMACS-REGIONS is false, however, this hook
- will never get called under any circumstances.
-
- - Variable: zmacs-deactivate-region-hook
- This normal hook is called when an active region becomes inactive.
- (Calling `zmacs-deactivate-region' when the region is inactive will
- _not_ cause this hook to be called.) If ZMACS-REGIONS is false,
- this hook will never get called.
-
- - Variable: zmacs-update-region-hook
- This normal hook is called when an active region is "updated" by
- `zmacs-update-region'. This normally gets called at the end of
- each command that sets ZMACS-REGION-STAYS to `t', indicating that
- the region should remain activated. The motion commands do this.
-
-\1f
-File: lispref.info, Node: Text, Next: Searching and Matching, Prev: Markers, Up: Top
-
-Text
-****
-
- This chapter describes the functions that deal with the text in a
-buffer. Most examine, insert, or delete text in the current buffer,
-often in the vicinity of point. Many are interactive. All the
-functions that change the text provide for undoing the changes (*note
-Undo::).
-
- Many text-related functions operate on a region of text defined by
-two buffer positions passed in arguments named START and END. These
-arguments should be either markers (*note Markers::) or numeric
-character positions (*note Positions::). The order of these arguments
-does not matter; it is all right for START to be the end of the region
-and END the beginning. For example, `(delete-region 1 10)' and
-`(delete-region 10 1)' are equivalent. An `args-out-of-range' error is
-signaled if either START or END is outside the accessible portion of
-the buffer. In an interactive call, point and the mark are used for
-these arguments.
-
- Throughout this chapter, "text" refers to the characters in the
-buffer, together with their properties (when relevant).
-
-* Menu:
-
-* Near Point:: Examining text in the vicinity of point.
-* Buffer Contents:: Examining text in a general fashion.
-* Comparing Text:: Comparing substrings of buffers.
-* Insertion:: Adding new text to a buffer.
-* Commands for Insertion:: User-level commands to insert text.
-* Deletion:: Removing text from a buffer.
-* User-Level Deletion:: User-level commands to delete text.
-* The Kill Ring:: Where removed text sometimes is saved for later use.
-* Undo:: Undoing changes to the text of a buffer.
-* Maintaining Undo:: How to enable and disable undo information.
- How to control how much information is kept.
-* Filling:: Functions for explicit filling.
-* Margins:: How to specify margins for filling commands.
-* Auto Filling:: How auto-fill mode is implemented to break lines.
-* Sorting:: Functions for sorting parts of the buffer.
-* Columns:: Computing horizontal positions, and using them.
-* Indentation:: Functions to insert or adjust indentation.
-* Case Changes:: Case conversion of parts of the buffer.
-* Text Properties:: Assigning Lisp property lists to text characters.
-* Substitution:: Replacing a given character wherever it appears.
-* Registers:: How registers are implemented. Accessing the text or
- position stored in a register.
-* Transposition:: Swapping two portions of a buffer.
-* Change Hooks:: Supplying functions to be run when text is changed.
-* Transformations:: MD5 and base64 support.
-
-\1f
-File: lispref.info, Node: Near Point, Next: Buffer Contents, Up: Text
-
-Examining Text Near Point
-=========================
-
- Many functions are provided to look at the characters around point.
-Several simple functions are described here. See also `looking-at' in
-*Note Regexp Search::.
-
- Many of these functions take an optional BUFFER argument. In all
-such cases, the current buffer will be used if this argument is
-omitted. (In FSF Emacs, and earlier versions of XEmacs, these functions
-usually did not have these optional BUFFER arguments and always
-operated on the current buffer.)
-
- - Function: char-after position &optional buffer
- This function returns the character in the buffer at (i.e.,
- immediately after) position POSITION. If POSITION is out of range
- for this purpose, either before the beginning of the buffer, or at
- or beyond the end, then the value is `nil'. If optional argument
- BUFFER is `nil', the current buffer is assumed.
-
- In the following example, assume that the first character in the
- buffer is `@':
-
- (char-to-string (char-after 1))
- => "@"
-
- - Function: following-char &optional buffer
- This function returns the character following point in the buffer.
- This is similar to `(char-after (point))'. However, if point is at
- the end of the buffer, then the result of `following-char' is 0.
- If optional argument BUFFER is `nil', the current buffer is
- assumed.
-
- Remember that point is always between characters, and the terminal
- cursor normally appears over the character following point.
- Therefore, the character returned by `following-char' is the
- character the cursor is over.
-
- In this example, point is between the `a' and the `c'.
-
- ---------- Buffer: foo ----------
- Gentlemen may cry ``Pea-!-ce! Peace!,''
- but there is no peace.
- ---------- Buffer: foo ----------
-
- (char-to-string (preceding-char))
- => "a"
- (char-to-string (following-char))
- => "c"
-
- - Function: preceding-char &optional buffer
- This function returns the character preceding point in the buffer.
- See above, under `following-char', for an example. If point is at
- the beginning of the buffer, `preceding-char' returns 0. If
- optional argument BUFFER is `nil', the current buffer is assumed.
-
- - Function: bobp &optional buffer
- This function returns `t' if point is at the beginning of the
- buffer. If narrowing is in effect, this means the beginning of the
- accessible portion of the text. If optional argument BUFFER is
- `nil', the current buffer is assumed. See also `point-min' in
- *Note Point::.
-
- - Function: eobp &optional buffer
- This function returns `t' if point is at the end of the buffer.
- If narrowing is in effect, this means the end of accessible
- portion of the text. If optional argument BUFFER is `nil', the
- current buffer is assumed. See also `point-max' in *Note Point::.
-
- - Function: bolp &optional buffer
- This function returns `t' if point is at the beginning of a line.
- If optional argument BUFFER is `nil', the current buffer is
- assumed. *Note Text Lines::. The beginning of the buffer (or its
- accessible portion) always counts as the beginning of a line.
-
- - Function: eolp &optional buffer
- This function returns `t' if point is at the end of a line. The
- end of the buffer is always considered the end of a line. If
- optional argument BUFFER is `nil', the current buffer is assumed.
- The end of the buffer (or of its accessible portion) is always
- considered the end of a line.
-
-\1f
-File: lispref.info, Node: Buffer Contents, Next: Comparing Text, Prev: Near Point, Up: Text
-
-Examining Buffer Contents
-=========================
-
- This section describes two functions that allow a Lisp program to
-convert any portion of the text in the buffer into a string.
-
- - Function: buffer-substring start end &optional buffer
- - Function: buffer-string start end &optional buffer
- These functions are equivalent and return a string containing a
- copy of the text of the region defined by positions START and END
- in the buffer. If the arguments are not positions in the
- accessible portion of the buffer, `buffer-substring' signals an
- `args-out-of-range' error. If optional argument BUFFER is `nil',
- the current buffer is assumed.
-
- If the region delineated by START and END contains duplicable
- extents, they will be remembered in the string. *Note Duplicable
- Extents::.
-
- It is not necessary for START to be less than END; the arguments
- can be given in either order. But most often the smaller argument
- is written first.
-
- ---------- Buffer: foo ----------
- This is the contents of buffer foo
-
- ---------- Buffer: foo ----------
-
- (buffer-substring 1 10)
- => "This is t"
- (buffer-substring (point-max) 10)
- => "he contents of buffer foo
- "
-
-\1f
-File: lispref.info, Node: Comparing Text, Next: Insertion, Prev: Buffer Contents, Up: Text
-
-Comparing Text
-==============
-
- This function lets you compare portions of the text in a buffer,
-without copying them into strings first.
-
- - Function: compare-buffer-substrings buffer1 start1 end1 buffer2
- start2 end2
- This function lets you compare two substrings of the same buffer
- or two different buffers. The first three arguments specify one
- substring, giving a buffer and two positions within the buffer.
- The last three arguments specify the other substring in the same
- way. You can use `nil' for BUFFER1, BUFFER2, or both to stand for
- the current buffer.
-
- The value is negative if the first substring is less, positive if
- the first is greater, and zero if they are equal. The absolute
- value of the result is one plus the index of the first differing
- characters within the substrings.
-
- This function ignores case when comparing characters if
- `case-fold-search' is non-`nil'. It always ignores text
- properties.
-
- Suppose the current buffer contains the text `foobarbar
- haha!rara!'; then in this example the two substrings are `rbar '
- and `rara!'. The value is 2 because the first substring is greater
- at the second character.
-
- (compare-buffer-substring nil 6 11 nil 16 21)
- => 2
-
-\1f
-File: lispref.info, Node: Insertion, Next: Commands for Insertion, Prev: Comparing Text, Up: Text
-
-Inserting Text
-==============
-
- "Insertion" means adding new text to a buffer. The inserted text
-goes at point--between the character before point and the character
-after point.
-
- Insertion relocates markers that point at positions after the
-insertion point, so that they stay with the surrounding text (*note
-Markers::). When a marker points at the place of insertion, insertion
-normally doesn't relocate the marker, so that it points to the
-beginning of the inserted text; however, certain special functions such
-as `insert-before-markers' relocate such markers to point after the
-inserted text.
-
- Some insertion functions leave point before the inserted text, while
-other functions leave it after. We call the former insertion "after
-point" and the latter insertion "before point".
-
- If a string with non-`nil' extent data is inserted, the remembered
-extents will also be inserted. *Note Duplicable Extents::.
-
- Insertion functions signal an error if the current buffer is
-read-only.
-
- These functions copy text characters from strings and buffers along
-with their properties. The inserted characters have exactly the same
-properties as the characters they were copied from. By contrast,
-characters specified as separate arguments, not part of a string or
-buffer, inherit their text properties from the neighboring text.
-
- - Function: insert &rest args
- This function inserts the strings and/or characters ARGS into the
- current buffer, at point, moving point forward. In other words, it
- inserts the text before point. An error is signaled unless all
- ARGS are either strings or characters. The value is `nil'.
-
- - Function: insert-before-markers &rest args
- This function inserts the strings and/or characters ARGS into the
- current buffer, at point, moving point forward. An error is
- signaled unless all ARGS are either strings or characters. The
- value is `nil'.
-
- This function is unlike the other insertion functions in that it
- relocates markers initially pointing at the insertion point, to
- point after the inserted text.
-
- - Function: insert-string string &optional buffer
- This function inserts STRING into BUFFER before point. BUFFER
- defaults to the current buffer if omitted. This function is
- chiefly useful if you want to insert a string in a buffer other
- than the current one (otherwise you could just use `insert').
-
- - Function: insert-char character count &optional buffer
- This function inserts COUNT instances of CHARACTER into BUFFER
- before point. COUNT must be a number, and CHARACTER must be a
- character. The value is `nil'. If optional argument BUFFER is
- `nil', the current buffer is assumed. (In FSF Emacs, the third
- argument is called INHERIT and refers to text properties.)
-
- - Function: insert-buffer-substring from-buffer-or-name &optional
- start end
- This function inserts a portion of buffer FROM-BUFFER-OR-NAME
- (which must already exist) into the current buffer before point.
- The text inserted is the region from START and END. (These
- arguments default to the beginning and end of the accessible
- portion of that buffer.) This function returns `nil'.
-
- In this example, the form is executed with buffer `bar' as the
- current buffer. We assume that buffer `bar' is initially empty.
-
- ---------- Buffer: foo ----------
- We hold these truths to be self-evident, that all
- ---------- Buffer: foo ----------
-
- (insert-buffer-substring "foo" 1 20)
- => nil
-
- ---------- Buffer: bar ----------
- We hold these truth-!-
- ---------- Buffer: bar ----------
-