home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / util / edit / jade / man / jade.info-7 (.txt) < prev    next >
GNU Info File  |  1994-10-16  |  50KB  |  981 lines

  1. This is Info file jade.info, produced by Makeinfo-1.55 from the input
  2. file jade.texi.
  3. START-INFO-DIR-ENTRY
  4. * Jade: (jade).            An editor for X11 and AmigaDOS
  5. END-INFO-DIR-ENTRY
  6.    This is Edition 1.3, last updated 7 October 1994, of `The Jade
  7. Manual', for Jade, Version 3.2.
  8.    Jade is a text editor for X11 (on Unix) and the Amiga.
  9.    Copyright 1993, 1994 John Harper.
  10.    Permission is granted to make and distribute verbatim copies of this
  11. manual provided the copyright notice and this permission notice are
  12. preserved on all copies.
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided that
  15. the entire resulting derived work is distributed under the terms of a
  16. permission notice identical to this one.
  17. File: jade.info,  Node: The Current Buffer,  Prev: The Buffer List,  Up: Buffers
  18. The Current Buffer
  19. ------------------
  20.    The "current buffer" is the buffer being displayed in the current
  21. window (*note Windows::.), all functions which take an optional BUFFER
  22. argument will operate on the current buffer if this argument is
  23. undefined.  Similarly if a WINDOW argument to a function is left
  24. undefined the current window will be used.
  25.  - Function: current-buffer &optional WINDOW
  26.      Returns the buffer being displayed by the window WINDOW (or the
  27.      current window).
  28.           (current-buffer)
  29.               => #<buffer programmer.texi>
  30.    The `set-current-buffer' function sets the current buffer of a
  31. window.  If, when the window is next redisplayed (i.e. after each
  32. command), the current buffer is different to what it was at the last
  33. redisplay the new buffer will be displayed in the window.
  34.  - Function: set-current-buffer BUFFER &optional WINDOW
  35.      Sets the buffer that the window is displaying.
  36.      Usually a window's current buffer will be the buffer which is at
  37.      the head of the window's `buffer-list'. The function `goto-buffer'
  38.      can be used to set both of these at once.
  39.  - Function: goto-buffer BUFFER
  40.      Set the current buffer to BUFFER which is either a buffer or a
  41.      string naming a buffer. The selected buffer is moved to the head
  42.      of the window's `buffer-list'.
  43.      If BUFFER is a string and no buffer exists of that name a new one
  44.      is created.
  45.    Often you will want to temporarily switch to a different current
  46. buffer, that is what the `with-buffer' special form is for.
  47.  - Special Form: with-buffer BUFFER FORMS...
  48.      Temporarily sets the current buffer to the value of evaluating
  49.      BUFFER, then evaluates the FORMS in sequence. The old value of the
  50.      current buffer is reinstated and the structure returns the value
  51.      of the last of the FORMS to be evaluated.
  52.      If the implicit progn evaluating FORMS is exited abnormally the
  53.      old value of the current buffer will still be reinstated.
  54.      If the window is redisplayed while the FORMS are being evaluated
  55.      (i.e.  in a recursive edit) the new buffer will be drawn into the
  56.      window.
  57.           (with-buffer new-buffer         ;Enter a recursive edit in
  58.             (recursive-edit))             ; the buffer `new-buffer'.
  59. File: jade.info,  Node: Windows,  Next: Positions,  Prev: Buffers,  Up: Programming Jade
  60. Windows
  61. =======
  62.    A "window" is a Lisp object representing a window (a rectangular
  63. section of the display) open in the windowing-system you are running
  64. Jade in.
  65.    Windows have two main functions, firstly to provide a means of seeing
  66. the contents of a buffer and secondly to receive input events. For more
  67. details about event handling see *Note Event Loop::.
  68.    A window *always* displays a buffer and there is *always* at least
  69. one window open. The editor remembers which of the open windows is the
  70. "current window", this is normally the window it last received an input
  71. event from, though it can be set by programs.
  72.    For some basic details about using windows see *Note Using Windows::.
  73.  - Function: windowp OBJECT
  74.      This function returns `t' if its argument is a window.
  75.  - Variable: window-list
  76.      This variable's value is a list of all the currently open windows.
  77.      The order of the elements in the list is insignificant.
  78.           window-list
  79.               => (#<window 20971528 *Info*> #<window 20971524 *jade*>)
  80. * Menu:
  81. * Opening Windows::             Creating new windows
  82. * Closing Windows::             Deleting windows
  83. * Iconifying Windows::          Temporarily removing windows
  84. * Displaying Messages::         Messages to the user
  85. * The Current Window::          The activated window, used by default
  86. * Window Font::                 Each window may use a different font
  87. * Window Information::          Details of a window's current state
  88. * Rendering::                   How buffers are drawn in windows
  89. * Block Marking::               Highlighting a region of a window
  90. File: jade.info,  Node: Opening Windows,  Next: Closing Windows,  Up: Windows
  91. Opening Windows
  92. ---------------
  93.  - Function: open-window &optional BUFFER X Y WIDTH HEIGHT
  94.      Opens a new window and returns it. If BUFFER is defined it is the
  95.      buffer to display in the new window, otherwise the current buffer
  96.      is displayed.
  97.      The X and Y arguments are the pixel coordinates of the new window's
  98.      top left corner in the display. The WIDTH and HEIGHT arguments are
  99.      the size of the window in columns and rows of characters
  100.      respectively.
  101.      What happens when the position and size of the window is undefined
  102.      will depend on the underlying window system, on the Amiga the
  103.      window will probably be the same as the current window, in X11 the
  104.      window manager will probably let the user size it interactively.
  105.      The new window will have its `buffer-list' variable initialised
  106.      suitably and it will be added to the head of the `window-list'
  107.      variable.
  108.    The `make-window' function is the lowest level of creating a new
  109. window, `open-window' uses it to open the window.
  110.  - Function: make-window &optional X Y WIDTH HEIGHT
  111.      Creates a new window and returns it, the arguments are similar to
  112.      those of the same name in the `open-window' function. The window
  113.      will display the current buffer.
  114.      After the window is created the `make-window-hook' will be called
  115.      with the window as its argument.
  116.  - Hook: make-window-hook
  117.      Hook called each time a new window is created. It has one
  118.      argument, the new window.
  119.  - Variable: pub-screen
  120.      This window-local variable is only used on the Amiga version of
  121.      Jade; it holds the name of the public screen which windows are
  122.      opened on. By default this is the Workbench screen.
  123.      When a window is opened it inherits this value from the current
  124.      window at the time.
  125. File: jade.info,  Node: Closing Windows,  Next: Iconifying Windows,  Prev: Opening Windows,  Up: Windows
  126. Closing Windows
  127. ---------------
  128.    Unlike buffers, window objects don't have indefinite extent, even
  129. when a window is incapable of being referenced the object will not be
  130. destroyed by the garbage collector; count the user looking at the window
  131. as a reference!
  132.    When the window is closed (by the `destroy-window' function) the
  133. object loses its `window-ness' and the garbage collector is free to
  134. reclaim its memory.
  135.  - Function: close-window &optional WINDOW
  136.      This function closes the window WINDOW (or the current window) and
  137.      deletes its entry from the `window-list' variable.
  138.      If this window is the only one the editor has open the user is
  139.      asked if it's okay to lose any modified buffers before the window
  140.      is closed.
  141.  - Function: close-other-windows &optional WINDOW
  142.      Uses `close-window' to close all windows except WINDOW (or the
  143.      current window).
  144.  - Function: destroy-window WINDOW
  145.      Closes the window WINDOW. After a window object has been closed it
  146.      is no longer a member of the type `window'.
  147.      Before closing the window the `destroy-window-hook' is evaluated
  148.      with the window being destroyed as an argument.
  149.      When the last window is closed the editor will exit automatically.
  150.      Like the `destroy-buffer' function, this function is dangerous if
  151.      used carelessly.
  152.      Both `close-window' and `close-other-windows' eventually call this
  153.      function.
  154.  - Hook: destroy-window-hook
  155.      Hook called by `destroy-window' before it does anything. It has
  156.      one argument -- the window to be destroyed.
  157. File: jade.info,  Node: Iconifying Windows,  Next: Displaying Messages,  Prev: Closing Windows,  Up: Windows
  158. Iconifying Windows
  159. ------------------
  160.    When you don't want a window cluttering the display, but don't want
  161. to kill it totally it can be iconified; the window will be displayed as
  162. a small icon which can be reactivated when the window is wanted again.
  163.  - Function: sleep-window &optional WINDOW
  164.      Iconifies the specified window.
  165.  - Function: unsleep-window &optional WINDOW
  166.      Uniconifies the specified window. This may be done automatically if
  167.      the user needs to be prompted.
  168.  - Function: toggle-iconic
  169.      Toggles the current window between the iconified and normal
  170.      states. This command is bound to the key sequence `Ctrl-z'.
  171.  - Function: window-asleep-p
  172.      Returns `t' when the current window is iconified.
  173. File: jade.info,  Node: Displaying Messages,  Next: The Current Window,  Prev: Iconifying Windows,  Up: Windows
  174. Displaying Messages
  175. -------------------
  176.    Often it is useful to be able to show the user a short one-line
  177. message, this is what the `message' function does.
  178.  - Function: message MESSAGE &optional DISPLAY-NOW
  179.      This function displays the string MESSAGE in the status line of
  180.      the current window, then returns MESSAGE.
  181.      If DISPLAY-NOW is non-`nil' the message is rendered into the
  182.      window immediately, otherwise it will not be visible until the next
  183.      general redisplay (usually after each command exits).
  184.    Note that an alternate way of writing in the status line is to use
  185. the output stream `t'. *Note Output Streams::.
  186.    When writing interactive programs it is sometimes useful to be able
  187. to render the cursor in the status line. This shows that the next key
  188. press will not be subject to normal editing key bindings but to the
  189. special user interface (usually explained by a message in the status
  190. line).
  191.    For example the `y-or-n-p' function uses this technique to show that
  192. it needs an answer.
  193.  - Variable: status-line-cursor
  194.      When this window-local variable is non-`nil' the window's cursor is
  195.      rendered at the end of the message in the status line, not at the
  196.      cursor's position in the main display.
  197.    Another way of alerting the user is to use the `beep' function,
  198.  - Function: beep
  199.      This function rings a bell or flashes the current window or screen
  200.      depending on your system.
  201. File: jade.info,  Node: The Current Window,  Next: Window Font,  Prev: Displaying Messages,  Up: Windows
  202. The Current Window
  203. ------------------
  204.    The current window is the window that functions operate on by
  205. default; every time the event loop receives some input from the user
  206. the window which the input event originated in becomes the current
  207. window. It is also possible for Lisp programs to set the current
  208. window, either permanently or temporarily.
  209.    The "active window" is the window which the windowing system will
  210. send any keyboard input to. Since Jade sets the current window to where
  211. it receives input from, it is often the case that the current window is
  212. the same as the active window. Jade also provides the means to set the
  213. active window; in some cases this may be best left to the user though.
  214.  - Function: current-window
  215.      This function returns the current window.
  216.           (current-window)
  217.               => #<window 20971524 programmer.texi>
  218.  - Function: set-current-window WINDOW &optional ACTIVATE
  219.      This function sets the current window to be the window WINDOW. If
  220.      the optional argument ACTIVATE is non-`nil' this window will also
  221.      become the active window.
  222.      When using the ACTIVATE argument bear in mind that it may be
  223.      confusing for the user if the active window is suddenly changed;
  224.      only change the active window synchronously with some input from
  225.      the user.
  226.  - Special Form: with-window WINDOW FORMS...
  227.      Temporarily sets the current window to the value of evaluating the
  228.      form WINDOW, then uses an implicit progn to evaluate the FORMS. The
  229.      old current window is then reinstated before returning the value
  230.      of the implicit progn.
  231. File: jade.info,  Node: Window Font,  Next: Window Information,  Prev: The Current Window,  Up: Windows
  232. Window Font
  233. -----------
  234.    Each window may use a different font; this font will be used for
  235. rendering all text in the window. When windows are created they inherit
  236. their font from the current window at the time.
  237.    Currently Jade only allows the use of fixed-width fonts; proportional
  238. fonts won't work properly.
  239.  - Command: set-font FONT-NAME &optional WINDOW
  240.      This function sets the font used in the window WINDOW (or the
  241.      current window) to the font named by the string FONT-NAME.
  242.      The format of the string FONT-NAME depends on the underlying
  243.      windowing system:
  244.     X11
  245.           Simply use the standard name of the font, asterisk characters
  246.           work like usual (i.e. match zero or more characters).
  247.     Amiga
  248.           This is different to the normal Amiga conventions, use the
  249.           name of the font followed by a dash and then the size of the
  250.           font. For example to get an 8-point topaz font, use
  251.           `topaz.font-8'.
  252.      When this function is called interactively it will prompt for
  253.      FONT-NAME.
  254.  - Function: font-name &optional WINDOW
  255.      Returns the name of the font being used in the specified window.
  256.      Note that on an Amiga this will only return the name, and not the
  257.      size of the font. For example, if `set-font' has been used with an
  258.      argument of `"topaz.font-8"', a call to `font-name' would produce
  259.      `"topaz.font"'.
  260.  - Function: font-x-size &optional WINDOW
  261.      Returns the width (in pixels) of a character in the specified
  262.      window's font.
  263.           (font-x-size)
  264.               => 7
  265.  - Function: font-y-size &optional WINDOW
  266.      Returns the height in pixels of each character in the window's
  267.      font.
  268.           (font-y-size)
  269.               => 13
  270. File: jade.info,  Node: Window Information,  Next: Rendering,  Prev: Window Font,  Up: Windows
  271. Window Information
  272. ------------------
  273.    There are a number of functions which provide information about the
  274. current state of a window.
  275.  - Function: window-id &optional WINDOW
  276.      Returns an integer which is the window system's `handle' on the
  277.      window WINDOW (or the current window). Under X11 this is the Window
  278.      identifier, on an Amiga it's a pointer to the window's `struct
  279.      Window'.
  280.           (window-id)
  281.               => 20971524
  282.  - Function: window-count
  283.      Returns the number of currently-opened windows.
  284.  - Function: screen-width
  285.      Returns the width of the root window or screen in pixels.
  286.  - Function: screen-height
  287.      Returns the height in pixels of the root window.
  288.  - Function: window-left-edge
  289.      Returns the x coordinate of the current window relative to the root
  290.      window's top-left corner.
  291.  - Function: window-top-edge
  292.      The y coordinate of the current window relative to the root
  293.      window's top-left corner.
  294.  - Function: window-width
  295.      Returns the width, in pixels, of the current window.
  296.  - Function: window-height
  297.      Returns the height in pixels of the current window.
  298.  - Function: window-bar-height
  299.      Only used by Amigas, this returns the height of the current
  300.      window's title bar. This will always be zero in X.
  301.  - Function: screen-top-line
  302.      Returns the line number of the first line being shown in the
  303.      current window.
  304.  - Function: screen-bottom-line
  305.      Returns the line number of the last line being shown in the
  306.      current window.
  307.  - Function: screen-first-column
  308.      Returns the column number of the first column being shown in the
  309.      current window.
  310.  - Function: screen-last-column
  311.      Returns the column number of the last column being shown in the
  312.      current window.
  313. File: jade.info,  Node: Rendering,  Next: Block Marking,  Prev: Window Information,  Up: Windows
  314. Rendering
  315. ---------
  316.    After each command is executed a full redisplay is done; the display
  317. of each window is made to be consistent with the contents of the buffer
  318. it is showing.
  319.  - Function: refresh-all
  320.      This function calls the redisplay code, any windows, whose display
  321.      is inconsistent with what it should be displaying, are updated.
  322.  - Function: cursor ON
  323.      Turns the cursor in the current window on or off (depending on
  324.      whether ON is non-`nil' or not). Normally the cursor is erased
  325.      while Lisp programs are executing.
  326.      If you use this function be sure to leave the cursor undrawn when
  327.      you've finished.
  328.  - Function: centre-display &optional WINDOW
  329.      If possible, this function will arrange it so that the line which
  330.      the cursor is on (*note The Cursor Position::.) will be in the
  331.      centre of the display.
  332.  - Function: next-screen &optional COUNT
  333.      Move COUNT (or 1 by default) screens forwards in the display, Lisp
  334.      programs shouldn't need to call this.
  335.  - Function: prev-screen &optional COUNT
  336.      Move COUNT screens backwards in the display. Don't call this from
  337.      Lisp programs.
  338.  - Function: flush-output
  339.      This function forces any locally-cached rendering operations to be
  340.      drawn into the actual window. This should be called after any use
  341.      of the `refresh-all' or `cursor' functions.
  342.      Currently this function only actually does anything in the X11
  343.      version of Jade (it calls XFlush()), but to ensure the portability
  344.      of Lisp programs it should be used anyway.
  345.  - Variable: max-scroll
  346.      This window-local variable defines the maximum number of lines
  347.      which may be scrolled in one go; if more than this number of lines
  348.      have to be moved when a redisplay happens the whole window will be
  349.      redrawn.
  350.  - Variable: y-scroll-step-ratio
  351.      This window-local variable controls the actual number of lines
  352.      scrolled when the cursor moves out of the visible part of the
  353.      window. The number of lines to move the display origin is
  354.      calculated with the formula:
  355.           (/ TOTAL-LINES-IN-WINDOW y-scroll-step-ratio)
  356.      If the variable's value is zero then the window will be scrolled
  357.      by the least number of lines necessary to get the cursor back into
  358.      the visible part.
  359.  - Variable: x-scroll-step-ratio
  360.      Similar to `y-scroll-step-ratio', except that it's used when the
  361.      cursor disappears to the left or the right of the display.
  362. File: jade.info,  Node: Block Marking,  Prev: Rendering,  Up: Windows
  363. Block Marking
  364. -------------
  365.    Each window may define one "block", this is a region of the buffer
  366. displayed in the window which is rendered in the opposite colours to
  367. normal (i.e. the same as the normal cursor, when the cursor is in a
  368. block it's drawn in the inverse of the block). Blocks are primarily
  369. used for marking areas of a buffer which will subsequently be
  370. manipulated.
  371.    Normally the area of the buffer contained by a block is delimited by
  372. two positions; the start and end of the block (these will track changes
  373. made to the buffer and adjust themselves, like marks do). It is also
  374. possible to mark rectangular blocks; these are also delimited by two
  375. positions, but they define the two opposite corners of the rectangular
  376. block.
  377.  - Function: blockp
  378.      Returns `t' if a block is marked in the current window.
  379.  - Function: mark-block START-POS END-POS
  380.      Define the beginning and end markers of the block to display in the
  381.      current window.
  382.  - Command: block-kill
  383.      Unmark the block displayed in the current window.
  384.  - Command: mark-word COUNT &optional POS
  385.      Mark COUNT words from POS (or the cursor pos) in the current
  386.      window.
  387.  - Command: mark-whole-buffer
  388.      Mark the whole of the current buffer.
  389.  - Function: block-start
  390.      Returns the position of the beginning of the block marked in the
  391.      current window. If no block is defined returns `nil'.
  392.  - Function: block-end
  393.      Returns the position of the end of the block, or `nil' if no block
  394.      is defined in the current window.
  395.  - Command: block-toggle
  396.      Toggles between marking the beginning, marking the end and totally
  397.      unmarking the block in the current window.
  398.  - Function: rect-blocks-p &optional WINDOW
  399.      Returns `t' if the block marked in the window is drawn as a
  400.      rectangle.
  401.  - Function: set-rect-blocks WINDOW STATUS
  402.      Defines whether or not the block drawn in WINDOW is drawn as a
  403.      rectangle or not. If STATUS is `nil' it isn't.
  404.  - Command: toggle-rect-blocks
  405.      Toggles between marking normal and rectangular blocks in the
  406.      current window.
  407. File: jade.info,  Node: Positions,  Next: Marks,  Prev: Windows,  Up: Programming Jade
  408. Positions
  409. =========
  410.    A "position" is a Lisp object representing the location of one of the
  411. characters in the contents of a buffer (*note Buffers::.). Since Jade
  412. stores buffer contents as an array of lines, two index values are
  413. needed to reference a single character. A position object contains two
  414. integers; the column and line numbers of the character, both these
  415. values count upwards from zero (i.e. the first character in a buffer
  416. has line and column numbers of zero).
  417.    Position objects have no read syntax; they print as,
  418.      #<pos COLUMN LINE>
  419.  - Function: posp OBJECT
  420.      This function returns `t' when its argument is a position object.
  421.  - Function: pos COLUMN LINE
  422.      Creates and returns a new position object, it points to column
  423.      number COLUMN and line number LINE (both integers).
  424.  - Function: copy-pos POS
  425.      Creates a new copy of the position object POS.
  426. * Menu:
  427. * Position Components::         Accessing the members of a position
  428. * The Cursor Position::         Where the cursor is drawn in the display
  429. * Movement Functions::          Position-motion functions
  430. * Positions and Offsets::       Converting between positions and buffer
  431.                                   offsets
  432. File: jade.info,  Node: Position Components,  Next: The Cursor Position,  Up: Positions
  433. Position Components
  434. -------------------
  435.    As previously noted, each position object has two components; one
  436. number defining the column, the other defining the line that the
  437. position represents. These components can be accessed individually.
  438.  - Function: pos-col POS
  439.      Returns the column which the position object POS points to.
  440.           (pos-col (pos 1 2))
  441.               => 1
  442.  - Function: pos-line POS
  443.      This function returns the line number which POS points to.
  444.  - Function: set-pos-col POS NEW-COL
  445.      Sets the number of the column which the position object POS points
  446.      to, to NEW-COL (an integer), then returns col.
  447.           (setq x (pos 1 2))
  448.               => #<pos 1 2>
  449.           (set-pos-col x 3)
  450.               => 3
  451.           x
  452.               => #<pos 3 2>
  453.  - Function: set-pos-line POS NEW-LINE
  454.      Similar to `set-pos-col' except the line number is modified.
  455. File: jade.info,  Node: The Cursor Position,  Next: Movement Functions,  Prev: Position Components,  Up: Positions
  456. The Cursor Position
  457. -------------------
  458.    Each window displays a "cursor", this is rendered as a character in
  459. the opposite colour to what it would usually be (i.e. normally a dark
  460. rectangle). The cursor is used to show the user where any characters
  461. they type will be inserted, each window has a separate cursor position
  462. and buffers which are not being displayed `remember' the last position
  463. of their cursor.
  464.  - Function: cursor-pos
  465.      This function returns a copy of the cursor position in the current
  466.      window.
  467.           (cursor-pos)
  468.               => #<pos 14 5638>
  469.  - Function: goto-char POS
  470.      Sets the position of the current window's cursor to the position
  471.      object POS, then returns POS.
  472.      Note that the components of POS are *copied*, any subsequent
  473.      modification of POS will not affect the cursor.
  474.      If the line number of POS points to a non-existent line the cursor
  475.      won't be moved and `nil' will be returned.
  476. File: jade.info,  Node: Movement Functions,  Next: Positions and Offsets,  Prev: The Cursor Position,  Up: Positions
  477. Movement Functions
  478. ------------------
  479.    This section documents the functions which are used to create and
  480. modify position objects so that they point to a different position
  481. which is related to the original position in some way.
  482.    The functions which begin `goto-' set the cursor position of the
  483. current window to the new position; the others do *not* move the
  484. cursor, they simply calculate the new position and return it.
  485.    In some cases the position argument itself will be modified and
  486. returned, this may cause confusion; if there are existing references to
  487. the object they subtle bugs may result. Consider the following,
  488.      (setq x (cursor-pos)
  489.            y (next-char 1 x))
  490.    At first glance this looks as though the variable `y' will point to
  491. one character after the variable `x' does. Since the `next-char'
  492. function *modifies* its argument position *both* variables will contain
  493. the same object, and therefore, point to the same position.
  494.    A solution is,
  495.      (setq x (cursor-pos)
  496.            y (next-char 1 (copy-pos x)))
  497.    Read each function's description carefully to see if it alters its
  498. arguments!
  499. * Menu:
  500. * Buffer Extremes::             The edges of a buffer
  501. * Character Movement::          Moving in terms of characters,
  502. * Word Movement::               or maybe words,
  503. * Tab Movement::                tabs,
  504. * Line Movement::               lines,
  505. * Expression Movement::         or even expressions.
  506. File: jade.info,  Node: Buffer Extremes,  Next: Character Movement,  Up: Movement Functions
  507. Buffer Extremes
  508. ...............
  509.  - Function: buffer-end &optional BUFFER
  510.      Create and return a new position object pointing to the character
  511.      after the last character in the buffer.
  512.  - Function: goto-buffer-end
  513.      Set the cursor to the character after the last character in the
  514.      current buffer.
  515.  - Function: buffer-start &optional BUFFER
  516.      Create a new position pointing to the first character in the
  517.      buffer. Currently this is always the position `#<pos 0 0>' and the
  518.      BUFFER argument is ignored.
  519.  - Function: goto-buffer-start
  520.      Set the cursor position to the first character in the buffer.
  521. File: jade.info,  Node: Character Movement,  Next: Word Movement,  Prev: Buffer Extremes,  Up: Movement Functions
  522. Character Movement
  523. ..................
  524.  - Function: left-char &optional COUNT POS
  525.      Alter and return POS (or a copy of the cursor pos) so that it
  526.      points COUNT characters (default is one) to the left of its
  527.      current position.  If the resulting column number is less than
  528.      zero `nil' is returned, else the position.
  529.           (goto-char (pos 20 0))
  530.               => #<pos 20 0>
  531.           (left-char)
  532.               => #<pos 19 0>
  533.           
  534.           (setq x (pos 4 1))
  535.               => #<pos 4 1>
  536.           (left-char 3 x)
  537.               => #<pos 1 1>
  538.           x
  539.               => #<pos 1 1>
  540.  - Function: goto-left-char &optional COUNT
  541.      Move COUNT (or one) characters to the left.
  542.  - Function: right-char &optional COUNT POS
  543.      Alter and return POS (or a copy of the cursor pos) so that it
  544.      points COUNT (or one) characters to the right of its current
  545.      position. May return a position which points to a character past
  546.      the end of the line.
  547.  - Function: goto-right-char &optional COUNT
  548.      Move COUNT (or one) characters to the right.
  549.    The following functions results depends on the contents of the buffer
  550. they are operating on; they move a certain number of *characters*, and
  551. hence will cross line boundaries.
  552.  - Function: next-char &optional COUNT POS BUFFER
  553.      Alter and return POS (or a copy of the cursor pos) to point to the
  554.      character COUNT characters in front of its current position.
  555.      If COUNT is negative this function will work backwards through the
  556.      buffer.
  557.  - Function: goto-next-char &optional COUNT
  558.      Move COUNT characters forwards.
  559.  - Function: prev-char &optional COUNT POS BUFFER
  560.      Similar to the `next-char' function but will work backwards when
  561.      COUNT is positive and forwards when it is negative.
  562.  - Function: goto-prev-char COUNT
  563.      Move COUNT characters backwards.
  564. File: jade.info,  Node: Word Movement,  Next: Tab Movement,  Prev: Character Movement,  Up: Movement Functions
  565. Word Movement
  566. .............
  567.    There are two buffer-local variables which control the syntax of
  568. words in each buffer.
  569.  - Variable: word-regexp
  570.      This buffer-local variable contains a regular expression which
  571.      will match each character allowed to be in a word.
  572.      The standard value is `[a-zA-Z0-9]', i.e. all alphanumeric
  573.      characters.
  574.  - Variable: word-not-regexp
  575.      A buffer-local variable. Holds a regular expression which will
  576.      match anything not in a word.
  577.      The normal value is `[^a-zA-Z0-9]|$', i.e. anything which is not
  578.      alphanumeric or the end of a line.
  579.    The following functions use these variables when deciding what is and
  580. what isn't a word.
  581.  - Function: forward-word &optional COUNT POS MOVE
  582.      Return the position of the first character after the end of the
  583.      word at position POS (or the cursor).  COUNT is the number of
  584.      words to move, negative values mean go backwards.
  585.      If MOVE is non-`nil' then the cursor is moved to the result.
  586.      Note that POS is not altered.
  587.  - Function: backward-word &optional COUNT POS MOVE
  588.      Similar to `forward-word' except that it works backwards. In fact,
  589.      all this function does is call `forward-word' with COUNT negated.
  590.  - Function: word-start &optional POS
  591.      Returns the position of the first character of the word at POS (or
  592.      the cursor position).
  593.  - Function: in-word-p &optional POS
  594.      This function returns `t' if POS (or the cursor) is in a word.
  595. File: jade.info,  Node: Tab Movement,  Next: Line Movement,  Prev: Word Movement,  Up: Movement Functions
  596. Tab Movement
  597. ............
  598.  - Function: prev-tab &optional COUNT POS SIZE
  599.      Alter and return POS (or a copy of the cursor position) so that it
  600.      points COUNT (default is one) tab stops to the left of its current
  601.      position. Returns `nil' if that position is before the start of
  602.      the line.
  603.      SIZE is optionally the number of glyphs in each tab, or the value
  604.      of the `tab-size' variable.
  605.      Note that the position returned is not the position of a character
  606.      but of a glyph (*note Glyph Positions::.).
  607.           (prev-tab 1 (pos 20 0))
  608.               => #<pos 16 0>
  609.  - Function: goto-prev-tab &optional COUNT SIZE
  610.      Move COUNT tab stops to the left.
  611.  - Function: next-tab &optional COUNT POS SIZE
  612.      Alter and return POS (or a copy of the cursor position) so that it
  613.      points COUNT tab stops to the right of its current position.
  614.      SIZE is optionally the number of glyphs in each tab, or the value
  615.      of the `tab-size' variable.
  616.      Note that the position returned is not the position of a character
  617.      but of a glyph (*note Glyph Positions::.).
  618.  - Function: goto-next-tab &optional COUNT SIZE
  619.      Move COUNT tab stops to the right.
  620. File: jade.info,  Node: Line Movement,  Next: Expression Movement,  Prev: Tab Movement,  Up: Movement Functions
  621. Line Movement
  622. .............
  623.  - Function: next-line &optional COUNT POS
  624.      Alter and return POS (or a copy of the cursor position) so that it
  625.      points COUNT (or one) lines forwards, the column component is not
  626.      changed.
  627.      If COUNT is negative (i.e. go backwards) and the resulting line
  628.      number is less than zero `nil' is returned.
  629.           (next-line 2 (pos 1 1))
  630.               => #<pos 1 3>
  631.           
  632.           (next-line -1 (pos 1 1))
  633.               => #<pos 1 0>
  634.  - Function: goto-next-line &optional COUNT
  635.      Move COUNT lines downwards, the column number of the cursor is
  636.      adjusted so that its glyph position is as close to its previous
  637.      glyph position as possible.
  638.  - Function: prev-line &optional COUNT POS
  639.      Similar to NEXT-LINE but goes backwards (or forwards with a
  640.      negative COUNT).
  641.  - Function: goto-prev-line &optional COUNT
  642.      Move COUNT lines backwards, adjusting the column number of the
  643.      cursor as necessary.
  644. File: jade.info,  Node: Expression Movement,  Prev: Line Movement,  Up: Movement Functions
  645. Expression Movement
  646. ...................
  647.    Some major modes provide functions to move backwards and forwards
  648. over expressions written in a buffer in the programming language that
  649. the mode supports (*note Mode-Specific Expressions::.), for example the
  650. Lisp mode defines the syntax of Lisp forms written in a buffer.
  651.  - Function: forward-exp &optional COUNT
  652.      This function moves the cursor over COUNT expressions, as defined
  653.      in the current buffer. If the buffer has no expression definitions
  654.      an error is signalled.
  655.  - Function: backward-exp &optional COUNT
  656.      Moves backwards over COUNT (or one) expressions, leaving the cursor
  657.      at the beginning of the expression. If the buffer has no
  658.      expression definition functions an error is signalled.
  659. File: jade.info,  Node: Positions and Offsets,  Prev: Movement Functions,  Up: Positions
  660. Positions and Offsets
  661. ---------------------
  662.    Although Jade stores the position of a character as a pair of two
  663. numbers many other programs define the position of a character as its
  664. offset from the beginning of the buffer or file it is in. The following
  665. functions may be used to convert between these two types of positions
  666. in a specified buffer.
  667.  - Function: pos-to-offset &optional POS BUFFER
  668.      This function returns the offset of the character at the position
  669.      POS (or the cursor position by default) in the specified buffer.
  670.      This will be an integer, the first character in a buffer is
  671.      represented by an offset of zero.
  672.           (pos-to-offset (pos 0 0))
  673.               => 0
  674.           
  675.           (pos-to-offset)
  676.               => 195654
  677.  - Function: offset-to-pos OFFSET &optional BUFFER
  678.      Creates a new position object which contains the position of the
  679.      character OFFSET characters from the start of the specified buffer.
  680.           (offset-to-pos 0)
  681.               => #<pos 0 0>
  682.           
  683.           (offset-to-pos 195654)
  684.               => #<pos 14 5974>
  685. File: jade.info,  Node: Marks,  Next: Glyph Tables,  Prev: Positions,  Up: Programming Jade
  686. Marks
  687. =====
  688.    A "mark" is a Lisp object which points to a character in a file (or
  689. buffer), as the buffer the file is stored in is modified the position
  690. the mark points to is also modified so that the mark will *always*
  691. point to the same character.
  692.    The character that a mark points to does not have to be loaded into
  693. the editor all the time either; if the file the character is in is not
  694. resident in a buffer the mark will simply contain the character's
  695. position and the file's name. When a file is loaded any marks pointing
  696. to the file are altered so that they point straight to the buffer
  697. containing the file.
  698.  - Function: markp OBJECT
  699.      This function returns `t' if its argument is a mark.
  700. * Menu:
  701. * Mark Components::             Marks contain two values; position and file
  702. * Mark Relocation::             How the position of a mark is updated as
  703.                                   its buffer is modified
  704. * Mark Residency::              Marks may point to files which have not
  705.                                   been loaded
  706. * Creating Marks::              Functions to allocate new mark objects
  707. * Altering Marks::              Setting the components of a mark
  708. * Moving to Marks::             Moving the cursor to the character a
  709.                                   mark points to
  710. File: jade.info,  Node: Mark Components,  Next: Mark Relocation,  Up: Marks
  711. Mark Components
  712. ---------------
  713.    Each mark object has two main components; the position of the
  714. character pointed to by the mark (a position object) and the file which
  715. the character is contained by.
  716.    The file is the most complex component, it can be either a string
  717. naming the file or a buffer. When the file component is a string the
  718. mark is said to be "non-resident" since none of the editor buffers
  719. contain the character which the mark points to.
  720.  - Function: mark-pos MARK
  721.      Returns the position object contained in the marker MARK, no copy
  722.      is made: if you modify the position returned it will be reflected
  723.      in the position of the mark.
  724.      Note that if you later modify the buffer the mark is resident in
  725.      the position previously returned by `mark-pos' may be altered by
  726.      the mark relocation process. *Note Mark Relocation::.
  727.  - Function: mark-file MARK
  728.      Returns the file component of MARK. This will be either the name of
  729.      the file or the buffer itself depending on whether the mark is
  730.      resident or not. *Note Mark Residency::.
  731. File: jade.info,  Node: Mark Relocation,  Next: Mark Residency,  Prev: Mark Components,  Up: Marks
  732. Mark Relocation
  733. ---------------
  734.    An important feature of marks is that they always point to the same
  735. character, even when the buffer has been modified, changing the position
  736. of the character (i.e. if some text is deleted from somewhere before the
  737. character its position will probably change).
  738.    Every time a buffer is modified each mark which points to a character
  739. in that buffer is examined and then, if necessary, the position it
  740. points to is changed to take account of the buffer's new state.
  741.    Basically, what happens is that each mark will try to point at the
  742. same character all the time. If some text is inserted at the position
  743. of the mark the mark's position will be advanced to the end of the
  744. insertion and hence the original character.
  745.    The only time the mark will not point at the same character is when
  746. the character is deleted from the buffer. In this case the mark will
  747. point to the start of the deletion.
  748. File: jade.info,  Node: Mark Residency,  Next: Creating Marks,  Prev: Mark Relocation,  Up: Marks
  749. Mark Residency
  750. --------------
  751.    As I have already explained, a mark does not necessarily have to
  752. point at a character loaded into a buffer; it can also point at a
  753. character in a file on disk somewhere. When this happens the mark is
  754. said to be non-resident.
  755.  - Function: mark-resident-p MARK
  756.      This function returns `t' when the character pointed to by the
  757.      marker MARK is resident in one of the editor's buffers.
  758.    When the function `mark-file' (*note Mark Components::.) is applied
  759. to a non-resident mark it returns the full name of the file, for
  760. example,
  761.      (setq x (make-mark (pos 0 20) "/tmp/foo.c"))
  762.          => #<mark "/tmp/foo.c" #<pos 1 21>>
  763.      (mark-resident-p x)
  764.          => nil
  765.      (mark-file x)
  766.          => "/tmp/foo.c"
  767.    When a file is loaded into a buffer all existing non-resident marks
  768. are examined to see if they point to that file. If so that mark has its
  769. file component set to the buffer that the file was loaded into.
  770.    Similarly, when a buffer is deleted any marks pointing to characters
  771. in that buffer are made non-resident: their file component is set to the
  772. name of the file.
  773.    When the function which moves the cursor to the position of a
  774. specific mark (`goto-mark', *note Moving to Marks::.) is called with a
  775. non-resident mark it will try to load the file into a buffer.
  776.    The following code fragment can be used to ensure that a mark MARK
  777. is resident,
  778.      (or (mark-resident-p MARK)
  779.          (open-file (mark-file MARK))
  780.          (error "Can't make mark resident, %S" MARK))
  781. File: jade.info,  Node: Creating Marks,  Next: Altering Marks,  Prev: Mark Residency,  Up: Marks
  782. Creating Marks
  783. --------------
  784.  - Function: make-mark &optional POS BUFFER-OR-FILENAME
  785.      This function allocates a new mark object and fills it in according
  786.      to the supplied arguments.
  787.      It will point at a character at position POS, or the position of
  788.      the cursor in the current window. Note that a copy of POS is made.
  789.      The BUFFER-OR-FILENAME argument specifies the file component of the
  790.      mark. If BUFFER-OR-FILENAME is a buffer (`nil' or undefined means
  791.      the current buffer) the mark will use it and therefore will be
  792.      resident (*note Mark Residency::.).
  793.      Alternatively, BUFFER-OR-FILENAME can be a string naming the file
  794.      explicitly. If the file is already loaded into a buffer that
  795.      buffer will be used and the mark will be resident. Otherwise the
  796.      mark will be non-resident and the string will be used as the file
  797.      component.
  798.      With no arguments this function will produce a resident mark
  799.      pointing at the cursor in the current buffer.
  800.           (make-mark)
  801.               => #<mark #<buffer programmer.texi> #<pos 46 6152>>
  802.           
  803.           (make-mark (buffer-start) "/tmp/foo")
  804.               => #<mark "/tmp/foo" #<pos 0 0>>
  805.           
  806.           (make-mark (pos 0 3))
  807.               => #<mark #<buffer programmer.texi> #<pos 0 3>>
  808. File: jade.info,  Node: Altering Marks,  Next: Moving to Marks,  Prev: Creating Marks,  Up: Marks
  809. Altering Marks
  810. --------------
  811.    If you just want to set the position of a mark you can modify its
  812. position component (*note Mark Components::.). Alternately the following
  813. function may be used. When you need to set the file a mark points to
  814. the only method is to use this function.
  815.  - Function: set-mark MARK &optional POS BUFFER-OR-FILENAME
  816.      This function sets either or both of the position and file
  817.      components of the mark object MARK, then returns MARK.
  818.      If POS is a position object the position component of MARK will be
  819.      set to it (a copy of it actually).
  820.      If the BUFFER-OR-FILENAME argument is non-`nil' the file component
  821.      of MARK will be set. This argument can be a buffer object or a
  822.      string naming a file. If a named file is already in a buffer that
  823.      buffer will be used instead.
  824.           (setq x (make-mark))
  825.               => #<mark #<buffer programmer.texi> #<pos 46 6186>>
  826.           (set-mark x (buffer-start))
  827.               => #<mark #<buffer programmer.texi> #<pos 0 0>>
  828.           (set-mark x nil "/tmp/foo")
  829.               => #<mark "/tmp/foo" #<pos 0 0>>
  830. File: jade.info,  Node: Moving to Marks,  Prev: Altering Marks,  Up: Marks
  831. Moving to Marks
  832. ---------------
  833.  - Function: goto-mark MARK
  834.      This function switches to the buffer containing MARK (if necessary)
  835.      and then moves the cursor to the character that the mark points to.
  836.      If the mark is not currently resident an attempt will be made to
  837.      load the mark's file into a new buffer and use that.
  838. File: jade.info,  Node: Glyph Tables,  Next: Input Events,  Prev: Marks,  Up: Programming Jade
  839. Glyph Tables
  840. ============
  841.    A "glyph table" is a Lisp object used to define a mapping between
  842. the characters which may occur in a buffer (anything with a numeric
  843. value between 0 and 255 inclusive) and the sequences of glyphs which are
  844. drawn into a window to represent these characters.
  845.    A "glyph" is a image which, when rendered into the display, takes up
  846. one character position. Each character in a buffer is rendered as a
  847. sequence of 1 or more glyphs.
  848.  - Function: glyph-table-p OBJECT
  849.      This function returns `t' when its argument is a glyph table.
  850. * Menu:
  851. * Glyph Table Basics::          How a glyph table defines mappings
  852. * Glyph Positions::             The position of a character and its
  853.                                   glyph sequence may be different
  854. * Creating Glyph Tables::       Making new glyph tables
  855. * Buffer Glyph Tables::         Each buffer may use a separate glyph
  856.                                 table for its display
  857. File: jade.info,  Node: Glyph Table Basics,  Next: Glyph Positions,  Up: Glyph Tables
  858. Glyph Table Basics
  859. ------------------
  860.    A glyph table is basically an array that has 256 elements; each
  861. element represents one character and contains between zero and four
  862. glyphs -- the glyphs which will be printed for the character.
  863.    A special case exists for the tab character; when an element in the
  864. table contains zero glyphs, enough spaces will be printed to fill in to
  865. the next tab stop.
  866.  - Function: get-glyph GLYPH-TABLE CHARACTER
  867.      This function returns a string containing the glyphs in the
  868.      element of the glyph table GLYPH-TABLE for the character CHARACTER.
  869.           (get-glyph (default-glyph-table) ?a)
  870.               => "a"
  871.           
  872.           (get-glyph (default-glyph-table) ?\t)
  873.               => ""        ;TAB is special
  874.           
  875.           (get-glyph (default-glyph-table) ?\000)
  876.               => "^@"      ;the NUL character
  877.  - Function: set-glyph GLYPH-TABLE CHARACTER GLYPH-STRING
  878.      This function sets the sequence of glyphs used to render the
  879.      character CHARACTER in the glyph table GLYPH-TABLE to the
  880.      characters in the string GLYPH-STRING.
  881.      An error is signalled if there are more than four characters in
  882.      GLYPH-STRING.
  883.      All buffers which use GLYPH-TABLE for their rendering will be
  884.      totally redrawn at the next redisplay.
  885. File: jade.info,  Node: Glyph Positions,  Next: Creating Glyph Tables,  Prev: Glyph Table Basics,  Up: Glyph Tables
  886. Glyph Positions
  887. ---------------
  888.    Position objects are usually used to refer to the position of a
  889. character in a buffer, this position (sometimes called the "character
  890. position" may not be the same as the position of the sequence of glyphs
  891. printed to represent the character. When a position object is used to
  892. refer to the position of a glyph it is called a "glyph position".
  893.    For example, consider a line in a buffer containing the string
  894. `a\tb' (where `\t' represents a tab character). When this is rendered
  895. in a buffer the glyphs which will actually be drawn are,
  896.      a       b
  897. That is, an `a' glyph, followed by seven (assuming `tab-size' is set to
  898. 8) ` ' glyphs, and lastly a `b' glyph.
  899.    The character position of the `b' character in the buffer is `#<pos
  900. 2 LINE>', where LINE is the line's number.
  901.    Now the confusing bit: the *glyph* position of the `b' *glyph* is
  902. `#<pos 8 LINE>' since it is actually the ninth glyph to be drawn.
  903.    The good news is that most of the time you can forget about glyph
  904. positions, they only need to be considered when you're thinking about
  905. how the buffer will look when rendered in the window. For example, Lisp
  906. programs which indent source code will definitely need to use glyph
  907. positions.
  908.    Two functions are provided for converting between character and glyph
  909. positions and vice versa.
  910.  - Function: char-to-glyph-pos &optional POS BUFFER
  911.      Return a new position object containing the glyph position of the
  912.      character at character position POS (or the cursor position) in the
  913.      specified buffer.
  914.  - Function: glyph-to-char-pos POS &optional BUFFER
  915.      This function returns a new position object containing the
  916.      character position of the glyph printed at glyph position POS in
  917.      the specified buffer.
  918.      If the glyph position POS is not the position of the first in a
  919.      sequence of glyphs representing a single character the position of
  920.      the next character will be returned.
  921. File: jade.info,  Node: Creating Glyph Tables,  Next: Buffer Glyph Tables,  Prev: Glyph Positions,  Up: Glyph Tables
  922. Creating Glyph Tables
  923. ---------------------
  924.  - Function: make-glyph-table SOURCE
  925.      This function creates a new glyph table, containing glyph sequences
  926.      defined by the SOURCE argument.
  927.      If SOURCE is a glyph table it will be copied, if it's a buffer
  928.      that buffer's glyph table will be copied or if SOURCE is `nil' a
  929.      copy of the default glyph table will be made.
  930. File: jade.info,  Node: Buffer Glyph Tables,  Prev: Creating Glyph Tables,  Up: Glyph Tables
  931. Buffer Glyph Tables
  932. -------------------
  933.    Each buffer may define its own glyph table that will be used to
  934. provide the character-to-glyph mappings for that buffer.
  935.  - Function: buffer-glyph-table &optional BUFFER
  936.      Returns the glyph table installed in the buffer.
  937.  - Function: set-buffer-glyph-table GLYPH-TABLE &optional BUFFER
  938.      Sets the glyph table being used in the buffer to GLYPH-TABLE.
  939.    By default, each buffer uses the "default glyph table". This is a
  940. glyph table set up when the editor initialise itself. The mappings it
  941. provides are very generic, for more details see *Note Character
  942. Images::.
  943.  - Function: default-glyph-table
  944.      This function returns the default glyph table.
  945.    Redefining some of the mappings in the default glyph table is an easy
  946. way to affect rendering operations, for example if I want the UK pound
  947. sign character (ASCII value is octal 243) to be printed as itself and
  948. not the usual escape sequence I can do the following,
  949.      (set-glyph (default-glyph-table) ?243 "\243")
  950. File: jade.info,  Node: Input Events,  Next: Keymaps,  Prev: Glyph Tables,  Up: Programming Jade
  951. Input Events
  952. ============
  953.    An "input event" is a Lisp object representing an action initiated
  954. by the user, i.e. a key press, pressing a mouse button and similar
  955. things.
  956.    Note that input events are often referred to as key presses, this
  957. isn't really accurate but since most input events are key presses the
  958. term sort of stuck. Anyway, wherever the phrase `key press' occurs in
  959. this manual it could be replaced by `input event'.
  960.    Each input event is represented by a cons cell (*note Cons Cells::.)
  961. containing two integers, these integers encode the actual input event.
  962. The encoding is opaque; the only way to access an event meaningfully is
  963. via the functions provided.
  964.  - Function: eventp OBJECT
  965.      This function returns `t' if its argument is an input event.
  966.    Each event has a textual name, for the actual format of these names
  967. see *Note Key Names::.
  968.    Functions are available to convert between the name of an event and
  969. the actual event itself, and vice versa.
  970.  - Function: lookup-event EVENT-NAME
  971.      Create and return a new input event whose name is EVENT-NAME.
  972.           (lookup-event "Ctrl-x")
  973.               => (120 . 9)
  974.           
  975.           (lookup-event "Ctrl-Meta-LMB-Click1")
  976.               => (1 . 58)
  977.  - Function: event-name EVENT
  978.      This function returns a string naming the input event EVENT.
  979.           (event-name (lookup-event "Ctrl-x"))
  980.               => "Ctrl-x"
  981.