home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / elisp.i16 (.txt) < prev    next >
GNU Info File  |  1993-06-14  |  49KB  |  872 lines

  1. This is Info file elisp, produced by Makeinfo-1.47 from the input file
  2. elisp.texi.
  3.    This file documents GNU Emacs Lisp.
  4.    This is edition 1.03 of the GNU Emacs Lisp Reference Manual, for
  5. Emacs Version 18.
  6.    Published by the Free Software Foundation, 675 Massachusetts Avenue,
  7. Cambridge, MA 02139 USA
  8.    Copyright (C) 1990 Free Software Foundation, Inc.
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided that
  14. the entire resulting derived work is distributed under the terms of a
  15. permission notice identical to this one.
  16.    Permission is granted to copy and distribute translations of this
  17. manual into another language, under the above conditions for modified
  18. versions, except that this permission notice may be stated in a
  19. translation approved by the Foundation.
  20. File: elisp,  Node: Deleting Windows,  Next: Selecting Windows,  Prev: Splitting Windows,  Up: Windows
  21. Deleting Windows
  22. ================
  23.    A "deleted window" no longer appears on the screen.  In Emacs
  24. version 18, the space it took up on the screen is divided
  25. proportionally among all siblings; in version 19, the space is given to
  26. one adjacent sibling.
  27.  -- Command: delete-window &optional WINDOW
  28.      This function removes WINDOW from the display.  If WINDOW is
  29.      omitted, then the selected window is deleted.  An error is signaled
  30.      if there is only one window when `delete-window' is called.
  31.           *Warning:* erroneous information or fatal errors may result
  32.           from using a deleted window.  Use `(window-point WINDOW)' to
  33.           test whether a window has been deleted; it yields `nil' for a
  34.           deleted window.
  35.      This function returns `nil'.
  36.      When `delete-window' is called interactively, WINDOW defaults to
  37.      the selected window.
  38.  -- Command: delete-other-windows &optional WINDOW
  39.      This function makes WINDOW the only window on the screen by
  40.      deleting all the other windows.  If WINDOW is omitted or `nil',
  41.      then the selected window is used by default.
  42.      The result is `nil'.
  43.  -- Command: delete-windows-on BUFFER
  44.      This function deletes all windows showing BUFFER.  If there are no
  45.      windows showing BUFFER, then this function does nothing.  If all
  46.      windows are showing BUFFER (including the case where there is only
  47.      one window), then the screen reverts to having a single window
  48.      showing the buffer chosen by `other-buffer'.  *Note The Buffer
  49.      List::.
  50.      If there are several windows showing different buffers, then those
  51.      showing BUFFER are removed, and the others are expanded to fill the
  52.      void.
  53.      The result is `nil'.
  54. File: elisp,  Node: Selecting Windows,  Next: Cyclic Window Ordering,  Prev: Deleting Windows,  Up: Windows
  55. Selecting Windows
  56. =================
  57.    When a window is selected, the buffer in the window becomes the
  58. current buffer, and the cursor will appear in it.
  59.  -- Function: selected-window
  60.      This function returns the selected window.  This is the window in
  61.      which the cursor appears and to which many commands apply.
  62.  -- Function: select-window WINDOW
  63.      This function makes WINDOW the selected window.  The cursor then
  64.      appears in WINDOW (on redisplay).  The buffer being displayed in
  65.      WINDOW is immediately designated the current buffer.
  66.      The return value is WINDOW.
  67.           (setq w (next-window))
  68.           (select-window w)
  69.                => #<window 65 on windows.texi>
  70.    The following functions choose one of the windows on the screen,
  71. offering various criteria for the choice.
  72.  -- Function: get-lru-window
  73.      This function returns the window least recently "used" (that is,
  74.      selected).  The selected window is always the most recently used
  75.      window.
  76.      The selected window can be the least recently used window if it is
  77.      the only window.  A newly created window becomes the least
  78.      recently used window until it is selected.  The minibuffer window
  79.      is not considered a candidate.
  80.  -- Function: get-largest-window
  81.      This function returns the window with the largest area (height
  82.      times width).  If there are no side-by-side windows, then this is
  83.      the window with the most lines.  The minibuffer window is not
  84.      considered a candidate.
  85.      If there are two windows of the same size, then the function
  86.      returns the window which is first in the cyclic ordering of
  87.      windows (see following section), starting from the selected window.
  88. File: elisp,  Node: Cyclic Window Ordering,  Next: Buffers and Windows,  Prev: Selecting Windows,  Up: Windows
  89. Cycling Ordering of Windows
  90. ===========================
  91.    When you use the command `C-x o' (`other-window') to select the next
  92. window, it moves through all the windows on the screen in a specific
  93. cyclic order.  For any given configuration of windows, this order never
  94. varies.  It is called the "cyclic ordering of windows".
  95.    This ordering generally goes from top to bottom, and from left to
  96. right.  But it may go down first or go right first, depending on the
  97. order in which the screen, or the windows within the screen, were split.
  98.    If the screen was first split vertically (into windows one above each
  99. other), and then the subwindows were split horizontally, then the
  100. ordering is left to right in the top, and then left to right in the next
  101. lower part of the screen, and so on.  If the screen was first split
  102. horizontally, the ordering is top to bottom in the left part, and so on.
  103. In general, within each set of siblings at any level in the window tree,
  104. the order is left to right, or top to bottom.
  105.  -- Function: next-window WINDOW &optional MINIBUF
  106.      This function returns the window following WINDOW in the cyclic
  107.      ordering of windows.  This is the window which `C-x o' would select
  108.      if done when WINDOW is selected.  If WINDOW is the only window
  109.      visible, then this function returns WINDOW.
  110.      The value of the argument MINIBUF determines whether the
  111.      minibuffer is included in the window order.  Normally, when
  112.      MINIBUF is `nil', the minibuffer is included if it is currently
  113.      active; this is the behavior of `C-x o'.
  114.      If MINIBUF is `t', then the cyclic ordering includes the
  115.      minibuffer window even if it is not active.  If MINIBUF is neither
  116.      `t' nor `nil', then the minibuffer window is not included even if
  117.      it is active.  (The minibuffer window is active while the
  118.      minibuffer is in use.  *Note Minibuffers::.)
  119.      This example shows two windows, which both happen to be displaying
  120.      the same buffer:
  121.           (selected-window)
  122.                => #<window 56 on windows.texi>
  123.           (next-window (selected-window))
  124.                => #<window 52 on windows.texi>
  125.           (next-window (next-window (selected-window)))
  126.                => #<window 56 on windows.texi>
  127.  -- Function: previous-window WINDOW
  128.      This function returns the window preceding WINDOW in the cyclic
  129.      ordering of windows.
  130.  -- Command: other-window COUNT
  131.      This function selects the COUNTth next window in the cyclic order.
  132.       If count is negative, then it selects the -COUNTth preceding
  133.      window.  It returns `nil'.
  134.      In an interactive call, COUNT is the numeric prefix argument.
  135. File: elisp,  Node: Buffers and Windows,  Next: Displaying Buffers,  Prev: Cyclic Window Ordering,  Up: Windows
  136. Buffers and Windows
  137. ===================
  138.    This section describes low-level functions to examine windows or to
  139. show buffers in windows in a precisely controlled fashion. *Note
  140. Displaying Buffers::, for related functions that find a window to use
  141. and specify a buffer for it. The functions described there are easier
  142. to use than these, but they employ heuristics in choosing or creating a
  143. window; use these functions when you need complete control.
  144.  -- Function: set-window-buffer WINDOW BUFFER-OR-NAME
  145.      This function makes WINDOW display BUFFER-OR-NAME as its contents.
  146.       It returns `nil'.
  147.           (set-window-buffer (selected-window) "foo")
  148.                => nil
  149.  -- Function: window-buffer &optional WINDOW
  150.      This function returns the buffer that WINDOW is displaying.  If
  151.      WINDOW is omitted, then this function returns the buffer for the
  152.      selected window.
  153.           (window-buffer)
  154.                => #<buffer windows.texi>
  155.  -- Function: get-buffer-window BUFFER-OR-NAME
  156.      This function returns a window currently displaying
  157.      BUFFER-OR-NAME, or `nil' if there is none.  If there are several
  158.      such windows, then the function returns the first one in the
  159.      cyclic ordering of windows, starting from the selected window.
  160.      *Note Cyclic Window Ordering::.
  161.  -- Command: replace-buffer-in-windows BUFFER
  162.      This function replaces BUFFER with some other buffer in all
  163.      windows displaying it.  The other buffer used is chosen with
  164.      `other-buffer'.  In the usual applications of this function, you
  165.      don't care which other buffer is used; you just want to make sure
  166.      that BUFFER is off the screen.
  167.      This function returns `nil'.
  168. File: elisp,  Node: Displaying Buffers,  Next: Window Point,  Prev: Buffers and Windows,  Up: Windows
  169. Displaying Buffers in Windows
  170. =============================
  171.    In this section we describe convenient functions that choose a window
  172. automatically and use it to display a specified buffer.  These functions
  173. can also split an existing window in certain circumstances.  We also
  174. describe variables that parameterize the heuristics used for choosing a
  175. window. *Note Buffers and Windows::, for low-level functions that give
  176. you more precise control.
  177.    Do not use the functions in this section in order to make a buffer
  178. current so that a Lisp program can access or modify it; they are too
  179. drastic for that purpose, since they change the display of buffers on
  180. the screen, which is gratuitous and will surprise the user.  Instead,
  181. use `set-buffer' (*note Current Buffer::.) and `save-excursion' (*note
  182. Excursions::.), which designate buffers as current for programmed
  183. access without affecting the display of buffers in windows.
  184.  -- Command: switch-to-buffer BUFFER-OR-NAME &optional NORECORD
  185.      This function makes BUFFER-OR-NAME the current buffer, and also
  186.      displays the buffer in the selected window.  This means that a
  187.      human can see the buffer and subsequent keyboard commands will
  188.      apply to it. Contrast this with `set-buffer', which makes
  189.      BUFFER-OR-NAME the current buffer but does not display it in the
  190.      selected window. *Note Current Buffer::.
  191.      If BUFFER-OR-NAME does not identify an existing buffer, then a new
  192.      buffer by that name is created.
  193.      Normally the specified buffer is put at the front of the buffer
  194.      list. This affects the operation of `other-buffer'.  However, if
  195.      NORECORD is non-`nil', this is not done.  *Note The Buffer List::.
  196.      The `switch-to-buffer' function is often used interactively, as
  197.      the binding of `C-x b'.  It is also used frequently in programs. 
  198.      It always returns `nil'.
  199.  -- Command: switch-to-buffer-other-window BUFFER-OR-NAME
  200.      This function makes BUFFER-OR-NAME the current buffer and displays
  201.      it in a window not currently selected.  It then selects that
  202.      window.  The handling of the buffer is the same as in
  203.      `switch-to-buffer'.
  204.      The previously selected window is absolutely never used to display
  205.      the buffer.  If it is the only window, then it is split to make a
  206.      distinct window for this purpose.  If the selected window is
  207.      already displaying the buffer, then it continues to do so, but
  208.      another window is nonetheless found to display it in as well.
  209.  -- Function: pop-to-buffer BUFFER-OR-NAME &optional OTHER-WINDOW
  210.      This function makes BUFFER-OR-NAME the current buffer and switches
  211.      to it in some window, preferably not the window previously
  212.      selected.  The "popped-to" window becomes the selected window.
  213.      If the variable `pop-up-windows' is non-`nil', windows may be
  214.      split to create a new window that is different from the original
  215.      window.
  216.      If OTHER-WINDOW is non-`nil', `pop-to-buffer' finds or creates
  217.      another window even if BUFFER-OR-NAME is already visible in the
  218.      selected window.  Thus BUFFER-OR-NAME could end up displayed in
  219.      two windows.  On the other hand, if BUFFER-OR-NAME is already
  220.      displayed in the selected window and OTHER-WINDOW is `nil', then
  221.      the selected window is considered sufficient display for
  222.      BUFFER-OR-NAME, so that nothing needs to be done.
  223.      If BUFFER-OR-NAME is a string that does not name an existing
  224.      buffer, a buffer by that name is created.
  225.      An example use of this function is found at the end of *Note
  226.      Filter Functions::.
  227.  -- Function: display-buffer BUFFER-OR-NAME &optional NOT-THIS-WINDOW
  228.      This function makes BUFFER-OR-NAME appear in some window, like
  229.      `pop-to-buffer', but it does not select that window and does not
  230.      make the buffer current.  The identity of the selected window is
  231.      unaltered by this function.
  232.      If NOT-THIS-WINDOW is non-`nil', it means that the specified
  233.      buffer should be displayed in a window other than the selected
  234.      one, even if it is already on display in the selected window. 
  235.      This can cause the buffer to appear in two windows at once. 
  236.      Otherwise, if BUFFER-OR-NAME is already being displayed in any
  237.      window, that is good enough, so this function does nothing.
  238.      If the variable `pop-up-windows' is non-`nil', windows can be
  239.      split to display the buffer.  If there are multiple windows,
  240.      `display-buffer' will split the largest window if it has more than
  241.      the number of lines specified by the variable
  242.      `split-height-threshold'.
  243.      `display-buffer' returns the window chosen to display
  244.      BUFFER-OR-NAME.
  245.  -- User Option: pop-up-windows
  246.      This variable controls whether `display-buffer' makes new windows.
  247.       If it is non-`nil' and there is only one window on the screen,
  248.      then that window is split.  If it is `nil', then `display-buffer'
  249.      does not split the single window, but rather replaces its buffer.
  250.      This variable also affects `pop-to-buffer', which uses
  251.      `display-buffer' as a subroutine.
  252.  -- User Option: split-height-threshold
  253.      This variable determines when `display-buffer' may split a window,
  254.      if there are multiple windows.  `display-buffer' splits the
  255.      largest window if it has at least this many lines.
  256.      If there is only one window, it is split regardless of this value,
  257.      provided `pop-up-windows' is non-`nil'.
  258. File: elisp,  Node: Window Point,  Next: Window Start,  Prev: Displaying Buffers,  Up: Windows
  259. Window Point
  260. ============
  261.    Each window has its own value of point, independent of the value of
  262. point in other windows displaying the same buffer.  This makes it useful
  263. to have multiple windows showing one buffer.
  264.    * The window point is established when a window is first created; it
  265.      is initialized from the buffer's point, or from the window point
  266.      of another window opened on the buffer if such a window exists.
  267.    * Selecting a window sets the value of point in its buffer to the
  268.      window's value of point.  Conversely, deselecting a window copies
  269.      the buffer's value of point into the window.  Thus, when you
  270.      switch between windows that display a given buffer, the point
  271.      value for the selected window is in effect in the buffer, while
  272.      the point values for the other windows are stored in those windows.
  273.    * As long as the selected window displays the current buffer, the
  274.      window's point and the buffer's point always move together; they
  275.      remain equal.
  276.    * *Note Positions::, for more details on positions.
  277.    As far as the user is concerned, point is where the cursor is, and
  278. when the user switches to another buffer, the cursor jumps to the
  279. position of point in that buffer.
  280.  -- Function: window-point WINDOW
  281.      This function returns the current position of point in WINDOW. For
  282.      a nonselected window, this is the value point would have (in that
  283.      window's buffer) if that window were selected.
  284.      When WINDOW is the selected window and its buffer is also the
  285.      current buffer, the value returned is the same as point in that
  286.      buffer.
  287.      Strictly speaking, it would be more correct to return the
  288.      "top-level" value of point, outside of any `save-excursion' forms.
  289.       But that value is hard to find.
  290.  -- Function: set-window-point WINDOW POSITION
  291.      This function positions point in WINDOW at position POSITION in
  292.      WINDOW's buffer.
  293. File: elisp,  Node: Window Start,  Next: Vertical Scrolling,  Prev: Window Point,  Up: Windows
  294. The Display-Start Position
  295. ==========================
  296.    Each window contains a marker used to keep track of a buffer position
  297. which specifies where in the buffer display should start.  This position
  298. is called the "display-start" position of the window.  The character
  299. after this position is the one that appears at the upper left corner of
  300. the window.  It is usually, but not inevitably, at the beginning of a
  301. text line.
  302.  -- Function: window-start &optional WINDOW
  303.      This function returns the display-start position of window WINDOW.
  304.       If WINDOW is `nil', the selected window is used.
  305.           (window-start)
  306.                => 7058
  307.      For a more complicated example of use, see the description of
  308.      `count-lines' in *Note Text Lines::.
  309.  -- Function: set-window-start WINDOW POSITION &optional NOFORCE
  310.      This function sets the display-start position of WINDOW to
  311.      POSITION in WINDOW's buffer.
  312.      The display routines insist that the position of point be visible
  313.      when a buffer is displayed.  Normally, they change the
  314.      display-start position (that is, scroll the window) whenever
  315.      necessary to make point visible. However, if you specify the start
  316.      position with this function with `nil' for NOFORCE, it means you
  317.      want display to start at POSITION even if that would put the
  318.      location of point off the screen.  What the display routines do in
  319.      this case is move point instead, to the left margin on the middle
  320.      line in the window.
  321.      For example, if point is 1 and you attempt to set the start of the
  322.      window to 2, then the position of point would be "above" the top
  323.      of the window.  The display routines would automatically move
  324.      point if it is still 1 when redisplay occurs.  Here is an example:
  325.           ;; Here is what `foo' looks like before executing
  326.           ;; the `set-window-start' expression.
  327.           
  328.           ---------- Buffer: foo ----------
  329.           -!-This is the contents of buffer foo.
  330.           2
  331.           3
  332.           4
  333.           5
  334.           6
  335.           ---------- Buffer: foo ----------
  336.           
  337.           (set-window-start (selected-window) (1+ (window-start)))
  338.           
  339.           ;; Here is what `foo' looks like after executing
  340.           ;; the `set-window-start' expression.
  341.           
  342.           ---------- Buffer: foo ----------
  343.           his is the contents of buffer foo.
  344.           2
  345.           3
  346.           -!-4
  347.           5
  348.           6
  349.           ---------- Buffer: foo ----------
  350.           
  351.                => 2
  352.      However, when NOFORCE is non-`nil', `set-window-start' does
  353.      nothing if the specified start position would make point invisible.
  354.      This function returns POSITION, regardless of whether the NOFORCE
  355.      option caused that position to be overruled.
  356.  -- Function: pos-visible-in-window-p &optional POSITION WINDOW
  357.      This function returns `t' if POSITION is within the range of text
  358.      currently visible on the screen in WINDOW.  It returns `nil' if
  359.      POSITION is scrolled vertically out of view.  The argument
  360.      POSITION defaults to the current position of point; WINDOW, to the
  361.      selected window.  Here is an example:
  362.           (or (pos-visible-in-window-p (point) (selected-window))
  363.               (recenter 0))
  364.      The `pos-visible-in-window-p' function considers only vertical
  365.      scrolling.  It returns `t' if POSITION is out of view only because
  366.      WINDOW has been scrolled horizontally.  *Note Horizontal
  367.      Scrolling::.
  368. File: elisp,  Node: Vertical Scrolling,  Next: Horizontal Scrolling,  Prev: Window Start,  Up: Windows
  369. Vertical Scrolling
  370. ==================
  371.    Vertical scrolling means moving the text up or down in a window.  It
  372. works by changing the value of the window's display-start location.  It
  373. may also change the value of `window-point' to keep it on the screen.
  374.    In the commands `scroll-up' and `scroll-down', the directions "up"
  375. and "down" refer to the motion of the text in the buffer at which you
  376. are looking through the window.  Imagine that the text is written on a
  377. long roll of paper and that the scrolling commands move the paper up
  378. and down.  Thus, if you are looking at text in the middle of a buffer
  379. and repeatedly call `scroll-down', you will eventually see the
  380. beginning of the buffer.
  381.    Some people have urged that the opposite convention be used: they
  382. imagine that the window moves over text that remains in place.  Then
  383. "down" commands would take you to the end of the buffer.  This view is
  384. more consistent with the actual relationship between windows and the
  385. text in the buffer, but it is less like what the user sees.  The
  386. position of a window on the terminal does not move, and short scrolling
  387. commands clearly move the text up or down on the screen.  We have chosen
  388. names that fit the user's point of view.
  389.    The scrolling functions (aside from `scroll-other-window') will have
  390. unpredictable results if the current buffer is different from the
  391. buffer that is displayed in the selected window.  *Note Current
  392. Buffer::.
  393.  -- Command: scroll-up &optional COUNT
  394.      This function scrolls the text in the selected window upward COUNT
  395.      lines.  If COUNT is negative, scrolling is actually downward.
  396.      If COUNT is `nil' (or omitted), then the length of the scroll is
  397.      `next-screen-context-lines' lines less than the usable height of
  398.      the window (not counting its mode line).
  399.      `scroll-up' returns `nil'.
  400.  -- Command: scroll-down &optional COUNT
  401.      This function scrolls the text in the selected window downward
  402.      COUNT lines.  If COUNT is negative, scrolling is actually upward.
  403.      If COUNT is omitted or `nil', then the length of the scroll is
  404.      `next-screen-context-lines' lines less than the usable height of
  405.      the window.
  406.      `scroll-down' returns `nil'.
  407.  -- Command: scroll-other-window &optional COUNT
  408.      This function scrolls the text in another window upward COUNT
  409.      lines.  Negative values of COUNT, or `nil', are handled as in
  410.      `scroll-up'.
  411.      The window that is scrolled is normally the one following the
  412.      selected window in the cyclic ordering of windows--the window that
  413.      `next-window' would return.  *Note Cyclic Window Ordering::.
  414.      If the selected window is the minibuffer, the next window is
  415.      normally the one at the top left corner.  However, you can specify
  416.      the window to scroll by binding the variable
  417.      `minibuffer-scroll-window'.  This variable has no effect when any
  418.      other window is selected. *Note Minibuffer Misc::.
  419.      When the minibuffer is active, it is the next window if the
  420.      selected window is the one at the bottom right corner.  In this
  421.      case, `scroll-other-window' will attempt to scroll the minibuffer.
  422.       If the minibuffer contains just one line, that line will be
  423.      redisplayed after the echo area momentarily displays the message
  424.      "Beginning of buffer".
  425.  -- User Option: scroll-step
  426.      This variable controls how scrolling is done automatically when
  427.      point moves off the screen.  If the value is zero, then the text
  428.      is scrolled so that point is centered vertically in the window. 
  429.      If the value is a positive integer N, then if it is possible to
  430.      bring point back on screen by scrolling N lines in either
  431.      direction, that is done; otherwise, point is centered vertically
  432.      as usual.  The default value is zero.
  433.  -- User Option: next-screen-context-lines
  434.      The value of this variable is the number of lines of continuity to
  435.      retain when scrolling by full screens.  For example, when
  436.      `scroll-up' executes, this many lines that were visible at the
  437.      bottom of the window move to the top of the window.  The default
  438.      value is `2'.
  439.  -- Command: recenter &optional COUNT
  440.      This function scrolls the selected window to put the text where
  441.      point is located at a specified screen position.
  442.      If COUNT is a nonnegative number, it puts the line containing
  443.      point COUNT lines down from the top of the window.  If COUNT is a
  444.      negative number, then it counts upward from the bottom of the
  445.      window, so that -1 stands for the last usable line in the window.
  446.      If COUNT is a non-`nil' list, then it stands for the line in the
  447.      middle of the window.
  448.      If COUNT is `nil', then it puts the line containing point in the
  449.      middle of the window, then clears and redisplays the entire screen.
  450.      When `recenter' is called interactively, Emacs sets COUNT to the
  451.      raw prefix argument.  Thus, typing `C-u' as the prefix sets the
  452.      COUNT to a non-`nil' list, while typing `C-u 4' sets COUNT to 4,
  453.      which positions the current line four lines from the top.
  454.      Typing `C-u 0 C-l' positions the current line at the top of the
  455.      window.  This action is so handy that some people bind the command
  456.      to a function key.  For example,
  457.           (defun line-to-top-of-window ()
  458.             "Scroll the selected window up so current line moves to the top.
  459.           Replaces three keystroke sequence C-u 0 C-l."
  460.             (interactive)
  461.             (recenter 0))
  462.           
  463.           (global-set-key "\C-cl" 'line-to-top-of-window)
  464. File: elisp,  Node: Horizontal Scrolling,  Next: Size of Window,  Prev: Vertical Scrolling,  Up: Windows
  465. Horizontal Scrolling
  466. ====================
  467.    Because we read English first from top to bottom and second from left
  468. to right, horizontal scrolling is not like vertical scrolling.  Vertical
  469. scrolling involves selection of a contiguous portion of text to display.
  470. Horizontal scrolling causes part of each line to go off screen.  The
  471. amount of horizontal scrolling is therefore specified as a number of
  472. columns rather than as a position in the buffer.  It has nothing to do
  473. with the display-start position returned by `window-start'.
  474.    Usually, no horizontal scrolling is in effect; then the leftmost
  475. column is at the left edge of the window.  In this state, scrolling to
  476. the right is meaningless, since there is no data to the left of the
  477. screen to be revealed by it, so it is not allowed.  Scrolling to the
  478. left is allowed; it causes the first columns of text to go off the edge
  479. of the window and can reveal additional columns on the right that were
  480. truncated before.  Once a window has a nonzero amount of leftward
  481. horizontal scrolling, you can scroll it back to the right, but only so
  482. far as to reduce the net horizontal scroll to zero.  There is no limit
  483. to how far left you can scroll, but eventually all the text will
  484. disappear off the left edge.
  485.  -- Command: scroll-left COUNT
  486.      This function scrolls the selected window COUNT columns to the
  487.      left (or to the right if COUNT is negative).  The return value is
  488.      the total amount of leftward horizontal scrolling in effect after
  489.      the change--just like the value returned by `window-hscroll'.
  490.  -- Command: scroll-right COUNT
  491.      This function scrolls the selected window COUNT columns to the
  492.      right  (or to the left if COUNT is negative).  The return value is
  493.      the total amount of leftward horizontal scrolling in effect after
  494.      the change--just like the value returned by `window-hscroll'.
  495.      Once you scroll a window as far right as it can go, back to its
  496.      normal position where the total leftward scrolling is zero,
  497.      attempts to scroll any farther have no effect.
  498.  -- Function: window-hscroll &optional WINDOW
  499.      This function returns the total leftward horizontal scrolling of
  500.      WINDOW--the number of columns by which the text in WINDOW is
  501.      scrolled left past the left margin.
  502.      The value is never negative.  It is zero when no horizontal
  503.      scrolling has been done in WINDOW (which is usually the case).
  504.      If WINDOW is `nil', the selected window is used.
  505.           (window-hscroll)
  506.                => 0
  507.           (scroll-left 5)
  508.                => 5
  509.           (window-hscroll)
  510.                => 5
  511.  -- Function: set-window-hscroll WINDOW COLUMNS
  512.      This function sets the number of columns from the left margin that
  513.      WINDOW is scrolled to the value of COLUMNS.  The argument COLUMNS
  514.      should be zero or positive; if not, it is taken as zero.
  515.      The value returned is COLUMNS.
  516.           (set-window-hscroll (selected-window) 10)
  517.                => 10
  518.    Here is how you can determine whether a given position POSITION is
  519. off the screen due to horizontal scrolling:
  520.      (save-excursion
  521.        (goto-char POSITION)
  522.        (and
  523.         (>= (- (current-column) (window-hscroll WINDOW)) 0)
  524.         (< (- (current-column) (window-hscroll WINDOW))
  525.            (window-width WINDOW))))
  526. File: elisp,  Node: Size of Window,  Next: Resizing Windows,  Prev: Horizontal Scrolling,  Up: Windows
  527. The Size of a Window
  528. ====================
  529.    An Emacs window is rectangular, and its size information consists of
  530. the height (the number of lines) and the width (the number of character
  531. positions in each line).  The mode line is included in the height.  For
  532. a window that does not abut the right hand edge of the screen, the
  533. column of `|' characters that separates it from the window on the right
  534. is included in the width.
  535.    The following three functions return size information about a window:
  536.  -- Function: window-height &optional WINDOW
  537.      This function returns the number of lines in WINDOW, including its
  538.      mode line.  If WINDOW fills the entire screen, this is one less
  539.      than the value of `(screen-height)' (since the last line is always
  540.      reserved for the minibuffer).
  541.      If WINDOW is `nil', the function uses the selected window.
  542.           (window-height)
  543.                => 23
  544.           (split-window-vertically)
  545.                => #<window 4 on windows.texi>
  546.           (window-height)
  547.                => 11
  548.  -- Function: window-width &optional WINDOW
  549.      This function returns the number of columns in WINDOW.  If WINDOW
  550.      fills the entire screen, this is the same as the value of
  551.      `(screen-width)'.
  552.      If WINDOW is `nil', the function uses the selected window.
  553.           (window-width)
  554.                => 80
  555.  -- Function: window-edges &optional WINDOW
  556.      This function returns a list of the edge coordinates of WINDOW. If
  557.      WINDOW is `nil', the selected window is used.
  558.      The order of the list is `(LEFT TOP RIGHT BOTTOM)', all elements
  559.      relative to 0, 0 at the top left corner of the screen.  The
  560.      element RIGHT of the value is one more than the rightmost column
  561.      used by WINDOW, and BOTTOM is one more than the bottommost row
  562.      used by WINDOW and its mode-line.
  563.      Here is the result obtained on a typical 24-line terminal with
  564.      just one window:
  565.           (window-edges (selected-window))
  566.                => (0 0 80 23)
  567.      If WINDOW is at the upper left corner of the screen, RIGHT and
  568.      BOTTOM are the same as the values returned by `(window-width)' and
  569.      `(window-height)' respectively, and TOP and BOTTOM are zero.  For
  570.      example, the edges of the following window are `0 0 5 8'. 
  571.      Assuming that the screen has more than 8 columns, the last column
  572.      of the window (column 7) holds a border rather than text.  The
  573.      last row (row 4) holds the mode line, shown here with `xxxxxxxxx'.
  574.                      0
  575.                      _______
  576.                   0 |       |
  577.                     |       |
  578.                     |       |
  579.                     |       |
  580.                     xxxxxxxxx  4
  581.           
  582.                             7
  583.      When there are side-by-side windows, any window not at the right
  584.      edge of the screen has a border in its last column.  This border
  585.      counts as one column in the width of the window.  A window never
  586.      includes a border on its left, since the border there belongs to
  587.      the window to the left.
  588.      In the following example, let's imagine that the screen is 7
  589.      columns wide.  Then the edges of the left window are `0 0 4 3' and
  590.      the edges of the right window are `4 0 7 3'.
  591.                      ___ ___
  592.                     |   |   |
  593.                     |   |   |
  594.                     xxxxxxxxx
  595.           
  596.                      0  34  7
  597. File: elisp,  Node: Resizing Windows,  Next: Window Configurations,  Prev: Size of Window,  Up: Windows
  598. Changing the Size of a Window
  599. =============================
  600.    The window size functions fall into two classes: high-level commands
  601. that change the size of windows and low-level functions that access
  602. window size.  Emacs does not permit overlapping windows or gaps between
  603. windows, so resizing one window affects other windows.
  604.  -- Command: enlarge-window SIZE &optional HORIZONTAL
  605.      This function makes the selected window SIZE lines bigger,
  606.      stealing lines from neighboring windows.  It generally tries to
  607.      steal equal numbers of lines from the other windows.  If a window
  608.      from which lines are stolen shrinks below `window-min-height',
  609.      then that window disappears.
  610.      If HORIZONTAL is non-`nil', then this function makes WINDOW wider
  611.      by SIZE columns, stealing columns as it does lines.  If a window
  612.      from which lines are stolen shrinks below `window-min-width', then
  613.      that window disappears.
  614.      If the screen is smaller than SIZE lines (or columns), then the
  615.      function makes the window occupy the entire height (or width) of
  616.      the screen.
  617.      If SIZE is negative, this function shrinks the window by -SIZE
  618.      lines.  If it becomes shorter than `window-min-height', it
  619.      disappears.
  620.      `enlarge-window' returns `nil'.
  621.  -- Command: enlarge-window-horizontally COLUMNS
  622.      This function makes the selected window COLUMNS wider. It could be
  623.      defined as follows:
  624.           (defun enlarge-window-horizontally (columns)
  625.             (enlarge-window columns t))
  626.  -- Command: shrink-window SIZE &optional HORIZONTAL
  627.      This function is like `enlarge-window' but negates the argument
  628.      SIZE, making the selected window smaller by giving lines (or
  629.      columns) to the other windows.  If the window shrinks below
  630.      `window-min-height' or `window-min-width', then it disappears.
  631.      If SIZE is negative, the window is enlarged by -SIZE lines.
  632.  -- Command: shrink-window-horizontally COLUMNS
  633.      This function makes the selected window COLUMNS narrower. It could
  634.      be defined as follows:
  635.           (defun shrink-window-horizontally (columns)
  636.             (shrink-window columns t))
  637.    The following two variables constrain the window size changing
  638. functions to a minimum height and width.
  639.  -- User Option: window-min-height
  640.      The value of this variable determines how short a window may become
  641.      before it disappears.  A window disappears when it becomes smaller
  642.      than `window-min-height', and no window may be created that is
  643.      smaller. The absolute minimum height is two (allowing one line for
  644.      the mode line, and one line for the buffer display).  Actions
  645.      which change window sizes reset this variable to two if it is less
  646.      than two.  The default value is 4.
  647.  -- User Option: window-min-width
  648.      The value of this variable determines how narrow a window may
  649.      become before it disappears.  A window disappears when it becomes
  650.      narrower than `window-min-width', and no window may be created
  651.      that is narrower. The absolute minimum width is one; any value
  652.      below that is ignored.  The default value is 10.
  653. File: elisp,  Node: Window Configurations,  Prev: Resizing Windows,  Up: Windows
  654. Window Configurations
  655. =====================
  656.    "Window configurations" record entire screen layouts--all windows,
  657. their sizes, which buffers they contain, what part of each buffer is
  658. displayed, and the values of point and the mark.  You can bring back an
  659. entire previous screen layout by restoring a window configuration that
  660. you had previously saved.
  661.  -- Function: current-window-configuration
  662.      This function returns a new object representing Emacs's current
  663.      window configuration, namely the number of windows, their sizes
  664.      and current buffers, which window is the selected window, and for
  665.      each window the displayed buffer, the display-start position, and
  666.      the positions of point and the mark.  An exception is made for
  667.      point in the current buffer, whose value is not saved.
  668.  -- Function: set-window-configuration CONFIGURATION
  669.      This function restores the configuration of Emacs's windows and
  670.      buffers to the state specified by CONFIGURATION.  The argument
  671.      CONFIGURATION must be a value that was previously returned by
  672.      `current-window-configuration'.
  673.      Here is a way of using this function to get the same effect as
  674.      `save-window-excursion':
  675.           (let ((config (current-window-configuration)))
  676.             (unwind-protect
  677.                 (progn (split-window-vertically nil)
  678.                        ...)
  679.               (set-window-configuration config)))
  680.  -- Special Form: save-window-excursion FORMS...
  681.      This special form executes FORMS in sequence, preserving window
  682.      sizes and contents, including the value of point and the portion
  683.      of the buffer which is visible.  However, it does not restore the
  684.      value of point in the current buffer; use `save-excursion' for
  685.      that.
  686.      The return value is the value of the final form in FORMS. For
  687.      example:
  688.           (split-window)
  689.                => #<window 25 on control.texi>
  690.           (setq w (selected-window))
  691.                => #<window 19 on control.texi>
  692.           (save-window-excursion
  693.             (delete-other-windows w)
  694.             (switch-to-buffer "foo")
  695.             'do-something)
  696.                => do-something
  697.             ;; The screen is now split again.
  698.    Primitives to look inside of window configurations would make sense,
  699. but none are implemented.  It is not clear they are useful enough to be
  700. worth implementing.
  701. File: elisp,  Node: Positions,  Next: Markers,  Prev: Windows,  Up: Top
  702. Positions
  703. *********
  704.    A "position" is the index of a character in the text of buffer. More
  705. precisely, a position identifies the place between two characters (or
  706. before the first character, or after the last character), so we can
  707. speak of the character before or after a given position.  However, the
  708. character after a position is often said to be "at" that position.
  709.    Positions are usually represented as integers starting from 1, but
  710. can also be represented as "markers"--special objects which relocate
  711. automatically when text is inserted or deleted so they stay with the
  712. surrounding characters.  *Note Markers::.
  713. * Menu:
  714. * Point::         The special position where editing takes place.
  715. * Motion::        Changing point.
  716. * Excursions::    Temporary motion and buffer changes.
  717. * Narrowing::     Restricting editing to a portion of the buffer.
  718. File: elisp,  Node: Point,  Next: Motion,  Prev: Positions,  Up: Positions
  719. Point
  720. =====
  721.    "Point" is a special buffer position used by many editing commands,
  722. including the self-inserting typed characters and text insertion
  723. functions.  Other commands move point through the text to allow editing
  724. and insertion at different places.
  725.    Like other positions, point designates a place between two characters
  726. (or before the first character, or after the last character), rather
  727. than a particular character.  Many terminals display the cursor over the
  728. character that immediately follows point; on such terminals, point is
  729. actually before the character on which the cursor sits.
  730.    The value of point is a number between 1 and the buffer size plus 1.
  731. If narrowing is in effect (*note Narrowing::.), then point is
  732. constrained to fall within the accessible portion of the buffer
  733. (possibly at one end of it).
  734.    Each buffer has its own value of point, which is independent of the
  735. value of point in other buffers.  Each window also has a value of point,
  736. which is independent of the value of point in other windows on the same
  737. buffer.  This is why point can have different values in various windows
  738. that display the same buffer.  When a buffer appears in only one window,
  739. the buffer's point and the window's point normally have the same value,
  740. so the distinction is rarely important.  *Note Window Point::, for more
  741. details.
  742.  -- Function: point
  743.      This function returns the position of point in the current buffer,
  744.      as an integer.
  745.           (point)
  746.                => 175
  747.  -- Function: point-min
  748.      This function returns the minimum accessible value of point in the
  749.      current buffer.  This is 1, unless narrowing is in effect, in
  750.      which case it is the position of the start of the region that you
  751.      narrowed to.  (*Note Narrowing::.)
  752.  -- Function: point-max
  753.      This function returns the maximum accessible value of point in the
  754.      current buffer.  This is `(1+ (buffer-size))', unless narrowing is
  755.      in effect, in which case it is the position of the end of the
  756.      region that you narrowed to.  (*Note Narrowing::).
  757.  -- Function: buffer-end FLAG
  758.      This function returns `(point-min)' if FLAG is less than 1,
  759.      `(point-max)' otherwise.  The argument FLAG must be a number.
  760.  -- Function: buffer-size
  761.      This function returns the total number of characters in the current
  762.      buffer.  In the absence of any narrowing (*note Narrowing::.),
  763.      `point-max' returns a value one larger than this.
  764.           (buffer-size)
  765.                => 35
  766.           (point-max)
  767.                => 36
  768.  -- Variable: buffer-saved-size
  769.      The value of this buffer-local variable is the former length of the
  770.      current buffer, as of the last time it was read in, saved or
  771.      auto-saved.
  772. File: elisp,  Node: Motion,  Next: Excursions,  Prev: Point,  Up: Positions
  773. Motion
  774. ======
  775.    Motion functions change the value of point, either relative to the
  776. current value of point, relative to the beginning or end of the buffer,
  777. or relative to the edges of the selected window.
  778. * Menu:
  779. * Character Motion::       Moving in terms of characters.
  780. * Word Motion::            Moving in terms of words.
  781. * Buffer End Motion::      Moving to the beginning or end of the buffer.
  782. * Text Lines::             Moving in terms of lines of text.
  783. * Screen Lines::           Moving in terms of lines as displayed.
  784. * Vertical Motion::        Implementation of `next-line' and
  785.                              `previous-line'.
  786. * List Motion::            Moving by parsing lists and sexps.
  787. * Skipping Characters::    Skipping characters belonging to a certain set.
  788. File: elisp,  Node: Character Motion,  Next: Word Motion,  Prev: Motion,  Up: Motion
  789. Motion by Characters
  790. --------------------
  791.    These functions move point based on a count of characters.
  792. `goto-char' is a fundamental primitive because it is the way to move
  793. point to a specified position.
  794.  -- Command: goto-char POSITION
  795.      This function sets point in the current buffer to the value
  796.      POSITION.  If POSITION is less than 1, then point is set to the
  797.      beginning of the buffer.  If it is greater than the length of the
  798.      buffer, then point is set to the end of the buffer.
  799.      If narrowing is in effect, then the position is still measured
  800.      from the beginning of the buffer, but point cannot be moved
  801.      outside of the accessible portion.  Therefore, if POSITION is too
  802.      small, point is set to the beginning of the accessible portion of
  803.      the text; if POSITION is too large, point is set to the end.
  804.      When this function is called interactively, POSITION is the
  805.      numeric prefix argument, if provided; otherwise it is read from the
  806.      minibuffer.
  807.      `goto-char' returns POSITION.
  808.  -- Command: forward-char &optional COUNT
  809.      This function moves point forward, towards the end of the buffer,
  810.      COUNT characters (or backward, towards the beginning of the
  811.      buffer, if COUNT is negative).  If the function attempts to move
  812.      point past the beginning or end of the buffer (or the limits of the
  813.      accessible portion, when narrowing is in effect), an error is
  814.      signaled with error code `beginning-of-buffer' or `end-of-buffer'.
  815.      In an interactive call, COUNT is the numeric prefix argument.
  816.  -- Command: backward-char &optional COUNT
  817.      This function moves point backward, towards the beginning of the
  818.      buffer, COUNT characters (or forward, towards the end of the
  819.      buffer, if COUNT is negative).  If the function attempts to move
  820.      point past the beginning or end of the buffer (or the limits of
  821.      the accessible portion, when narrowing is in effect), an error is
  822.      signaled with error code `beginning-of-buffer' or `end-of-buffer'.
  823.      In an interactive call, COUNT is the numeric prefix argument.
  824. File: elisp,  Node: Word Motion,  Next: Buffer End Motion,  Prev: Character Motion,  Up: Motion
  825. Motion by Words
  826. ---------------
  827.    These functions for parsing words use the syntax table to decide
  828. whether a given character is part of a word.  *Note Syntax Tables::.
  829.  -- Command: forward-word COUNT
  830.      This function moves point forward COUNT words (or backward if
  831.      COUNT is negative).  Normally it returns `t'.  If this motion
  832.      encounters the beginning or end of the buffer, or the limits of the
  833.      accessible portion when narrowing is in effect, point stops there
  834.      and the value is `nil'.
  835.      In an interactive call, COUNT is set to the numeric prefix
  836.      argument.
  837.  -- Command: backward-word COUNT
  838.      This function just like `forward-word', except that it moves
  839.      backward until encountering the front of a word, rather than
  840.      forward.
  841.      In an interactive call, COUNT is set to the numeric prefix
  842.      argument.
  843.      This function is rarely used in programs, as it is more efficient
  844.      to call `forward-word' with negative argument.
  845. File: elisp,  Node: Buffer End Motion,  Next: Text Lines,  Prev: Word Motion,  Up: Motion
  846. Motion to an End of the Buffer
  847. ------------------------------
  848.    To move point to the beginning of the buffer, write:
  849.      (goto-char (point-min))
  850. Likewise, to move to the end of the buffer, use:
  851.      (goto-char (point-max))
  852.    Here are two commands which users use to do these things.  They are
  853. documented here to warn you not to use them in Lisp programs, because
  854. they set the mark and display messages in the echo area.
  855.  -- Command: beginning-of-buffer &optional N
  856.      This function moves point to the beginning of the buffer (or the
  857.      limits of the accessible portion, when narrowing is in effect),
  858.      setting the mark at the previous position.  If N is non-`nil',
  859.      then it puts point N tenths of the way from the beginning of the
  860.      buffer.
  861.      In an interactive call, N is the numeric prefix argument, if
  862.      provided; otherwise N defaults to `nil'.
  863.      Don't use this function in Lisp programs!
  864.  -- Command: end-of-buffer &optional N
  865.      This function moves point to the end of the buffer (or the limits
  866.      of the accessible portion, when narrowing is in effect), setting
  867.      the mark at the previous position.  If N is non-`nil', then it puts
  868.      point N tenths of the way from the end.
  869.      In an interactive call, N is the numeric prefix argument, if
  870.      provided; otherwise N defaults to `nil'.
  871.      Don't use this function in Lisp programs!
  872.