home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / elisp / elisp-28 < prev    next >
Encoding:
GNU Info File  |  1993-05-31  |  45.9 KB  |  1,177 lines

  1. This is Info file elisp, produced by Makeinfo-1.55 from the input file
  2. elisp.texi.
  3.  
  4.    This is edition 2.0 of the GNU Emacs Lisp Reference Manual, for
  5. Emacs Version 19.
  6.  
  7.    Published by the Free Software Foundation, 675 Massachusetts Avenue,
  8. Cambridge, MA 02139 USA
  9.  
  10.    Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  11.  
  12.    Permission is granted to make and distribute verbatim copies of this
  13. manual provided the copyright notice and this permission notice are
  14. preserved on all copies.
  15.  
  16.    Permission is granted to copy and distribute modified versions of
  17. this manual under the conditions for verbatim copying, provided that
  18. the entire resulting derived work is distributed under the terms of a
  19. permission notice identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for modified
  23. versions, except that this permission notice may be stated in a
  24. translation approved by the Foundation.
  25.  
  26. 
  27. File: elisp,  Node: Emacs Display,  Next: Calendar,  Prev: System Interface,  Up: Top
  28.  
  29. Emacs Display
  30. *************
  31.  
  32.    This chapter describes a number of features related to the display
  33. that Emacs presents to the user.
  34.  
  35. * Menu:
  36.  
  37. * Refresh Screen::      Clearing the screen and redrawing everything on it.
  38. * Screen Size::         How big is the Emacs screen.
  39. * Truncation::          Folding or wrapping long text lines.
  40. * The Echo Area::       Where messages are displayed.
  41. * Selective Display::   Hiding part of the buffer text.
  42. * Overlay Arrow::       Display of an arrow to indicate position.
  43. * Temporary Displays::  Displays that go away automatically.
  44. * Overlays::        Use overlays to highlight parts of the buffer.
  45. * Faces::        A face defines a graphics appearance: font, color, etc.
  46. * Blinking::            How Emacs shows the matching open parenthesis.
  47. * Inverse Video::    Specifying how the screen looks.
  48. * Usual Display::    The usual conventions for displaying nonprinting chars.
  49. * Display Tables::    How to specify other conventions.
  50. * Beeping::             Audible signal to the user.
  51. * Window Systems::      Which window system is being used.
  52.  
  53. 
  54. File: elisp,  Node: Refresh Screen,  Next: Screen Size,  Up: Emacs Display
  55.  
  56. Refreshing the Screen
  57. =====================
  58.  
  59.    The function `redraw-frame' redisplays the entire contents of a
  60. given frame.  *Note Frames::.
  61.  
  62.  - Function: redraw-frame FRAME
  63.      This function clears and redisplays frame FRAME.
  64.  
  65.    Even more powerful is `redraw-display'.
  66.  
  67.  - Command: redraw-display
  68.      This function clears and redisplays all visible frames.
  69.  
  70.    Normally, suspending and resuming Emacs also refreshes the screen.
  71. Some terminal emulators record separate contents for display-oriented
  72. programs such as Emacs and for ordinary sequential display.  If you are
  73. using such a terminal, you might want to inhibit the redisplay on
  74. resumption.  *Note Suspending Emacs::.
  75.  
  76.  - Variable: no-redraw-on-reenter
  77.      This variable controls whether Emacs redraws the entire screen
  78.      after it has been suspended and resumed.  Non-`nil' means yes,
  79.      `nil' means no.
  80.  
  81.    Processing user input takes absolute priority over redisplay.  If you
  82. call these functions when input is available, they do nothing
  83. immediately, but a full redisplay does happen eventually--after all the
  84. input has been processed.
  85.  
  86. 
  87. File: elisp,  Node: Screen Size,  Next: Truncation,  Prev: Refresh Screen,  Up: Emacs Display
  88.  
  89. Screen Size
  90. ===========
  91.  
  92.    The screen size functions report or tell Emacs the height or width of
  93. the terminal.  When you are using multiple frames, they apply to the
  94. selected frame (*note Frames::.).
  95.  
  96.  - Function: screen-height
  97.      This function returns the number of lines on the screen that are
  98.      available for display.
  99.  
  100.           (screen-height)
  101.                => 50
  102.  
  103.  - Function: screen-width
  104.      This function returns the number of columns on the screen that are
  105.      available for display.
  106.  
  107.           (screen-width)
  108.                => 80
  109.  
  110.  - Function: set-screen-height LINES &optional NOT-ACTUAL-SIZE
  111.      This function declares that the terminal can display LINES lines.
  112.      The sizes of existing windows are altered proportionally to fit.
  113.  
  114.      If NOT-ACTUAL-SIZE is non-`nil', then Emacs displays LINES lines
  115.      of output, but does not change its value for the actual height of
  116.      the screen.  (Knowing the correct actual size may be necessary for
  117.      correct cursor positioning.)  Using a smaller height than the
  118.      terminal actually implements may be useful to reproduce behavior
  119.      observed on a smaller screen, or if the terminal malfunctions when
  120.      using its whole screen.
  121.  
  122.      If LINES is different from what it was previously, then the entire
  123.      screen is cleared and redisplayed using the new size.
  124.  
  125.      This function returns `nil'.
  126.  
  127.  - Function: set-screen-width COLUMNS &optional NOT-ACTUAL-SIZE
  128.      This function declares that the terminal can display COLUMNS
  129.      columns.  The details are as in `set-screen-height'.
  130.  
  131. 
  132. File: elisp,  Node: Truncation,  Next: The Echo Area,  Prev: Screen Size,  Up: Emacs Display
  133.  
  134. Truncation
  135. ==========
  136.  
  137.    When a line of text extends beyond the right edge of a window, the
  138. line can either be truncated or continued on the next line.  When a line
  139. is truncated, this is shown with a `$' in the rightmost column of the
  140. window.  When a line is continued or "wrapped" onto the next line, this
  141. is shown with a `\' on the rightmost column of the window.  The
  142. additional screen lines used to display a long text line are called
  143. "continuation" lines.  (Note that wrapped lines are not filled; filling
  144. has nothing to do with continuation and truncation.  *Note Filling::.)
  145.  
  146.  - User Option: truncate-lines
  147.      This buffer-local variable controls how Emacs displays lines that
  148.      extend beyond the right edge of the window.  If it is non-`nil',
  149.      then Emacs does not display continuation lines; rather each line of
  150.      text occupies exactly one screen line, and a dollar sign appears
  151.      at the edge of any line that extends to or beyond the edge of the
  152.      window.  The default is `nil'.
  153.  
  154.      If the variable `truncate-partial-width-windows' is non-`nil',
  155.      then truncation is used for windows that are not the full width of
  156.      the screen, regardless of the value of `truncate-lines'.
  157.  
  158.  - Variable: default-truncate-lines
  159.      This variable is the default value for `truncate-lines' in buffers
  160.      that do not have local values for it.
  161.  
  162.  - User Option: truncate-partial-width-windows
  163.      This variable determines how lines that are too wide to fit on the
  164.      screen are displayed in side-by-side windows (*note Splitting
  165.      Windows::.).  If it is non-`nil', then wide lines are truncated
  166.      (with a `$' at the end of the line); otherwise they wrap to the
  167.      next screen line (with a `\' at the end of the line).
  168.  
  169.    You can override the images that indicate continuation or truncation
  170. with the display table; see *Note Display Tables::.
  171.  
  172. 
  173. File: elisp,  Node: The Echo Area,  Next: Selective Display,  Prev: Truncation,  Up: Emacs Display
  174.  
  175. The Echo Area
  176. =============
  177.  
  178.    The "echo area" is used for displaying messages made with the
  179. `message' primitive, and for echoing keystrokes.  It is not the same as
  180. the minibuffer, despite the fact that the minibuffer appears (when
  181. active) in the same place on the screen as the echo area.  The `GNU
  182. Emacs Manual' specifies the rules for resolving conflicts between the
  183. echo area and the minibuffer for use of that screen space (*note The
  184. Minibuffer: (emacs)Minibuffer.).  Error messages appear in the echo
  185. area; see *Note Errors::.
  186.  
  187.    You can write output in the echo area by using the Lisp printing
  188. functions with `t' as the stream (*note Output Functions::.), or as
  189. follows:
  190.  
  191.  - Function: message STRING &rest ARGUMENTS
  192.      This function prints a one-line message in the echo area.  The
  193.      argument STRING is similar to a C language `printf' control
  194.      string.  See `format' in *Note String Conversion::, for the details
  195.      on the conversion specifications.  `message' returns the
  196.      constructed string.
  197.  
  198.      If STRING is `nil', `message' clears the echo area.  If the
  199.      minibuffer is active, this brings the minibuffer contents back onto
  200.      the screen immediately.
  201.           (message
  202.            "Minibuffer depth is %d."
  203.            (minibuffer-depth))
  204.           => "Minibuffer depth is 0."
  205.           
  206.           ---------- Echo Area ----------
  207.           Minibuffer depth is 0.
  208.           ---------- Echo Area ----------
  209.  
  210.  - Variable: cursor-in-echo-area
  211.      This variable controls where the cursor appears when a message is
  212.      displayed in the echo area.  If it is non-`nil', then the cursor
  213.      appears at the end of the message.  Otherwise, the cursor appears
  214.      at point--not in the echo area at all.
  215.  
  216.      The value is normally `nil'; Lisp programs bind it to `t' for
  217.      brief periods of time.
  218.  
  219. 
  220. File: elisp,  Node: Selective Display,  Next: Overlay Arrow,  Prev: The Echo Area,  Up: Emacs Display
  221.  
  222. Selective Display
  223. =================
  224.  
  225.    "Selective display" is a class of minor modes in which specially
  226. marked lines do not appear on the screen, or in which highly indented
  227. lines do not appear.
  228.  
  229.    The first variant, explicit selective display, is designed for use in
  230. a Lisp program.  The program controls which lines are hidden by altering
  231. the text.  Outline mode uses this variant.  In the second variant, the
  232. choice of lines to hide is made automatically based on indentation.
  233. This variant is designed as a user-level feature.
  234.  
  235.    The way you control explicit selective display is by replacing a
  236. newline (control-j) with a control-m.  The text which was formerly a
  237. line following that newline is now invisible.  Strictly speaking, it is
  238. temporarily no longer a line at all, since only newlines can separate
  239. lines; it is now part of the previous line.
  240.  
  241.    Selective display does not directly affect editing commands.  For
  242. example, `C-f' (`forward-char') moves point unhesitatingly into
  243. invisible space.  However, the replacement of newline characters with
  244. carriage return characters affects some editing commands.  For example,
  245. `next-line' skips invisible lines, since it searches only for newlines.
  246. Modes that use selective display can also define commands that take
  247. account of the newlines, or which make parts of the text visible or
  248. invisible.
  249.  
  250.    When you write a selectively displayed buffer into a file, all the
  251. control-m's are replaced by their original newlines.  This means that
  252. when you next read in the file, it looks OK, with nothing invisible.
  253. The selective display effect is seen only within Emacs.
  254.  
  255.  - Variable: selective-display
  256.      This buffer-local variable enables selective display.  This means
  257.      that lines, or portions of lines, may be made invisible.
  258.  
  259.         * If the value of `selective-display' is `t', then any portion
  260.           of a line that follows a control-m is not displayed.
  261.  
  262.         * If the value of `selective-display' is a positive integer,
  263.           then lines that start with more than `selective-display'
  264.           columns of indentation are not displayed.
  265.  
  266.      When some portion of a buffer is invisible, the vertical movement
  267.      commands operate as if that portion did not exist, allowing a
  268.      single `next-line' command to skip any number of invisible lines.
  269.      However, character movement commands (such as `forward-char') do
  270.      not skip the invisible portion, and it is possible (if tricky) to
  271.      insert or delete text in an invisible portion.
  272.  
  273.      In the examples below, what is shown is the *display* of the buffer
  274.      `foo', which changes with the value of `selective-display'.  The
  275.      *contents* of the buffer do not change.
  276.  
  277.           (setq selective-display nil)
  278.                => nil
  279.           
  280.           ---------- Buffer: foo ----------
  281.           1 on this column
  282.            2on this column
  283.             3n this column
  284.             3n this column
  285.            2on this column
  286.           1 on this column
  287.           ---------- Buffer: foo ----------
  288.           
  289.           (setq selective-display 2)
  290.                => 2
  291.           
  292.           ---------- Buffer: foo ----------
  293.           1 on this column
  294.            2on this column
  295.            2on this column
  296.           1 on this column
  297.           ---------- Buffer: foo ----------
  298.  
  299.  - Variable: selective-display-ellipses
  300.      If this buffer-local variable is non-`nil', then Emacs displays
  301.      `...' at the end of a line that is followed by invisible text.
  302.      This example is a continuation of the previous one.
  303.  
  304.           (setq selective-display-ellipses t)
  305.                => t
  306.           
  307.           ---------- Buffer: foo ----------
  308.           1 on this column
  309.            2on this column ...
  310.            2on this column
  311.           1 on this column
  312.           ---------- Buffer: foo ----------
  313.  
  314.      You can use a display table to substitute other text for the
  315.      ellipsis (`...').  *Note Display Tables::.
  316.  
  317. 
  318. File: elisp,  Node: Overlay Arrow,  Next: Temporary Displays,  Prev: Selective Display,  Up: Emacs Display
  319.  
  320. Overlay Arrow
  321. =============
  322.  
  323.    The "overlay arrow" is useful for directing the user's attention to
  324. a particular line in a buffer.  For example, in the modes used for
  325. interface to debuggers, the overlay arrow indicates the line of code
  326. about to be executed.
  327.  
  328.  - Variable: overlay-arrow-string
  329.      This variable holds the string to display as an arrow, or `nil' if
  330.      the arrow feature is not in use.
  331.  
  332.  - Variable: overlay-arrow-position
  333.      This variable holds a marker which indicates where to display the
  334.      arrow.  It should point at the beginning of a line.  The arrow
  335.      text is displayed at the beginning of that line, overlaying any
  336.      text that would otherwise appear.  Since the arrow is usually
  337.      short, and the line usually begins with indentation, normally
  338.      nothing significant is overwritten.
  339.  
  340.      The overlay string is displayed only in the buffer which this
  341.      marker points into.  Thus, only one buffer can have an overlay
  342.      arrow at any given time.
  343.  
  344. 
  345. File: elisp,  Node: Temporary Displays,  Next: Overlays,  Prev: Overlay Arrow,  Up: Emacs Display
  346.  
  347. Temporary Displays
  348. ==================
  349.  
  350.    Temporary displays are used by commands to put output into a buffer
  351. and then present it to the user for perusal rather than for editing.
  352. Many of the help commands use this feature.
  353.  
  354.  - Special Form: with-output-to-temp-buffer BUFFER-NAME FORMS...
  355.      This function executes FORMS while arranging to insert any output
  356.      they print into the buffer named BUFFER-NAME.  The buffer is then
  357.      shown in some window for viewing, displayed but not selected.
  358.  
  359.      The string BUFFER-NAME specifies the temporary buffer, which need
  360.      not already exist.  The argument must be a string, not a buffer.
  361.      The buffer is erased initially (with no questions asked), and it is
  362.      marked as unmodified after `with-output-to-temp-buffer' exits.
  363.  
  364.      `with-output-to-temp-buffer' binds `standard-output' to the
  365.      temporary buffer, then it evaluates the forms in FORMS.  Output
  366.      using the Lisp output functions within FORMS goes by default to
  367.      that buffer (but screen display and messages in the echo area,
  368.      although output in the general sense of the word, are not
  369.      affected).  *Note Output Functions::.
  370.  
  371.      The value of the last form in FORMS is returned.
  372.  
  373.           ---------- Buffer: foo ----------
  374.            This is the contents of foo.
  375.           ---------- Buffer: foo ----------
  376.           
  377.           (with-output-to-temp-buffer "foo"
  378.               (print 20)
  379.               (print standard-output))
  380.           => #<buffer foo>
  381.           
  382.           ---------- Buffer: foo ----------
  383.           20
  384.           
  385.           #<buffer foo>
  386.           
  387.           ---------- Buffer: foo ----------
  388.  
  389.  - Variable: temp-buffer-show-function
  390.      The value of this variable, if non-`nil', is called as a function
  391.      to display a help buffer.  This variable is used by
  392.      `with-output-to-temp-buffer'.
  393.  
  394.      In Emacs versions 18 and earlier, this variable was called
  395.      `temp-buffer-show-hook'.
  396.  
  397.  - Function: momentary-string-display STRING POSITION &optional CHAR
  398.           MESSAGE
  399.      This function momentarily displays STRING in the current buffer at
  400.      POSITION (which is a character offset from the beginning of the
  401.      buffer).  The display remains until the next character is typed.
  402.  
  403.      If the next character the user types is CHAR, Emacs ignores it.
  404.      Otherwise, that character remains buffered for subsequent use as
  405.      input.  Thus, typing CHAR will simply remove the string from the
  406.      display, while typing (say) `C-f' will remove the string from the
  407.      display and later (presumably) move point forward.  The argument
  408.      CHAR is a space by default.
  409.  
  410.      The return value of `momentary-string-display' is not meaningful.
  411.  
  412.      If MESSAGE is non-`nil', it is displayed in the echo area while
  413.      STRING is displayed in the buffer.  If it is `nil', then
  414.      instructions to type CHAR are displayed there, e.g., `Type RET to
  415.      continue editing'.
  416.  
  417.      In this example, point is initially located at the beginning of the
  418.      second line:
  419.  
  420.           ---------- Buffer: foo ----------
  421.           This is the contents of foo.
  422.           -!-Second line.
  423.           ---------- Buffer: foo ----------
  424.           
  425.           (momentary-string-display
  426.              "**** Important Message! ****" (point) ?\r
  427.              "Type RET when done reading")
  428.           => t
  429.           
  430.           ---------- Buffer: foo ----------
  431.           This is the contents of foo.
  432.           **** Important Message! ****Second line.
  433.           ---------- Buffer: foo ----------
  434.           
  435.           ---------- Echo Area ----------
  436.           Type RET when done reading
  437.           ---------- Echo Area ----------
  438.  
  439.      This function works by actually changing the text in the buffer.
  440.      As a result, if you later undo in this buffer, you will see the
  441.      message come and go.
  442.  
  443. 
  444. File: elisp,  Node: Overlays,  Next: Faces,  Prev: Temporary Displays,  Up: Emacs Display
  445.  
  446. Overlays
  447. ========
  448.  
  449.    You can use "overlays" to alter the appearance of a buffer's text on
  450. the screen.  An overlay is an object which belongs to a particular
  451. buffer, and has a specified beginning and end.  It also has properties
  452. which you can examine and set; these affect the display of the text
  453. within the overlay.
  454.  
  455. * Menu:
  456.  
  457. * Overlay Properties::    How to read and set properties.
  458.             What properties do to the screen display.
  459. * Managing Overlays::   Creating, moving, finding overlays.
  460.  
  461. 
  462. File: elisp,  Node: Overlay Properties,  Next: Managing Overlays,  Up: Overlays
  463.  
  464. Overlay Properties
  465. ------------------
  466.  
  467.    Overlay properties are like text properties in some respects, but the
  468. differences are more important than the similarities.  Text properties
  469. are considered a part of the text; overlays are specifically considered
  470. not to be part of the text.  Thus, copying text between various buffers
  471. and strings preserves text properties, but does not try to preserve
  472. overlays.  Changing a buffer's text properties marks the buffer as
  473. modified, while moving an overlay or changing its properties does not.
  474.  
  475. `face'
  476.      This property controls the font and color of text.  *Note Faces::,
  477.      for more information.  This feature is temporary; in the future,
  478.      we may replace it with other ways of specifying how to display
  479.      text.
  480.  
  481. `mouse-face'
  482.      This property is used instead of `face' when the mouse is within
  483.      the range of the overlay.  This feature is not yet implemented,
  484.      and may be temporary.  It is documented here because we are likely
  485.      to implement it this way at least for a while.
  486.  
  487. `priority'
  488.      This property's value (which should be a nonnegative number)
  489.      determines the priority of the overlay.  The priority matters when
  490.      two or more overlays cover the same character and both specify a
  491.      face for display; the one whose `priority' value is larger takes
  492.      priority over the other, and its face attributes override the face
  493.      attributes of the lower priority overlay.
  494.  
  495.      Currently, all overlays take priority over text properties.  Please
  496.      avoid using negative priority values, as we have not yet decided
  497.      just what they should mean.
  498.  
  499. `window'
  500.      If the `window' property is non-`nil', then the overlay applies
  501.      only on that window.
  502.  
  503. `before-string'
  504.      This property's value is a string to add to the display at the
  505.      beginning of the overlay.  The string does not appear in the
  506.      buffer in any sense--only on the screen.  This is not yet
  507.      implemented, but will be.
  508.  
  509. `after-string'
  510.      This property's value is a string to add to the display at the end
  511.      of the overlay.  The string does not appear in the buffer in any
  512.      sense--only on the screen.  This is not yet implemented, but will
  513.      be.
  514.  
  515.    These are the functions for reading and writing the properties of an
  516. overlay.
  517.  
  518.  - Function: overlay-get OVERLAY PROP
  519.      This function returns the value of property PROP recorded in
  520.      OVERLAY.  If OVERLAY does not record any value for that property,
  521.      then the value is `nil'.
  522.  
  523.  - Function: overlay-put OVERLAY PROP VALUE
  524.      This function set the value of property PROP recorded in OVERLAY
  525.      to VALUE.  It returns VALUE.
  526.  
  527. 
  528. File: elisp,  Node: Managing Overlays,  Prev: Overlay Properties,  Up: Overlays
  529.  
  530. Managing Overlays
  531. -----------------
  532.  
  533.  - Function: make-overlay START END &optional BUFFER
  534.      This function creates and returns an overlay which belongs to
  535.      BUFFER and ranges from START to END.  Both START and END must
  536.      specify buffer positions; they may be integers or markers.  If
  537.      BUFFER is omitted, the overlay is created in the current buffer.
  538.  
  539.      The return value is the overlay itself.
  540.  
  541.  - Function: overlay-start OVERLAY
  542.      This function returns the position at which OVERLAY starts.
  543.  
  544.  - Function: overlay-end OVERLAY
  545.      This function returns the position at which OVERLAY ends.
  546.  
  547.  - Function: overlay-buffer OVERLAY
  548.      This function returns the buffer that OVERLAY belongs to.
  549.  
  550.  - Function: delete-overlay OVERLAY
  551.      This function deletes OVERLAY.  The overlay continues to exist as
  552.      a Lisp object, but ceases to be part of the buffer it belonged to,
  553.      and ceases to have any effect on display.
  554.  
  555.  - Function: move-overlay OVERLAY START END &optional BUFFER
  556.      This function moves OVERLAY to BUFFER, and places its bounds at
  557.      START and END.  Both arguments START and END must specify buffer
  558.      positions; they may be integers or markers.  If BUFFER is omitted,
  559.      the overlay stays in the same buffer.
  560.  
  561.      The return value is OVERLAY.
  562.  
  563.      This is the only valid way to change the endpoints of an overlay.
  564.      Do not try modifying the markers in the overlay by hand, as that
  565.      fails to update other vital data structures and can cause some
  566.      overlays to be "lost".
  567.  
  568.  - Function: overlays-at POS
  569.      This function returns a list of all the overlays that contain
  570.      position POS in the current buffer.  The list is in no particular
  571.      order.  An overlay contains position POS if it begins at or before
  572.      POS, and ends after POS.
  573.  
  574.  - Function: next-overlay-change POS
  575.      This function returns the buffer position of the next beginning or
  576.      end of an overlay, after POS.
  577.  
  578. 
  579. File: elisp,  Node: Faces,  Next: Blinking,  Prev: Overlays,  Up: Emacs Display
  580.  
  581. Faces
  582. =====
  583.  
  584.    A "face" is a named collection of graphical attributes: font,
  585. foreground color, background color and optional underlining.  Faces
  586. control the display of text on the screen.
  587.  
  588.    Each face has its own "face id number" which distinguishes faces at
  589. low levels within Emacs.  However, for most purposes, you can refer to
  590. faces in Lisp programs by their names.
  591.  
  592.    Each face name is meaningful for all frames, and by default it has
  593. the same meaning in all frames.  But you can arrange to give a
  594. particular face name a special meaning in one frame if you wish.
  595.  
  596.    The face named `default' is used for ordinary text.  The face named
  597. `modeline' is used for displaying the mode line and menu bars.  The
  598. face named `region' is used for highlighting the region (in Transient
  599. Mark mode only).
  600.  
  601. * Menu:
  602.  
  603. * Merging Faces::    How Emacs decides which face to use for a character.
  604. * Face Functions::    How to define and examine faces.
  605.  
  606. 
  607. File: elisp,  Node: Merging Faces,  Next: Face Functions,  Up: Faces
  608.  
  609. Merging Faces for Display
  610. -------------------------
  611.  
  612.    Here are all the ways to specify which face to use for display of
  613. text:
  614.  
  615.    * With defaults.  Each frame has a "default face", whose id number is
  616.      zero, which is used for all text that doesn't somehow specify
  617.      another face.
  618.  
  619.    * With text properties.  A character may have a `face' property; if
  620.      so, it's displayed with that face.  If the character has a
  621.      `mouse-face' property, that is used instead of the `face' property
  622.      when the mouse is "near enough" to the character.  *Note Special
  623.      Properties::.
  624.  
  625.    * With overlays.  An overlay may have `face' and `mouse-face'
  626.      properties too; they apply to all the text covered by the overlay.
  627.  
  628.    * With special glyphs.  Each glyph can specify a particular face id
  629.      number.  *Note Glyphs::.
  630.  
  631.    If these various sources together specify more than one face for a
  632. particular character, Emacs merges the attributes of the various faces
  633. specified.  The attributes of the faces of special glyphs come first;
  634. then come attributes of faces from overlays, followed by those from text
  635. properties, and last the default face.
  636.  
  637.    When multiple overlays cover one character, an overlay with higher
  638. priority overrides those with lower priority.  *Note Overlays::.
  639.  
  640.    If an attribute such as the font or a color is not specified in any
  641. of the above ways, the frame's own font or color is used.
  642.  
  643. 
  644. File: elisp,  Node: Face Functions,  Prev: Merging Faces,  Up: Faces
  645.  
  646. Functions for Working with Faces
  647. --------------------------------
  648.  
  649.    The attributes a face can specify include the font, the foreground
  650. color, the background color, and underlining.  The face can also leave
  651. these unspecified by giving the value `nil' for them.
  652.  
  653.    Here are the primitives for creating and changing faces.
  654.  
  655.  - Function: make-face NAME
  656.      This function defines a new face named NAME, initially with all
  657.      attributes `nil'.  It does nothing if there is already a face named
  658.      NAME.
  659.  
  660.  - Function: face-list
  661.      This function returns a list of all defined face names.
  662.  
  663.  - Function: copy-face OLD-FACE NEW-NAME &optional FRAME
  664.      This function defines a new face named NEW which is a copy of the
  665.      existing face named OLD.  If there is already a face named NEW,
  666.      then it alters the face to have the same attributes as OLD.
  667.  
  668.      If the optional argument FRAME is given, this function applies
  669.      only to that frame.  Otherwise it applies to each frame
  670.      individually.
  671.  
  672.    You can modify the attributes of an existing face with the following
  673. functions.  If you specify FRAME, they affect just that frame;
  674. otherwise, they affect all frames as well as the defaults that apply to
  675. new frames.
  676.  
  677.  - Function: set-face-foreground FACE COLOR &optional FRAME
  678.  - Function: set-face-background FACE COLOR &optional FRAME
  679.      These functions set the foreground (respectively, background)
  680.      color of face FACE to COLOR.  The argument COLOR color should be a
  681.      string, the name of a color.
  682.  
  683.  - Function: set-face-font FACE FONT &optional FRAME
  684.      This function sets the font of face FACE.  The argument FONT
  685.      should be a string.
  686.  
  687.  - Function: set-face-underline-p FACE UNDERLINE-P &optional FRAME
  688.      This function sets the underline attribute of face FACE.
  689.  
  690.  - Function: invert-face FACE &optional FRAME
  691.      Swap the foreground and background colors of face FACE.  If the
  692.      face doesn't specify both foreground and background, then its
  693.      foreground and background are set to the default background and
  694.      foreground.
  695.  
  696.    These functions examine the attributes of a face.  If you don't
  697. specify FRAME, they refer to the default data for new frames.
  698.  
  699.  - Function: face-foreground FACE &optional FRAME
  700.  - Function: face-background FACE &optional FRAME
  701.      These functions return the foreground (respectively, background)
  702.      color of face FACE.  The argument COLOR color should be a string,
  703.      the name of a color.
  704.  
  705.  - Function: face-font FACE &optional FRAME
  706.      This function returns the name of the font of face FACE.
  707.  
  708.  - Function: face-underline-p FACE &optional FRAME
  709.      This function returns the underline attribute of face FACE.
  710.  
  711.  - Function: face-id-number FACE
  712.      This function returns the id number of face FACE.
  713.  
  714.  - Function: face-equal FACE1 FACE2 &optional FRAME
  715.      This returns `t' if the faces FACE1 and FACE2 have the same
  716.      attributes for display.
  717.  
  718.  - Function: face-differs-from-default-p FACE &optional FRAME
  719.      This returns `t' if the face FACE displays differently from the
  720.      default face.  A face is considered to be "the same" as the normal
  721.      face if each attribute is either the same as that of the default
  722.      face or `nil' (meaning to inherit from the default).
  723.  
  724.  - Variable: region-face
  725.      This variable's value specifies the face id to use to display
  726.      characters in the region when it is active (in Transient Mark mode
  727.      only).  The face thus specified takes precedence over all faces
  728.      that come from text properties and overlays, for characters in the
  729.      region.  *Note The Mark::, for more information about Transient
  730.      Mark mode.
  731.  
  732.      Normally, the value is the id number of the face named `region'.
  733.  
  734. 
  735. File: elisp,  Node: Blinking,  Next: Inverse Video,  Prev: Faces,  Up: Emacs Display
  736.  
  737. Blinking
  738. ========
  739.  
  740.    This section describes the mechanism by which Emacs shows a matching
  741. open parenthesis when the user inserts a close parenthesis.
  742.  
  743.  - Variable: blink-paren-function
  744.      The value of this variable should be a function (of no arguments)
  745.      to be called whenever a char with close parenthesis syntax is
  746.      inserted.  The value of `blink-paren-function' may be `nil', in
  747.      which case nothing is done.
  748.  
  749.           *Please note:* this variable was named `blink-paren-hook' in
  750.           older Emacs versions, but since it is not called with the
  751.           standard convention for hooks, it was renamed to
  752.           `blink-paren-function' in version 19.
  753.  
  754.  - Variable: blink-matching-paren
  755.      If this variable is `nil', then `blink-matching-open' does nothing.
  756.  
  757.  - Variable: blink-matching-paren-distance
  758.      This variable specifies the maximum distance to scan for a matching
  759.      parenthesis before giving up.
  760.  
  761.  - Function: blink-matching-open
  762.      This function is the default value of `blink-paren-function'.  It
  763.      assumes that point follows a character with close parenthesis
  764.      syntax and moves the cursor momentarily to the matching opening
  765.      character.  If that character is not already on the screen, then
  766.      its context is shown by displaying it in the echo area.  To avoid
  767.      long delays, this function does not search farther than
  768.      `blink-matching-paren-distance' characters.
  769.  
  770.      Here is an example of calling this function explicitly.
  771.  
  772.           (defun interactive-blink-matching-open ()
  773.             "Indicate momentarily the start of sexp before point."
  774.             (interactive)
  775.             (let ((blink-matching-paren-distance
  776.                    (buffer-size))
  777.                   (blink-matching-paren t))
  778.               (blink-matching-open)))
  779.  
  780. 
  781. File: elisp,  Node: Inverse Video,  Next: Usual Display,  Prev: Blinking,  Up: Emacs Display
  782.  
  783. Inverse Video
  784. =============
  785.  
  786.  - User Option: inverse-video
  787.      This variable controls whether Emacs uses inverse video for all
  788.      text on the screen.  Non-`nil' means yes, `nil' means no.  The
  789.      default is `nil'.
  790.  
  791.  - User Option: mode-line-inverse-video
  792.      This variable controls the use of inverse video for mode lines.
  793.      If it is non-`nil', then mode lines are displayed in inverse video
  794.      (under X, this uses the face named `modeline', which you can set
  795.      as you wish).  Otherwise, mode lines are displayed normally, just
  796.      like text.  The default is `t'.
  797.  
  798. 
  799. File: elisp,  Node: Usual Display,  Next: Display Tables,  Prev: Inverse Video,  Up: Emacs Display
  800.  
  801. Usual Display Conventions
  802. =========================
  803.  
  804.    The usual display conventions define how to display each character
  805. code.  You can override these conventions by setting up a display table
  806. (*note Display Tables::.).  Here are the usual display conventions:
  807.  
  808.    * Character codes 32 through 126 map to glyph codes 32 through 126.
  809.      Normally this means they display as themselves.
  810.  
  811.    * Character code 9 is a horizontal tab.  It displays as whitespace
  812.      up to a position determined by `tab-width'.
  813.  
  814.    * Character code 10 is a newline.
  815.  
  816.    * All other codes in the range 0 through 31, and code 127, display
  817.      in one of two ways according to the value of `ctl-arrow'.  If it
  818.      is is non-`nil', these codes map to sequences of two glyphs, where
  819.      the first glyph is the ASCII code for `^'.  Otherwise, these codes
  820.      map just like the codes in the range 128 to 255.
  821.  
  822.    * Character codes 128 through 255 map to sequences of four glyphs,
  823.      where the first glyph is the ASCII code for `\', and the others
  824.      are digit characters representing the code in octal.
  825.  
  826.    The usual display conventions apply even when there is a display
  827. table, for any character whose entry in the active display table is
  828. `nil'.  Thus, when you set up a display table, you need only specify
  829. the the characters for which you want unusual behavior.
  830.  
  831.    These variables affect the way certain characters are displayed on
  832. the screen.  Since they change the number of columns the characters
  833. occupy, they also affect the indentation functions.
  834.  
  835.  - User Option: ctl-arrow
  836.      This buffer-local variable controls how control characters are
  837.      displayed.  If it is non-`nil', they are displayed as a caret
  838.      followed by the character: `^A'.  If it is `nil', they are
  839.      displayed as a backslash followed by three octal digits: `\001'.
  840.  
  841.  - Variable: default-ctl-arrow
  842.      The value of this variable is the default value for `ctl-arrow' in
  843.      buffers that do not override it.  This is the same as executing the
  844.      following expression:
  845.  
  846.           (default-value 'ctl-arrow)
  847.  
  848.      *Note Default Value::.
  849.  
  850.  - User Option: tab-width
  851.      The value of this variable is the spacing between tab stops used
  852.      for displaying tab characters in Emacs buffers.  The default is 8.
  853.      Note that this feature is completely independent from the
  854.      user-settable tab stops used by the command `tab-to-tab-stop'.
  855.      *Note Indent Tabs::.
  856.  
  857. 
  858. File: elisp,  Node: Display Tables,  Next: Beeping,  Prev: Usual Display,  Up: Emacs Display
  859.  
  860. Display Tables
  861. ==============
  862.  
  863.    You can use the "display table" feature to control how all 256
  864. possible character codes display on the screen.  This is useful for
  865. displaying European languages that have letters not in the ASCII
  866. character set.
  867.  
  868.    The display table maps each character code into a sequence of
  869. "glyphs", each glyph being an image that takes up one character
  870. position on the screen.  You can also define how to display each glyph
  871. on your terminal, using the "glyph table".
  872.  
  873. * Menu:
  874.  
  875. * Display Table Format::    What a display table consists of.
  876. * Active Display Table::    How Emacs selects a display table to use.
  877. * Glyphs::            How to define a glyph, and what glyphs mean.
  878. * ISO Latin 1::            How to use display tables
  879.                   to support the ISO Latin 1 character set.
  880.  
  881. 
  882. File: elisp,  Node: Display Table Format,  Next: Active Display Table,  Up: Display Tables
  883.  
  884. Display Table Format
  885. --------------------
  886.  
  887.    A display table is actually an array of 261 elements.
  888.  
  889.  - Function: make-display-table
  890.      This creates and returns a display table.  The table initially has
  891.      `nil' in all elements.
  892.  
  893.    The first 256 elements correspond to character codes; the Nth
  894. element says how to display the character code N.  The value should be
  895. `nil' or a vector of glyph values (*note Glyphs::.).  If an element is
  896. `nil', it says to display that character according to the usual display
  897. conventions (*note Usual Display::.).
  898.  
  899.    The remaining five elements of a display table serve special
  900. purposes, and `nil' means use the default stated below.
  901.  
  902. 256
  903.      The glyph for the end of a truncated screen line (the default for
  904.      this is `$').  *Note Glyphs::.
  905.  
  906. 257
  907.      The glyph for the end of a continued line (the default is `\').
  908.  
  909. 258
  910.      The glyph for indicating a character displayed as an octal
  911.      character code (the default is `\').
  912.  
  913. 259
  914.      The glyph for indicating a control character (the default is `^').
  915.  
  916. 260
  917.      A vector of glyphs for indicating the presence of invisible lines
  918.      (the default is `...').  *Note Selective Display::.
  919.  
  920.    For example, here is how to construct a display table that mimics the
  921. effect of setting `ctl-arrow' to a non-`nil' value:
  922.  
  923.      (setq disptab (make-display-table))
  924.      (let ((i 0))
  925.        (while (< i 32)
  926.          (or (= i ?\t) (= i ?\n)
  927.              (aset disptab i (vector ?^ (+ i 64))))
  928.          (setq i (1+ i)))
  929.        (aset disptab 127 (vector ?^ ??)))
  930.  
  931. 
  932. File: elisp,  Node: Active Display Table,  Next: Glyphs,  Prev: Display Table Format,  Up: Display Tables
  933.  
  934. Active Display Table
  935. --------------------
  936.  
  937.    Each window can specify a display table, and so can each buffer.
  938. When a buffer B is displayed in window W, display uses the display
  939. table for window W if it has one; otherwise, the display table for
  940. buffer B if it has one; otherwise, the standard display table if any.
  941. The display table chosen is called the "active" display table.
  942.  
  943.  - Function: window-display-table WINDOW
  944.      This function returns WINDOW's display table, or `nil' if WINDOW
  945.      does not have an assigned display table.
  946.  
  947.  - Function: set-window-display-table WINDOW TABLE
  948.      This function sets the display table of WINDOW to TABLE.  The
  949.      argument TABLE should be either a display table or `nil'.
  950.  
  951.  - Variable: buffer-display-table
  952.      This variable is automatically local in all buffers; its value in a
  953.      particular buffer is the display table for that buffer, or `nil' if
  954.      the buffer does not have any assigned display table.
  955.  
  956.  - Variable: standard-display-table
  957.      This variable's value is the default display table, used when
  958.      neither the current buffer nor the window displaying it has an
  959.      assigned display table.  This variable is `nil' by default.
  960.  
  961.    If neither the selected window nor the current buffer has a display
  962. table, and if the variable `standard-display-table' is `nil', then
  963. Emacs uses the usual display conventions.  *Note Usual Display::.
  964.  
  965. 
  966. File: elisp,  Node: Glyphs,  Next: ISO Latin 1,  Prev: Active Display Table,  Up: Display Tables
  967.  
  968. Glyphs
  969. ------
  970.  
  971.    A "glyph" is a generalization of a character; it stands for an image
  972. that takes up a single character position on the screen.  Glyphs are
  973. represented in Lisp as integers, just as characters are.
  974.  
  975.    The meaning of each integer, as a glyph, is defined by the glyph
  976. table, which is the value of the variable `glyph-table'.
  977.  
  978.  - Variable: glyph-table
  979.      The value of this variable is the current glyph table.  It should
  980.      be a vector; the Gth element defines glyph code G.  If the value
  981.      is `nil' instead of a vector, then all glyphs are simple (see
  982.      below).
  983.  
  984.    Here are the possible types of elements in the glyph table:
  985.  
  986. INTEGER
  987.      Define this glyph code as an alias for code INTEGER.  This is used
  988.      with X Windows to specify a face code.
  989.  
  990. STRING
  991.      Send the characters in STRING to the terminal to output this
  992.      glyph.  This alternative is available on character terminals, but
  993.      not under X.
  994.  
  995. `NIL'
  996.      This glyph is simple.  On an ordinary terminal, the glyph code mod
  997.      256 is the character to output.  With X, the glyph code mod 256 is
  998.      character to output, and the glyph code divided by 256 specifies
  999.      the "face id number" to use while outputting it.  *Note Faces::.
  1000.  
  1001.    If a glyph code is greater than or equal to the length of the glyph
  1002. table, that code is automatically simple.
  1003.  
  1004. 
  1005. File: elisp,  Node: ISO Latin 1,  Prev: Glyphs,  Up: Display Tables
  1006.  
  1007. ISO Latin 1
  1008. -----------
  1009.  
  1010.    If you have a terminal that can handle the entire ISO Latin 1
  1011. character set, you can arrange to use that character set as follows:
  1012.  
  1013.      (require 'disp-table)
  1014.      ;; Set char codes 160--255 to display as themselves.
  1015.      ;; (Codes 128--159 are the additional control characters.)
  1016.      (standard-display-8bit 160 255)
  1017.  
  1018.    If you are editing buffers written in the ISO Latin 1 character set
  1019. and your terminal doesn't handle anything but ASCII, you can load the
  1020. file `iso-ascii' to set up a display table which makes the other ISO
  1021. characters display as sequences of ASCII characters.  For example, the
  1022. character "o with umlaut" displays as `{"o}'.
  1023.  
  1024.    Some European countries have terminals that don't support ISO Latin 1
  1025. but do support the special characters for that country's language.  You
  1026. can define a display table to work one language using such terminals.
  1027. For an example, see `lisp/iso-swed.el', which handles certain Swedish
  1028. terminals.
  1029.  
  1030.    You can load the appropriate display table for your terminal
  1031. automatically by writing a terminal-specific Lisp file for the terminal
  1032. type.
  1033.  
  1034. 
  1035. File: elisp,  Node: Beeping,  Next: Window Systems,  Prev: Display Tables,  Up: Emacs Display
  1036.  
  1037. Beeping
  1038. =======
  1039.  
  1040.    You can make Emacs ring a bell (or blink the screen) to attract the
  1041. user's attention.  Be conservative about how often you do this; frequent
  1042. bells can become irritating.  Also be careful not to use beeping alone
  1043. when signaling an error is appropriate.  (*Note Errors::.)
  1044.  
  1045.  - Function: ding &optional DONT-TERMINATE
  1046.      This function beeps, or flashes the screen (see `visible-bell'
  1047.      below).  It also terminates any keyboard macro currently executing
  1048.      unless DONT-TERMINATE is non-`nil'.
  1049.  
  1050.  - Function: beep &optional DONT-TERMINATE
  1051.      This is a synonym for `ding'.
  1052.  
  1053.  - Variable: visible-bell
  1054.      This variable determines whether Emacs should flash the screen to
  1055.      represent a bell.  Non-`nil' means yes, `nil' means no.  This is
  1056.      effective only if the Termcap entry for the terminal in use has the
  1057.      visible bell flag (`vb') set.
  1058.  
  1059. 
  1060. File: elisp,  Node: Window Systems,  Prev: Beeping,  Up: Emacs Display
  1061.  
  1062. Window Systems
  1063. ==============
  1064.  
  1065.    Emacs works with several window systems, most notably the X Window
  1066. Syste,.  Note that both Emacs and X use the term "window", but use it
  1067. differently.  An Emacs frame is a single window as far as X is
  1068. concerned; the individual Emacs windows are not known to X at all.
  1069.  
  1070.  - Variable: window-system
  1071.      This variable tells Lisp programs what window system Emacs is
  1072.      running under.  Its value should be a symbol such as `x' (if Emacs
  1073.      is running under X) or `nil' (if Emacs is running on an ordinary
  1074.      terminal).
  1075.  
  1076.  - Variable: window-system-version
  1077.      This variable distinguishes between different versions of the X
  1078.      Window System.  Its value is 10 or 11 when using X; `nil'
  1079.      otherwise.
  1080.  
  1081.  - Variable: window-setup-hook
  1082.      This variable is a normal hook which Emacs runs after loading your
  1083.      `.emacs' file and the default initialization file (if any), after
  1084.      loading terminal-specific Lisp code, and after running the hook
  1085.      `term-setup-hook'.
  1086.  
  1087.      This hook is used for internal purposes: setting up communication
  1088.      with the window system, and creating the initial window.  Users
  1089.      should not interfere with it.
  1090.  
  1091. 
  1092. File: elisp,  Node: Calendar,  Next: Tips,  Prev: Emacs Display,  Up: Top
  1093.  
  1094. Customizing the Calendar and Diary
  1095. **********************************
  1096.  
  1097.    There are many customizations that you can use to make the calendar
  1098. and diary suit your personal tastes.
  1099.  
  1100. * Menu:
  1101.  
  1102. * Calendar Customizing::   Defaults you can set.
  1103. * Holiday Customizing::    Defining your own holidays.
  1104. * Date Display Format::    Changing the format.
  1105. * Time Display Format::    Changing the format.
  1106. * Daylight Savings::       Changing the default.
  1107. * Diary Customizing::      Defaults you can set.
  1108. * Hebrew/Islamic Entries:: How to obtain them.
  1109. * Fancy Diary Display::    Enhancing the diary display, sorting entries.
  1110. * Included Diary Files::   Sharing a common diary file.
  1111. * Sexp Diary Entries::     Fancy things you can do.
  1112. * Appt Customizing::       Customizing appointment reminders.
  1113.  
  1114. 
  1115. File: elisp,  Node: Calendar Customizing,  Next: Holiday Customizing,  Up: Calendar
  1116.  
  1117. Customizing the Calendar
  1118. ========================
  1119.  
  1120.    If you set the variable `view-diary-entries-initially' to `t',
  1121. calling up the calendar automatically displays the diary entries for
  1122. the current date as well.  The diary dates appear only if the current
  1123. date is visible.  If you add both of the following lines to your
  1124. `.emacs' file:
  1125.  
  1126.      (setq view-diary-entries-initially t)
  1127.      (calendar)
  1128.  
  1129. they display both the calendar and diary windows whenever you start
  1130. Emacs.
  1131.  
  1132.    Similarly, if you set the variable
  1133. `view-calendar-holidays-initially' to `t', entering the calendar
  1134. automatically displays a list of holidays for the current three month
  1135. period.  The holiday list appears in a separate window.
  1136.  
  1137.    You can set the variable `mark-diary-entries-in-calendar' to `t' in
  1138. order to place a plus sign (`+') beside any dates with diary entries.
  1139. Whenever the calendar window is displayed or redisplayed, the diary
  1140. entries are automatically marked for holidays.
  1141.  
  1142.    Similarly, setting the variable `mark-holidays-in-calendar' to `t'
  1143. places an asterisk (`*') after all holiday dates visible in the
  1144. calendar window.
  1145.  
  1146.    There are many customizations that you can make with the hooks
  1147. provided.  For example, the variable `calendar-load-hook', whose
  1148. default value is `nil', is a normal hook run when the calendar package
  1149. is first loaded (before actually starting to display the calendar).
  1150.  
  1151.    The variable `initial-calendar-window-hook', whose default value is
  1152. `nil', is a normal hook run the first time the calendar window is
  1153. displayed.  The function is invoked only when you first enter Calendar
  1154. mode, not when you redisplay an existing Calendar window.  But if you
  1155. leave the calendar with the `q' command and reenter it, the hook runs
  1156. again.
  1157.  
  1158.    The variable `today-visible-calendar-hook', whose default value is
  1159. `nil', is a normal hook run after the calendar buffer has been prepared
  1160. with the calendar when the current date is visible in the window.  One
  1161. use of this hook is to replace today's date with asterisks; a function
  1162. `calendar-star-date' is included for this purpose.  In your `.emacs'
  1163. file, put:
  1164.  
  1165.      (setq today-visible-calendar-hook 'calendar-star-date)
  1166.  
  1167. Another standard hook function adds asterisks around the current date.
  1168. Here's how to use it:
  1169.  
  1170.      (setq today-visible-calendar-hook 'calendar-mark-today)
  1171.  
  1172. A corresponding variable, `today-invisible-calendar-hook', whose
  1173. default value is `nil', is a normal hook run after the calendar buffer
  1174. text has been prepared, if the current date is *not* visible in the
  1175. window.
  1176.  
  1177.