Commit | Line | Data |
---|---|---|
42b85554 RS |
1 | @c -*-texinfo-*- |
2 | @c This is part of the GNU Emacs Lisp Reference Manual. | |
82c3d852 | 3 | @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001, 2002 |
177c0ea7 | 4 | @c Free Software Foundation, Inc. |
42b85554 RS |
5 | @c See the file elisp.texi for copying conditions. |
6 | @setfilename ../info/display | |
969fe9b5 | 7 | @node Display, Calendar, Processes, Top |
42b85554 RS |
8 | @chapter Emacs Display |
9 | ||
10 | This chapter describes a number of features related to the display | |
11 | that Emacs presents to the user. | |
12 | ||
13 | @menu | |
14 | * Refresh Screen:: Clearing the screen and redrawing everything on it. | |
8241495d | 15 | * Forcing Redisplay:: Forcing redisplay. |
42b85554 RS |
16 | * Truncation:: Folding or wrapping long text lines. |
17 | * The Echo Area:: Where messages are displayed. | |
8a6ca431 | 18 | * Warnings:: Displaying warning messages for the user. |
22697dac KH |
19 | * Invisible Text:: Hiding part of the buffer text. |
20 | * Selective Display:: Hiding part of the buffer text (the old way). | |
42b85554 RS |
21 | * Overlay Arrow:: Display of an arrow to indicate position. |
22 | * Temporary Displays:: Displays that go away automatically. | |
02c77ee9 | 23 | * Overlays:: Use overlays to highlight parts of the buffer. |
a40d4712 | 24 | * Width:: How wide a character or string is on the screen. |
02c77ee9 | 25 | * Faces:: A face defines a graphics style for text characters: |
a40d4712 | 26 | font, colors, etc. |
8a6ca431 | 27 | * Fringes:: Controlling window fringes. |
9b6e4bc3 | 28 | * Fringe Bitmaps:: Customizing fringe bitmaps. |
f6cad089 | 29 | * Scroll Bars:: Controlling vertical scroll bars. |
61e74968 | 30 | * Pointer Shape:: Controlling the mouse pointer shape. |
8241495d RS |
31 | * Display Property:: Enabling special display features. |
32 | * Images:: Displaying images in Emacs buffers. | |
02c77ee9 | 33 | * Buttons:: Adding clickable buttons to Emacs buffers. |
42b85554 | 34 | * Blinking:: How Emacs shows the matching open parenthesis. |
02c77ee9 MB |
35 | * Inverse Video:: Specifying how the screen looks. |
36 | * Usual Display:: The usual conventions for displaying nonprinting chars. | |
37 | * Display Tables:: How to specify other conventions. | |
42b85554 RS |
38 | * Beeping:: Audible signal to the user. |
39 | * Window Systems:: Which window system is being used. | |
40 | @end menu | |
41 | ||
42 | @node Refresh Screen | |
43 | @section Refreshing the Screen | |
44 | ||
45 | The function @code{redraw-frame} redisplays the entire contents of a | |
1911e6e5 | 46 | given frame (@pxref{Frames}). |
42b85554 RS |
47 | |
48 | @c Emacs 19 feature | |
49 | @defun redraw-frame frame | |
50 | This function clears and redisplays frame @var{frame}. | |
51 | @end defun | |
52 | ||
53 | Even more powerful is @code{redraw-display}: | |
54 | ||
55 | @deffn Command redraw-display | |
56 | This function clears and redisplays all visible frames. | |
57 | @end deffn | |
58 | ||
00b3c1cd RS |
59 | This function forces certain windows to be redisplayed |
60 | but does not clear them. | |
61 | ||
62 | @defun force-window-update object | |
63 | This function forces redisplay of some or all windows. If | |
64 | @var{object} is a window, it forces redisplay of that window. If | |
65 | @var{object} is a buffer or buffer name, it forces redisplay of all | |
66 | windows displaying that buffer. If @var{object} is @code{nil}, it | |
67 | forces redisplay of all windows. | |
68 | @end defun | |
69 | ||
bfe721d1 KH |
70 | Processing user input takes absolute priority over redisplay. If you |
71 | call these functions when input is available, they do nothing | |
72 | immediately, but a full redisplay does happen eventually---after all the | |
73 | input has been processed. | |
74 | ||
42b85554 RS |
75 | Normally, suspending and resuming Emacs also refreshes the screen. |
76 | Some terminal emulators record separate contents for display-oriented | |
77 | programs such as Emacs and for ordinary sequential display. If you are | |
78 | using such a terminal, you might want to inhibit the redisplay on | |
78608595 | 79 | resumption. |
42b85554 RS |
80 | |
81 | @defvar no-redraw-on-reenter | |
82 | @cindex suspend (cf. @code{no-redraw-on-reenter}) | |
83 | @cindex resume (cf. @code{no-redraw-on-reenter}) | |
84 | This variable controls whether Emacs redraws the entire screen after it | |
f9f59935 | 85 | has been suspended and resumed. Non-@code{nil} means there is no need |
969fe9b5 | 86 | to redraw, @code{nil} means redrawing is needed. The default is @code{nil}. |
42b85554 RS |
87 | @end defvar |
88 | ||
8241495d RS |
89 | @node Forcing Redisplay |
90 | @section Forcing Redisplay | |
91 | @cindex forcing redisplay | |
92 | ||
93 | Emacs redisplay normally stops if input arrives, and does not happen | |
94 | at all if input is available before it starts. Most of the time, this | |
95 | is exactly what you want. However, you can prevent preemption by | |
96 | binding @code{redisplay-dont-pause} to a non-@code{nil} value. | |
97 | ||
98 | @tindex redisplay-dont-pause | |
99 | @defvar redisplay-dont-pause | |
100 | If this variable is non-@code{nil}, pending input does not | |
101 | prevent or halt redisplay; redisplay occurs, and finishes, | |
102 | regardless of whether input is available. This feature is available | |
103 | as of Emacs 21. | |
104 | @end defvar | |
105 | ||
106 | You can request a display update, but only if no input is pending, | |
107 | with @code{(sit-for 0)}. To force a display update even when input is | |
108 | pending, do this: | |
109 | ||
110 | @example | |
111 | (let ((redisplay-dont-pause t)) | |
112 | (sit-for 0)) | |
113 | @end example | |
114 | ||
42b85554 RS |
115 | @node Truncation |
116 | @section Truncation | |
117 | @cindex line wrapping | |
118 | @cindex continuation lines | |
119 | @cindex @samp{$} in display | |
120 | @cindex @samp{\} in display | |
121 | ||
122 | When a line of text extends beyond the right edge of a window, the | |
123 | line can either be continued on the next screen line, or truncated to | |
124 | one screen line. The additional screen lines used to display a long | |
125 | text line are called @dfn{continuation} lines. Normally, a @samp{$} in | |
126 | the rightmost column of the window indicates truncation; a @samp{\} on | |
969fe9b5 RS |
127 | the rightmost column indicates a line that ``wraps'' onto the next line, |
128 | which is also called @dfn{continuing} the line. (The display table can | |
129 | specify alternative indicators; see @ref{Display Tables}.) | |
42b85554 | 130 | |
6e2391a8 | 131 | On a windowed display, the @samp{$} and @samp{\} indicators are |
8a6ca431 RS |
132 | replaced with graphics bitmaps displayed in the window fringes |
133 | (@pxref{Fringes}). | |
6e2391a8 | 134 | |
42b85554 RS |
135 | Note that continuation is different from filling; continuation happens |
136 | on the screen only, not in the buffer contents, and it breaks a line | |
137 | precisely at the right margin, not at a word boundary. @xref{Filling}. | |
138 | ||
139 | @defopt truncate-lines | |
140 | This buffer-local variable controls how Emacs displays lines that extend | |
141 | beyond the right edge of the window. The default is @code{nil}, which | |
142 | specifies continuation. If the value is non-@code{nil}, then these | |
143 | lines are truncated. | |
144 | ||
145 | If the variable @code{truncate-partial-width-windows} is non-@code{nil}, | |
146 | then truncation is always used for side-by-side windows (within one | |
147 | frame) regardless of the value of @code{truncate-lines}. | |
148 | @end defopt | |
149 | ||
bfe721d1 | 150 | @defopt default-truncate-lines |
42b85554 | 151 | This variable is the default value for @code{truncate-lines}, for |
969fe9b5 | 152 | buffers that do not have buffer-local values for it. |
bfe721d1 | 153 | @end defopt |
42b85554 RS |
154 | |
155 | @defopt truncate-partial-width-windows | |
156 | This variable controls display of lines that extend beyond the right | |
157 | edge of the window, in side-by-side windows (@pxref{Splitting Windows}). | |
158 | If it is non-@code{nil}, these lines are truncated; otherwise, | |
159 | @code{truncate-lines} says what to do with them. | |
160 | @end defopt | |
161 | ||
a9f0a989 RS |
162 | When horizontal scrolling (@pxref{Horizontal Scrolling}) is in use in |
163 | a window, that forces truncation. | |
164 | ||
f9f59935 RS |
165 | You can override the glyphs that indicate continuation or truncation |
166 | using the display table; see @ref{Display Tables}. | |
42b85554 | 167 | |
1911e6e5 | 168 | If your buffer contains @emph{very} long lines, and you use |
22697dac | 169 | continuation to display them, just thinking about them can make Emacs |
bfe721d1 KH |
170 | redisplay slow. The column computation and indentation functions also |
171 | become slow. Then you might find it advisable to set | |
172 | @code{cache-long-line-scans} to @code{t}. | |
22697dac KH |
173 | |
174 | @defvar cache-long-line-scans | |
175 | If this variable is non-@code{nil}, various indentation and motion | |
bfe721d1 KH |
176 | functions, and Emacs redisplay, cache the results of scanning the |
177 | buffer, and consult the cache to avoid rescanning regions of the buffer | |
178 | unless they are modified. | |
22697dac | 179 | |
bfe721d1 | 180 | Turning on the cache slows down processing of short lines somewhat. |
22697dac | 181 | |
969fe9b5 | 182 | This variable is automatically buffer-local in every buffer. |
22697dac KH |
183 | @end defvar |
184 | ||
42b85554 RS |
185 | @node The Echo Area |
186 | @section The Echo Area | |
187 | @cindex error display | |
188 | @cindex echo area | |
189 | ||
22697dac | 190 | The @dfn{echo area} is used for displaying messages made with the |
42b85554 RS |
191 | @code{message} primitive, and for echoing keystrokes. It is not the |
192 | same as the minibuffer, despite the fact that the minibuffer appears | |
193 | (when active) in the same place on the screen as the echo area. The | |
194 | @cite{GNU Emacs Manual} specifies the rules for resolving conflicts | |
195 | between the echo area and the minibuffer for use of that screen space | |
196 | (@pxref{Minibuffer,, The Minibuffer, emacs, The GNU Emacs Manual}). | |
197 | Error messages appear in the echo area; see @ref{Errors}. | |
198 | ||
199 | You can write output in the echo area by using the Lisp printing | |
200 | functions with @code{t} as the stream (@pxref{Output Functions}), or as | |
201 | follows: | |
202 | ||
203 | @defun message string &rest arguments | |
a2f2ceaa | 204 | This function displays a message in the echo area. The |
42b85554 RS |
205 | argument @var{string} is similar to a C language @code{printf} control |
206 | string. See @code{format} in @ref{String Conversion}, for the details | |
207 | on the conversion specifications. @code{message} returns the | |
208 | constructed string. | |
209 | ||
b22f3a19 RS |
210 | In batch mode, @code{message} prints the message text on the standard |
211 | error stream, followed by a newline. | |
212 | ||
8241495d RS |
213 | If @var{string}, or strings among the @var{arguments}, have @code{face} |
214 | text properties, these affect the way the message is displayed. | |
215 | ||
42b85554 | 216 | @c Emacs 19 feature |
8241495d RS |
217 | If @var{string} is @code{nil}, @code{message} clears the echo area; if |
218 | the echo area has been expanded automatically, this brings it back to | |
219 | its normal size. If the minibuffer is active, this brings the | |
220 | minibuffer contents back onto the screen immediately. | |
b22f3a19 | 221 | |
a2f2ceaa | 222 | @vindex message-truncate-lines |
caae20c7 RS |
223 | Normally, displaying a long message resizes the echo area to display |
224 | the entire message. But if the variable @code{message-truncate-lines} | |
225 | is non-@code{nil}, the echo area does not resize, and the message is | |
226 | truncated to fit it, as in Emacs 20 and before. | |
a2f2ceaa | 227 | |
42b85554 RS |
228 | @example |
229 | @group | |
230 | (message "Minibuffer depth is %d." | |
231 | (minibuffer-depth)) | |
232 | @print{} Minibuffer depth is 0. | |
233 | @result{} "Minibuffer depth is 0." | |
234 | @end group | |
235 | ||
236 | @group | |
237 | ---------- Echo Area ---------- | |
238 | Minibuffer depth is 0. | |
239 | ---------- Echo Area ---------- | |
240 | @end group | |
241 | @end example | |
a43709e6 MB |
242 | |
243 | To automatically display a message in the echo area or in a pop-buffer, | |
244 | depending on its size, use @code{display-message-or-buffer}. | |
42b85554 RS |
245 | @end defun |
246 | ||
b6954afd RS |
247 | @tindex with-temp-message |
248 | @defmac with-temp-message message &rest body | |
249 | This construct displays a message in the echo area temporarily, during | |
250 | the execution of @var{body}. It displays @var{message}, executes | |
251 | @var{body}, then returns the value of the last body form while restoring | |
252 | the previous echo area contents. | |
253 | @end defmac | |
254 | ||
39d6d9bd RS |
255 | @defun message-or-box string &rest arguments |
256 | This function displays a message like @code{message}, but may display it | |
257 | in a dialog box instead of the echo area. If this function is called in | |
258 | a command that was invoked using the mouse---more precisely, if | |
259 | @code{last-nonmenu-event} (@pxref{Command Loop Info}) is either | |
260 | @code{nil} or a list---then it uses a dialog box or pop-up menu to | |
261 | display the message. Otherwise, it uses the echo area. (This is the | |
262 | same criterion that @code{y-or-n-p} uses to make a similar decision; see | |
263 | @ref{Yes-or-No Queries}.) | |
264 | ||
265 | You can force use of the mouse or of the echo area by binding | |
266 | @code{last-nonmenu-event} to a suitable value around the call. | |
267 | @end defun | |
268 | ||
269 | @defun message-box string &rest arguments | |
270 | This function displays a message like @code{message}, but uses a dialog | |
271 | box (or a pop-up menu) whenever that is possible. If it is impossible | |
272 | to use a dialog box or pop-up menu, because the terminal does not | |
273 | support them, then @code{message-box} uses the echo area, like | |
274 | @code{message}. | |
275 | @end defun | |
276 | ||
a43709e6 | 277 | @defun display-message-or-buffer message &optional buffer-name not-this-window frame |
26f42fed | 278 | @tindex display-message-or-buffer |
a43709e6 MB |
279 | This function displays the message @var{message}, which may be either a |
280 | string or a buffer. If it is shorter than the maximum height of the | |
281 | echo area, as defined by @code{max-mini-window-height}, it is displayed | |
282 | in the echo area, using @code{message}. Otherwise, | |
283 | @code{display-buffer} is used to show it in a pop-up buffer. | |
284 | ||
285 | Returns either the string shown in the echo area, or when a pop-up | |
286 | buffer is used, the window used to display it. | |
287 | ||
288 | If @var{message} is a string, then the optional argument | |
289 | @var{buffer-name} is the name of the buffer used to display it when a | |
290 | pop-up buffer is used, defaulting to @samp{*Message*}. In the case | |
291 | where @var{message} is a string and displayed in the echo area, it is | |
292 | not specified whether the contents are inserted into the buffer anyway. | |
293 | ||
294 | The optional arguments @var{not-this-window} and @var{frame} are as for | |
295 | @code{display-buffer}, and only used if a buffer is displayed. | |
296 | @end defun | |
297 | ||
f9f59935 RS |
298 | @defun current-message |
299 | This function returns the message currently being displayed in the | |
300 | echo area, or @code{nil} if there is none. | |
301 | @end defun | |
302 | ||
969fe9b5 RS |
303 | @defvar cursor-in-echo-area |
304 | This variable controls where the cursor appears when a message is | |
305 | displayed in the echo area. If it is non-@code{nil}, then the cursor | |
306 | appears at the end of the message. Otherwise, the cursor appears at | |
307 | point---not in the echo area at all. | |
308 | ||
309 | The value is normally @code{nil}; Lisp programs bind it to @code{t} | |
310 | for brief periods of time. | |
311 | @end defvar | |
312 | ||
f9f59935 RS |
313 | @defvar echo-area-clear-hook |
314 | This normal hook is run whenever the echo area is cleared---either by | |
315 | @code{(message nil)} or for any other reason. | |
316 | @end defvar | |
317 | ||
22697dac KH |
318 | Almost all the messages displayed in the echo area are also recorded |
319 | in the @samp{*Messages*} buffer. | |
320 | ||
321 | @defopt message-log-max | |
322 | This variable specifies how many lines to keep in the @samp{*Messages*} | |
323 | buffer. The value @code{t} means there is no limit on how many lines to | |
324 | keep. The value @code{nil} disables message logging entirely. Here's | |
325 | how to display a message and prevent it from being logged: | |
326 | ||
327 | @example | |
328 | (let (message-log-max) | |
329 | (message @dots{})) | |
330 | @end example | |
331 | @end defopt | |
332 | ||
bfe721d1 KH |
333 | @defvar echo-keystrokes |
334 | This variable determines how much time should elapse before command | |
65e8b582 DL |
335 | characters echo. Its value must be an integer or floating point number, |
336 | which specifies the | |
bfe721d1 KH |
337 | number of seconds to wait before echoing. If the user types a prefix |
338 | key (such as @kbd{C-x}) and then delays this many seconds before | |
a9f0a989 RS |
339 | continuing, the prefix key is echoed in the echo area. (Once echoing |
340 | begins in a key sequence, all subsequent characters in the same key | |
341 | sequence are echoed immediately.) | |
bfe721d1 KH |
342 | |
343 | If the value is zero, then command input is not echoed. | |
344 | @end defvar | |
345 | ||
8a6ca431 RS |
346 | @node Warnings |
347 | @section Reporting Warnings | |
348 | @cindex warnings | |
349 | ||
350 | @dfn{Warnings} are a facility for a program to inform the user of a | |
351 | possible problem, but continue running. | |
352 | ||
353 | @menu | |
354 | * Warning Basics:: Warnings concepts and functions to report them. | |
355 | * Warning Variables:: Variables programs bind to customize their warnings. | |
356 | * Warning Options:: Variables users set to control display of warnings. | |
357 | @end menu | |
358 | ||
359 | @node Warning Basics | |
360 | @subsection Warning Basics | |
361 | @cindex severity level | |
362 | ||
363 | Every warning has a textual message, which explains the problem for | |
364 | the user, and a @dfn{severity level} which is a symbol. Here are the | |
365 | possible severity levels, in order of decreasing severity, and their | |
366 | meanings: | |
367 | ||
368 | @table @code | |
369 | @item :emergency | |
370 | A problem that will seriously impair Emacs operation soon | |
371 | if you do not attend to it promptly. | |
372 | @item :error | |
373 | A report of data or circumstances that are inherently wrong. | |
374 | @item :warning | |
375 | A report of data or circumstances that are not inherently wrong, but | |
376 | raise suspicion of a possible problem. | |
377 | @item :debug | |
378 | A report of information that may be useful if you are debugging. | |
379 | @end table | |
380 | ||
381 | When your program encounters invalid input data, it can either | |
382 | signal a Lisp error by calling @code{error} or @code{signal} or report | |
383 | a warning with severity @code{:error}. Signaling a Lisp error is the | |
384 | easiest thing to do, but it means the program cannot continue | |
385 | processing. If you want to take the trouble to implement a way to | |
386 | continue processing despite the bad data, then reporting a warning of | |
387 | severity @code{:error} is the right way to inform the user of the | |
388 | problem. For instance, the Emacs Lisp byte compiler can report an | |
389 | error that way and continue compiling other functions. (If the | |
390 | program signals a Lisp error and then handles it with | |
391 | @code{condition-case}, the user won't see the error message; it could | |
392 | show the message to the user by reporting it as a warning.) | |
393 | ||
c00d3ba4 | 394 | @cindex warning type |
8a6ca431 RS |
395 | Each warning has a @dfn{warning type} to classify it. The type is a |
396 | list of symbols. The first symbol should be the custom group that you | |
397 | use for the program's user options. For example, byte compiler | |
398 | warnings use the warning type @code{(bytecomp)}. You can also | |
399 | subcategorize the warnings, if you wish, by using more symbols in the | |
400 | list. | |
401 | ||
402 | @defun display-warning type message &optional level buffer-name | |
403 | This function reports a warning, using @var{message} as the message | |
404 | and @var{type} as the warning type. @var{level} should be the | |
405 | severity level, with @code{:warning} being the default. | |
406 | ||
407 | @var{buffer-name}, if non-@code{nil}, specifies the name of the buffer | |
408 | for logging the warning. By default, it is @samp{*Warnings*}. | |
409 | @end defun | |
410 | ||
411 | @defun lwarn type level message &rest args | |
412 | This function reports a warning using the value of @code{(format | |
413 | @var{message} @var{args}...)} as the message. In other respects it is | |
414 | equivalent to @code{display-warning}. | |
415 | @end defun | |
416 | ||
417 | @defun warn message &rest args | |
418 | This function reports a warning using the value of @code{(format | |
419 | @var{message} @var{args}...)} as the message, @code{(emacs)} as the | |
420 | type, and @code{:warning} as the severity level. It exists for | |
421 | compatibility only; we recommend not using it, because you should | |
422 | specify a specific warning type. | |
423 | @end defun | |
424 | ||
425 | @node Warning Variables | |
426 | @subsection Warning Variables | |
427 | ||
428 | Programs can customize how their warnings appear by binding | |
429 | the variables described in this section. | |
430 | ||
431 | @defvar warning-levels | |
432 | This list defines the meaning and severity order of the warning | |
433 | severity levels. Each element defines one severity level, | |
434 | and they are arranged in order of decreasing severity. | |
435 | ||
436 | Each element has the form @code{(@var{level} @var{string} | |
437 | @var{function})}, where @var{level} is the severity level it defines. | |
438 | @var{string} specifies the textual description of this level. | |
439 | @var{string} should use @samp{%s} to specify where to put the warning | |
440 | type information, or it can omit the @samp{%s} so as not to include | |
441 | that information. | |
442 | ||
443 | The optional @var{function}, if non-@code{nil}, is a function to call | |
444 | with no arguments, to get the user's attention. | |
445 | ||
446 | Normally you should not change the value of this variable. | |
447 | @end defvar | |
448 | ||
449 | @defvar warning-prefix-function | |
812a2341 | 450 | If non-@code{nil}, the value is a function to generate prefix text for |
8a6ca431 RS |
451 | warnings. Programs can bind the variable to a suitable function. |
452 | @code{display-warning} calls this function with the warnings buffer | |
453 | current, and the function can insert text in it. That text becomes | |
454 | the beginning of the warning message. | |
455 | ||
456 | The function is called with two arguments, the severity level and its | |
457 | entry in @code{warning-levels}. It should return a list to use as the | |
458 | entry (this value need not be an actual member of | |
812a2341 | 459 | @code{warning-levels}). By constructing this value, the function can |
8a6ca431 RS |
460 | change the severity of the warning, or specify different handling for |
461 | a given severity level. | |
462 | ||
463 | If the variable's value is @code{nil} then there is no function | |
464 | to call. | |
465 | @end defvar | |
466 | ||
467 | @defvar warning-series | |
468 | Programs can bind this variable to @code{t} to say that the next | |
469 | warning should begin a series. When several warnings form a series, | |
470 | that means to leave point on the first warning of the series, rather | |
812a2341 | 471 | than keep moving it for each warning so that it appears on the last one. |
8a6ca431 RS |
472 | The series ends when the local binding is unbound and |
473 | @code{warning-series} becomes @code{nil} again. | |
474 | ||
475 | The value can also be a symbol with a function definition. That is | |
476 | equivalent to @code{t}, except that the next warning will also call | |
477 | the function with no arguments with the warnings buffer current. The | |
478 | function can insert text which will serve as a header for the series | |
479 | of warnings. | |
480 | ||
481 | Once a series has begun, the value is a marker which points to the | |
482 | buffer position in the warnings buffer of the start of the series. | |
483 | ||
484 | The variable's normal value is @code{nil}, which means to handle | |
485 | each warning separately. | |
486 | @end defvar | |
487 | ||
488 | @defvar warning-fill-prefix | |
489 | When this variable is non-@code{nil}, it specifies a fill prefix to | |
490 | use for filling each warning's text. | |
491 | @end defvar | |
492 | ||
493 | @defvar warning-type-format | |
494 | This variable specifies the format for displaying the warning type | |
495 | in the warning message. The result of formatting the type this way | |
496 | gets included in the message under the control of the string in the | |
497 | entry in @code{warning-levels}. The default value is @code{" (%s)"}. | |
498 | If you bind it to @code{""} then the warning type won't appear at | |
499 | all. | |
500 | @end defvar | |
501 | ||
502 | @node Warning Options | |
503 | @subsection Warning Options | |
504 | ||
505 | These variables are used by users to control what happens | |
506 | when a Lisp program reports a warning. | |
507 | ||
508 | @defopt warning-minimum-level | |
509 | This user option specifies the minimum severity level that should be | |
510 | shown immediately to the user. The default is @code{:warning}, which | |
511 | means to immediately display all warnings except @code{:debug} | |
512 | warnings. | |
513 | @end defopt | |
514 | ||
515 | @defopt warning-minimum-log-level | |
516 | This user option specifies the minimum severity level that should be | |
517 | logged in the warnings buffer. The default is @code{:warning}, which | |
518 | means to log all warnings except @code{:debug} warnings. | |
519 | @end defopt | |
520 | ||
521 | @defopt warning-suppress-types | |
522 | This list specifies which warning types should not be displayed | |
523 | immediately for the user. Each element of the list should be a list | |
524 | of symbols. If its elements match the first elements in a warning | |
525 | type, then that warning is not displayed immediately. | |
526 | @end defopt | |
527 | ||
528 | @defopt warning-suppress-log-types | |
529 | This list specifies which warning types should not be logged in the | |
530 | warnings buffer. Each element of the list should be a list of | |
531 | symbols. If it matches the first few elements in a warning type, then | |
532 | that warning is not logged. | |
533 | @end defopt | |
00b3c1cd | 534 | |
22697dac KH |
535 | @node Invisible Text |
536 | @section Invisible Text | |
537 | ||
538 | @cindex invisible text | |
539 | You can make characters @dfn{invisible}, so that they do not appear on | |
540 | the screen, with the @code{invisible} property. This can be either a | |
a9f0a989 RS |
541 | text property (@pxref{Text Properties}) or a property of an overlay |
542 | (@pxref{Overlays}). | |
22697dac KH |
543 | |
544 | In the simplest case, any non-@code{nil} @code{invisible} property makes | |
545 | a character invisible. This is the default case---if you don't alter | |
546 | the default value of @code{buffer-invisibility-spec}, this is how the | |
31b0520f RS |
547 | @code{invisible} property works. You should normally use @code{t} |
548 | as the value of the @code{invisible} property if you don't plan | |
549 | to set @code{buffer-invisibility-spec} yourself. | |
22697dac KH |
550 | |
551 | More generally, you can use the variable @code{buffer-invisibility-spec} | |
552 | to control which values of the @code{invisible} property make text | |
553 | invisible. This permits you to classify the text into different subsets | |
554 | in advance, by giving them different @code{invisible} values, and | |
555 | subsequently make various subsets visible or invisible by changing the | |
556 | value of @code{buffer-invisibility-spec}. | |
557 | ||
558 | Controlling visibility with @code{buffer-invisibility-spec} is | |
a40d4712 PR |
559 | especially useful in a program to display the list of entries in a |
560 | database. It permits the implementation of convenient filtering | |
561 | commands to view just a part of the entries in the database. Setting | |
562 | this variable is very fast, much faster than scanning all the text in | |
563 | the buffer looking for properties to change. | |
22697dac KH |
564 | |
565 | @defvar buffer-invisibility-spec | |
566 | This variable specifies which kinds of @code{invisible} properties | |
658f691f RS |
567 | actually make a character invisible. Setting this variable makes it |
568 | buffer-local. | |
22697dac KH |
569 | |
570 | @table @asis | |
571 | @item @code{t} | |
572 | A character is invisible if its @code{invisible} property is | |
573 | non-@code{nil}. This is the default. | |
574 | ||
575 | @item a list | |
969fe9b5 RS |
576 | Each element of the list specifies a criterion for invisibility; if a |
577 | character's @code{invisible} property fits any one of these criteria, | |
578 | the character is invisible. The list can have two kinds of elements: | |
22697dac KH |
579 | |
580 | @table @code | |
581 | @item @var{atom} | |
969fe9b5 | 582 | A character is invisible if its @code{invisible} property value |
22697dac KH |
583 | is @var{atom} or if it is a list with @var{atom} as a member. |
584 | ||
585 | @item (@var{atom} . t) | |
969fe9b5 | 586 | A character is invisible if its @code{invisible} property value |
22697dac KH |
587 | is @var{atom} or if it is a list with @var{atom} as a member. |
588 | Moreover, if this character is at the end of a line and is followed | |
589 | by a visible newline, it displays an ellipsis. | |
590 | @end table | |
591 | @end table | |
592 | @end defvar | |
593 | ||
f9f59935 RS |
594 | Two functions are specifically provided for adding elements to |
595 | @code{buffer-invisibility-spec} and removing elements from it. | |
596 | ||
f9f59935 | 597 | @defun add-to-invisibility-spec element |
31b0520f RS |
598 | This function adds the element @var{element} to |
599 | @code{buffer-invisibility-spec} (if it is not already present in that | |
600 | list). If @code{buffer-invisibility-spec} was @code{t}, it changes to | |
601 | a list, @code{(t)}, so that text whose @code{invisible} property | |
602 | is @code{t} remains invisible. | |
f9f59935 RS |
603 | @end defun |
604 | ||
f9f59935 | 605 | @defun remove-from-invisibility-spec element |
812a2341 | 606 | This removes the element @var{element} from |
31b0520f RS |
607 | @code{buffer-invisibility-spec}. This does nothing if @var{element} |
608 | is not in the list. | |
f9f59935 RS |
609 | @end defun |
610 | ||
31b0520f RS |
611 | A convention for use of @code{buffer-invisibility-spec} is that a |
612 | major mode should use the mode's own name as an element of | |
613 | @code{buffer-invisibility-spec} and as the value of the | |
614 | @code{invisible} property: | |
f9f59935 RS |
615 | |
616 | @example | |
969fe9b5 | 617 | ;; @r{If you want to display an ellipsis:} |
177c0ea7 | 618 | (add-to-invisibility-spec '(my-symbol . t)) |
969fe9b5 | 619 | ;; @r{If you don't want ellipsis:} |
177c0ea7 | 620 | (add-to-invisibility-spec 'my-symbol) |
f9f59935 RS |
621 | |
622 | (overlay-put (make-overlay beginning end) | |
623 | 'invisible 'my-symbol) | |
624 | ||
969fe9b5 | 625 | ;; @r{When done with the overlays:} |
f9f59935 | 626 | (remove-from-invisibility-spec '(my-symbol . t)) |
969fe9b5 | 627 | ;; @r{Or respectively:} |
f9f59935 RS |
628 | (remove-from-invisibility-spec 'my-symbol) |
629 | @end example | |
630 | ||
5e8ae792 | 631 | @vindex line-move-ignore-invisible |
00b3c1cd | 632 | Ordinarily, functions that operate on text or move point do not care |
5e8ae792 RS |
633 | whether the text is invisible. The user-level line motion commands |
634 | explicitly ignore invisible newlines if | |
635 | @code{line-move-ignore-invisible} is non-@code{nil}, but only because | |
636 | they are explicitly programmed to do so. | |
bfe721d1 | 637 | |
00b3c1cd RS |
638 | However, if a command ends with point inside or immediately after |
639 | invisible text, the main editing loop moves point further forward or | |
640 | further backward (in the same direction that the command already moved | |
641 | it) until that condition is no longer true. Thus, if the command | |
642 | moved point back into an invisible range, Emacs moves point back to | |
643 | the beginning of that range, following the previous visible character. | |
644 | If the command moved point forward into an invisible range, Emacs | |
645 | moves point forward past the first visible character that follows the | |
646 | invisible text. | |
647 | ||
f9f59935 RS |
648 | Incremental search can make invisible overlays visible temporarily |
649 | and/or permanently when a match includes invisible text. To enable | |
650 | this, the overlay should have a non-@code{nil} | |
651 | @code{isearch-open-invisible} property. The property value should be a | |
652 | function to be called with the overlay as an argument. This function | |
653 | should make the overlay visible permanently; it is used when the match | |
654 | overlaps the overlay on exit from the search. | |
655 | ||
656 | During the search, such overlays are made temporarily visible by | |
657 | temporarily modifying their invisible and intangible properties. If you | |
ebc6903b | 658 | want this to be done differently for a certain overlay, give it an |
f9f59935 RS |
659 | @code{isearch-open-invisible-temporary} property which is a function. |
660 | The function is called with two arguments: the first is the overlay, and | |
f21b06b7 | 661 | the second is @code{nil} to make the overlay visible, or @code{t} to |
a9f0a989 | 662 | make it invisible again. |
f9f59935 | 663 | |
42b85554 RS |
664 | @node Selective Display |
665 | @section Selective Display | |
666 | @cindex selective display | |
667 | ||
969fe9b5 RS |
668 | @dfn{Selective display} refers to a pair of related features for |
669 | hiding certain lines on the screen. | |
42b85554 RS |
670 | |
671 | The first variant, explicit selective display, is designed for use in | |
969fe9b5 RS |
672 | a Lisp program: it controls which lines are hidden by altering the text. |
673 | The invisible text feature (@pxref{Invisible Text}) has partially | |
674 | replaced this feature. | |
22697dac KH |
675 | |
676 | In the second variant, the choice of lines to hide is made | |
bfe721d1 | 677 | automatically based on indentation. This variant is designed to be a |
22697dac | 678 | user-level feature. |
42b85554 RS |
679 | |
680 | The way you control explicit selective display is by replacing a | |
78608595 | 681 | newline (control-j) with a carriage return (control-m). The text that |
42b85554 RS |
682 | was formerly a line following that newline is now invisible. Strictly |
683 | speaking, it is temporarily no longer a line at all, since only newlines | |
684 | can separate lines; it is now part of the previous line. | |
685 | ||
686 | Selective display does not directly affect editing commands. For | |
687 | example, @kbd{C-f} (@code{forward-char}) moves point unhesitatingly into | |
688 | invisible text. However, the replacement of newline characters with | |
689 | carriage return characters affects some editing commands. For example, | |
690 | @code{next-line} skips invisible lines, since it searches only for | |
691 | newlines. Modes that use selective display can also define commands | |
692 | that take account of the newlines, or that make parts of the text | |
693 | visible or invisible. | |
694 | ||
695 | When you write a selectively displayed buffer into a file, all the | |
696 | control-m's are output as newlines. This means that when you next read | |
697 | in the file, it looks OK, with nothing invisible. The selective display | |
698 | effect is seen only within Emacs. | |
699 | ||
700 | @defvar selective-display | |
701 | This buffer-local variable enables selective display. This means that | |
177c0ea7 | 702 | lines, or portions of lines, may be made invisible. |
42b85554 RS |
703 | |
704 | @itemize @bullet | |
705 | @item | |
a40d4712 PR |
706 | If the value of @code{selective-display} is @code{t}, then the character |
707 | control-m marks the start of invisible text; the control-m, and the rest | |
708 | of the line following it, are not displayed. This is explicit selective | |
709 | display. | |
42b85554 RS |
710 | |
711 | @item | |
712 | If the value of @code{selective-display} is a positive integer, then | |
713 | lines that start with more than that many columns of indentation are not | |
714 | displayed. | |
715 | @end itemize | |
716 | ||
717 | When some portion of a buffer is invisible, the vertical movement | |
718 | commands operate as if that portion did not exist, allowing a single | |
719 | @code{next-line} command to skip any number of invisible lines. | |
720 | However, character movement commands (such as @code{forward-char}) do | |
721 | not skip the invisible portion, and it is possible (if tricky) to insert | |
722 | or delete text in an invisible portion. | |
723 | ||
724 | In the examples below, we show the @emph{display appearance} of the | |
725 | buffer @code{foo}, which changes with the value of | |
726 | @code{selective-display}. The @emph{contents} of the buffer do not | |
727 | change. | |
728 | ||
729 | @example | |
730 | @group | |
731 | (setq selective-display nil) | |
732 | @result{} nil | |
733 | ||
734 | ---------- Buffer: foo ---------- | |
735 | 1 on this column | |
736 | 2on this column | |
737 | 3n this column | |
738 | 3n this column | |
739 | 2on this column | |
740 | 1 on this column | |
741 | ---------- Buffer: foo ---------- | |
742 | @end group | |
743 | ||
744 | @group | |
745 | (setq selective-display 2) | |
746 | @result{} 2 | |
747 | ||
748 | ---------- Buffer: foo ---------- | |
749 | 1 on this column | |
750 | 2on this column | |
751 | 2on this column | |
752 | 1 on this column | |
753 | ---------- Buffer: foo ---------- | |
754 | @end group | |
755 | @end example | |
756 | @end defvar | |
757 | ||
758 | @defvar selective-display-ellipses | |
759 | If this buffer-local variable is non-@code{nil}, then Emacs displays | |
760 | @samp{@dots{}} at the end of a line that is followed by invisible text. | |
761 | This example is a continuation of the previous one. | |
762 | ||
763 | @example | |
764 | @group | |
765 | (setq selective-display-ellipses t) | |
766 | @result{} t | |
767 | ||
768 | ---------- Buffer: foo ---------- | |
769 | 1 on this column | |
770 | 2on this column ... | |
771 | 2on this column | |
772 | 1 on this column | |
773 | ---------- Buffer: foo ---------- | |
774 | @end group | |
775 | @end example | |
776 | ||
777 | You can use a display table to substitute other text for the ellipsis | |
778 | (@samp{@dots{}}). @xref{Display Tables}. | |
779 | @end defvar | |
780 | ||
781 | @node Overlay Arrow | |
782 | @section The Overlay Arrow | |
783 | @cindex overlay arrow | |
784 | ||
785 | The @dfn{overlay arrow} is useful for directing the user's attention | |
786 | to a particular line in a buffer. For example, in the modes used for | |
787 | interface to debuggers, the overlay arrow indicates the line of code | |
788 | about to be executed. | |
789 | ||
790 | @defvar overlay-arrow-string | |
78608595 RS |
791 | This variable holds the string to display to call attention to a |
792 | particular line, or @code{nil} if the arrow feature is not in use. | |
bb2337f5 DL |
793 | On a graphical display the contents of the string are ignored; instead a |
794 | glyph is displayed in the fringe area to the left of the display area. | |
42b85554 RS |
795 | @end defvar |
796 | ||
797 | @defvar overlay-arrow-position | |
78608595 | 798 | This variable holds a marker that indicates where to display the overlay |
bb2337f5 DL |
799 | arrow. It should point at the beginning of a line. On a non-graphical |
800 | display the arrow text | |
78608595 RS |
801 | appears at the beginning of that line, overlaying any text that would |
802 | otherwise appear. Since the arrow is usually short, and the line | |
803 | usually begins with indentation, normally nothing significant is | |
804 | overwritten. | |
805 | ||
806 | The overlay string is displayed only in the buffer that this marker | |
42b85554 RS |
807 | points into. Thus, only one buffer can have an overlay arrow at any |
808 | given time. | |
809 | @c !!! overlay-arrow-position: but the overlay string may remain in the display | |
810 | @c of some other buffer until an update is required. This should be fixed | |
811 | @c now. Is it? | |
812 | @end defvar | |
813 | ||
969fe9b5 | 814 | You can do a similar job by creating an overlay with a |
22697dac KH |
815 | @code{before-string} property. @xref{Overlay Properties}. |
816 | ||
42b85554 RS |
817 | @node Temporary Displays |
818 | @section Temporary Displays | |
819 | ||
969fe9b5 RS |
820 | Temporary displays are used by Lisp programs to put output into a |
821 | buffer and then present it to the user for perusal rather than for | |
822 | editing. Many help commands use this feature. | |
42b85554 RS |
823 | |
824 | @defspec with-output-to-temp-buffer buffer-name forms@dots{} | |
b6954afd RS |
825 | This function executes @var{forms} while arranging to insert any output |
826 | they print into the buffer named @var{buffer-name}, which is first | |
827 | created if necessary, and put into Help mode. Finally, the buffer is | |
828 | displayed in some window, but not selected. | |
829 | ||
d7cd58d7 LT |
830 | If the @var{forms} do not change the major mode in the output buffer, |
831 | so that it is still Help mode at the end of their execution, then | |
b6954afd | 832 | @code{with-output-to-temp-buffer} makes this buffer read-only at the |
d7cd58d7 | 833 | end, and also scans it for function and variable names to make them |
68e74f25 LT |
834 | into clickable cross-references. @xref{Docstring hyperlinks, , Tips |
835 | for Documentation Strings}, in particular the item on hyperlinks in | |
836 | documentation strings, for more details. | |
42b85554 RS |
837 | |
838 | The string @var{buffer-name} specifies the temporary buffer, which | |
839 | need not already exist. The argument must be a string, not a buffer. | |
840 | The buffer is erased initially (with no questions asked), and it is | |
841 | marked as unmodified after @code{with-output-to-temp-buffer} exits. | |
842 | ||
843 | @code{with-output-to-temp-buffer} binds @code{standard-output} to the | |
844 | temporary buffer, then it evaluates the forms in @var{forms}. Output | |
845 | using the Lisp output functions within @var{forms} goes by default to | |
846 | that buffer (but screen display and messages in the echo area, although | |
847 | they are ``output'' in the general sense of the word, are not affected). | |
848 | @xref{Output Functions}. | |
849 | ||
b6954afd RS |
850 | Several hooks are available for customizing the behavior |
851 | of this construct; they are listed below. | |
852 | ||
42b85554 RS |
853 | The value of the last form in @var{forms} is returned. |
854 | ||
855 | @example | |
856 | @group | |
857 | ---------- Buffer: foo ---------- | |
858 | This is the contents of foo. | |
859 | ---------- Buffer: foo ---------- | |
860 | @end group | |
861 | ||
862 | @group | |
863 | (with-output-to-temp-buffer "foo" | |
864 | (print 20) | |
865 | (print standard-output)) | |
866 | @result{} #<buffer foo> | |
867 | ||
868 | ---------- Buffer: foo ---------- | |
869 | 20 | |
870 | ||
871 | #<buffer foo> | |
872 | ||
873 | ---------- Buffer: foo ---------- | |
874 | @end group | |
875 | @end example | |
876 | @end defspec | |
877 | ||
878 | @defvar temp-buffer-show-function | |
78608595 | 879 | If this variable is non-@code{nil}, @code{with-output-to-temp-buffer} |
42b85554 RS |
880 | calls it as a function to do the job of displaying a help buffer. The |
881 | function gets one argument, which is the buffer it should display. | |
a9f0a989 RS |
882 | |
883 | It is a good idea for this function to run @code{temp-buffer-show-hook} | |
884 | just as @code{with-output-to-temp-buffer} normally would, inside of | |
b6954afd | 885 | @code{save-selected-window} and with the chosen window and buffer |
a9f0a989 RS |
886 | selected. |
887 | @end defvar | |
888 | ||
b6954afd RS |
889 | @defvar temp-buffer-setup-hook |
890 | @tindex temp-buffer-setup-hook | |
891 | This normal hook is run by @code{with-output-to-temp-buffer} before | |
13a8e917 RS |
892 | evaluating @var{body}. When the hook runs, the temporary buffer is |
893 | current. This hook is normally set up with a function to put the | |
894 | buffer in Help mode. | |
b6954afd RS |
895 | @end defvar |
896 | ||
a9f0a989 RS |
897 | @defvar temp-buffer-show-hook |
898 | This normal hook is run by @code{with-output-to-temp-buffer} after | |
13a8e917 RS |
899 | displaying the temporary buffer. When the hook runs, the temporary buffer |
900 | is current, and the window it was displayed in is selected. This hook | |
901 | is normally set up with a function to make the buffer read only, and | |
902 | find function names and variable names in it, provided the major mode | |
903 | is Help mode. | |
42b85554 RS |
904 | @end defvar |
905 | ||
906 | @defun momentary-string-display string position &optional char message | |
907 | This function momentarily displays @var{string} in the current buffer at | |
908 | @var{position}. It has no effect on the undo list or on the buffer's | |
909 | modification status. | |
910 | ||
911 | The momentary display remains until the next input event. If the next | |
912 | input event is @var{char}, @code{momentary-string-display} ignores it | |
913 | and returns. Otherwise, that event remains buffered for subsequent use | |
914 | as input. Thus, typing @var{char} will simply remove the string from | |
915 | the display, while typing (say) @kbd{C-f} will remove the string from | |
916 | the display and later (presumably) move point forward. The argument | |
917 | @var{char} is a space by default. | |
918 | ||
919 | The return value of @code{momentary-string-display} is not meaningful. | |
920 | ||
bfe721d1 | 921 | If the string @var{string} does not contain control characters, you can |
969fe9b5 RS |
922 | do the same job in a more general way by creating (and then subsequently |
923 | deleting) an overlay with a @code{before-string} property. | |
924 | @xref{Overlay Properties}. | |
bfe721d1 | 925 | |
42b85554 RS |
926 | If @var{message} is non-@code{nil}, it is displayed in the echo area |
927 | while @var{string} is displayed in the buffer. If it is @code{nil}, a | |
928 | default message says to type @var{char} to continue. | |
929 | ||
930 | In this example, point is initially located at the beginning of the | |
931 | second line: | |
932 | ||
933 | @example | |
934 | @group | |
935 | ---------- Buffer: foo ---------- | |
936 | This is the contents of foo. | |
937 | @point{}Second line. | |
938 | ---------- Buffer: foo ---------- | |
939 | @end group | |
940 | ||
941 | @group | |
942 | (momentary-string-display | |
943 | "**** Important Message! ****" | |
944 | (point) ?\r | |
945 | "Type RET when done reading") | |
946 | @result{} t | |
947 | @end group | |
948 | ||
949 | @group | |
950 | ---------- Buffer: foo ---------- | |
951 | This is the contents of foo. | |
952 | **** Important Message! ****Second line. | |
953 | ---------- Buffer: foo ---------- | |
954 | ||
955 | ---------- Echo Area ---------- | |
956 | Type RET when done reading | |
957 | ---------- Echo Area ---------- | |
958 | @end group | |
959 | @end example | |
960 | @end defun | |
961 | ||
962 | @node Overlays | |
963 | @section Overlays | |
964 | @cindex overlays | |
965 | ||
966 | You can use @dfn{overlays} to alter the appearance of a buffer's text on | |
bfe721d1 KH |
967 | the screen, for the sake of presentation features. An overlay is an |
968 | object that belongs to a particular buffer, and has a specified | |
969 | beginning and end. It also has properties that you can examine and set; | |
970 | these affect the display of the text within the overlay. | |
42b85554 | 971 | |
812a2341 RS |
972 | An overlays uses markers to record its beginning and end; thus, |
973 | editing the text of the buffer adjusts the beginning and end of each | |
974 | overlay so that it stays with the text. When you create the overlay, | |
975 | you can specify whether text inserted at the beginning should be | |
976 | inside the overlay or outside, and likewise for the end of the overlay. | |
977 | ||
42b85554 | 978 | @menu |
02c77ee9 | 979 | * Overlay Properties:: How to read and set properties. |
42b85554 | 980 | What properties do to the screen display. |
eda77a0f DL |
981 | * Managing Overlays:: Creating and moving overlays. |
982 | * Finding Overlays:: Searching for overlays. | |
42b85554 RS |
983 | @end menu |
984 | ||
985 | @node Overlay Properties | |
986 | @subsection Overlay Properties | |
987 | ||
8241495d | 988 | Overlay properties are like text properties in that the properties that |
a9f0a989 RS |
989 | alter how a character is displayed can come from either source. But in |
990 | most respects they are different. Text properties are considered a part | |
991 | of the text; overlays are specifically considered not to be part of the | |
992 | text. Thus, copying text between various buffers and strings preserves | |
993 | text properties, but does not try to preserve overlays. Changing a | |
994 | buffer's text properties marks the buffer as modified, while moving an | |
995 | overlay or changing its properties does not. Unlike text property | |
996 | changes, overlay changes are not recorded in the buffer's undo list. | |
997 | @xref{Text Properties}, for comparison. | |
42b85554 | 998 | |
8241495d RS |
999 | These functions are used for reading and writing the properties of an |
1000 | overlay: | |
1001 | ||
1002 | @defun overlay-get overlay prop | |
1003 | This function returns the value of property @var{prop} recorded in | |
1004 | @var{overlay}, if any. If @var{overlay} does not record any value for | |
1005 | that property, but it does have a @code{category} property which is a | |
1006 | symbol, that symbol's @var{prop} property is used. Otherwise, the value | |
1007 | is @code{nil}. | |
1008 | @end defun | |
1009 | ||
1010 | @defun overlay-put overlay prop value | |
1011 | This function sets the value of property @var{prop} recorded in | |
1012 | @var{overlay} to @var{value}. It returns @var{value}. | |
00b3c1cd RS |
1013 | @end defun |
1014 | ||
1015 | @defun overlay-properties overlay | |
1016 | This returns a copy of the property list of @var{overlay}. | |
8241495d RS |
1017 | @end defun |
1018 | ||
1019 | See also the function @code{get-char-property} which checks both | |
1020 | overlay properties and text properties for a given character. | |
1021 | @xref{Examining Properties}. | |
1022 | ||
1023 | Many overlay properties have special meanings; here is a table | |
1024 | of them: | |
1025 | ||
42b85554 RS |
1026 | @table @code |
1027 | @item priority | |
1028 | @kindex priority @r{(overlay property)} | |
f1579f52 RS |
1029 | This property's value (which should be a nonnegative integer number) |
1030 | determines the priority of the overlay. The priority matters when two | |
1031 | or more overlays cover the same character and both specify the same | |
1032 | property; the one whose @code{priority} value is larger takes priority | |
1033 | over the other. For the @code{face} property, the higher priority | |
1034 | value does not completely replace the other; instead, its face | |
1035 | attributes override the face attributes of the lower priority | |
1036 | @code{face} property. | |
42b85554 RS |
1037 | |
1038 | Currently, all overlays take priority over text properties. Please | |
1039 | avoid using negative priority values, as we have not yet decided just | |
1040 | what they should mean. | |
1041 | ||
1042 | @item window | |
1043 | @kindex window @r{(overlay property)} | |
1044 | If the @code{window} property is non-@code{nil}, then the overlay | |
1045 | applies only on that window. | |
1046 | ||
22697dac KH |
1047 | @item category |
1048 | @kindex category @r{(overlay property)} | |
1049 | If an overlay has a @code{category} property, we call it the | |
bfe721d1 | 1050 | @dfn{category} of the overlay. It should be a symbol. The properties |
22697dac KH |
1051 | of the symbol serve as defaults for the properties of the overlay. |
1052 | ||
42b85554 RS |
1053 | @item face |
1054 | @kindex face @r{(overlay property)} | |
f9f59935 | 1055 | This property controls the way text is displayed---for example, which |
8241495d | 1056 | font and which colors. @xref{Faces}, for more information. |
f9f59935 | 1057 | |
8241495d | 1058 | In the simplest case, the value is a face name. It can also be a list; |
a40d4712 | 1059 | then each element can be any of these possibilities: |
8241495d RS |
1060 | |
1061 | @itemize @bullet | |
1062 | @item | |
1063 | A face name (a symbol or string). | |
1064 | ||
1065 | @item | |
1066 | Starting in Emacs 21, a property list of face attributes. This has the | |
1067 | form (@var{keyword} @var{value} @dots{}), where each @var{keyword} is a | |
1068 | face attribute name and @var{value} is a meaningful value for that | |
1069 | attribute. With this feature, you do not need to create a face each | |
1070 | time you want to specify a particular attribute for certain text. | |
1071 | @xref{Face Attributes}. | |
1072 | ||
1073 | @item | |
1074 | A cons cell of the form @code{(foreground-color . @var{color-name})} or | |
1075 | @code{(background-color . @var{color-name})}. These elements specify | |
1076 | just the foreground color or just the background color. | |
1077 | ||
1078 | @code{(foreground-color . @var{color-name})} is equivalent to | |
1079 | @code{(:foreground @var{color-name})}, and likewise for the background. | |
1080 | @end itemize | |
42b85554 RS |
1081 | |
1082 | @item mouse-face | |
1083 | @kindex mouse-face @r{(overlay property)} | |
1084 | This property is used instead of @code{face} when the mouse is within | |
f9f59935 | 1085 | the range of the overlay. |
42b85554 | 1086 | |
8241495d RS |
1087 | @item display |
1088 | @kindex display @r{(overlay property)} | |
1089 | This property activates various features that change the | |
1090 | way text is displayed. For example, it can make text appear taller | |
24eb6c0e | 1091 | or shorter, higher or lower, wider or narrower, or replaced with an image. |
8241495d RS |
1092 | @xref{Display Property}. |
1093 | ||
1094 | @item help-echo | |
1095 | @kindex help-echo @r{(text property)} | |
e3b9fc91 DL |
1096 | If an overlay has a @code{help-echo} property, then when you move the |
1097 | mouse onto the text in the overlay, Emacs displays a help string in the | |
1098 | echo area, or in the tooltip window. For details see @ref{Text | |
2e46cd09 | 1099 | help-echo}. |
8241495d | 1100 | |
42b85554 RS |
1101 | @item modification-hooks |
1102 | @kindex modification-hooks @r{(overlay property)} | |
1103 | This property's value is a list of functions to be called if any | |
1104 | character within the overlay is changed or if text is inserted strictly | |
22697dac KH |
1105 | within the overlay. |
1106 | ||
1107 | The hook functions are called both before and after each change. | |
1108 | If the functions save the information they receive, and compare notes | |
1109 | between calls, they can determine exactly what change has been made | |
1110 | in the buffer text. | |
1111 | ||
1112 | When called before a change, each function receives four arguments: the | |
1113 | overlay, @code{nil}, and the beginning and end of the text range to be | |
a890e1b0 | 1114 | modified. |
42b85554 | 1115 | |
22697dac KH |
1116 | When called after a change, each function receives five arguments: the |
1117 | overlay, @code{t}, the beginning and end of the text range just | |
1118 | modified, and the length of the pre-change text replaced by that range. | |
1119 | (For an insertion, the pre-change length is zero; for a deletion, that | |
1120 | length is the number of characters deleted, and the post-change | |
bfe721d1 | 1121 | beginning and end are equal.) |
22697dac | 1122 | |
42b85554 RS |
1123 | @item insert-in-front-hooks |
1124 | @kindex insert-in-front-hooks @r{(overlay property)} | |
22697dac KH |
1125 | This property's value is a list of functions to be called before and |
1126 | after inserting text right at the beginning of the overlay. The calling | |
1127 | conventions are the same as for the @code{modification-hooks} functions. | |
42b85554 RS |
1128 | |
1129 | @item insert-behind-hooks | |
1130 | @kindex insert-behind-hooks @r{(overlay property)} | |
22697dac KH |
1131 | This property's value is a list of functions to be called before and |
1132 | after inserting text right at the end of the overlay. The calling | |
1133 | conventions are the same as for the @code{modification-hooks} functions. | |
42b85554 RS |
1134 | |
1135 | @item invisible | |
1136 | @kindex invisible @r{(overlay property)} | |
22697dac KH |
1137 | The @code{invisible} property can make the text in the overlay |
1138 | invisible, which means that it does not appear on the screen. | |
1139 | @xref{Invisible Text}, for details. | |
1140 | ||
1141 | @item intangible | |
1142 | @kindex intangible @r{(overlay property)} | |
1143 | The @code{intangible} property on an overlay works just like the | |
bfe721d1 | 1144 | @code{intangible} text property. @xref{Special Properties}, for details. |
f9f59935 RS |
1145 | |
1146 | @item isearch-open-invisible | |
a9f0a989 RS |
1147 | This property tells incremental search how to make an invisible overlay |
1148 | visible, permanently, if the final match overlaps it. @xref{Invisible | |
f9f59935 | 1149 | Text}. |
42b85554 | 1150 | |
a9f0a989 RS |
1151 | @item isearch-open-invisible-temporary |
1152 | This property tells incremental search how to make an invisible overlay | |
1153 | visible, temporarily, during the search. @xref{Invisible Text}. | |
1154 | ||
42b85554 RS |
1155 | @item before-string |
1156 | @kindex before-string @r{(overlay property)} | |
1157 | This property's value is a string to add to the display at the beginning | |
1158 | of the overlay. The string does not appear in the buffer in any | |
a40d4712 | 1159 | sense---only on the screen. |
42b85554 RS |
1160 | |
1161 | @item after-string | |
1162 | @kindex after-string @r{(overlay property)} | |
1163 | This property's value is a string to add to the display at the end of | |
1164 | the overlay. The string does not appear in the buffer in any | |
a40d4712 | 1165 | sense---only on the screen. |
22697dac KH |
1166 | |
1167 | @item evaporate | |
1168 | @kindex evaporate @r{(overlay property)} | |
1169 | If this property is non-@code{nil}, the overlay is deleted automatically | |
11cd6064 RS |
1170 | if it becomes empty (i.e., if its length becomes zero). If you give |
1171 | an empty overlay a non-@code{nil} @code{evaporate} property, that deletes | |
1172 | it immediately. | |
d2609065 | 1173 | |
ce75fd23 | 1174 | @item local-map |
969fe9b5 | 1175 | @cindex keymap of character (and overlays) |
ce75fd23 | 1176 | @kindex local-map @r{(overlay property)} |
d2609065 RS |
1177 | If this property is non-@code{nil}, it specifies a keymap for a portion |
1178 | of the text. The property's value replaces the buffer's local map, when | |
1179 | the character after point is within the overlay. @xref{Active Keymaps}. | |
62fb5c66 DL |
1180 | |
1181 | @item keymap | |
1182 | @kindex keymap @r{(overlay property)} | |
1183 | The @code{keymap} property is similar to @code{local-map} but overrides the | |
1184 | buffer's local map (and the map specified by the @code{local-map} | |
1185 | property) rather than replacing it. | |
42b85554 RS |
1186 | @end table |
1187 | ||
42b85554 RS |
1188 | @node Managing Overlays |
1189 | @subsection Managing Overlays | |
1190 | ||
1191 | This section describes the functions to create, delete and move | |
1192 | overlays, and to examine their contents. | |
1193 | ||
00b3c1cd RS |
1194 | @defun overlayp object |
1195 | This function returns @code{t} if @var{object} is an overlay. | |
1196 | @end defun | |
1197 | ||
f9f59935 | 1198 | @defun make-overlay start end &optional buffer front-advance rear-advance |
78608595 | 1199 | This function creates and returns an overlay that belongs to |
42b85554 RS |
1200 | @var{buffer} and ranges from @var{start} to @var{end}. Both @var{start} |
1201 | and @var{end} must specify buffer positions; they may be integers or | |
1202 | markers. If @var{buffer} is omitted, the overlay is created in the | |
1203 | current buffer. | |
f9f59935 RS |
1204 | |
1205 | The arguments @var{front-advance} and @var{rear-advance} specify the | |
1206 | insertion type for the start of the overlay and for the end of the | |
812a2341 RS |
1207 | overlay, respectively. @xref{Marker Insertion Types}. If |
1208 | @var{front-advance} is non-@code{nil}, text inserted at the beginning | |
1209 | of the overlay is excluded from the overlay. If @var{read-advance} is | |
1210 | non-@code{nil}, text inserted at the beginning of the overlay is | |
1211 | included in the overlay. | |
42b85554 RS |
1212 | @end defun |
1213 | ||
1214 | @defun overlay-start overlay | |
f9f59935 RS |
1215 | This function returns the position at which @var{overlay} starts, |
1216 | as an integer. | |
42b85554 RS |
1217 | @end defun |
1218 | ||
1219 | @defun overlay-end overlay | |
f9f59935 RS |
1220 | This function returns the position at which @var{overlay} ends, |
1221 | as an integer. | |
42b85554 RS |
1222 | @end defun |
1223 | ||
1224 | @defun overlay-buffer overlay | |
1225 | This function returns the buffer that @var{overlay} belongs to. | |
1226 | @end defun | |
1227 | ||
1228 | @defun delete-overlay overlay | |
1229 | This function deletes @var{overlay}. The overlay continues to exist as | |
2468d0c0 DL |
1230 | a Lisp object, and its property list is unchanged, but it ceases to be |
1231 | attached to the buffer it belonged to, and ceases to have any effect on | |
1232 | display. | |
a9f0a989 | 1233 | |
2468d0c0 DL |
1234 | A deleted overlay is not permanently disconnected. You can give it a |
1235 | position in a buffer again by calling @code{move-overlay}. | |
42b85554 RS |
1236 | @end defun |
1237 | ||
1238 | @defun move-overlay overlay start end &optional buffer | |
1239 | This function moves @var{overlay} to @var{buffer}, and places its bounds | |
1240 | at @var{start} and @var{end}. Both arguments @var{start} and @var{end} | |
2468d0c0 DL |
1241 | must specify buffer positions; they may be integers or markers. |
1242 | ||
1243 | If @var{buffer} is omitted, @var{overlay} stays in the same buffer it | |
1244 | was already associated with; if @var{overlay} was deleted, it goes into | |
1245 | the current buffer. | |
42b85554 RS |
1246 | |
1247 | The return value is @var{overlay}. | |
1248 | ||
1249 | This is the only valid way to change the endpoints of an overlay. Do | |
1250 | not try modifying the markers in the overlay by hand, as that fails to | |
1251 | update other vital data structures and can cause some overlays to be | |
1252 | ``lost''. | |
1253 | @end defun | |
1254 | ||
2468d0c0 DL |
1255 | Here are some examples: |
1256 | ||
1257 | @example | |
1258 | ;; @r{Create an overlay.} | |
1259 | (setq foo (make-overlay 1 10)) | |
1260 | @result{} #<overlay from 1 to 10 in display.texi> | |
1261 | (overlay-start foo) | |
1262 | @result{} 1 | |
1263 | (overlay-end foo) | |
1264 | @result{} 10 | |
1265 | (overlay-buffer foo) | |
1266 | @result{} #<buffer display.texi> | |
1267 | ;; @r{Give it a property we can check later.} | |
1268 | (overlay-put foo 'happy t) | |
1269 | @result{} t | |
1270 | ;; @r{Verify the property is present.} | |
1271 | (overlay-get foo 'happy) | |
1272 | @result{} t | |
1273 | ;; @r{Move the overlay.} | |
1274 | (move-overlay foo 5 20) | |
1275 | @result{} #<overlay from 5 to 20 in display.texi> | |
1276 | (overlay-start foo) | |
1277 | @result{} 5 | |
1278 | (overlay-end foo) | |
1279 | @result{} 20 | |
1280 | ;; @r{Delete the overlay.} | |
1281 | (delete-overlay foo) | |
1282 | @result{} nil | |
1283 | ;; @r{Verify it is deleted.} | |
1284 | foo | |
1285 | @result{} #<overlay in no buffer> | |
1286 | ;; @r{A deleted overlay has no position.} | |
1287 | (overlay-start foo) | |
1288 | @result{} nil | |
1289 | (overlay-end foo) | |
1290 | @result{} nil | |
1291 | (overlay-buffer foo) | |
1292 | @result{} nil | |
1293 | ;; @r{Undelete the overlay.} | |
1294 | (move-overlay foo 1 20) | |
1295 | @result{} #<overlay from 1 to 20 in display.texi> | |
1296 | ;; @r{Verify the results.} | |
1297 | (overlay-start foo) | |
1298 | @result{} 1 | |
1299 | (overlay-end foo) | |
1300 | @result{} 20 | |
1301 | (overlay-buffer foo) | |
1302 | @result{} #<buffer display.texi> | |
05aea714 | 1303 | ;; @r{Moving and deleting the overlay does not change its properties.} |
2468d0c0 DL |
1304 | (overlay-get foo 'happy) |
1305 | @result{} t | |
1306 | @end example | |
1307 | ||
1308 | @node Finding Overlays | |
1309 | @subsection Searching for Overlays | |
1310 | ||
42b85554 | 1311 | @defun overlays-at pos |
2468d0c0 DL |
1312 | This function returns a list of all the overlays that cover the |
1313 | character at position @var{pos} in the current buffer. The list is in | |
1314 | no particular order. An overlay contains position @var{pos} if it | |
1315 | begins at or before @var{pos}, and ends after @var{pos}. | |
1316 | ||
1317 | To illustrate usage, here is a Lisp function that returns a list of the | |
1318 | overlays that specify property @var{prop} for the character at point: | |
1319 | ||
1320 | @smallexample | |
1321 | (defun find-overlays-specifying (prop) | |
1322 | (let ((overlays (overlays-at (point))) | |
1323 | found) | |
1324 | (while overlays | |
86b032fa | 1325 | (let ((overlay (car overlays))) |
2468d0c0 DL |
1326 | (if (overlay-get overlay prop) |
1327 | (setq found (cons overlay found)))) | |
1328 | (setq overlays (cdr overlays))) | |
1329 | found)) | |
1330 | @end smallexample | |
42b85554 RS |
1331 | @end defun |
1332 | ||
f9f59935 RS |
1333 | @defun overlays-in beg end |
1334 | This function returns a list of the overlays that overlap the region | |
1335 | @var{beg} through @var{end}. ``Overlap'' means that at least one | |
1336 | character is contained within the overlay and also contained within the | |
1337 | specified region; however, empty overlays are included in the result if | |
2468d0c0 | 1338 | they are located at @var{beg}, or strictly between @var{beg} and @var{end}. |
f9f59935 RS |
1339 | @end defun |
1340 | ||
42b85554 RS |
1341 | @defun next-overlay-change pos |
1342 | This function returns the buffer position of the next beginning or end | |
1343 | of an overlay, after @var{pos}. | |
1344 | @end defun | |
1345 | ||
22697dac KH |
1346 | @defun previous-overlay-change pos |
1347 | This function returns the buffer position of the previous beginning or | |
1348 | end of an overlay, before @var{pos}. | |
1349 | @end defun | |
1350 | ||
2468d0c0 DL |
1351 | Here's an easy way to use @code{next-overlay-change} to search for the |
1352 | next character which gets a non-@code{nil} @code{happy} property from | |
1353 | either its overlays or its text properties (@pxref{Property Search}): | |
1354 | ||
1355 | @smallexample | |
1356 | (defun find-overlay-prop (prop) | |
1357 | (save-excursion | |
1358 | (while (and (not (eobp)) | |
1359 | (not (get-char-property (point) 'happy))) | |
1360 | (goto-char (min (next-overlay-change (point)) | |
1361 | (next-single-property-change (point) 'happy)))) | |
1362 | (point))) | |
1363 | @end smallexample | |
1364 | ||
f9f59935 RS |
1365 | @node Width |
1366 | @section Width | |
1367 | ||
1368 | Since not all characters have the same width, these functions let you | |
969fe9b5 RS |
1369 | check the width of a character. @xref{Primitive Indent}, and |
1370 | @ref{Screen Lines}, for related functions. | |
f9f59935 | 1371 | |
f9f59935 RS |
1372 | @defun char-width char |
1373 | This function returns the width in columns of the character @var{char}, | |
1374 | if it were displayed in the current buffer and the selected window. | |
1375 | @end defun | |
1376 | ||
f9f59935 RS |
1377 | @defun string-width string |
1378 | This function returns the width in columns of the string @var{string}, | |
1379 | if it were displayed in the current buffer and the selected window. | |
1380 | @end defun | |
1381 | ||
f9f59935 RS |
1382 | @defun truncate-string-to-width string width &optional start-column padding |
1383 | This function returns the part of @var{string} that fits within | |
1384 | @var{width} columns, as a new string. | |
1385 | ||
1386 | If @var{string} does not reach @var{width}, then the result ends where | |
1387 | @var{string} ends. If one multi-column character in @var{string} | |
1388 | extends across the column @var{width}, that character is not included in | |
1389 | the result. Thus, the result can fall short of @var{width} but cannot | |
1390 | go beyond it. | |
1391 | ||
1392 | The optional argument @var{start-column} specifies the starting column. | |
1393 | If this is non-@code{nil}, then the first @var{start-column} columns of | |
1394 | the string are omitted from the value. If one multi-column character in | |
1395 | @var{string} extends across the column @var{start-column}, that | |
1396 | character is not included. | |
1397 | ||
1398 | The optional argument @var{padding}, if non-@code{nil}, is a padding | |
1399 | character added at the beginning and end of the result string, to extend | |
1400 | it to exactly @var{width} columns. The padding character is used at the | |
1401 | end of the result if it falls short of @var{width}. It is also used at | |
1402 | the beginning of the result if one multi-column character in | |
1403 | @var{string} extends across the column @var{start-column}. | |
1404 | ||
1405 | @example | |
1406 | (truncate-string-to-width "\tab\t" 12 4) | |
1407 | @result{} "ab" | |
6bc3abcb | 1408 | (truncate-string-to-width "\tab\t" 12 4 ?\s) |
f9f59935 RS |
1409 | @result{} " ab " |
1410 | @end example | |
1411 | @end defun | |
1412 | ||
42b85554 RS |
1413 | @node Faces |
1414 | @section Faces | |
b9bc6c81 | 1415 | @cindex faces |
42b85554 | 1416 | |
8241495d RS |
1417 | A @dfn{face} is a named collection of graphical attributes: font |
1418 | family, foreground color, background color, optional underlining, and | |
1419 | many others. Faces are used in Emacs to control the style of display of | |
1420 | particular parts of the text or the frame. | |
42b85554 RS |
1421 | |
1422 | @cindex face id | |
969fe9b5 | 1423 | Each face has its own @dfn{face number}, which distinguishes faces at |
8241495d | 1424 | low levels within Emacs. However, for most purposes, you refer to |
42b85554 RS |
1425 | faces in Lisp programs by their names. |
1426 | ||
22697dac KH |
1427 | @defun facep object |
1428 | This function returns @code{t} if @var{object} is a face name symbol (or | |
1429 | if it is a vector of the kind used internally to record face data). It | |
1430 | returns @code{nil} otherwise. | |
1431 | @end defun | |
1432 | ||
42b85554 RS |
1433 | Each face name is meaningful for all frames, and by default it has the |
1434 | same meaning in all frames. But you can arrange to give a particular | |
1435 | face name a special meaning in one frame if you wish. | |
1436 | ||
1437 | @menu | |
1438 | * Standard Faces:: The faces Emacs normally comes with. | |
969fe9b5 | 1439 | * Defining Faces:: How to define a face with @code{defface}. |
8241495d | 1440 | * Face Attributes:: What is in a face? |
02c77ee9 MB |
1441 | * Attribute Functions:: Functions to examine and set face attributes. |
1442 | * Merging Faces:: How Emacs combines the faces specified for a character. | |
8241495d | 1443 | * Font Selection:: Finding the best available font for a face. |
02c77ee9 | 1444 | * Face Functions:: How to define and examine faces. |
8241495d RS |
1445 | * Auto Faces:: Hook for automatic face assignment. |
1446 | * Font Lookup:: Looking up the names of available fonts | |
1447 | and information about them. | |
1448 | * Fontsets:: A fontset is a collection of fonts | |
1449 | that handle a range of character sets. | |
42b85554 RS |
1450 | @end menu |
1451 | ||
1452 | @node Standard Faces | |
1453 | @subsection Standard Faces | |
1454 | ||
8241495d RS |
1455 | This table lists all the standard faces and their uses. Most of them |
1456 | are used for displaying certain parts of the frames or certain kinds of | |
1457 | text; you can control how those places look by customizing these faces. | |
42b85554 RS |
1458 | |
1459 | @table @code | |
1460 | @item default | |
1461 | @kindex default @r{(face name)} | |
1462 | This face is used for ordinary text. | |
1463 | ||
8241495d RS |
1464 | @item mode-line |
1465 | @kindex mode-line @r{(face name)} | |
d211eec7 EZ |
1466 | This face is used for the mode line of the selected window, and for |
1467 | menu bars when toolkit menus are not used---but only if | |
1468 | @code{mode-line-inverse-video} is non-@code{nil}. | |
8241495d | 1469 | |
42b85554 RS |
1470 | @item modeline |
1471 | @kindex modeline @r{(face name)} | |
8241495d RS |
1472 | This is an alias for the @code{mode-line} face, for compatibility with |
1473 | old Emacs versions. | |
1474 | ||
d211eec7 EZ |
1475 | @item mode-line-inactive |
1476 | @kindex mode-line-inactive @r{(face name)} | |
1477 | This face is used for mode lines of non-selected windows. | |
9b9d845d RS |
1478 | This face inherits from @code{mode-line}, so changes |
1479 | in that face affect all windows. | |
d211eec7 | 1480 | |
8241495d RS |
1481 | @item header-line |
1482 | @kindex header-line @r{(face name)} | |
1483 | This face is used for the header lines of windows that have them. | |
1484 | ||
a40d4712 PR |
1485 | @item menu |
1486 | This face controls the display of menus, both their colors and their | |
1487 | font. (This works only on certain systems.) | |
1488 | ||
8241495d RS |
1489 | @item fringe |
1490 | @kindex fringe @r{(face name)} | |
9b6e4bc3 | 1491 | This face controls the default colors of window fringes, the thin areas on |
8241495d RS |
1492 | either side that are used to display continuation and truncation glyphs. |
1493 | ||
2811080b EZ |
1494 | @item minibuffer-prompt |
1495 | @kindex minibuffer-prompt @r{(face name)} | |
1496 | @vindex minibuffer-prompt-properties | |
1497 | This face is used for the text of minibuffer prompts. By default, | |
1498 | Emacs automatically adds this face to the value of | |
1499 | @code{minibuffer-prompt-properties}, which is a list of text | |
1500 | properties used to display the prompt text. | |
1501 | ||
8241495d RS |
1502 | @item scroll-bar |
1503 | @kindex scroll-bar @r{(face name)} | |
1504 | This face controls the colors for display of scroll bars. | |
1505 | ||
1506 | @item tool-bar | |
1507 | @kindex tool-bar @r{(face name)} | |
1508 | This face is used for display of the tool bar, if any. | |
42b85554 RS |
1509 | |
1510 | @item region | |
1511 | @kindex region @r{(face name)} | |
1512 | This face is used for highlighting the region in Transient Mark mode. | |
1513 | ||
1514 | @item secondary-selection | |
1515 | @kindex secondary-selection @r{(face name)} | |
1516 | This face is used to show any secondary selection you have made. | |
1517 | ||
1518 | @item highlight | |
1519 | @kindex highlight @r{(face name)} | |
1520 | This face is meant to be used for highlighting for various purposes. | |
1521 | ||
8241495d RS |
1522 | @item trailing-whitespace |
1523 | @kindex trailing-whitespace @r{(face name)} | |
a40d4712 PR |
1524 | This face is used to display excess whitespace at the end of a line, |
1525 | if @code{show-trailing-whitespace} is non-@code{nil}. | |
8241495d | 1526 | @end table |
42b85554 | 1527 | |
8241495d RS |
1528 | In contrast, these faces are provided to change the appearance of text |
1529 | in specific ways. You can use them on specific text, when you want | |
1530 | the effects they produce. | |
1531 | ||
1532 | @table @code | |
42b85554 RS |
1533 | @item bold |
1534 | @kindex bold @r{(face name)} | |
1535 | This face uses a bold font, if possible. It uses the bold variant of | |
1536 | the frame's font, if it has one. It's up to you to choose a default | |
1537 | font that has a bold variant, if you want to use one. | |
1538 | ||
1539 | @item italic | |
1540 | @kindex italic @r{(face name)} | |
1541 | This face uses the italic variant of the frame's font, if it has one. | |
1542 | ||
1543 | @item bold-italic | |
1544 | @kindex bold-italic @r{(face name)} | |
1545 | This face uses the bold italic variant of the frame's font, if it has | |
1546 | one. | |
8241495d RS |
1547 | |
1548 | @item underline | |
1549 | @kindex underline @r{(face name)} | |
1550 | This face underlines text. | |
1551 | ||
24eb6c0e GM |
1552 | @item fixed-pitch |
1553 | @kindex fixed-pitch @r{(face name)} | |
8241495d RS |
1554 | This face forces use of a particular fixed-width font. |
1555 | ||
24eb6c0e GM |
1556 | @item variable-pitch |
1557 | @kindex variable-pitch @r{(face name)} | |
8241495d | 1558 | This face forces use of a particular variable-width font. It's |
a40d4712 | 1559 | reasonable to customize this to use a different variable-width font, if |
8241495d | 1560 | you like, but you should not make it a fixed-width font. |
42b85554 RS |
1561 | @end table |
1562 | ||
a40d4712 PR |
1563 | @defvar show-trailing-whitespace |
1564 | @tindex show-trailing-whitespace | |
1565 | If this variable is non-@code{nil}, Emacs uses the | |
1566 | @code{trailing-whitespace} face to display any spaces and tabs at the | |
1567 | end of a line. | |
1568 | @end defvar | |
1569 | ||
969fe9b5 | 1570 | @node Defining Faces |
a9f0a989 | 1571 | @subsection Defining Faces |
969fe9b5 RS |
1572 | |
1573 | The way to define a new face is with @code{defface}. This creates a | |
1574 | kind of customization item (@pxref{Customization}) which the user can | |
1575 | customize using the Customization buffer (@pxref{Easy Customization,,, | |
1576 | emacs, The GNU Emacs Manual}). | |
1577 | ||
177c0ea7 | 1578 | @defmac defface face spec doc [keyword value]... |
a40d4712 PR |
1579 | This declares @var{face} as a customizable face that defaults according |
1580 | to @var{spec}. You should not quote the symbol @var{face}. The | |
1581 | argument @var{doc} specifies the face documentation. The keywords you | |
1582 | can use in @code{defface} are the same ones that are meaningful in both | |
1583 | @code{defgroup} and @code{defcustom} (@pxref{Common Keywords}). | |
969fe9b5 RS |
1584 | |
1585 | When @code{defface} executes, it defines the face according to | |
a9f0a989 | 1586 | @var{spec}, then uses any customizations that were read from the |
a40d4712 | 1587 | init file (@pxref{Init File}) to override that specification. |
969fe9b5 RS |
1588 | |
1589 | The purpose of @var{spec} is to specify how the face should appear on | |
1590 | different kinds of terminals. It should be an alist whose elements have | |
a40d4712 PR |
1591 | the form @code{(@var{display} @var{atts})}. Each element's @sc{car}, |
1592 | @var{display}, specifies a class of terminals. The element's second element, | |
969fe9b5 RS |
1593 | @var{atts}, is a list of face attributes and their values; it specifies |
1594 | what the face should look like on that kind of terminal. The possible | |
1595 | attributes are defined in the value of @code{custom-face-attributes}. | |
1596 | ||
1597 | The @var{display} part of an element of @var{spec} determines which | |
1598 | frames the element applies to. If more than one element of @var{spec} | |
1599 | matches a given frame, the first matching element is the only one used | |
1600 | for that frame. There are two possibilities for @var{display}: | |
1601 | ||
1602 | @table @asis | |
1603 | @item @code{t} | |
1604 | This element of @var{spec} matches all frames. Therefore, any | |
1605 | subsequent elements of @var{spec} are never used. Normally | |
1606 | @code{t} is used in the last (or only) element of @var{spec}. | |
1607 | ||
a9f0a989 | 1608 | @item a list |
1911e6e5 | 1609 | If @var{display} is a list, each element should have the form |
969fe9b5 RS |
1610 | @code{(@var{characteristic} @var{value}@dots{})}. Here |
1611 | @var{characteristic} specifies a way of classifying frames, and the | |
1612 | @var{value}s are possible classifications which @var{display} should | |
1613 | apply to. Here are the possible values of @var{characteristic}: | |
1614 | ||
1615 | @table @code | |
1616 | @item type | |
9a6b7dcd MB |
1617 | The kind of window system the frame uses---either @code{graphic} (any |
1618 | graphics-capable display), @code{x}, @code{pc} (for the MS-DOS console), | |
1619 | @code{w32} (for MS Windows 9X/NT), or @code{tty} (a non-graphics-capable | |
1620 | display). | |
969fe9b5 RS |
1621 | |
1622 | @item class | |
1623 | What kinds of colors the frame supports---either @code{color}, | |
1624 | @code{grayscale}, or @code{mono}. | |
1625 | ||
1626 | @item background | |
1911e6e5 | 1627 | The kind of background---either @code{light} or @code{dark}. |
82c3d852 | 1628 | |
9fe84db6 EZ |
1629 | @item min-colors |
1630 | An integer that represents the minimum number of colors the frame should | |
1631 | support, it is compared with the result of @code{display-color-cells}. | |
1632 | ||
82c3d852 | 1633 | @item supports |
95b5b933 MB |
1634 | Whether or not the frame can display the face attributes given in |
1635 | @var{value}@dots{} (@pxref{Face Attributes}). See the documentation | |
1636 | for the function @code{display-supports-face-attributes-p} for more | |
1637 | information on exactly how this testing is done. @xref{Display Face | |
1638 | Attribute Testing}. | |
969fe9b5 RS |
1639 | @end table |
1640 | ||
1641 | If an element of @var{display} specifies more than one @var{value} for a | |
1642 | given @var{characteristic}, any of those values is acceptable. If | |
1643 | @var{display} has more than one element, each element should specify a | |
1644 | different @var{characteristic}; then @emph{each} characteristic of the | |
1645 | frame must match one of the @var{value}s specified for it in | |
1646 | @var{display}. | |
1647 | @end table | |
1648 | @end defmac | |
1649 | ||
a40d4712 | 1650 | Here's how the standard face @code{region} is defined: |
969fe9b5 RS |
1651 | |
1652 | @example | |
a40d4712 | 1653 | @group |
9fe84db6 EZ |
1654 | '((((class color) (min-colors 88) (background dark)) |
1655 | :background "blue3") | |
a40d4712 | 1656 | @end group |
9fe84db6 EZ |
1657 | (((class color) (min-colors 88) (background light)) |
1658 | :background "lightgoldenrod2") | |
1659 | (((class color) (min-colors 16) (background dark)) | |
1660 | :background "blue3") | |
1661 | (((class color) (min-colors 16) (background light)) | |
1662 | :background "lightgoldenrod2") | |
1663 | (((class color) (min-colors 8)) | |
1664 | :background "blue" :foreground "white") | |
a40d4712 | 1665 | (((type tty) (class mono)) |
9fe84db6 EZ |
1666 | :inverse-video t) |
1667 | (t :background "gray")) | |
a40d4712 PR |
1668 | @group |
1669 | "Basic face for highlighting the region." | |
1670 | :group 'basic-faces) | |
1671 | @end group | |
969fe9b5 RS |
1672 | @end example |
1673 | ||
1674 | Internally, @code{defface} uses the symbol property | |
1675 | @code{face-defface-spec} to record the face attributes specified in | |
1676 | @code{defface}, @code{saved-face} for the attributes saved by the user | |
1677 | with the customization buffer, and @code{face-documentation} for the | |
1678 | documentation string. | |
1679 | ||
1911e6e5 RS |
1680 | @defopt frame-background-mode |
1681 | This option, if non-@code{nil}, specifies the background type to use for | |
1682 | interpreting face definitions. If it is @code{dark}, then Emacs treats | |
1683 | all frames as if they had a dark background, regardless of their actual | |
1684 | background colors. If it is @code{light}, then Emacs treats all frames | |
1685 | as if they had a light background. | |
1686 | @end defopt | |
1687 | ||
8241495d RS |
1688 | @node Face Attributes |
1689 | @subsection Face Attributes | |
1690 | @cindex face attributes | |
42b85554 | 1691 | |
8241495d RS |
1692 | The effect of using a face is determined by a fixed set of @dfn{face |
1693 | attributes}. This table lists all the face attributes, and what they | |
a40d4712 PR |
1694 | mean. Note that in general, more than one face can be specified for a |
1695 | given piece of text; when that happens, the attributes of all the faces | |
1696 | are merged to specify how to display the text. @xref{Merging Faces}. | |
42b85554 | 1697 | |
8241495d RS |
1698 | In Emacs 21, any attribute in a face can have the value |
1699 | @code{unspecified}. This means the face doesn't specify that attribute. | |
1700 | In face merging, when the first face fails to specify a particular | |
1701 | attribute, that means the next face gets a chance. However, the | |
1702 | @code{default} face must specify all attributes. | |
42b85554 | 1703 | |
a40d4712 PR |
1704 | Some of these font attributes are meaningful only on certain kinds of |
1705 | displays---if your display cannot handle a certain attribute, the | |
1706 | attribute is ignored. (The attributes @code{:family}, @code{:width}, | |
1707 | @code{:height}, @code{:weight}, and @code{:slant} correspond to parts of | |
1708 | an X Logical Font Descriptor.) | |
42b85554 | 1709 | |
8241495d RS |
1710 | @table @code |
1711 | @item :family | |
1712 | Font family name, or fontset name (@pxref{Fontsets}). If you specify a | |
a40d4712 PR |
1713 | font family name, the wild-card characters @samp{*} and @samp{?} are |
1714 | allowed. | |
8241495d RS |
1715 | |
1716 | @item :width | |
1717 | Relative proportionate width, also known as the character set width or | |
1718 | set width. This should be one of the symbols @code{ultra-condensed}, | |
1719 | @code{extra-condensed}, @code{condensed}, @code{semi-condensed}, | |
1720 | @code{normal}, @code{semi-expanded}, @code{expanded}, | |
1721 | @code{extra-expanded}, or @code{ultra-expanded}. | |
177c0ea7 | 1722 | |
8241495d | 1723 | @item :height |
96f71a49 MB |
1724 | Either the font height, an integer in units of 1/10 point, a floating |
1725 | point number specifying the amount by which to scale the height of any | |
1726 | underlying face, or a function, which is called with the old height | |
1727 | (from the underlying face), and should return the new height. | |
177c0ea7 | 1728 | |
8241495d RS |
1729 | @item :weight |
1730 | Font weight---a symbol from this series (from most dense to most faint): | |
1731 | @code{ultra-bold}, @code{extra-bold}, @code{bold}, @code{semi-bold}, | |
1732 | @code{normal}, @code{semi-light}, @code{light}, @code{extra-light}, | |
a40d4712 | 1733 | or @code{ultra-light}. |
66f54605 | 1734 | |
a40d4712 PR |
1735 | On a text-only terminal, any weight greater than normal is displayed as |
1736 | extra bright, and any weight less than normal is displayed as | |
1737 | half-bright (provided the terminal supports the feature). | |
1738 | ||
8241495d RS |
1739 | @item :slant |
1740 | Font slant---one of the symbols @code{italic}, @code{oblique}, @code{normal}, | |
1741 | @code{reverse-italic}, or @code{reverse-oblique}. | |
66f54605 PR |
1742 | |
1743 | On a text-only terminal, slanted text is displayed as half-bright, if | |
1744 | the terminal supports the feature. | |
1745 | ||
8241495d RS |
1746 | @item :foreground |
1747 | Foreground color, a string. | |
177c0ea7 | 1748 | |
8241495d RS |
1749 | @item :background |
1750 | Background color, a string. | |
1751 | ||
1752 | @item :inverse-video | |
1753 | Whether or not characters should be displayed in inverse video. The | |
1754 | value should be @code{t} (yes) or @code{nil} (no). | |
1755 | ||
1756 | @item :stipple | |
a40d4712 | 1757 | The background stipple, a bitmap. |
8241495d | 1758 | |
a40d4712 PR |
1759 | The value can be a string; that should be the name of a file containing |
1760 | external-format X bitmap data. The file is found in the directories | |
1761 | listed in the variable @code{x-bitmap-file-path}. | |
8241495d | 1762 | |
a3fbafe2 RS |
1763 | Alternatively, the value can specify the bitmap directly, with a list |
1764 | of the form @code{(@var{width} @var{height} @var{data})}. Here, | |
1765 | @var{width} and @var{height} specify the size in pixels, and | |
1766 | @var{data} is a string containing the raw bits of the bitmap, row by | |
1767 | row. Each row occupies @math{(@var{width} + 7) / 8} consecutive bytes | |
1768 | in the string (which should be a unibyte string for best results). | |
1769 | This means that each row always occupies at least one whole byte. | |
8241495d RS |
1770 | |
1771 | If the value is @code{nil}, that means use no stipple pattern. | |
1772 | ||
1773 | Normally you do not need to set the stipple attribute, because it is | |
1774 | used automatically to handle certain shades of gray. | |
1775 | ||
1776 | @item :underline | |
1777 | Whether or not characters should be underlined, and in what color. If | |
1778 | the value is @code{t}, underlining uses the foreground color of the | |
1779 | face. If the value is a string, underlining uses that color. The | |
1780 | value @code{nil} means do not underline. | |
1781 | ||
1782 | @item :overline | |
1783 | Whether or not characters should be overlined, and in what color. | |
1784 | The value is used like that of @code{:underline}. | |
1785 | ||
1786 | @item :strike-through | |
1787 | Whether or not characters should be strike-through, and in what | |
1788 | color. The value is used like that of @code{:underline}. | |
1789 | ||
96f71a49 MB |
1790 | @item :inherit |
1791 | The name of a face from which to inherit attributes, or a list of face | |
1792 | names. Attributes from inherited faces are merged into the face like an | |
1793 | underlying face would be, with higher priority than underlying faces. | |
1794 | ||
8241495d RS |
1795 | @item :box |
1796 | Whether or not a box should be drawn around characters, its color, the | |
a40d4712 | 1797 | width of the box lines, and 3D appearance. |
8241495d | 1798 | @end table |
42b85554 | 1799 | |
8241495d RS |
1800 | Here are the possible values of the @code{:box} attribute, and what |
1801 | they mean: | |
42b85554 | 1802 | |
8241495d RS |
1803 | @table @asis |
1804 | @item @code{nil} | |
1805 | Don't draw a box. | |
bfe721d1 | 1806 | |
8241495d RS |
1807 | @item @code{t} |
1808 | Draw a box with lines of width 1, in the foreground color. | |
42b85554 | 1809 | |
8241495d RS |
1810 | @item @var{color} |
1811 | Draw a box with lines of width 1, in color @var{color}. | |
42b85554 | 1812 | |
8241495d RS |
1813 | @item @code{(:line-width @var{width} :color @var{color} :style @var{style})} |
1814 | This way you can explicitly specify all aspects of the box. The value | |
1815 | @var{width} specifies the width of the lines to draw; it defaults to 1. | |
42b85554 | 1816 | |
8241495d RS |
1817 | The value @var{color} specifies the color to draw with. The default is |
1818 | the foreground color of the face for simple boxes, and the background | |
1819 | color of the face for 3D boxes. | |
42b85554 | 1820 | |
8241495d RS |
1821 | The value @var{style} specifies whether to draw a 3D box. If it is |
1822 | @code{released-button}, the box looks like a 3D button that is not being | |
1823 | pressed. If it is @code{pressed-button}, the box looks like a 3D button | |
1824 | that is being pressed. If it is @code{nil} or omitted, a plain 2D box | |
1825 | is used. | |
1826 | @end table | |
42b85554 | 1827 | |
8241495d RS |
1828 | The attributes @code{:overline}, @code{:strike-through} and |
1829 | @code{:box} are new in Emacs 21. The attributes @code{:family}, | |
1830 | @code{:height}, @code{:width}, @code{:weight}, @code{:slant} are also | |
a40d4712 PR |
1831 | new; previous versions used the following attributes, now semi-obsolete, |
1832 | to specify some of the same information: | |
42b85554 | 1833 | |
8241495d RS |
1834 | @table @code |
1835 | @item :font | |
a40d4712 | 1836 | This attribute specifies the font name. |
42b85554 | 1837 | |
8241495d RS |
1838 | @item :bold |
1839 | A non-@code{nil} value specifies a bold font. | |
42b85554 | 1840 | |
8241495d RS |
1841 | @item :italic |
1842 | A non-@code{nil} value specifies an italic font. | |
1843 | @end table | |
42b85554 | 1844 | |
8241495d RS |
1845 | For compatibility, you can still set these ``attributes'' in Emacs 21, |
1846 | even though they are not real face attributes. Here is what that does: | |
42b85554 | 1847 | |
8241495d RS |
1848 | @table @code |
1849 | @item :font | |
a40d4712 PR |
1850 | You can specify an X font name as the ``value'' of this ``attribute''; |
1851 | that sets the @code{:family}, @code{:width}, @code{:height}, | |
1852 | @code{:weight}, and @code{:slant} attributes according to the font name. | |
8241495d RS |
1853 | |
1854 | If the value is a pattern with wildcards, the first font that matches | |
1855 | the pattern is used to set these attributes. | |
1856 | ||
1857 | @item :bold | |
1858 | A non-@code{nil} makes the face bold; @code{nil} makes it normal. | |
1859 | This actually works by setting the @code{:weight} attribute. | |
1860 | ||
1861 | @item :italic | |
1862 | A non-@code{nil} makes the face italic; @code{nil} makes it normal. | |
1863 | This actually works by setting the @code{:slant} attribute. | |
1864 | @end table | |
42b85554 | 1865 | |
8241495d RS |
1866 | @defvar x-bitmap-file-path |
1867 | This variable specifies a list of directories for searching | |
1868 | for bitmap files, for the @code{:stipple} attribute. | |
1869 | @end defvar | |
1870 | ||
ea7220f8 | 1871 | @defun bitmap-spec-p object |
2252bdcf RS |
1872 | This returns @code{t} if @var{object} is a valid bitmap specification, |
1873 | suitable for use with @code{:stipple} (see above). It returns | |
1874 | @code{nil} otherwise. | |
a40d4712 PR |
1875 | @end defun |
1876 | ||
8241495d RS |
1877 | @node Attribute Functions |
1878 | @subsection Face Attribute Functions | |
42b85554 RS |
1879 | |
1880 | You can modify the attributes of an existing face with the following | |
1881 | functions. If you specify @var{frame}, they affect just that frame; | |
1882 | otherwise, they affect all frames as well as the defaults that apply to | |
1883 | new frames. | |
1884 | ||
8241495d RS |
1885 | @tindex set-face-attribute |
1886 | @defun set-face-attribute face frame &rest arguments | |
1887 | This function sets one or more attributes of face @var{face} | |
1888 | for frame @var{frame}. If @var{frame} is @code{nil}, it sets | |
1889 | the attribute for all frames, and the defaults for new frames. | |
1890 | ||
1891 | The extra arguments @var{arguments} specify the attributes to set, and | |
1892 | the values for them. They should consist of alternating attribute names | |
a40d4712 | 1893 | (such as @code{:family} or @code{:underline}) and corresponding values. |
8241495d RS |
1894 | Thus, |
1895 | ||
1896 | @example | |
1897 | (set-face-attribute 'foo nil | |
dbcff00c RS |
1898 | :width 'extended |
1899 | :weight 'bold | |
8241495d RS |
1900 | :underline "red") |
1901 | @end example | |
1902 | ||
1903 | @noindent | |
1904 | sets the attributes @code{:width}, @code{:weight} and @code{:underline} | |
1905 | to the corresponding values. | |
1906 | @end defun | |
1907 | ||
1908 | @tindex face-attribute | |
35f23bbf | 1909 | @defun face-attribute face attribute &optional frame inherit |
8241495d RS |
1910 | This returns the value of the @var{attribute} attribute of face |
1911 | @var{face} on @var{frame}. If @var{frame} is @code{nil}, | |
8d82c597 | 1912 | that means the selected frame (@pxref{Input Focus}). |
8241495d RS |
1913 | |
1914 | If @var{frame} is @code{t}, the value is the default for | |
1915 | @var{face} for new frames. | |
1916 | ||
9a8dc0d3 | 1917 | If @var{inherit} is @code{nil}, only attributes directly defined by |
35f23bbf | 1918 | @var{face} are considered, so the return value may be |
9a8dc0d3 RS |
1919 | @code{unspecified}, or a relative value. If @var{inherit} is |
1920 | non-@code{nil}, @var{face}'s definition of @var{attribute} is merged | |
1921 | with the faces specified by its @code{:inherit} attribute; however the | |
1922 | return value may still be @code{unspecified} or relative. If | |
1923 | @var{inherit} is a face or a list of faces, then the result is further | |
1924 | merged with that face (or faces), until it becomes specified and | |
1925 | absolute. | |
35f23bbf MB |
1926 | |
1927 | To ensure that the return value is always specified and absolute, use | |
1928 | a value of @code{default} for @var{inherit}; this will resolve any | |
1929 | unspecified or relative values by merging with the @code{default} face | |
1930 | (which is always completely specified). | |
1931 | ||
8241495d RS |
1932 | For example, |
1933 | ||
1934 | @example | |
1935 | (face-attribute 'bold :weight) | |
1936 | @result{} bold | |
1937 | @end example | |
1938 | @end defun | |
1939 | ||
a40d4712 PR |
1940 | The functions above did not exist before Emacs 21. For compatibility |
1941 | with older Emacs versions, you can use the following functions to set | |
8241495d RS |
1942 | and examine the face attributes which existed in those versions. |
1943 | ||
35f23bbf MB |
1944 | @tindex face-attribute-relative-p |
1945 | @defun face-attribute-relative-p attribute value | |
812a2341 | 1946 | This function returns non-@code{nil} if @var{value}, when used as |
35f23bbf MB |
1947 | the value of the face attribute @var{attribute}, is relative (that is, |
1948 | if it modifies an underlying or inherited value of @var{attribute}). | |
1949 | @end defun | |
1950 | ||
1951 | @tindex merge-face-attribute | |
1952 | @defun merge-face-attribute attribute value1 value2 | |
1953 | If @var{value1} is a relative value for the face attribute | |
1954 | @var{attribute}, returns it merged with the underlying value | |
1955 | @var{value2}; otherwise, if @var{value1} is an absolute value for the | |
9ee1638e | 1956 | face attribute @var{attribute}, returns @var{value1} unchanged. |
35f23bbf MB |
1957 | @end defun |
1958 | ||
42b85554 RS |
1959 | @defun set-face-foreground face color &optional frame |
1960 | @defunx set-face-background face color &optional frame | |
78608595 RS |
1961 | These functions set the foreground (or background, respectively) color |
1962 | of face @var{face} to @var{color}. The argument @var{color} should be a | |
42b85554 | 1963 | string, the name of a color. |
bfe721d1 KH |
1964 | |
1965 | Certain shades of gray are implemented by stipple patterns on | |
1966 | black-and-white screens. | |
1967 | @end defun | |
1968 | ||
1969 | @defun set-face-stipple face pattern &optional frame | |
2252bdcf RS |
1970 | This function sets the background stipple pattern of face @var{face} |
1971 | to @var{pattern}. The argument @var{pattern} should be the name of a | |
1972 | stipple pattern defined by the X server, or actual bitmap data | |
1973 | (@pxref{Face Attributes}), or @code{nil} meaning don't use stipple. | |
bfe721d1 KH |
1974 | |
1975 | Normally there is no need to pay attention to stipple patterns, because | |
1976 | they are used automatically to handle certain shades of gray. | |
42b85554 RS |
1977 | @end defun |
1978 | ||
1979 | @defun set-face-font face font &optional frame | |
8241495d RS |
1980 | This function sets the font of face @var{face}. |
1981 | ||
1982 | In Emacs 21, this actually sets the attributes @code{:family}, | |
1983 | @code{:width}, @code{:height}, @code{:weight}, and @code{:slant} | |
1984 | according to the font name @var{font}. | |
1985 | ||
1986 | In Emacs 20, this sets the font attribute. Once you set the font | |
a9f0a989 | 1987 | explicitly, the bold and italic attributes cease to have any effect, |
8241495d | 1988 | because the precise font that you specified is used. |
21cffb83 RS |
1989 | @end defun |
1990 | ||
f9f59935 | 1991 | @defun set-face-bold-p face bold-p &optional frame |
8241495d RS |
1992 | This function specifies whether @var{face} should be bold. If |
1993 | @var{bold-p} is non-@code{nil}, that means yes; @code{nil} means no. | |
1994 | ||
1995 | In Emacs 21, this sets the @code{:weight} attribute. | |
1996 | In Emacs 20, it sets the @code{:bold} attribute. | |
21cffb83 RS |
1997 | @end defun |
1998 | ||
f9f59935 | 1999 | @defun set-face-italic-p face italic-p &optional frame |
8241495d RS |
2000 | This function specifies whether @var{face} should be italic. If |
2001 | @var{italic-p} is non-@code{nil}, that means yes; @code{nil} means no. | |
2002 | ||
2003 | In Emacs 21, this sets the @code{:slant} attribute. | |
2004 | In Emacs 20, it sets the @code{:italic} attribute. | |
42b85554 RS |
2005 | @end defun |
2006 | ||
969fe9b5 RS |
2007 | @defun set-face-underline-p face underline-p &optional frame |
2008 | This function sets the underline attribute of face @var{face}. | |
2009 | Non-@code{nil} means do underline; @code{nil} means don't. | |
2010 | @end defun | |
2011 | ||
42b85554 | 2012 | @defun invert-face face &optional frame |
8241495d RS |
2013 | This function inverts the @code{:inverse-video} attribute of face |
2014 | @var{face}. If the attribute is @code{nil}, this function sets it to | |
2015 | @code{t}, and vice versa. | |
42b85554 RS |
2016 | @end defun |
2017 | ||
2018 | These functions examine the attributes of a face. If you don't | |
2019 | specify @var{frame}, they refer to the default data for new frames. | |
a40d4712 PR |
2020 | They return the symbol @code{unspecified} if the face doesn't define any |
2021 | value for that attribute. | |
42b85554 | 2022 | |
69137def | 2023 | @defun face-foreground face &optional frame inherit |
42b85554 | 2024 | @defunx face-background face &optional frame |
78608595 RS |
2025 | These functions return the foreground color (or background color, |
2026 | respectively) of face @var{face}, as a string. | |
69137def | 2027 | |
00991494 JH |
2028 | If @var{inherit} is @code{nil}, only a color directly defined by the face is |
2029 | returned. If @var{inherit} is non-@code{nil}, any faces specified by its | |
69137def MB |
2030 | @code{:inherit} attribute are considered as well, and if @var{inherit} |
2031 | is a face or a list of faces, then they are also considered, until a | |
2032 | specified color is found. To ensure that the return value is always | |
2033 | specified, use a value of @code{default} for @var{inherit}. | |
42b85554 RS |
2034 | @end defun |
2035 | ||
69137def | 2036 | @defun face-stipple face &optional frame inherit |
bfe721d1 KH |
2037 | This function returns the name of the background stipple pattern of face |
2038 | @var{face}, or @code{nil} if it doesn't have one. | |
69137def | 2039 | |
9a8dc0d3 RS |
2040 | If @var{inherit} is @code{nil}, only a stipple directly defined by the |
2041 | face is returned. If @var{inherit} is non-@code{nil}, any faces | |
2042 | specified by its @code{:inherit} attribute are considered as well, and | |
2043 | if @var{inherit} is a face or a list of faces, then they are also | |
2044 | considered, until a specified stipple is found. To ensure that the | |
2045 | return value is always specified, use a value of @code{default} for | |
2046 | @var{inherit}. | |
bfe721d1 KH |
2047 | @end defun |
2048 | ||
42b85554 RS |
2049 | @defun face-font face &optional frame |
2050 | This function returns the name of the font of face @var{face}. | |
2051 | @end defun | |
2052 | ||
f9f59935 | 2053 | @defun face-bold-p face &optional frame |
8241495d RS |
2054 | This function returns @code{t} if @var{face} is bold---that is, if it is |
2055 | bolder than normal. It returns @code{nil} otherwise. | |
f9f59935 RS |
2056 | @end defun |
2057 | ||
f9f59935 | 2058 | @defun face-italic-p face &optional frame |
8241495d RS |
2059 | This function returns @code{t} if @var{face} is italic or oblique, |
2060 | @code{nil} otherwise. | |
f9f59935 RS |
2061 | @end defun |
2062 | ||
969fe9b5 | 2063 | @defun face-underline-p face &optional frame |
8241495d RS |
2064 | This function returns the @code{:underline} attribute of face @var{face}. |
2065 | @end defun | |
2066 | ||
2067 | @defun face-inverse-video-p face &optional frame | |
2068 | This function returns the @code{:inverse-video} attribute of face @var{face}. | |
2069 | @end defun | |
2070 | ||
2071 | @node Merging Faces | |
2072 | @subsection Merging Faces for Display | |
2073 | ||
2074 | Here are the ways to specify which faces to use for display of text: | |
2075 | ||
2076 | @itemize @bullet | |
2077 | @item | |
2078 | With defaults. The @code{default} face is used as the ultimate | |
2079 | default for all text. (In Emacs 19 and 20, the @code{default} | |
2080 | face is used only when no other face is specified.) | |
2081 | ||
2082 | For a mode line or header line, the face @code{modeline} or | |
2083 | @code{header-line} is used just before @code{default}. | |
2084 | ||
2085 | @item | |
2086 | With text properties. A character can have a @code{face} property; if | |
2087 | so, the faces and face attributes specified there apply. @xref{Special | |
2088 | Properties}. | |
2089 | ||
2090 | If the character has a @code{mouse-face} property, that is used instead | |
2091 | of the @code{face} property when the mouse is ``near enough'' to the | |
2092 | character. | |
2093 | ||
2094 | @item | |
2095 | With overlays. An overlay can have @code{face} and @code{mouse-face} | |
2096 | properties too; they apply to all the text covered by the overlay. | |
2097 | ||
2098 | @item | |
2099 | With a region that is active. In Transient Mark mode, the region is | |
2100 | highlighted with the face @code{region} (@pxref{Standard Faces}). | |
2101 | ||
2102 | @item | |
177c0ea7 | 2103 | With special glyphs. Each glyph can specify a particular face |
8241495d RS |
2104 | number. @xref{Glyphs}. |
2105 | @end itemize | |
2106 | ||
2107 | If these various sources together specify more than one face for a | |
2108 | particular character, Emacs merges the attributes of the various faces | |
2109 | specified. The attributes of the faces of special glyphs come first; | |
2110 | then comes the face for region highlighting, if appropriate; | |
2111 | then come attributes of faces from overlays, followed by those from text | |
2112 | properties, and last the default face. | |
2113 | ||
2114 | When multiple overlays cover one character, an overlay with higher | |
2115 | priority overrides those with lower priority. @xref{Overlays}. | |
2116 | ||
2117 | In Emacs 20, if an attribute such as the font or a color is not | |
2118 | specified in any of the above ways, the frame's own font or color is | |
2119 | used. In newer Emacs versions, this cannot happen, because the | |
2120 | @code{default} face specifies all attributes---in fact, the frame's own | |
2121 | font and colors are synonymous with those of the default face. | |
2122 | ||
2123 | @node Font Selection | |
2124 | @subsection Font Selection | |
2125 | ||
2126 | @dfn{Selecting a font} means mapping the specified face attributes for | |
2127 | a character to a font that is available on a particular display. The | |
2128 | face attributes, as determined by face merging, specify most of the | |
2129 | font choice, but not all. Part of the choice depends on what character | |
2130 | it is. | |
2131 | ||
8241495d RS |
2132 | If the face specifies a fontset name, that fontset determines a |
2133 | pattern for fonts of the given charset. If the face specifies a font | |
2134 | family, a font pattern is constructed. | |
2135 | ||
2136 | Emacs tries to find an available font for the given face attributes | |
2137 | and character's registry and encoding. If there is a font that matches | |
2138 | exactly, it is used, of course. The hard case is when no available font | |
2139 | exactly fits the specification. Then Emacs looks for one that is | |
1dffc5db RS |
2140 | ``close''---one attribute at a time. You can specify the order to |
2141 | consider the attributes. In the case where a specified font family is | |
2142 | not available, you can specify a set of mappings for alternatives to | |
2143 | try. | |
8241495d RS |
2144 | |
2145 | @defvar face-font-selection-order | |
2146 | @tindex face-font-selection-order | |
2147 | This variable specifies the order of importance of the face attributes | |
2148 | @code{:width}, @code{:height}, @code{:weight}, and @code{:slant}. The | |
2149 | value should be a list containing those four symbols, in order of | |
2150 | decreasing importance. | |
2151 | ||
2152 | Font selection first finds the best available matches for the first | |
2153 | attribute listed; then, among the fonts which are best in that way, it | |
2154 | searches for the best matches in the second attribute, and so on. | |
2155 | ||
2156 | The attributes @code{:weight} and @code{:width} have symbolic values in | |
2157 | a range centered around @code{normal}. Matches that are more extreme | |
2158 | (farther from @code{normal}) are somewhat preferred to matches that are | |
2159 | less extreme (closer to @code{normal}); this is designed to ensure that | |
2160 | non-normal faces contrast with normal ones, whenever possible. | |
2161 | ||
2162 | The default is @code{(:width :height :weight :slant)}, which means first | |
2163 | find the fonts closest to the specified @code{:width}, then---among the | |
2164 | fonts with that width---find a best match for the specified font height, | |
2165 | and so on. | |
2166 | ||
2167 | One example of a case where this variable makes a difference is when the | |
2168 | default font has no italic equivalent. With the default ordering, the | |
2169 | @code{italic} face will use a non-italic font that is similar to the | |
2170 | default one. But if you put @code{:slant} before @code{:height}, the | |
2171 | @code{italic} face will use an italic font, even if its height is not | |
2172 | quite right. | |
2173 | @end defvar | |
2174 | ||
52d89894 GM |
2175 | @defvar face-font-family-alternatives |
2176 | @tindex face-font-family-alternatives | |
8241495d RS |
2177 | This variable lets you specify alternative font families to try, if a |
2178 | given family is specified and doesn't exist. Each element should have | |
2179 | this form: | |
2180 | ||
2181 | @example | |
2182 | (@var{family} @var{alternate-families}@dots{}) | |
2183 | @end example | |
2184 | ||
2185 | If @var{family} is specified but not available, Emacs will try the other | |
2186 | families given in @var{alternate-families}, one by one, until it finds a | |
2187 | family that does exist. | |
52d89894 GM |
2188 | @end defvar |
2189 | ||
2190 | @defvar face-font-registry-alternatives | |
2191 | @tindex face-font-registry-alternatives | |
2192 | This variable lets you specify alternative font registries to try, if a | |
2193 | given registry is specified and doesn't exist. Each element should have | |
2194 | this form: | |
2195 | ||
2196 | @example | |
2197 | (@var{registry} @var{alternate-registries}@dots{}) | |
2198 | @end example | |
2199 | ||
2200 | If @var{registry} is specified but not available, Emacs will try the | |
2201 | other registries given in @var{alternate-registries}, one by one, | |
2202 | until it finds a registry that does exist. | |
8241495d RS |
2203 | @end defvar |
2204 | ||
2205 | Emacs can make use of scalable fonts, but by default it does not use | |
2206 | them, since the use of too many or too big scalable fonts can crash | |
2207 | XFree86 servers. | |
2208 | ||
2209 | @defvar scalable-fonts-allowed | |
2210 | @tindex scalable-fonts-allowed | |
2211 | This variable controls which scalable fonts to use. A value of | |
2212 | @code{nil}, the default, means do not use scalable fonts. @code{t} | |
2213 | means to use any scalable font that seems appropriate for the text. | |
2214 | ||
2215 | Otherwise, the value must be a list of regular expressions. Then a | |
2216 | scalable font is enabled for use if its name matches any regular | |
2217 | expression in the list. For example, | |
2218 | ||
2219 | @example | |
2220 | (setq scalable-fonts-allowed '("muleindian-2$")) | |
2221 | @end example | |
2222 | ||
2223 | @noindent | |
2224 | allows the use of scalable fonts with registry @code{muleindian-2}. | |
eda77a0f | 2225 | @end defvar |
8241495d RS |
2226 | |
2227 | @defun clear-face-cache &optional unload-p | |
2228 | @tindex clear-face-cache | |
2229 | This function clears the face cache for all frames. | |
2230 | If @var{unload-p} is non-@code{nil}, that means to unload | |
2231 | all unused fonts as well. | |
2232 | @end defun | |
2233 | ||
6bc3abcb RS |
2234 | @defvar face-font-rescale-alist |
2235 | This variable specifies scaling for certain faces. Its value should | |
2236 | be a list of elements of the form | |
2237 | ||
2238 | @example | |
2239 | (@var{fontname-regexp} . @var{scale-factor}) | |
2240 | @end example | |
2241 | ||
2242 | If @var{fontname-regexp} matches the font name that is about to be | |
2243 | used, this says to choose a larger similar font according to the | |
2244 | factor @var{scale-factor}. You would use this feature to normalize | |
2245 | the font size if certain fonts are bigger or smaller than their | |
2246 | nominal heights and widths would suggest. | |
2247 | @end defvar | |
2248 | ||
8241495d RS |
2249 | @node Face Functions |
2250 | @subsection Functions for Working with Faces | |
2251 | ||
2252 | Here are additional functions for creating and working with faces. | |
2253 | ||
2254 | @defun make-face name | |
2255 | This function defines a new face named @var{name}, initially with all | |
2256 | attributes @code{nil}. It does nothing if there is already a face named | |
2257 | @var{name}. | |
2258 | @end defun | |
2259 | ||
2260 | @defun face-list | |
2261 | This function returns a list of all defined face names. | |
2262 | @end defun | |
2263 | ||
2264 | @defun copy-face old-face new-name &optional frame new-frame | |
2265 | This function defines the face @var{new-name} as a copy of the existing | |
2266 | face named @var{old-face}. It creates the face @var{new-name} if that | |
2267 | doesn't already exist. | |
2268 | ||
2269 | If the optional argument @var{frame} is given, this function applies | |
2270 | only to that frame. Otherwise it applies to each frame individually, | |
2271 | copying attributes from @var{old-face} in each frame to @var{new-face} | |
2272 | in the same frame. | |
2273 | ||
2274 | If the optional argument @var{new-frame} is given, then @code{copy-face} | |
2275 | copies the attributes of @var{old-face} in @var{frame} to @var{new-name} | |
2276 | in @var{new-frame}. | |
969fe9b5 RS |
2277 | @end defun |
2278 | ||
bfe721d1 | 2279 | @defun face-id face |
969fe9b5 | 2280 | This function returns the face number of face @var{face}. |
42b85554 RS |
2281 | @end defun |
2282 | ||
f9f59935 RS |
2283 | @defun face-documentation face |
2284 | This function returns the documentation string of face @var{face}, or | |
2285 | @code{nil} if none was specified for it. | |
2286 | @end defun | |
2287 | ||
42b85554 RS |
2288 | @defun face-equal face1 face2 &optional frame |
2289 | This returns @code{t} if the faces @var{face1} and @var{face2} have the | |
2290 | same attributes for display. | |
2291 | @end defun | |
2292 | ||
2293 | @defun face-differs-from-default-p face &optional frame | |
7e07a66d MB |
2294 | This returns non-@code{nil} if the face @var{face} displays |
2295 | differently from the default face. | |
1911e6e5 RS |
2296 | @end defun |
2297 | ||
8241495d RS |
2298 | @node Auto Faces |
2299 | @subsection Automatic Face Assignment | |
2300 | @cindex automatic face assignment | |
2301 | @cindex faces, automatic choice | |
2302 | ||
2303 | @cindex Font-Lock mode | |
2304 | Starting with Emacs 21, a hook is available for automatically | |
2305 | assigning faces to text in the buffer. This hook is used for part of | |
2306 | the implementation of Font-Lock mode. | |
2307 | ||
2308 | @tindex fontification-functions | |
2309 | @defvar fontification-functions | |
2310 | This variable holds a list of functions that are called by Emacs | |
2311 | redisplay as needed to assign faces automatically to text in the buffer. | |
2312 | ||
2313 | The functions are called in the order listed, with one argument, a | |
2314 | buffer position @var{pos}. Each function should attempt to assign faces | |
2315 | to the text in the current buffer starting at @var{pos}. | |
2316 | ||
2317 | Each function should record the faces they assign by setting the | |
2318 | @code{face} property. It should also add a non-@code{nil} | |
2319 | @code{fontified} property for all the text it has assigned faces to. | |
2320 | That property tells redisplay that faces have been assigned to that text | |
2321 | already. | |
2322 | ||
2323 | It is probably a good idea for each function to do nothing if the | |
2324 | character after @var{pos} already has a non-@code{nil} @code{fontified} | |
2325 | property, but this is not required. If one function overrides the | |
2326 | assignments made by a previous one, the properties as they are | |
2327 | after the last function finishes are the ones that really matter. | |
2328 | ||
2329 | For efficiency, we recommend writing these functions so that they | |
2330 | usually assign faces to around 400 to 600 characters at each call. | |
2331 | @end defvar | |
2332 | ||
2333 | @node Font Lookup | |
2334 | @subsection Looking Up Fonts | |
2335 | ||
2336 | @defun x-list-fonts pattern &optional face frame maximum | |
2337 | This function returns a list of available font names that match | |
2338 | @var{pattern}. If the optional arguments @var{face} and @var{frame} are | |
2339 | specified, then the list is limited to fonts that are the same size as | |
2340 | @var{face} currently is on @var{frame}. | |
2341 | ||
2342 | The argument @var{pattern} should be a string, perhaps with wildcard | |
2343 | characters: the @samp{*} character matches any substring, and the | |
2344 | @samp{?} character matches any single character. Pattern matching | |
2345 | of font names ignores case. | |
2346 | ||
2347 | If you specify @var{face} and @var{frame}, @var{face} should be a face name | |
2348 | (a symbol) and @var{frame} should be a frame. | |
2349 | ||
2350 | The optional argument @var{maximum} sets a limit on how many fonts to | |
2351 | return. If this is non-@code{nil}, then the return value is truncated | |
2352 | after the first @var{maximum} matching fonts. Specifying a small value | |
2353 | for @var{maximum} can make this function much faster, in cases where | |
2354 | many fonts match the pattern. | |
2355 | @end defun | |
2356 | ||
2357 | These additional functions are available starting in Emacs 21. | |
2358 | ||
2359 | @defun x-family-fonts &optional family frame | |
2360 | @tindex x-family-fonts | |
2361 | This function returns a list describing the available fonts for family | |
2362 | @var{family} on @var{frame}. If @var{family} is omitted or @code{nil}, | |
2363 | this list applies to all families, and therefore, it contains all | |
2364 | available fonts. Otherwise, @var{family} must be a string; it may | |
2365 | contain the wildcards @samp{?} and @samp{*}. | |
2366 | ||
2367 | The list describes the display that @var{frame} is on; if @var{frame} is | |
8d82c597 EZ |
2368 | omitted or @code{nil}, it applies to the selected frame's display |
2369 | (@pxref{Input Focus}). | |
8241495d RS |
2370 | |
2371 | The list contains a vector of the following form for each font: | |
2372 | ||
2373 | @example | |
2374 | [@var{family} @var{width} @var{point-size} @var{weight} @var{slant} | |
2375 | @var{fixed-p} @var{full} @var{registry-and-encoding}] | |
2376 | @end example | |
2377 | ||
2378 | The first five elements correspond to face attributes; if you | |
2379 | specify these attributes for a face, it will use this font. | |
2380 | ||
2381 | The last three elements give additional information about the font. | |
9a8dc0d3 RS |
2382 | @var{fixed-p} is non-@code{nil} if the font is fixed-pitch. |
2383 | @var{full} is the full name of the font, and | |
2384 | @var{registry-and-encoding} is a string giving the registry and | |
2385 | encoding of the font. | |
8241495d RS |
2386 | |
2387 | The result list is sorted according to the current face font sort order. | |
2388 | @end defun | |
2389 | ||
2390 | @defun x-font-family-list &optional frame | |
2391 | @tindex x-font-family-list | |
2392 | This function returns a list of the font families available for | |
2393 | @var{frame}'s display. If @var{frame} is omitted or @code{nil}, it | |
8d82c597 | 2394 | describes the selected frame's display (@pxref{Input Focus}). |
8241495d RS |
2395 | |
2396 | The value is a list of elements of this form: | |
2397 | ||
2398 | @example | |
2399 | (@var{family} . @var{fixed-p}) | |
2400 | @end example | |
2401 | ||
2402 | @noindent | |
2403 | Here @var{family} is a font family, and @var{fixed-p} is | |
2404 | non-@code{nil} if fonts of that family are fixed-pitch. | |
2405 | @end defun | |
2406 | ||
2407 | @defvar font-list-limit | |
2408 | @tindex font-list-limit | |
2409 | This variable specifies maximum number of fonts to consider in font | |
2410 | matching. The function @code{x-family-fonts} will not return more than | |
2411 | that many fonts, and font selection will consider only that many fonts | |
2412 | when searching a matching font for face attributes. The default is | |
2413 | currently 100. | |
2414 | @end defvar | |
2415 | ||
2416 | @node Fontsets | |
2417 | @subsection Fontsets | |
2418 | ||
2419 | A @dfn{fontset} is a list of fonts, each assigned to a range of | |
2420 | character codes. An individual font cannot display the whole range of | |
2421 | characters that Emacs supports, but a fontset can. Fontsets have names, | |
2422 | just as fonts do, and you can use a fontset name in place of a font name | |
2423 | when you specify the ``font'' for a frame or a face. Here is | |
2424 | information about defining a fontset under Lisp program control. | |
2425 | ||
2426 | @defun create-fontset-from-fontset-spec fontset-spec &optional style-variant-p noerror | |
2427 | This function defines a new fontset according to the specification | |
2428 | string @var{fontset-spec}. The string should have this format: | |
2429 | ||
2430 | @smallexample | |
2431 | @var{fontpattern}, @r{[}@var{charsetname}:@var{fontname}@r{]@dots{}} | |
2432 | @end smallexample | |
2433 | ||
2434 | @noindent | |
2435 | Whitespace characters before and after the commas are ignored. | |
2436 | ||
2437 | The first part of the string, @var{fontpattern}, should have the form of | |
2438 | a standard X font name, except that the last two fields should be | |
2439 | @samp{fontset-@var{alias}}. | |
2440 | ||
2441 | The new fontset has two names, one long and one short. The long name is | |
2442 | @var{fontpattern} in its entirety. The short name is | |
2443 | @samp{fontset-@var{alias}}. You can refer to the fontset by either | |
2444 | name. If a fontset with the same name already exists, an error is | |
2445 | signaled, unless @var{noerror} is non-@code{nil}, in which case this | |
2446 | function does nothing. | |
2447 | ||
2448 | If optional argument @var{style-variant-p} is non-@code{nil}, that says | |
2449 | to create bold, italic and bold-italic variants of the fontset as well. | |
2450 | These variant fontsets do not have a short name, only a long one, which | |
2451 | is made by altering @var{fontpattern} to indicate the bold or italic | |
2452 | status. | |
2453 | ||
2454 | The specification string also says which fonts to use in the fontset. | |
2455 | See below for the details. | |
2456 | @end defun | |
2457 | ||
2458 | The construct @samp{@var{charset}:@var{font}} specifies which font to | |
2459 | use (in this fontset) for one particular character set. Here, | |
2460 | @var{charset} is the name of a character set, and @var{font} is the font | |
2461 | to use for that character set. You can use this construct any number of | |
2462 | times in the specification string. | |
2463 | ||
2464 | For the remaining character sets, those that you don't specify | |
2465 | explicitly, Emacs chooses a font based on @var{fontpattern}: it replaces | |
2466 | @samp{fontset-@var{alias}} with a value that names one character set. | |
ad800164 | 2467 | For the @acronym{ASCII} character set, @samp{fontset-@var{alias}} is replaced |
8241495d RS |
2468 | with @samp{ISO8859-1}. |
2469 | ||
2470 | In addition, when several consecutive fields are wildcards, Emacs | |
2471 | collapses them into a single wildcard. This is to prevent use of | |
2472 | auto-scaled fonts. Fonts made by scaling larger fonts are not usable | |
2473 | for editing, and scaling a smaller font is not useful because it is | |
2474 | better to use the smaller font in its own size, which Emacs does. | |
2475 | ||
2476 | Thus if @var{fontpattern} is this, | |
2477 | ||
2478 | @example | |
2479 | -*-fixed-medium-r-normal-*-24-*-*-*-*-*-fontset-24 | |
2480 | @end example | |
2481 | ||
2482 | @noindent | |
ad800164 | 2483 | the font specification for @acronym{ASCII} characters would be this: |
8241495d RS |
2484 | |
2485 | @example | |
2486 | -*-fixed-medium-r-normal-*-24-*-ISO8859-1 | |
2487 | @end example | |
2488 | ||
2489 | @noindent | |
2490 | and the font specification for Chinese GB2312 characters would be this: | |
2491 | ||
2492 | @example | |
2493 | -*-fixed-medium-r-normal-*-24-*-gb2312*-* | |
2494 | @end example | |
2495 | ||
2496 | You may not have any Chinese font matching the above font | |
2497 | specification. Most X distributions include only Chinese fonts that | |
2498 | have @samp{song ti} or @samp{fangsong ti} in the @var{family} field. In | |
2499 | such a case, @samp{Fontset-@var{n}} can be specified as below: | |
2500 | ||
2501 | @smallexample | |
2502 | Emacs.Fontset-0: -*-fixed-medium-r-normal-*-24-*-*-*-*-*-fontset-24,\ | |
2503 | chinese-gb2312:-*-*-medium-r-normal-*-24-*-gb2312*-* | |
2504 | @end smallexample | |
2505 | ||
2506 | @noindent | |
2507 | Then, the font specifications for all but Chinese GB2312 characters have | |
2508 | @samp{fixed} in the @var{family} field, and the font specification for | |
2509 | Chinese GB2312 characters has a wild card @samp{*} in the @var{family} | |
2510 | field. | |
2511 | ||
885fef7c KH |
2512 | @defun set-fontset-font name character fontname &optional frame |
2513 | This function modifies the existing fontset @var{name} to | |
2514 | use the font name @var{fontname} for the character @var{character}. | |
2515 | ||
a2296bf9 | 2516 | If @var{name} is @code{nil}, this function modifies the default |
812a2341 | 2517 | fontset, whose short name is @samp{fontset-default}. |
885fef7c | 2518 | |
a2296bf9 KH |
2519 | @var{character} may be a cons; @code{(@var{from} . @var{to})}, where |
2520 | @var{from} and @var{to} are non-generic characters. In that case, use | |
2521 | @var{fontname} for all characters in the range @var{from} and @var{to} | |
2522 | (inclusive). | |
885fef7c KH |
2523 | |
2524 | @var{character} may be a charset. In that case, use | |
2525 | @var{fontname} for all character in the charsets. | |
2526 | ||
a2296bf9 KH |
2527 | @var{fontname} may be a cons; @code{(@var{family} . @var{registry})}, |
2528 | where @var{family} is a family name of a font (possibly including a | |
2529 | foundry name at the head), @var{registry} is a registry name of a font | |
2530 | (possibly including an encoding name at the tail). | |
885fef7c | 2531 | |
a2296bf9 KH |
2532 | For instance, this changes the default fontset to use a font of which |
2533 | registry name is @samp{JISX0208.1983} for all characters belonging to | |
2534 | the charset @code{japanese-jisx0208}. | |
885fef7c KH |
2535 | |
2536 | @example | |
2537 | (set-fontset-font nil 'japanese-jisx0208 '(nil . "JISX0208.1983")) | |
2538 | @end example | |
2539 | ||
2540 | @end defun | |
2541 | ||
f6cad089 RS |
2542 | @defun char-displayable-p char |
2543 | This function returns @code{t} if Emacs ought to be able to display | |
2544 | @var{char}. More precisely, if the selected frame's fontset has a | |
2545 | font to display the character set that @var{char} belongs to. | |
2546 | ||
2547 | Fontsets can specify a font on a per-character basis; when the fontset | |
2548 | does that, this function's value may not be accurate. | |
2549 | @end defun | |
2550 | ||
8a6ca431 RS |
2551 | @node Fringes |
2552 | @section Fringes | |
2553 | @cindex Fringes | |
2554 | ||
2555 | The @dfn{fringes} of a window are thin vertical strips down the | |
2556 | sides that are used for displaying bitmaps that indicate truncation, | |
812a2341 | 2557 | continuation, horizontal scrolling, and the overlay arrow. The |
8a6ca431 RS |
2558 | fringes normally appear between the display margins and the window |
2559 | text, but you can put them outside the display margins for a specific | |
2560 | buffer by setting @code{fringes-outside-margins} buffer-locally to a | |
2561 | non-@code{nil} value. | |
2562 | ||
2563 | @defvar fringes-outside-margins | |
2564 | If the value is non-@code{nil}, the frames appear outside | |
9b6e4bc3 | 2565 | the display margins. |
8a6ca431 RS |
2566 | @end defvar |
2567 | ||
2568 | @defvar left-fringe-width | |
2569 | This variable, if non-@code{nil}, specifies the width of the left | |
2570 | fringe in pixels. | |
2571 | @end defvar | |
2572 | ||
2573 | @defvar right-fringe-width | |
2574 | This variable, if non-@code{nil}, specifies the width of the right | |
2575 | fringe in pixels. | |
2576 | @end defvar | |
2577 | ||
2578 | The values of these variables take effect when you display the | |
2579 | buffer in a window. If you change them while the buffer is visible, | |
812a2341 RS |
2580 | you can call @code{set-window-buffer} to display it once again in the |
2581 | same window, to make the changes take effect. | |
8a6ca431 RS |
2582 | |
2583 | @defun set-window-fringes window left &optional right outside-margins | |
812a2341 | 2584 | This function sets the fringe widths of window @var{window}. |
479dbc9d | 2585 | If @var{window} is @code{nil}, the selected window is used. |
8a6ca431 RS |
2586 | |
2587 | The argument @var{left} specifies the width in pixels of the left | |
2588 | fringe, and likewise @var{right} for the right fringe. A value of | |
2589 | @code{nil} for either one stands for the default width. If | |
2590 | @var{outside-margins} is non-@code{nil}, that specifies that fringes | |
2591 | should appear outside of the display margins. | |
2592 | @end defun | |
2593 | ||
479dbc9d | 2594 | @defun window-fringes &optional window |
8a6ca431 | 2595 | This function returns information about the fringes of a window |
479dbc9d KS |
2596 | @var{window}. If @var{window} is omitted or @code{nil}, the selected |
2597 | window is used. The value has the form @code{(@var{left-width} | |
c00d3ba4 | 2598 | @var{right-width} @var{frames-outside-margins})}. |
8a6ca431 RS |
2599 | @end defun |
2600 | ||
9b6e4bc3 KS |
2601 | @defvar overflow-newline-into-fringe |
2602 | This variable, if non-@code{nil}, specifies that lines which are | |
2603 | exactly as wide as the window (not counting the final newline | |
2604 | character) shall not be broken into two lines on the display (with | |
2605 | just the newline on the second line). Instead, the newline now | |
2606 | overflows into the right fringe, and the cursor will be displayed in | |
2607 | the fringe when positioned on that newline. | |
2608 | @end defvar | |
2609 | ||
2610 | @defvar indicate-buffer-boundaries | |
2611 | This buffer-local variable controls how the buffer boundaries and | |
2612 | window scrolling is indicated in the fringes. | |
2613 | ||
2614 | The buffer boundaries, i.e. first and last line in the buffer, can be | |
2615 | marked with angle bitmaps in the left or right fringe. This can be | |
2616 | combined with up and down arrow bitmaps shown at the top and bottom of | |
2617 | the left or right fringe if the window can be scrolled in either | |
2618 | direction. | |
2619 | ||
2620 | If the value is @code{left} or @code{right}, both angle and arrow | |
2621 | bitmaps are displayed in the left or right fringe, respectively. | |
2622 | Any other non-@code{nil} value causes the bitmap on the top line to be | |
2623 | displayed in the left fringe, and the bitmap on the bottom line in the | |
2624 | right fringe. | |
2625 | ||
2626 | If value is a cons @code{(angles . arrows)}, the car specifies the | |
2627 | position of the angle bitmaps, and the cdr specifies the position of | |
2628 | the arrow bitmaps. For example, @code{(t . right)} places the top | |
2629 | angle bitmap in left fringe, the bottom angle bitmap in right fringe, | |
2630 | and both arrow bitmaps in right fringe. To show just the angle | |
2631 | bitmaps in the left fringe, but no arrow bitmaps, use @code{(left . nil)}. | |
2632 | @end defvar | |
2633 | ||
2634 | @defvar default-indicate-buffer-boundaries | |
2635 | The value of this variable is the default value for | |
2636 | @code{indicate-buffer-boundaries} in buffers that do not override it. | |
2637 | @end defvar | |
2638 | ||
2639 | @node Fringe Bitmaps | |
2640 | @section Fringe Bitmaps | |
2641 | @cindex Fringe Bitmaps | |
2642 | ||
2643 | The @dfn{fringe bitmaps} are tiny icons Emacs displays in the fringe | |
2644 | on a window system to indicate truncated or continued lines, buffer | |
2645 | boundaries, overlay arrow, etc. The fringe bitmaps are shared by all | |
2646 | frames and windows. | |
2647 | ||
2648 | You can redefine the built-in fringe bitmaps, and you can define new | |
2649 | fringe bitmaps. Emacs can handle a maximum of 255 different fringe | |
2650 | bitmaps. | |
2651 | ||
2652 | A fringe bitmap is identified by an opaque integer, but Lisp code | |
2653 | should use the following names defined by @code{(require 'fringe)}: | |
2654 | ||
2655 | Truncation and continuation line bitmaps: | |
2656 | @code{left-truncation-fringe-bitmap}, | |
2657 | @code{right-truncation-fringe-bitmap}, | |
2658 | @code{continued-line-fringe-bitmap}, | |
2659 | @code{continuation-line-fringe-bitmap}. | |
2660 | ||
2661 | Buffer indication bitmaps: | |
2662 | @code{up-arrow-fringe-bitmap}, | |
2663 | @code{down-arrow-fringe-bitmap}, | |
2664 | @code{top-left-angle-fringe-bitmap}, | |
2665 | @code{top-right-angle-fringe-bitmap}, | |
2666 | @code{bottom-left-angle-fringe-bitmap}, | |
2667 | @code{bottom-right-angle-fringe-bitmap}, | |
2668 | @code{left-bracket-fringe-bitmap}, | |
2669 | @code{right-bracket-fringe-bitmap}. | |
2670 | ||
2671 | Empty line indication bitmap: | |
2672 | @code{empty-line-fringe-bitmap}. | |
2673 | ||
2674 | Overlay arrow bitmap: | |
2675 | @code{overlay-arrow-fringe-bitmap}. | |
2676 | ||
2677 | Bitmaps for displaying the cursor in right fringe: | |
2678 | @code{filled-box-cursor-fringe-bitmap}, | |
2679 | @code{hollow-box-cursor-fringe-bitmap}, | |
2680 | @code{hollow-square-fringe-bitmap}, @code{bar-cursor-fringe-bitmap}, | |
2681 | @code{hbar-cursor-fringe-bitmap}. | |
2682 | ||
2683 | Fringe bitmap opaque value indicating that no fringe bitmap is present: | |
2684 | @code{no-fringe-bitmap}. | |
2685 | ||
2686 | Fringe bitmap opaque value indicating a reference to an undefined bitmap: | |
2687 | @code{undef-fringe-bitmap}. | |
2688 | ||
2689 | To display an specific fringe bitmap on a line in an Emacs window, | |
2690 | use it as a @code{left-fringe} or @code{right-fringe} specifier in the | |
2691 | @code{display} property of some text that is displayed on that line | |
2692 | (@pxref{Display Property}). | |
2693 | ||
2694 | @defun define-fringe-bitmap bits &optional height width align bitmap | |
2695 | Define a new fringe bitmap, or change an existing bitmap. | |
2696 | ||
2697 | The argument @code{bits} is either a string or a vector of integers, | |
2698 | where each element (typically) corresponds to one row of the bitmap, | |
2699 | and each bit of an integer corresponds to one pixel of the bitmap. | |
2700 | ||
2701 | The optional argument @code{height} specifies the height of the bitmap. | |
2702 | If @code{height} is @code{nil}, the length of @code{bits} is used. | |
2703 | ||
2704 | The optional argument @code{width} specifies the width of the bitmap; | |
2705 | it must be an integer between 1 and 16, or @code{nil} which defaults | |
2706 | to a width of 8 pixels. | |
2707 | ||
2708 | The optional argument @code{align} may be one of @code{top}, | |
2709 | @code{center}, or @code{bottom}, indicating the positioning of the | |
2710 | bitmap relative to the rows where it is used; the default is to center | |
2711 | the bitmap. | |
2712 | ||
2713 | The @code{align} argument may also be a list @code{(ALIGN PERIODIC)} | |
2714 | where @code{ALIGN} is intepreted as described above, and if | |
2715 | @code{PERIODIC} is non-@code{nil} it specifies that the @code{bits} should | |
2716 | be repeated until a bitmap of the specified @code{height} is created. | |
2717 | ||
2718 | The optional argument @code{bitmap} specifies the opaque integer that | |
2719 | identifies an existing bitmap to redefine. | |
2720 | ||
2721 | The return value is a new opaque integer identifying the new bitmap number, | |
2722 | or @code{nil} of there are no more free bitmap slots. | |
2723 | @end defun | |
2724 | ||
2725 | @defun destroy-fringe-bitmap bitmap | |
2726 | Destroy the fringe bitmap identified by the opaque integer | |
2727 | @code{bitmap}. If @code{bitmap} identifies a standard fringe bitmap, | |
2728 | the original built-in bitmap is restored. | |
2729 | @end defun | |
2730 | ||
2731 | @defun set-fringe-bitmap-face bitmap &optional face | |
2732 | Set face for a specific fringe bitmap @code{bitmap} to the face | |
2733 | specified by the argument @code{face}. | |
2734 | If @code{face} is @code{nil}, reset face to default @code{fringe} face. | |
2735 | ||
2736 | Normally, the specified face should be a face derived from the | |
2737 | @code{fringe} face, only specifying the foreground color as the | |
2738 | desired color of the fringe bitmap. | |
2739 | @end defun | |
2740 | ||
f6cad089 RS |
2741 | @node Scroll Bars |
2742 | @section Scroll Bars | |
2743 | ||
2744 | Normally the frame parameter @code{vertical-scroll-bars} controls | |
2745 | whether the windows in the frame have vertical scroll bars. A | |
2746 | non-@code{nil} parameter value means they do. The frame parameter | |
2747 | @code{scroll-bar-width} specifies how wide they are (@code{nil} | |
2748 | meaning the default). @xref{Window Frame Parameters}. | |
2749 | ||
2750 | You can also control this for individual windows. Call the function | |
2751 | @code{set-window-scroll-bars} to specify what to do for a specific window: | |
2752 | ||
2753 | @defun set-window-scroll-bars window width &optional vertical-type horizontal-type | |
9b6e4bc3 | 2754 | Set width and type of scroll bars of window @var{window}. |
479dbc9d | 2755 | If @var{window} is @code{nil}, the selected window is used. |
f6cad089 RS |
2756 | @var{width} specifies the scroll bar width in pixels (@code{nil} means |
2757 | use whatever is specified for width for the frame). | |
2758 | @var{vertical-type} specifies whether to have a vertical scroll bar | |
2759 | and, if so, where. The possible values are @code{left}, @code{right} | |
2760 | and @code{nil}, just like the values of the | |
2761 | @code{vertical-scroll-bars} frame parameter. | |
2762 | ||
2763 | The argument @var{horizontal-type} is meant to specify whether and | |
2764 | where to have horizontal scroll bars, but since they are not | |
2765 | implemented, it has no effect. | |
2766 | @end defun | |
2767 | ||
2768 | @defun window-scroll-bars &optional window | |
2769 | Report the width and type of scroll bars specified for @var{window}. | |
479dbc9d KS |
2770 | If @var{window} is omitted or @code{nil}, the selected window is used. |
2771 | The value is a list of the form @code{(@var{width} | |
f6cad089 RS |
2772 | @var{cols} @var{vertical-type} @var{horizontal-type})}. The value |
2773 | @var{width} is the value that was specified for the width (which may | |
2774 | be @code{nil}); @var{cols} is the number of columns that the scroll | |
2775 | bar actually occupies. | |
2776 | ||
2777 | @var{horizontal-type} is not actually meaningful. | |
2778 | @end defun | |
2779 | ||
2780 | If you don't specify these values for a window with | |
2781 | @code{set-window-scroll-bars}, the buffer-local variables | |
2782 | @code{scroll-bar-mode} and @code{scroll-bar-width} in the buffer being | |
2783 | displayed control the window's vertical scroll bars. The function | |
2784 | @code{set-window-buffer} examines these variables. If you change them | |
2785 | in a buffer that is already visible in a window, you can make the | |
2786 | window take note of the new values by calling @code{set-window-buffer} | |
2787 | specifying the same buffer that is already displayed. | |
2788 | ||
61e74968 LT |
2789 | @node Pointer Shape |
2790 | @section Pointer Shape | |
9b6e4bc3 KS |
2791 | |
2792 | Normally, the mouse pointer has the @code{text} shape over text and | |
2793 | the @code{arrow} shape over window areas which do not correspond to | |
2794 | any buffer text. | |
2795 | ||
2796 | The available pointer shapes are: @code{text} (or @code{nil}), | |
2797 | @code{arrow}, @code{hand}, @code{vdrag}, @code{hdrag}, | |
2798 | @code{modeline}, and @code{hourglass}. | |
2799 | ||
2800 | The mouse pointer shape over text or images can be changed via the | |
2801 | @code{pointer} text property, and for image with the @code{:pointer} | |
2802 | and @code{:map} image properties. | |
2803 | ||
2804 | @defvar void-text-area-pointer | |
2805 | @tindex void-text-area-pointer | |
2806 | This variable specifies the mouse pointer shape in void text areas, | |
2807 | i.e. the areas after the end of a line or below the last line in the | |
2808 | buffer. The default is to use the @code{arrow} (non-text) pointer. | |
2809 | @end defvar | |
2810 | ||
8241495d RS |
2811 | @node Display Property |
2812 | @section The @code{display} Property | |
2813 | @cindex display specification | |
2814 | @kindex display @r{(text property)} | |
2815 | ||
a40d4712 PR |
2816 | The @code{display} text property (or overlay property) is used to |
2817 | insert images into text, and also control other aspects of how text | |
2818 | displays. These features are available starting in Emacs 21. The value | |
2819 | of the @code{display} property should be a display specification, or a | |
2820 | list or vector containing several display specifications. The rest of | |
2821 | this section describes several kinds of display specifications and what | |
2822 | they mean. | |
8241495d RS |
2823 | |
2824 | @menu | |
02c77ee9 | 2825 | * Specified Space:: Displaying one space with a specified width. |
9b6e4bc3 | 2826 | * Pixel Specification:: Specifying space width or height in pixels. |
02c77ee9 | 2827 | * Other Display Specs:: Displaying an image; magnifying text; moving it |
177c0ea7 | 2828 | up or down on the page; adjusting the width |
a40d4712 PR |
2829 | of spaces within text. |
2830 | * Display Margins:: Displaying text or images to the side of the main text. | |
9b6e4bc3 | 2831 | * Display Fringe Bitmaps:: Displaying a fringe bitmap in a specific line. |
02c77ee9 | 2832 | * Conditional Display:: Making any of the above features conditional |
a40d4712 | 2833 | depending on some Lisp expression. |
8241495d RS |
2834 | @end menu |
2835 | ||
2836 | @node Specified Space | |
2837 | @subsection Specified Spaces | |
2838 | @cindex spaces, specified height or width | |
2839 | @cindex specified spaces | |
2840 | @cindex variable-width spaces | |
2841 | ||
2842 | To display a space of specified width and/or height, use a display | |
a40d4712 PR |
2843 | specification of the form @code{(space . @var{props})}, where |
2844 | @var{props} is a property list (a list of alternating properties and | |
2845 | values). You can put this property on one or more consecutive | |
2846 | characters; a space of the specified height and width is displayed in | |
2847 | place of @emph{all} of those characters. These are the properties you | |
0b0e8041 | 2848 | can use in @var{props} to specify the weight of the space: |
8241495d RS |
2849 | |
2850 | @table @code | |
2851 | @item :width @var{width} | |
9b6e4bc3 KS |
2852 | If @var{width} is an integer or floating point number, it specifies |
2853 | that the space width should be @var{width} times the normal character | |
2854 | width. The @var{width} may also be a @dfn{pixel width} specification | |
2855 | (@pxref{Pixel Specification}). | |
8241495d RS |
2856 | |
2857 | @item :relative-width @var{factor} | |
2858 | Specifies that the width of the stretch should be computed from the | |
2859 | first character in the group of consecutive characters that have the | |
2860 | same @code{display} property. The space width is the width of that | |
2861 | character, multiplied by @var{factor}. | |
2862 | ||
2863 | @item :align-to @var{hpos} | |
9b6e4bc3 KS |
2864 | Specifies that the space should be wide enough to reach @var{hpos}. |
2865 | If the value @var{hpos} is an integer or a floating point number, it | |
2866 | is measured in units of the normal character width. The @var{hpos} | |
2867 | may also be a @dfn{pixel width} specification (@pxref{Pixel Specification}). | |
8241495d RS |
2868 | @end table |
2869 | ||
9b6e4bc3 KS |
2870 | The @code{:height} and @code{:align-to} properties are also supported |
2871 | on non-window systems. | |
2872 | ||
0b0e8041 RS |
2873 | You should use one and only one of the above properties. You can |
2874 | also specify the height of the space, with other properties: | |
8241495d RS |
2875 | |
2876 | @table @code | |
2877 | @item :height @var{height} | |
9b6e4bc3 KS |
2878 | Specifies the height of the space. |
2879 | If @var{height} is an integer or floating point number, it specifies | |
2880 | that the space height should be @var{height} times the normal character | |
2881 | height. The @var{height} may also be a @dfn{pixel height} specification | |
2882 | (@pxref{Pixel Specification}). | |
8241495d RS |
2883 | |
2884 | @item :relative-height @var{factor} | |
2885 | Specifies the height of the space, multiplying the ordinary height | |
2886 | of the text having this display specification by @var{factor}. | |
2887 | ||
2888 | @item :ascent @var{ascent} | |
9b6e4bc3 KS |
2889 | If the value of @var{ascent} is a non-negative number no greater than |
2890 | 100, it specifies that @var{ascent} percent of the height of the space | |
2891 | should be considered as the ascent of the space---that is, the part | |
2892 | above the baseline. The ascent may also be specified in pixel units | |
2893 | with a @dfn{pixel ascent} specification (@pxref{Pixel Specification}). | |
2894 | ||
8241495d RS |
2895 | @end table |
2896 | ||
0b0e8041 | 2897 | Don't use both @code{:height} and @code{:relative-height} together. |
8241495d | 2898 | |
9b6e4bc3 KS |
2899 | @node Pixel Specification |
2900 | @subsection Pixel Specification for Spaces | |
2901 | @cindex spaces, pixel specification | |
2902 | ||
2903 | The value of the @code{:width}, @code{:align-to}, @code{:height}, | |
2904 | and @code{:ascent} properties can be a (trivial) expression | |
2905 | which is evaluated during redisplay. The result of the evaluation is | |
2906 | used as an absolute number of pixels. | |
2907 | ||
2908 | The following expressions are supported: | |
2909 | ||
2910 | @example | |
2911 | @group | |
2912 | EXPR ::= NUM | (NUM) | UNIT | ELEM | POS | IMAGE | FORM | |
2913 | NUM ::= INTEGER | FLOAT | SYMBOL | |
2914 | UNIT ::= in | mm | cm | width | height | |
2915 | ELEM ::= left-fringe | right-fringe | left-margin | right-margin | |
2916 | | scroll-bar | text | |
2917 | POS ::= left | center | right | |
2918 | FORM ::= (NUM . EXPR) | (OP EXPR ...) | |
2919 | OP ::= + | - | |
2920 | @end group | |
2921 | @end example | |
2922 | ||
2923 | The form @var{NUM} specifies a fractional width or height of the | |
61e74968 | 2924 | default frame font size. The form @code{(@var{NUM})} specifies an |
9b6e4bc3 KS |
2925 | absolute number of pixels. If a symbol @var{SYMBOL} is specified, its |
2926 | buffer-local variable binding is used. | |
2927 | ||
2928 | The @code{in}, @code{mm}, and @code{cm} units specifies the number | |
2929 | of pixels per inch, milli-meter, and centi-meter, resp. The | |
2930 | @code{width} and @code{height} units correspond to the width and | |
2931 | height of the current face font. An image specification @var{IMAGE} | |
2932 | corresponds to the width or height of the image. | |
2933 | ||
2934 | The @code{left-fringe}, @code{right-fringe}, @code{left-margin}, | |
2935 | @code{right-margin}, @code{scroll-bar}, and @code{text} elements | |
2936 | specify to the width of the corresponding area of the window. | |
2937 | ||
2938 | The @code{left}, @code{center}, and @code{right} positions can be | |
2939 | used with @code{:align-to} to specify a position relative to the left | |
2940 | edge, center, or right edge of the text area. | |
2941 | ||
2942 | One of the above window elements (except @code{text}) can also be | |
2943 | used with @code{:align-to} to specify that the position is relative to | |
2944 | the left edge of the given area. Once the base offset for a relative | |
2945 | position has been set (by the first occurrence of one of these | |
2946 | symbols), further occurences of these symbols are interpreted as the | |
2947 | width of the specified area. For example, to align to the center of | |
2948 | the left-margin, use | |
2949 | ||
2950 | @example | |
2951 | :align-to (+ left-margin (0.5 . left-margin)) | |
2952 | @end example | |
2953 | ||
2954 | If no specific base offset is set for alignment, it is always relative | |
2955 | to the left edge of the text area. For example, @samp{:align-to 0} in a | |
2956 | header-line aligns with the first text column in the text area. | |
2957 | ||
61e74968 | 2958 | The value of the form @code{(@var{NUM} . @var{EXPR})} is the value of |
9b6e4bc3 KS |
2959 | @var{NUM} multiplied by the value of the expression @var{EXPR}. For |
2960 | example, @samp{(2 . in)} specifies a width of 2 inches, while | |
2961 | @samp{(0.5 . IMAGE)} specifies half the width (or height) of the | |
2962 | specified image. | |
2963 | ||
2964 | The form @code{(+ @var{EXPR} ...)} adds up the value of the | |
2965 | expressions. The form @code{(- @var{EXPR} ...)} negates or subtracts | |
2966 | the value of the expressions. | |
2967 | ||
2968 | ||
8241495d RS |
2969 | @node Other Display Specs |
2970 | @subsection Other Display Specifications | |
2971 | ||
2972 | @table @code | |
2973 | @item (image . @var{image-props}) | |
2974 | This is in fact an image descriptor (@pxref{Images}). When used as a | |
2975 | display specification, it means to display the image instead of the text | |
2976 | that has the display specification. | |
2977 | ||
9b6e4bc3 KS |
2978 | @item (slice @var{x} @var{y} @var{width} @var{height}) |
2979 | This property is used with an @code{image} property to specify a | |
2980 | @dfn{slice} (a partial area) of the image to display. The top left | |
2981 | corner of the slice is specified by @var{y} and @var{x} and the width | |
2982 | and height of the slice is specified by @var{width} and @var{height}. | |
2983 | Integer values are taken as pixel values. A floating point number in | |
2984 | the range 0.0 - 1.0 is relative to the width or height of the whole | |
2985 | image. | |
2986 | ||
1574933b DL |
2987 | @item ((margin nil) @var{string}) |
2988 | @itemx @var{string} | |
2989 | A display specification of this form means to display @var{string} | |
2990 | instead of the text that has the display specification, at the same | |
2991 | position as that text. This is a special case of marginal display | |
2992 | (@pxref{Display Margins}). | |
2993 | ||
0b0e8041 RS |
2994 | Recursive display specifications are not supported---string display |
2995 | specifications must not have @code{display} properties themselves. | |
5143d8a4 | 2996 | |
8241495d | 2997 | @item (space-width @var{factor}) |
a40d4712 PR |
2998 | This display specification affects all the space characters within the |
2999 | text that has the specification. It displays all of these spaces | |
3000 | @var{factor} times as wide as normal. The element @var{factor} should | |
3001 | be an integer or float. Characters other than spaces are not affected | |
3002 | at all; in particular, this has no effect on tab characters. | |
8241495d RS |
3003 | |
3004 | @item (height @var{height}) | |
3005 | This display specification makes the text taller or shorter. | |
3006 | Here are the possibilities for @var{height}: | |
3007 | ||
3008 | @table @asis | |
3009 | @item @code{(+ @var{n})} | |
3010 | This means to use a font that is @var{n} steps larger. A ``step'' is | |
a40d4712 PR |
3011 | defined by the set of available fonts---specifically, those that match |
3012 | what was otherwise specified for this text, in all attributes except | |
3013 | height. Each size for which a suitable font is available counts as | |
3014 | another step. @var{n} should be an integer. | |
8241495d RS |
3015 | |
3016 | @item @code{(- @var{n})} | |
3017 | This means to use a font that is @var{n} steps smaller. | |
3018 | ||
3019 | @item a number, @var{factor} | |
3020 | A number, @var{factor}, means to use a font that is @var{factor} times | |
3021 | as tall as the default font. | |
3022 | ||
3023 | @item a symbol, @var{function} | |
3024 | A symbol is a function to compute the height. It is called with the | |
3025 | current height as argument, and should return the new height to use. | |
3026 | ||
3027 | @item anything else, @var{form} | |
3028 | If the @var{height} value doesn't fit the previous possibilities, it is | |
3029 | a form. Emacs evaluates it to get the new height, with the symbol | |
3030 | @code{height} bound to the current specified font height. | |
3031 | @end table | |
3032 | ||
3033 | @item (raise @var{factor}) | |
3034 | This kind of display specification raises or lowers the text | |
3035 | it applies to, relative to the baseline of the line. | |
3036 | ||
3037 | @var{factor} must be a number, which is interpreted as a multiple of the | |
3038 | height of the affected text. If it is positive, that means to display | |
3039 | the characters raised. If it is negative, that means to display them | |
3040 | lower down. | |
3041 | ||
3042 | If the text also has a @code{height} display specification, that does | |
3043 | not affect the amount of raising or lowering, which is based on the | |
3044 | faces used for the text. | |
3045 | @end table | |
3046 | ||
3047 | @node Display Margins | |
3048 | @subsection Displaying in the Margins | |
3049 | @cindex display margins | |
3050 | @cindex margins, display | |
3051 | ||
3052 | A buffer can have blank areas called @dfn{display margins} on the left | |
3053 | and on the right. Ordinary text never appears in these areas, but you | |
3054 | can put things into the display margins using the @code{display} | |
3055 | property. | |
3056 | ||
3057 | To put text in the left or right display margin of the window, use a | |
3058 | display specification of the form @code{(margin right-margin)} or | |
3059 | @code{(margin left-margin)} on it. To put an image in a display margin, | |
3060 | use that display specification along with the display specification for | |
a8e171ce RS |
3061 | the image. Unfortunately, there is currently no way to make |
3062 | text or images in the margin mouse-sensitive. | |
8241495d | 3063 | |
78263139 RS |
3064 | If you put such a display specification directly on text in the |
3065 | buffer, the specified margin display appears @emph{instead of} that | |
3066 | buffer text itself. To put something in the margin @emph{in | |
3067 | association with} certain buffer text without preventing or altering | |
3068 | the display of that text, put a @code{before-string} property on the | |
3069 | text and put the display specification on the contents of the | |
3070 | before-string. | |
3071 | ||
8241495d RS |
3072 | Before the display margins can display anything, you must give |
3073 | them a nonzero width. The usual way to do that is to set these | |
3074 | variables: | |
3075 | ||
3076 | @defvar left-margin-width | |
3077 | @tindex left-margin-width | |
3078 | This variable specifies the width of the left margin. | |
3079 | It is buffer-local in all buffers. | |
3080 | @end defvar | |
3081 | ||
3082 | @defvar right-margin-width | |
3083 | @tindex right-margin-width | |
3084 | This variable specifies the width of the right margin. | |
3085 | It is buffer-local in all buffers. | |
3086 | @end defvar | |
3087 | ||
3088 | Setting these variables does not immediately affect the window. These | |
3089 | variables are checked when a new buffer is displayed in the window. | |
3090 | Thus, you can make changes take effect by calling | |
3091 | @code{set-window-buffer}. | |
3092 | ||
3093 | You can also set the margin widths immediately. | |
3094 | ||
5143d8a4 | 3095 | @defun set-window-margins window left &optional right |
8241495d RS |
3096 | @tindex set-window-margins |
3097 | This function specifies the margin widths for window @var{window}. | |
177c0ea7 | 3098 | The argument @var{left} controls the left margin and |
5143d8a4 | 3099 | @var{right} controls the right margin (default @code{0}). |
8241495d RS |
3100 | @end defun |
3101 | ||
3102 | @defun window-margins &optional window | |
3103 | @tindex window-margins | |
3104 | This function returns the left and right margins of @var{window} | |
3105 | as a cons cell of the form @code{(@var{left} . @var{right})}. | |
3106 | If @var{window} is @code{nil}, the selected window is used. | |
3107 | @end defun | |
3108 | ||
9b6e4bc3 KS |
3109 | @node Display Fringe Bitmaps |
3110 | @subsection Displaying Bitmaps in the Fringes | |
3111 | @cindex display fringes | |
3112 | @cindex margins, fringes | |
3113 | ||
3114 | You can display a bitmap in the left or right fringes for a given | |
3115 | line in a window using the @code{display} property. | |
3116 | ||
3117 | To put text in the left or right fringe of the window, use a | |
3118 | display specification of the form @code{(left-fringe @var{bitmap} [@var{face}])} | |
3119 | or @code{(right-fringe @var{bitmap} [@var{face}])} on one of the | |
3120 | characters on the corresponding text line. | |
3121 | ||
3122 | The @var{bitmap} is an opaque integer identifying the bitmap, and the | |
3123 | optional @var{face} is the name of the face whose foreground and | |
3124 | background color is to be used for displaying the bitmap. | |
3125 | ||
3126 | @defun fringe-bitmaps-at-pos &optional pos window | |
3127 | This function returns the fringe bitmaps of the display row containing | |
3128 | position @var{pos} in window @var{window}. The return value is a cons | |
3129 | @code{(@var{left} . @var{right})} where @var{left} and @var{right} | |
3130 | are the fringe bitmap numbers for the bitmaps in the left and right | |
3131 | fringe, resp. | |
3132 | ||
3133 | Returns @code{nil} if @var{pos} is not visible in window | |
3134 | @var{window}. If @var{window} is @code{nil}, use the selected window. | |
3135 | If @var{pos} is @code{nil}, use value of point in that window. | |
3136 | @end defun | |
3137 | ||
8241495d RS |
3138 | @node Conditional Display |
3139 | @subsection Conditional Display Specifications | |
3140 | @cindex conditional display specifications | |
3141 | ||
3142 | You can make any display specification conditional. To do that, | |
bb2337f5 | 3143 | package it in another list of the form @code{(when @var{condition} . |
8241495d RS |
3144 | @var{spec})}. Then the specification @var{spec} applies only when |
3145 | @var{condition} evaluates to a non-@code{nil} value. During the | |
5fd2dcb8 GM |
3146 | evaluation, @code{object} is bound to the string or buffer having the |
3147 | conditional @code{display} property. @code{position} and | |
3148 | @code{buffer-position} are bound to the position within @code{object} | |
3149 | and the buffer position where the @code{display} property was found, | |
3150 | respectively. Both positions can be different when @code{object} is a | |
3151 | string. | |
8241495d RS |
3152 | |
3153 | @node Images | |
3154 | @section Images | |
3155 | @cindex images in buffers | |
3156 | ||
3157 | To display an image in an Emacs buffer, you must first create an image | |
3158 | descriptor, then use it as a display specifier in the @code{display} | |
3159 | property of text that is displayed (@pxref{Display Property}). Like the | |
3160 | @code{display} property, this feature is available starting in Emacs 21. | |
3161 | ||
3162 | Emacs can display a number of different image formats; some of them | |
da4b7798 JB |
3163 | are supported only if particular support libraries are installed on |
3164 | your machine. In some environments, Emacs allows loading image | |
3165 | libraries on demand; if so, the variable @code{image-library-alist} | |
3166 | can be used to modify the set of known names for these dynamic | |
3167 | libraries (though it is not posible to add new image formats). | |
3168 | ||
3169 | The supported image formats include XBM, XPM (needing the | |
8241495d RS |
3170 | libraries @code{libXpm} version 3.4k and @code{libz}), GIF (needing |
3171 | @code{libungif} 4.1.0), Postscript, PBM, JPEG (needing the | |
3172 | @code{libjpeg} library version v6a), TIFF (needing @code{libtiff} v3.4), | |
3173 | and PNG (needing @code{libpng} 1.0.2). | |
3174 | ||
3175 | You specify one of these formats with an image type symbol. The image | |
3176 | type symbols are @code{xbm}, @code{xpm}, @code{gif}, @code{postscript}, | |
3177 | @code{pbm}, @code{jpeg}, @code{tiff}, and @code{png}. | |
3178 | ||
3179 | @defvar image-types | |
3180 | This variable contains a list of those image type symbols that are | |
da4b7798 JB |
3181 | potentially supported in the current configuration. |
3182 | @emph{Potentially} here means that Emacs knows about the image types, | |
3183 | not necessarily that they can be loaded (they could depend on | |
3184 | unavailable dynamic libraries, for example). | |
3185 | ||
3186 | To know which image types are really available, use | |
3187 | @code{image-type-available-p}. | |
8241495d RS |
3188 | @end defvar |
3189 | ||
da4b7798 | 3190 | @defvar image-library-alist |
da4b7798 JB |
3191 | This in an alist of image types vs external libraries needed to |
3192 | display them. | |
3193 | ||
aa0e4da8 | 3194 | Each element is a list @code{(@var{image-type} @var{library}...)}, |
da4b7798 JB |
3195 | where the car is a supported image format from @code{image-types}, and |
3196 | the rest are strings giving alternate filenames for the corresponding | |
3197 | external libraries to load. | |
3198 | ||
e6263643 JB |
3199 | Emacs tries to load the libraries in the order they appear on the |
3200 | list; if none is loaded, the running session of Emacs won't support | |
3201 | the image type. @code{pbm} and @code{xbm} don't need to be listed; | |
da4b7798 JB |
3202 | they're always supported. |
3203 | ||
3204 | This variable is ignored if the image libraries are statically linked | |
3205 | into Emacs. | |
3206 | @end defvar | |
3207 | ||
3208 | @defun image-type-available-p type | |
3209 | @findex image-type-available-p | |
3210 | ||
aa0e4da8 JB |
3211 | This function returns non-@code{nil} if image type @var{type} is |
3212 | available, i.e., if images of this type can be loaded and displayed in | |
3213 | Emacs. @var{type} should be one of the types contained in | |
3214 | @code{image-types}. | |
da4b7798 JB |
3215 | |
3216 | For image types whose support libraries are statically linked, this | |
3217 | function always returns @code{t}; for other image types, it returns | |
3218 | @code{t} if the dynamic library could be loaded, @code{nil} otherwise. | |
3219 | @end defun | |
3220 | ||
8241495d | 3221 | @menu |
a40d4712 PR |
3222 | * Image Descriptors:: How to specify an image for use in @code{:display}. |
3223 | * XBM Images:: Special features for XBM format. | |
3224 | * XPM Images:: Special features for XPM format. | |
3225 | * GIF Images:: Special features for GIF format. | |
3226 | * Postscript Images:: Special features for Postscript format. | |
3227 | * Other Image Types:: Various other formats are supported. | |
3228 | * Defining Images:: Convenient ways to define an image for later use. | |
3229 | * Showing Images:: Convenient ways to display an image once it is defined. | |
3230 | * Image Cache:: Internal mechanisms of image display. | |
8241495d RS |
3231 | @end menu |
3232 | ||
3233 | @node Image Descriptors | |
3234 | @subsection Image Descriptors | |
3235 | @cindex image descriptor | |
3236 | ||
3237 | An image description is a list of the form @code{(image | |
3238 | . @var{props})}, where @var{props} is a property list containing | |
3239 | alternating keyword symbols (symbols whose names start with a colon) and | |
14ac7224 GM |
3240 | their values. You can use any Lisp object as a property, but the only |
3241 | properties that have any special meaning are certain symbols, all of | |
3242 | them keywords. | |
3243 | ||
3244 | Every image descriptor must contain the property @code{:type | |
3245 | @var{type}} to specify the format of the image. The value of @var{type} | |
3246 | should be an image type symbol; for example, @code{xpm} for an image in | |
3247 | XPM format. | |
8241495d RS |
3248 | |
3249 | Here is a list of other properties that are meaningful for all image | |
3250 | types: | |
3251 | ||
3252 | @table @code | |
2cd8656e RS |
3253 | @item :file @var{file} |
3254 | The @code{:file} property specifies to load the image from file | |
3255 | @var{file}. If @var{file} is not an absolute file name, it is expanded | |
3256 | in @code{data-directory}. | |
3257 | ||
3258 | @item :data @var{data} | |
3259 | The @code{:data} property specifies the actual contents of the image. | |
3260 | Each image must use either @code{:data} or @code{:file}, but not both. | |
3261 | For most image types, the value of the @code{:data} property should be a | |
3262 | string containing the image data; we recommend using a unibyte string. | |
3263 | ||
3264 | Before using @code{:data}, look for further information in the section | |
3265 | below describing the specific image format. For some image types, | |
3266 | @code{:data} may not be supported; for some, it allows other data types; | |
3267 | for some, @code{:data} alone is not enough, so you need to use other | |
3268 | image properties along with @code{:data}. | |
3269 | ||
3270 | @item :margin @var{margin} | |
3271 | The @code{:margin} property specifies how many pixels to add as an | |
9ee1638e | 3272 | extra margin around the image. The value, @var{margin}, must be a |
2cd8656e RS |
3273 | non-negative number, or a pair @code{(@var{x} . @var{y})} of such |
3274 | numbers. If it is a pair, @var{x} specifies how many pixels to add | |
3275 | horizontally, and @var{y} specifies how many pixels to add vertically. | |
3276 | If @code{:margin} is not specified, the default is zero. | |
3277 | ||
8241495d | 3278 | @item :ascent @var{ascent} |
04545643 GM |
3279 | The @code{:ascent} property specifies the amount of the image's |
3280 | height to use for its ascent---that is, the part above the baseline. | |
3281 | The value, @var{ascent}, must be a number in the range 0 to 100, or | |
3282 | the symbol @code{center}. | |
3283 | ||
3284 | If @var{ascent} is a number, that percentage of the image's height is | |
3285 | used for its ascent. | |
3286 | ||
3287 | If @var{ascent} is @code{center}, the image is vertically centered | |
3288 | around a centerline which would be the vertical centerline of text drawn | |
3289 | at the position of the image, in the manner specified by the text | |
3290 | properties and overlays that apply to the image. | |
3291 | ||
3292 | If this property is omitted, it defaults to 50. | |
8241495d | 3293 | |
8241495d RS |
3294 | @item :relief @var{relief} |
3295 | The @code{:relief} property, if non-@code{nil}, adds a shadow rectangle | |
3296 | around the image. The value, @var{relief}, specifies the width of the | |
3297 | shadow lines, in pixels. If @var{relief} is negative, shadows are drawn | |
3298 | so that the image appears as a pressed button; otherwise, it appears as | |
3299 | an unpressed button. | |
3300 | ||
f864120f GM |
3301 | @item :conversion @var{algorithm} |
3302 | The @code{:conversion} property, if non-@code{nil}, specifies a | |
8241495d RS |
3303 | conversion algorithm that should be applied to the image before it is |
3304 | displayed; the value, @var{algorithm}, specifies which algorithm. | |
3305 | ||
62fb5c66 DL |
3306 | @table @code |
3307 | @item laplace | |
3308 | @itemx emboss | |
3309 | Specifies the Laplace edge detection algorithm, which blurs out small | |
3310 | differences in color while highlighting larger differences. People | |
3311 | sometimes consider this useful for displaying the image for a | |
3312 | ``disabled'' button. | |
3313 | ||
3314 | @item (edge-detection :matrix @var{matrix} :color-adjust @var{adjust}) | |
3315 | Specifies a general edge-detection algorithm. @var{matrix} must be | |
3316 | either a nine-element list or a nine-element vector of numbers. A pixel | |
3317 | at position @math{x/y} in the transformed image is computed from | |
3318 | original pixels around that position. @var{matrix} specifies, for each | |
3319 | pixel in the neighborhood of @math{x/y}, a factor with which that pixel | |
3320 | will influence the transformed pixel; element @math{0} specifies the | |
3321 | factor for the pixel at @math{x-1/y-1}, element @math{1} the factor for | |
3322 | the pixel at @math{x/y-1} etc., as shown below: | |
3323 | @iftex | |
3324 | @tex | |
3325 | $$\pmatrix{x-1/y-1 & x/y-1 & x+1/y-1 \cr | |
3326 | x-1/y & x/y & x+1/y \cr | |
3327 | x-1/y+1& x/y+1 & x+1/y+1 \cr}$$ | |
3328 | @end tex | |
3329 | @end iftex | |
3330 | @ifnottex | |
3331 | @display | |
3332 | (x-1/y-1 x/y-1 x+1/y-1 | |
3333 | x-1/y x/y x+1/y | |
3334 | x-1/y+1 x/y+1 x+1/y+1) | |
3335 | @end display | |
3336 | @end ifnottex | |
3337 | ||
3338 | The resulting pixel is computed from the color intensity of the color | |
3339 | resulting from summing up the RGB values of surrounding pixels, | |
3340 | multiplied by the specified factors, and dividing that sum by the sum | |
3341 | of the factors' absolute values. | |
3342 | ||
3343 | Laplace edge-detection currently uses a matrix of | |
3344 | @iftex | |
3345 | @tex | |
3346 | $$\pmatrix{1 & 0 & 0 \cr | |
3347 | 0& 0 & 0 \cr | |
3348 | 9 & 9 & -1 \cr}$$ | |
3349 | @end tex | |
3350 | @end iftex | |
3351 | @ifnottex | |
3352 | @display | |
3353 | (1 0 0 | |
3354 | 0 0 0 | |
3355 | 9 9 -1) | |
3356 | @end display | |
3357 | @end ifnottex | |
3358 | ||
3359 | Emboss edge-detection uses a matrix of | |
3360 | @iftex | |
3361 | @tex | |
3362 | $$\pmatrix{ 2 & -1 & 0 \cr | |
3363 | -1 & 0 & 1 \cr | |
3364 | 0 & 1 & -2 \cr}$$ | |
3365 | @end tex | |
3366 | @end iftex | |
3367 | @ifnottex | |
3368 | @display | |
3369 | ( 2 -1 0 | |
3370 | -1 0 1 | |
3371 | 0 1 -2) | |
3372 | @end display | |
3373 | @end ifnottex | |
3374 | ||
3375 | @item disabled | |
3376 | Specifies transforming the image so that it looks ``disabled''. | |
3377 | @end table | |
8241495d | 3378 | |
62fb5c66 DL |
3379 | @item :mask @var{mask} |
3380 | If @var{mask} is @code{heuristic} or @code{(heuristic @var{bg})}, build | |
3381 | a clipping mask for the image, so that the background of a frame is | |
3382 | visible behind the image. If @var{bg} is not specified, or if @var{bg} | |
3383 | is @code{t}, determine the background color of the image by looking at | |
3384 | the four corners of the image, assuming the most frequently occurring | |
3385 | color from the corners is the background color of the image. Otherwise, | |
3386 | @var{bg} must be a list @code{(@var{red} @var{green} @var{blue})} | |
3387 | specifying the color to assume for the background of the image. | |
8241495d | 3388 | |
9a8dc0d3 RS |
3389 | If @var{mask} is @code{nil}, remove a mask from the image, if it has |
3390 | one. Images in some formats include a mask which can be removed by | |
3391 | specifying @code{:mask nil}. | |
9b6e4bc3 KS |
3392 | |
3393 | @item :pointer @var{shape} | |
3394 | This specifies the pointer shape when the mouse pointer is over this | |
3395 | image. @xref{Pointer Shapes}, for available pointer shapes. | |
3396 | ||
3397 | @item :map @var{map} | |
3398 | This associates an image map of @dfn{hot spots} with this image. | |
3399 | ||
3400 | An image map is an alist where each element has the format | |
3401 | @code{(@var{area} @var{id} @var{plist})}. An @var{area} is specified | |
3402 | as either a rectangle, a circle, or a polygon. | |
3403 | ||
3404 | A rectangle is a cons | |
3405 | @code{(rect . ((@var{x0} . @var{y0}) . (@var{x1} . @var{y1})))} | |
3406 | which specifies the pixel coordinates of the upper left and bottom right | |
3407 | corners of the rectangle area. | |
3408 | ||
3409 | A circle is a cons | |
3410 | @code{(circle . ((@var{x0} . @var{y0}) . @var{r}))} | |
3411 | which specifies the center and the radius of the circle; @var{r} may | |
3412 | be a float or integer. | |
3413 | ||
3414 | A polygon is a cons | |
61e74968 | 3415 | @code{(poly . [@var{x0} @var{y0} @var{x1} @var{y1} ...])} |
9b6e4bc3 KS |
3416 | where each pair in the vector describes one corner in the polygon. |
3417 | ||
3418 | When the mouse pointer is above a hot-spot area of an image, the | |
3419 | @var{plist} of that hot-spot is consulted; if it contains a @code{help-echo} | |
3420 | property it defines a tool-tip for the hot-spot, and if it contains | |
3421 | a @code{pointer} property, it defines the shape of the mouse cursor when | |
3422 | it is over the hot-spot. | |
3423 | @xref{Pointer Shapes}, for available pointer shapes. | |
3424 | ||
3425 | When you click the mouse when the mouse pointer is over a hot-spot, an | |
3426 | event is composed by combining the @var{id} of the hot-spot with the | |
3427 | mouse event, e.g. @samp{[area4 mouse-1]} if the hot-spot's @var{id} is | |
3428 | @samp{area4}. | |
3429 | ||
8241495d RS |
3430 | @end table |
3431 | ||
62fb5c66 DL |
3432 | @defun image-mask-p spec &optional frame |
3433 | @tindex image-mask-p | |
3434 | This function returns @code{t} if image @var{spec} has a mask bitmap. | |
3435 | @var{frame} is the frame on which the image will be displayed. | |
8d82c597 EZ |
3436 | @var{frame} @code{nil} or omitted means to use the selected frame |
3437 | (@pxref{Input Focus}). | |
62fb5c66 DL |
3438 | @end defun |
3439 | ||
8241495d RS |
3440 | @node XBM Images |
3441 | @subsection XBM Images | |
3442 | @cindex XBM | |
3443 | ||
3444 | To use XBM format, specify @code{xbm} as the image type. This image | |
3445 | format doesn't require an external library, so images of this type are | |
3446 | always supported. | |
3447 | ||
3448 | Additional image properties supported for the @code{xbm} image type are: | |
3449 | ||
3450 | @table @code | |
3451 | @item :foreground @var{foreground} | |
3452 | The value, @var{foreground}, should be a string specifying the image | |
0d88b7d0 GM |
3453 | foreground color, or @code{nil} for the default color. This color is |
3454 | used for each pixel in the XBM that is 1. The default is the frame's | |
3455 | foreground color. | |
8241495d RS |
3456 | |
3457 | @item :background @var{background} | |
3458 | The value, @var{background}, should be a string specifying the image | |
0d88b7d0 GM |
3459 | background color, or @code{nil} for the default color. This color is |
3460 | used for each pixel in the XBM that is 0. The default is the frame's | |
3461 | background color. | |
8241495d RS |
3462 | @end table |
3463 | ||
72821190 | 3464 | If you specify an XBM image using data within Emacs instead of an |
96f66dc5 | 3465 | external file, use the following three properties: |
8241495d RS |
3466 | |
3467 | @table @code | |
96f66dc5 GM |
3468 | @item :data @var{data} |
3469 | The value, @var{data}, specifies the contents of the image. | |
3470 | There are three formats you can use for @var{data}: | |
8241495d | 3471 | |
96f66dc5 GM |
3472 | @itemize @bullet |
3473 | @item | |
3474 | A vector of strings or bool-vectors, each specifying one line of the | |
3475 | image. Do specify @code{:height} and @code{:width}. | |
8241495d | 3476 | |
96f66dc5 GM |
3477 | @item |
3478 | A string containing the same byte sequence as an XBM file would contain. | |
3479 | You must not specify @code{:height} and @code{:width} in this case, | |
3480 | because omitting them is what indicates the data has the format of an | |
3481 | XBM file. The file contents specify the height and width of the image. | |
8241495d | 3482 | |
96f66dc5 GM |
3483 | @item |
3484 | A string or a bool-vector containing the bits of the image (plus perhaps | |
3485 | some extra bits at the end that will not be used). It should contain at | |
3486 | least @var{width} * @code{height} bits. In this case, you must specify | |
3487 | @code{:height} and @code{:width}, both to indicate that the string | |
3488 | contains just the bits rather than a whole XBM file, and to specify the | |
3489 | size of the image. | |
3490 | @end itemize | |
3491 | ||
3492 | @item :width @var{width} | |
3493 | The value, @var{width}, specifies the width of the image, in pixels. | |
3494 | ||
3495 | @item :height @var{height} | |
3496 | The value, @var{height}, specifies the height of the image, in pixels. | |
8241495d RS |
3497 | @end table |
3498 | ||
3499 | @node XPM Images | |
3500 | @subsection XPM Images | |
3501 | @cindex XPM | |
3502 | ||
72821190 RS |
3503 | To use XPM format, specify @code{xpm} as the image type. The |
3504 | additional image property @code{:color-symbols} is also meaningful with | |
3505 | the @code{xpm} image type: | |
8241495d RS |
3506 | |
3507 | @table @code | |
3508 | @item :color-symbols @var{symbols} | |
3509 | The value, @var{symbols}, should be an alist whose elements have the | |
3510 | form @code{(@var{name} . @var{color})}. In each element, @var{name} is | |
3511 | the name of a color as it appears in the image file, and @var{color} | |
3512 | specifies the actual color to use for displaying that name. | |
8241495d RS |
3513 | @end table |
3514 | ||
3515 | @node GIF Images | |
3516 | @subsection GIF Images | |
3517 | @cindex GIF | |
3518 | ||
3519 | For GIF images, specify image type @code{gif}. Because of the patents | |
3520 | in the US covering the LZW algorithm, the continued use of GIF format is | |
3521 | a problem for the whole Internet; to end this problem, it is a good idea | |
572fd5aa | 3522 | for everyone, even outside the US, to stop using GIFs right away |
8241495d RS |
3523 | (@uref{http://www.burnallgifs.org/}). But if you still want to use |
3524 | them, Emacs can display them. | |
3525 | ||
3526 | @table @code | |
3527 | @item :index @var{index} | |
3528 | You can use @code{:index} to specify one image from a GIF file that | |
3529 | contains more than one image. This property specifies use of image | |
00b3c1cd RS |
3530 | number @var{index} from the file. If the GIF file doesn't contain an |
3531 | image with index @var{index}, the image displays as a hollow box. | |
8241495d RS |
3532 | @end table |
3533 | ||
3534 | @ignore | |
3535 | This could be used to implement limited support for animated GIFs. | |
3536 | For example, the following function displays a multi-image GIF file | |
3537 | at point-min in the current buffer, switching between sub-images | |
3538 | every 0.1 seconds. | |
3539 | ||
3540 | (defun show-anim (file max) | |
3541 | "Display multi-image GIF file FILE which contains MAX subimages." | |
3542 | (display-anim (current-buffer) file 0 max t)) | |
3543 | ||
3544 | (defun display-anim (buffer file idx max first-time) | |
3545 | (when (= idx max) | |
3546 | (setq idx 0)) | |
3547 | (let ((img (create-image file nil :image idx))) | |
3548 | (save-excursion | |
3549 | (set-buffer buffer) | |
3550 | (goto-char (point-min)) | |
3551 | (unless first-time (delete-char 1)) | |
3552 | (insert-image img)) | |
3553 | (run-with-timer 0.1 nil 'display-anim buffer file (1+ idx) max nil))) | |
3554 | @end ignore | |
3555 | ||
3556 | @node Postscript Images | |
3557 | @subsection Postscript Images | |
3558 | @cindex Postscript images | |
3559 | ||
3560 | To use Postscript for an image, specify image type @code{postscript}. | |
3561 | This works only if you have Ghostscript installed. You must always use | |
3562 | these three properties: | |
3563 | ||
3564 | @table @code | |
3565 | @item :pt-width @var{width} | |
3566 | The value, @var{width}, specifies the width of the image measured in | |
3567 | points (1/72 inch). @var{width} must be an integer. | |
3568 | ||
3569 | @item :pt-height @var{height} | |
3570 | The value, @var{height}, specifies the height of the image in points | |
3571 | (1/72 inch). @var{height} must be an integer. | |
3572 | ||
3573 | @item :bounding-box @var{box} | |
3574 | The value, @var{box}, must be a list or vector of four integers, which | |
3575 | specifying the bounding box of the Postscript image, analogous to the | |
3576 | @samp{BoundingBox} comment found in Postscript files. | |
3577 | ||
3578 | @example | |
3579 | %%BoundingBox: 22 171 567 738 | |
3580 | @end example | |
3581 | @end table | |
3582 | ||
72821190 RS |
3583 | Displaying Postscript images from Lisp data is not currently |
3584 | implemented, but it may be implemented by the time you read this. | |
3585 | See the @file{etc/NEWS} file to make sure. | |
3586 | ||
8241495d RS |
3587 | @node Other Image Types |
3588 | @subsection Other Image Types | |
3589 | @cindex PBM | |
3590 | ||
3591 | For PBM images, specify image type @code{pbm}. Color, gray-scale and | |
7ccd82bd GM |
3592 | monochromatic images are supported. For mono PBM images, two additional |
3593 | image properties are supported. | |
3594 | ||
3595 | @table @code | |
3596 | @item :foreground @var{foreground} | |
3597 | The value, @var{foreground}, should be a string specifying the image | |
0d88b7d0 GM |
3598 | foreground color, or @code{nil} for the default color. This color is |
3599 | used for each pixel in the XBM that is 1. The default is the frame's | |
3600 | foreground color. | |
7ccd82bd GM |
3601 | |
3602 | @item :background @var{background} | |
3603 | The value, @var{background}, should be a string specifying the image | |
0d88b7d0 GM |
3604 | background color, or @code{nil} for the default color. This color is |
3605 | used for each pixel in the XBM that is 0. The default is the frame's | |
3606 | background color. | |
7ccd82bd | 3607 | @end table |
8241495d | 3608 | |
72821190 | 3609 | For JPEG images, specify image type @code{jpeg}. |
8241495d RS |
3610 | |
3611 | For TIFF images, specify image type @code{tiff}. | |
3612 | ||
3613 | For PNG images, specify image type @code{png}. | |
3614 | ||
3615 | @node Defining Images | |
3616 | @subsection Defining Images | |
3617 | ||
e3b9fc91 DL |
3618 | The functions @code{create-image}, @code{defimage} and |
3619 | @code{find-image} provide convenient ways to create image descriptors. | |
8241495d RS |
3620 | |
3621 | @defun create-image file &optional type &rest props | |
3622 | @tindex create-image | |
3623 | This function creates and returns an image descriptor which uses the | |
3624 | data in @var{file}. | |
3625 | ||
3626 | The optional argument @var{type} is a symbol specifying the image type. | |
3627 | If @var{type} is omitted or @code{nil}, @code{create-image} tries to | |
3628 | determine the image type from the file's first few bytes, or else | |
3629 | from the file's name. | |
3630 | ||
3631 | The remaining arguments, @var{props}, specify additional image | |
3632 | properties---for example, | |
3633 | ||
3634 | @example | |
3635 | (create-image "foo.xpm" 'xpm :heuristic-mask t) | |
3636 | @end example | |
3637 | ||
3638 | The function returns @code{nil} if images of this type are not | |
3639 | supported. Otherwise it returns an image descriptor. | |
3640 | @end defun | |
3641 | ||
11519a5e | 3642 | @defmac defimage symbol specs &optional doc |
8241495d | 3643 | @tindex defimage |
11519a5e EZ |
3644 | This macro defines @var{symbol} as an image name. The arguments |
3645 | @var{specs} is a list which specifies how to display the image. | |
3646 | The third argument, @var{doc}, is an optional documentation string. | |
8241495d RS |
3647 | |
3648 | Each argument in @var{specs} has the form of a property list, and each | |
11519a5e EZ |
3649 | one should specify at least the @code{:type} property and either the |
3650 | @code{:file} or the @code{:data} property. The value of @code{:type} | |
3651 | should be a symbol specifying the image type, the value of | |
3652 | @code{:file} is the file to load the image from, and the value of | |
3653 | @code{:data} is a string containing the actual image data. Here is an | |
3654 | example: | |
8241495d | 3655 | |
a40d4712 PR |
3656 | @example |
3657 | (defimage test-image | |
f43c34a0 RS |
3658 | ((:type xpm :file "~/test1.xpm") |
3659 | (:type xbm :file "~/test1.xbm"))) | |
a40d4712 | 3660 | @end example |
8241495d RS |
3661 | |
3662 | @code{defimage} tests each argument, one by one, to see if it is | |
3663 | usable---that is, if the type is supported and the file exists. The | |
3664 | first usable argument is used to make an image descriptor which is | |
11519a5e | 3665 | stored in @var{symbol}. |
8241495d | 3666 | |
11519a5e | 3667 | If none of the alternatives will work, then @var{symbol} is defined |
8241495d RS |
3668 | as @code{nil}. |
3669 | @end defmac | |
3670 | ||
e3b9fc91 DL |
3671 | @defun find-image specs |
3672 | @tindex find-image | |
3673 | This function provides a convenient way to find an image satisfying one | |
3674 | of a list of image specifications @var{specs}. | |
3675 | ||
3676 | Each specification in @var{specs} is a property list with contents | |
3677 | depending on image type. All specifications must at least contain the | |
3678 | properties @code{:type @var{type}} and either @w{@code{:file @var{file}}} | |
3679 | or @w{@code{:data @var{DATA}}}, where @var{type} is a symbol specifying | |
3680 | the image type, e.g.@: @code{xbm}, @var{file} is the file to load the | |
3681 | image from, and @var{data} is a string containing the actual image data. | |
3682 | The first specification in the list whose @var{type} is supported, and | |
3683 | @var{file} exists, is used to construct the image specification to be | |
3684 | returned. If no specification is satisfied, @code{nil} is returned. | |
3685 | ||
3686 | The image is looked for first on @code{load-path} and then in | |
3687 | @code{data-directory}. | |
3688 | @end defun | |
3689 | ||
8241495d RS |
3690 | @node Showing Images |
3691 | @subsection Showing Images | |
3692 | ||
3693 | You can use an image descriptor by setting up the @code{display} | |
3694 | property yourself, but it is easier to use the functions in this | |
3695 | section. | |
3696 | ||
9b6e4bc3 | 3697 | @defun insert-image image &optional string area slice |
8241495d RS |
3698 | This function inserts @var{image} in the current buffer at point. The |
3699 | value @var{image} should be an image descriptor; it could be a value | |
3700 | returned by @code{create-image}, or the value of a symbol defined with | |
a40d4712 PR |
3701 | @code{defimage}. The argument @var{string} specifies the text to put in |
3702 | the buffer to hold the image. | |
8241495d RS |
3703 | |
3704 | The argument @var{area} specifies whether to put the image in a margin. | |
3705 | If it is @code{left-margin}, the image appears in the left margin; | |
3706 | @code{right-margin} specifies the right margin. If @var{area} is | |
3707 | @code{nil} or omitted, the image is displayed at point within the | |
3708 | buffer's text. | |
3709 | ||
9b6e4bc3 KS |
3710 | The argument @var{slice} specifies a slice of the image to insert. If |
3711 | @var{slice} is @code{nil} or omitted the whole image is inserted. | |
3712 | Otherwise, @var{slice} is a list | |
3713 | @code{(@var{x} @var{y} @var{width} @var{height})} | |
3714 | which specifies the @var{x} and @var{y} positions and | |
3715 | @var{width} and @var{height} of the image area to insert. Integer | |
3716 | values are taken as pixel values. A floating point number in the | |
3717 | range 0.0 - 1.0 is relative to the width or height of the image. | |
3718 | ||
a40d4712 PR |
3719 | Internally, this function inserts @var{string} in the buffer, and gives |
3720 | it a @code{display} property which specifies @var{image}. @xref{Display | |
8241495d RS |
3721 | Property}. |
3722 | @end defun | |
3723 | ||
9b6e4bc3 KS |
3724 | @defun insert-sliced-image image &optional string area rows cols |
3725 | This function inserts @var{image} in the current buffer at point like | |
3726 | @code{insert-image}, but the image is automatically split into | |
3727 | @var{rows} x @var{cols} equally sized slices. | |
3728 | @end defun | |
3729 | ||
bb2337f5 | 3730 | @defun put-image image pos &optional string area |
8241495d RS |
3731 | This function puts image @var{image} in front of @var{pos} in the |
3732 | current buffer. The argument @var{pos} should be an integer or a | |
3733 | marker. It specifies the buffer position where the image should appear. | |
bb2337f5 DL |
3734 | The argument @var{string} specifies the text that should hold the image |
3735 | as an alternative to the default. | |
8241495d RS |
3736 | |
3737 | The argument @var{image} must be an image descriptor, perhaps returned | |
3738 | by @code{create-image} or stored by @code{defimage}. | |
3739 | ||
3740 | The argument @var{area} specifies whether to put the image in a margin. | |
3741 | If it is @code{left-margin}, the image appears in the left margin; | |
3742 | @code{right-margin} specifies the right margin. If @var{area} is | |
3743 | @code{nil} or omitted, the image is displayed at point within the | |
3744 | buffer's text. | |
3745 | ||
3746 | Internally, this function creates an overlay, and gives it a | |
3747 | @code{before-string} property containing text that has a @code{display} | |
3748 | property whose value is the image. (Whew!) | |
3749 | @end defun | |
3750 | ||
3751 | @defun remove-images start end &optional buffer | |
3752 | This function removes images in @var{buffer} between positions | |
3753 | @var{start} and @var{end}. If @var{buffer} is omitted or @code{nil}, | |
3754 | images are removed from the current buffer. | |
3755 | ||
05aea714 | 3756 | This removes only images that were put into @var{buffer} the way |
8241495d RS |
3757 | @code{put-image} does it, not images that were inserted with |
3758 | @code{insert-image} or in other ways. | |
3759 | @end defun | |
3760 | ||
e3b9fc91 DL |
3761 | @defun image-size spec &optional pixels frame |
3762 | @tindex image-size | |
3763 | This function returns the size of an image as a pair | |
3764 | @w{@code{(@var{width} . @var{height})}}. @var{spec} is an image | |
9a8dc0d3 RS |
3765 | specification. @var{pixels} non-@code{nil} means return sizes |
3766 | measured in pixels, otherwise return sizes measured in canonical | |
3767 | character units (fractions of the width/height of the frame's default | |
3768 | font). @var{frame} is the frame on which the image will be displayed. | |
8d82c597 EZ |
3769 | @var{frame} null or omitted means use the selected frame (@pxref{Input |
3770 | Focus}). | |
e3b9fc91 DL |
3771 | @end defun |
3772 | ||
8241495d RS |
3773 | @node Image Cache |
3774 | @subsection Image Cache | |
3775 | ||
3776 | Emacs stores images in an image cache when it displays them, so it can | |
3777 | display them again more efficiently. It removes an image from the cache | |
3778 | when it hasn't been displayed for a specified period of time. | |
3779 | ||
3e8b2a01 GM |
3780 | When an image is looked up in the cache, its specification is compared |
3781 | with cached image specifications using @code{equal}. This means that | |
3782 | all images with equal specifications share the same image in the cache. | |
3783 | ||
8241495d RS |
3784 | @defvar image-cache-eviction-delay |
3785 | @tindex image-cache-eviction-delay | |
3786 | This variable specifies the number of seconds an image can remain in the | |
3787 | cache without being displayed. When an image is not displayed for this | |
3788 | length of time, Emacs removes it from the image cache. | |
3789 | ||
3790 | If the value is @code{nil}, Emacs does not remove images from the cache | |
3791 | except when you explicitly clear it. This mode can be useful for | |
3792 | debugging. | |
3793 | @end defvar | |
3794 | ||
3795 | @defun clear-image-cache &optional frame | |
3796 | @tindex clear-image-cache | |
3797 | This function clears the image cache. If @var{frame} is non-@code{nil}, | |
3798 | only the cache for that frame is cleared. Otherwise all frames' caches | |
3799 | are cleared. | |
3800 | @end defun | |
a065c889 | 3801 | |
02c77ee9 MB |
3802 | @node Buttons |
3803 | @section Buttons | |
a3cb3b2e | 3804 | @cindex buttons |
02c77ee9 MB |
3805 | @cindex buttons in buffers |
3806 | @cindex clickable buttons in buffers | |
3807 | ||
3808 | The @emph{button} package defines functions for inserting and | |
3809 | manipulating clickable (with the mouse, or via keyboard commands) | |
a3cb3b2e MB |
3810 | buttons in Emacs buffers, such as might be used for help hyper-links, |
3811 | etc. Emacs uses buttons for the hyper-links in help text and the like. | |
02c77ee9 MB |
3812 | |
3813 | A button is essentially a set of properties attached (via text | |
058296d3 | 3814 | properties or overlays) to a region of text in an Emacs buffer, which |
02c77ee9 MB |
3815 | are called its button properties. @xref{Button Properties}. |
3816 | ||
3817 | One of the these properties (@code{action}) is a function, which will | |
3818 | be called when the user invokes it using the keyboard or the mouse. | |
3819 | The invoked function may then examine the button and use its other | |
3820 | properties as desired. | |
3821 | ||
058296d3 | 3822 | In some ways the Emacs button package duplicates functionality offered |
02c77ee9 MB |
3823 | by the widget package (@pxref{Top, , Introduction, widget, The Emacs |
3824 | Widget Library}), but the button package has the advantage that it is | |
3825 | much faster, much smaller, and much simpler to use (for elisp | |
3826 | programmers---for users, the result is about the same). The extra | |
3827 | speed and space savings are useful mainly if you need to create many | |
3828 | buttons in a buffer (for instance an @code{*Apropos*} buffer uses | |
3829 | buttons to make entries clickable, and may contain many thousands of | |
3830 | entries). | |
3831 | ||
3832 | @menu | |
3833 | * Button Properties:: Button properties with special meanings. | |
3834 | * Button Types:: Defining common properties for classes of buttons. | |
058296d3 | 3835 | * Making Buttons:: Adding buttons to Emacs buffers. |
02c77ee9 MB |
3836 | * Manipulating Buttons:: Getting and setting properties of buttons. |
3837 | * Button Buffer Commands:: Buffer-wide commands and bindings for buttons. | |
9b6e4bc3 | 3838 | * Manipulating Button Types:: |
02c77ee9 MB |
3839 | @end menu |
3840 | ||
3841 | @node Button Properties | |
3842 | @subsection Button Properties | |
3843 | @cindex button properties | |
3844 | ||
3845 | Buttons have an associated list of properties defining their | |
3846 | appearance and behavior, and other arbitrary properties may be used | |
3847 | for application specific purposes. | |
3848 | ||
3849 | Some properties that have special meaning to the button package | |
3850 | include: | |
3851 | ||
3852 | @table @code | |
3853 | ||
3854 | @item action | |
a3cb3b2e | 3855 | @kindex action @r{(button property)} |
02c77ee9 MB |
3856 | The function to call when the user invokes the button, which is passed |
3857 | the single argument @var{button}. By default this is @code{ignore}, | |
3858 | which does nothing. | |
3859 | ||
3860 | @item mouse-action | |
a3cb3b2e | 3861 | @kindex mouse-action @r{(button property)} |
02c77ee9 MB |
3862 | This is similar to @code{action}, and when present, will be used |
3863 | instead of @code{action} for button invocations resulting from | |
3864 | mouse-clicks (instead of the user hitting @key{RET}). If not | |
3865 | present, mouse-clicks use @code{action} instead. | |
3866 | ||
3867 | @item face | |
a3cb3b2e | 3868 | @kindex face @r{(button property)} |
058296d3 | 3869 | This is an Emacs face controlling how buttons of this type are |
02c77ee9 MB |
3870 | displayed; by default this is the @code{button} face. |
3871 | ||
3872 | @item mouse-face | |
a3cb3b2e | 3873 | @kindex mouse-face @r{(button property)} |
02c77ee9 MB |
3874 | This is an additional face which controls appearance during |
3875 | mouse-overs (merged with the usual button face); by default this is | |
058296d3 | 3876 | the usual Emacs @code{highlight} face. |
02c77ee9 MB |
3877 | |
3878 | @item keymap | |
a3cb3b2e | 3879 | @kindex keymap @r{(button property)} |
02c77ee9 MB |
3880 | The button's keymap, defining bindings active within the button |
3881 | region. By default this is the usual button region keymap, stored | |
3882 | in the variable @code{button-map}, which defines @key{RET} and | |
eb3c144c | 3883 | @key{mouse-2} to invoke the button. |
02c77ee9 MB |
3884 | |
3885 | @item type | |
a3cb3b2e | 3886 | @kindex type @r{(button property)} |
02c77ee9 MB |
3887 | The button-type of the button. When creating a button, this is |
3888 | usually specified using the @code{:type} keyword argument. | |
3889 | @xref{Button Types}. | |
3890 | ||
3891 | @item help-echo | |
a3cb3b2e | 3892 | @kindex help-index @r{(button property)} |
058296d3 | 3893 | A string displayed by the Emacs tool-tip help system; by default, |
02c77ee9 MB |
3894 | @code{"mouse-2, RET: Push this button"}. |
3895 | ||
3896 | @item button | |
a3cb3b2e | 3897 | @kindex button @r{(button property)} |
02c77ee9 MB |
3898 | All buttons have a non-@code{nil} @code{button} property, which may be useful |
3899 | in finding regions of text that comprise buttons (which is what the | |
3900 | standard button functions do). | |
3901 | @end table | |
3902 | ||
3903 | There are other properties defined for the regions of text in a | |
3904 | button, but these are not generally interesting for typical uses. | |
3905 | ||
3906 | @node Button Types | |
3907 | @subsection Button Types | |
3908 | @cindex button types | |
3909 | ||
3910 | Every button has a button @emph{type}, which defines default values | |
a3cb3b2e MB |
3911 | for the button's properties. Button types are arranged in a |
3912 | hierarchy, with specialized types inheriting from more general types, | |
3913 | so that it's easy to define special-purpose types of buttons for | |
3914 | specific tasks. | |
02c77ee9 MB |
3915 | |
3916 | @defun define-button-type name &rest properties | |
3917 | @tindex define-button-type | |
3918 | Define a `button type' called @var{name}. The remaining arguments | |
3919 | form a sequence of @var{property value} pairs, specifying default | |
3920 | property values for buttons with this type (a button's type may be set | |
3921 | by giving it a @code{type} property when creating the button, using | |
3922 | the @code{:type} keyword argument). | |
3923 | ||
3924 | In addition, the keyword argument @code{:supertype} may be used to | |
3925 | specify a button-type from which @var{name} inherits its default | |
3926 | property values. Note that this inheritance happens only when | |
3927 | @var{name} is defined; subsequent changes to a supertype are not | |
3928 | reflected in its subtypes. | |
3929 | @end defun | |
3930 | ||
3931 | Using @code{define-button-type} to define default properties for | |
a3cb3b2e MB |
3932 | buttons is not necessary---buttons without any specified type use the |
3933 | built-in button-type @code{button}---but it is is encouraged, since | |
3934 | doing so usually makes the resulting code clearer and more efficient. | |
02c77ee9 | 3935 | |
a3cb3b2e MB |
3936 | @node Making Buttons |
3937 | @subsection Making Buttons | |
02c77ee9 MB |
3938 | @cindex making buttons |
3939 | ||
3940 | Buttons are associated with a region of text, using an overlay or | |
3941 | text-properties to hold button-specific information, all of which are | |
3942 | initialized from the button's type (which defaults to the built-in | |
058296d3 | 3943 | button type @code{button}). Like all Emacs text, the appearance of |
02c77ee9 MB |
3944 | the button is governed by the @code{face} property; by default (via |
3945 | the @code{face} property inherited from the @code{button} button-type) | |
3946 | this is a simple underline, like a typical web-page link. | |
3947 | ||
3948 | For convenience, there are two sorts of button-creation functions, | |
3949 | those that add button properties to an existing region of a buffer, | |
3950 | called @code{make-...button}, and those also insert the button text, | |
3951 | called @code{insert-...button}. | |
3952 | ||
3953 | The button-creation functions all take the @code{&rest} argument | |
3954 | @var{properties}, which should be a sequence of @var{property value} | |
3955 | pairs, specifying properties to add to the button; see @ref{Button | |
3956 | Properties}. In addition, the keyword argument @code{:type} may be | |
3957 | used to specify a button-type from which to inherit other properties; | |
3958 | see @ref{Button Types}. Any properties not explicitly specified | |
3959 | during creation will be inherited from the button's type (if the type | |
3960 | defines such a property). | |
3961 | ||
3962 | The following functions add a button using an overlay | |
3963 | (@pxref{Overlays}) to hold the button properties: | |
3964 | ||
3965 | @defun make-button beg end &rest properties | |
3966 | @tindex make-button | |
3967 | Make a button from @var{beg} to @var{end} in the current buffer. | |
3968 | @end defun | |
3969 | ||
3970 | @defun insert-button label &rest properties | |
3971 | @tindex insert-button | |
3972 | Insert a button with the label @var{label}. | |
3973 | @end defun | |
3974 | ||
058296d3 | 3975 | The following functions are similar, but use Emacs text-properties |
02c77ee9 MB |
3976 | (@pxref{Text Properties}) to hold the button properties, making the |
3977 | button actually part of the text instead of being a property of the | |
3978 | buffer (using text-properties is usually faster than using overlays, | |
3979 | so this may be preferable when creating large numbers of buttons): | |
3980 | ||
3981 | @defun make-text-button beg end &rest properties | |
3982 | @tindex make-text-button | |
3983 | Make a button from @var{beg} to @var{end} in the current buffer, using | |
3984 | text-properties. | |
3985 | @end defun | |
3986 | ||
3987 | @defun insert-text-button label &rest properties | |
3988 | @tindex insert-text-button | |
3989 | Insert a button with the label @var{label}, using text-properties. | |
3990 | @end defun | |
3991 | ||
3992 | Buttons using text-properties retain no markers into the buffer are | |
3993 | retained, which is important for speed in cases where there are | |
3994 | extremely large numbers of buttons. | |
3995 | ||
3996 | @node Manipulating Buttons | |
3997 | @subsection Manipulating Buttons | |
3998 | @cindex manipulating buttons | |
3999 | ||
4000 | These are functions for getting and setting properties of buttons. | |
4001 | Often these are used by a button's invocation function to determine | |
4002 | what to do. | |
4003 | ||
4004 | Where a @var{button} parameter is specified, it means an object | |
4005 | referring to a specific button, either an overlay (for overlay | |
4006 | buttons), or a buffer-position or marker (for text property buttons). | |
4007 | Such an object is passed as the first argument to a button's | |
4008 | invocation function when it is invoked. | |
4009 | ||
4010 | @defun button-start button | |
4011 | @tindex button-start | |
4012 | Return the position at which @var{button} starts. | |
4013 | @end defun | |
4014 | ||
4015 | @defun button-end button | |
4016 | @tindex button-end | |
4017 | Return the position at which @var{button} ends. | |
4018 | @end defun | |
4019 | ||
4020 | @defun button-get button prop | |
4021 | @tindex button-get | |
4022 | Get the property of button @var{button} named @var{prop}. | |
4023 | @end defun | |
4024 | ||
4025 | @defun button-put button prop val | |
4026 | @tindex button-put | |
4027 | Set @var{button}'s @var{prop} property to @var{val}. | |
4028 | @end defun | |
4029 | ||
4030 | @defun button-activate button &optional use-mouse-action | |
4031 | @tindex button-activate | |
4032 | Call @var{button}'s @code{action} property (i.e., invoke it). If | |
4033 | @var{use-mouse-action} is non-@code{nil}, try to invoke the button's | |
a3cb3b2e MB |
4034 | @code{mouse-action} property instead of @code{action}; if the button |
4035 | has no @code{mouse-action} property, use @code{action} as normal. | |
02c77ee9 MB |
4036 | @end defun |
4037 | ||
4038 | @defun button-label button | |
4039 | @tindex button-label | |
4040 | Return @var{button}'s text label. | |
4041 | @end defun | |
4042 | ||
4043 | @defun button-type button | |
4044 | @tindex button-type | |
4045 | Return @var{button}'s button-type. | |
4046 | @end defun | |
4047 | ||
4048 | @defun button-has-type-p button type | |
4049 | @tindex button-has-type-p | |
4050 | Return @code{t} if @var{button} has button-type @var{type}, or one of | |
4051 | @var{type}'s subtypes. | |
4052 | @end defun | |
4053 | ||
4054 | @defun button-at pos | |
4055 | @tindex button-at | |
4056 | Return the button at position @var{pos} in the current buffer, or @code{nil}. | |
4057 | @end defun | |
4058 | ||
4059 | @node Button Buffer Commands | |
4060 | @subsection Button Buffer Commands | |
4061 | @cindex button buffer commands | |
4062 | ||
4063 | These are commands and functions for locating and operating on | |
058296d3 | 4064 | buttons in an Emacs buffer. |
02c77ee9 MB |
4065 | |
4066 | @code{push-button} is the command that a user uses to actually `push' | |
4067 | a button, and is bound by default in the button itself to @key{RET} | |
eb3c144c | 4068 | and to @key{mouse-2} using a region-specific keymap. Commands |
02c77ee9 MB |
4069 | that are useful outside the buttons itself, such as |
4070 | @code{forward-button} and @code{backward-button} are additionally | |
4071 | available in the keymap stored in @code{button-buffer-map}; a mode | |
4072 | which uses buttons may want to use @code{button-buffer-map} as a | |
4073 | parent keymap for its keymap. | |
4074 | ||
4075 | @deffn Command push-button &optional pos use-mouse-action | |
4076 | @tindex push-button | |
4077 | Perform the action specified by a button at location @var{pos}. | |
4078 | @var{pos} may be either a buffer position or a mouse-event. If | |
a3cb3b2e MB |
4079 | @var{use-mouse-action} is non-@code{nil}, or @var{pos} is a |
4080 | mouse-event (@pxref{Mouse Events}), try to invoke the button's | |
4081 | @code{mouse-action} property instead of @code{action}; if the button | |
4082 | has no @code{mouse-action} property, use @code{action} as normal. | |
4083 | @var{pos} defaults to point, except when @code{push-button} is invoked | |
4084 | interactively as the result of a mouse-event, in which case, the mouse | |
4085 | event's position is used. If there's no button at @var{pos}, do | |
02c77ee9 MB |
4086 | nothing and return @code{nil}, otherwise return @code{t}. |
4087 | @end deffn | |
4088 | ||
4089 | @deffn Command forward-button n &optional wrap display-message | |
4090 | @tindex forward-button | |
4091 | Move to the @var{n}th next button, or @var{n}th previous button if | |
4092 | @var{n} is negative. If @var{n} is zero, move to the start of any | |
4093 | button at point. If @var{wrap} is non-@code{nil}, moving past either | |
4094 | end of the buffer continues from the other end. If | |
4095 | @var{display-message} is non-@code{nil}, the button's help-echo string | |
a3cb3b2e MB |
4096 | is displayed. Any button with a non-@code{nil} @code{skip} property |
4097 | is skipped over. Returns the button found. | |
02c77ee9 MB |
4098 | @end deffn |
4099 | ||
4100 | @deffn Command backward-button n &optional wrap display-message | |
4101 | @tindex backward-button | |
4102 | Move to the @var{n}th previous button, or @var{n}th next button if | |
4103 | @var{n} is negative. If @var{n} is zero, move to the start of any | |
4104 | button at point. If @var{wrap} is non-@code{nil}, moving past either | |
4105 | end of the buffer continues from the other end. If | |
4106 | @var{display-message} is non-@code{nil}, the button's help-echo string | |
a3cb3b2e MB |
4107 | is displayed. Any button with a non-@code{nil} @code{skip} property |
4108 | is skipped over. Returns the button found. | |
02c77ee9 MB |
4109 | @end deffn |
4110 | ||
4111 | @defun next-button pos &optional count-current | |
4112 | @tindex next-button | |
4113 | Return the next button after position @var{pos} in the current buffer. | |
4114 | If @var{count-current} is non-@code{nil}, count any button at | |
4115 | @var{pos} in the search, instead of starting at the next button. | |
4116 | @end defun | |
4117 | ||
4118 | @defun previous-button pos &optional count-current | |
4119 | @tindex previous-button | |
4120 | Return the @var{n}th button before position @var{pos} in the current | |
4121 | buffer. If @var{count-current} is non-@code{nil}, count any button at | |
4122 | @var{pos} in the search, instead of starting at the next button. | |
4123 | @end defun | |
4124 | ||
4125 | @node Manipulating Button Types | |
4126 | @subsection Manipulating Button Types | |
4127 | @cindex manipulating button types | |
4128 | ||
4129 | @defun button-type-put type prop val | |
4130 | @tindex button-type-put | |
4131 | Set the button-type @var{type}'s @var{prop} property to @var{val}. | |
4132 | @end defun | |
4133 | ||
4134 | @defun button-type-get type prop | |
4135 | @tindex button-type-get | |
4136 | Get the property of button-type @var{type} named @var{prop}. | |
4137 | @end defun | |
4138 | ||
4139 | @defun button-type-subtype-p type supertype | |
4140 | @tindex button-type-subtype-p | |
4141 | Return @code{t} if button-type @var{type} is a subtype of @var{supertype}. | |
4142 | @end defun | |
4143 | ||
42b85554 RS |
4144 | @node Blinking |
4145 | @section Blinking Parentheses | |
4146 | @cindex parenthesis matching | |
4147 | @cindex blinking | |
4148 | @cindex balancing parentheses | |
4149 | @cindex close parenthesis | |
4150 | ||
4151 | This section describes the mechanism by which Emacs shows a matching | |
4152 | open parenthesis when the user inserts a close parenthesis. | |
4153 | ||
42b85554 RS |
4154 | @defvar blink-paren-function |
4155 | The value of this variable should be a function (of no arguments) to | |
4156 | be called whenever a character with close parenthesis syntax is inserted. | |
4157 | The value of @code{blink-paren-function} may be @code{nil}, in which | |
4158 | case nothing is done. | |
42b85554 RS |
4159 | @end defvar |
4160 | ||
1911e6e5 | 4161 | @defopt blink-matching-paren |
42b85554 RS |
4162 | If this variable is @code{nil}, then @code{blink-matching-open} does |
4163 | nothing. | |
1911e6e5 | 4164 | @end defopt |
42b85554 | 4165 | |
1911e6e5 | 4166 | @defopt blink-matching-paren-distance |
42b85554 RS |
4167 | This variable specifies the maximum distance to scan for a matching |
4168 | parenthesis before giving up. | |
1911e6e5 | 4169 | @end defopt |
42b85554 | 4170 | |
1911e6e5 | 4171 | @defopt blink-matching-delay |
bfe721d1 KH |
4172 | This variable specifies the number of seconds for the cursor to remain |
4173 | at the matching parenthesis. A fraction of a second often gives | |
4174 | good results, but the default is 1, which works on all systems. | |
1911e6e5 | 4175 | @end defopt |
bfe721d1 | 4176 | |
1911e6e5 | 4177 | @deffn Command blink-matching-open |
42b85554 RS |
4178 | This function is the default value of @code{blink-paren-function}. It |
4179 | assumes that point follows a character with close parenthesis syntax and | |
4180 | moves the cursor momentarily to the matching opening character. If that | |
4181 | character is not already on the screen, it displays the character's | |
4182 | context in the echo area. To avoid long delays, this function does not | |
4183 | search farther than @code{blink-matching-paren-distance} characters. | |
4184 | ||
4185 | Here is an example of calling this function explicitly. | |
4186 | ||
4187 | @smallexample | |
4188 | @group | |
4189 | (defun interactive-blink-matching-open () | |
4190 | @c Do not break this line! -- rms. | |
4191 | @c The first line of a doc string | |
4192 | @c must stand alone. | |
4193 | "Indicate momentarily the start of sexp before point." | |
4194 | (interactive) | |
4195 | @end group | |
4196 | @group | |
4197 | (let ((blink-matching-paren-distance | |
4198 | (buffer-size)) | |
4199 | (blink-matching-paren t)) | |
4200 | (blink-matching-open))) | |
4201 | @end group | |
4202 | @end smallexample | |
1911e6e5 | 4203 | @end deffn |
42b85554 RS |
4204 | |
4205 | @node Inverse Video | |
4206 | @section Inverse Video | |
4207 | @cindex Inverse Video | |
4208 | ||
4209 | @defopt inverse-video | |
4210 | @cindex highlighting | |
4211 | This variable controls whether Emacs uses inverse video for all text | |
4212 | on the screen. Non-@code{nil} means yes, @code{nil} means no. The | |
4213 | default is @code{nil}. | |
4214 | @end defopt | |
4215 | ||
4216 | @defopt mode-line-inverse-video | |
a40d4712 PR |
4217 | This variable controls the use of inverse video for mode lines and menu |
4218 | bars. If it is non-@code{nil}, then these lines are displayed in | |
05aea714 | 4219 | inverse video. Otherwise, these lines are displayed normally, just like |
a40d4712 PR |
4220 | other text. The default is @code{t}. |
4221 | ||
4222 | For window frames, this feature actually applies the face named | |
4223 | @code{mode-line}; that face is normally set up as the inverse of the | |
4224 | default face, unless you change it. | |
42b85554 RS |
4225 | @end defopt |
4226 | ||
4227 | @node Usual Display | |
4228 | @section Usual Display Conventions | |
4229 | ||
4230 | The usual display conventions define how to display each character | |
4231 | code. You can override these conventions by setting up a display table | |
4232 | (@pxref{Display Tables}). Here are the usual display conventions: | |
4233 | ||
4234 | @itemize @bullet | |
4235 | @item | |
4236 | Character codes 32 through 126 map to glyph codes 32 through 126. | |
4237 | Normally this means they display as themselves. | |
4238 | ||
4239 | @item | |
4240 | Character code 9 is a horizontal tab. It displays as whitespace | |
4241 | up to a position determined by @code{tab-width}. | |
4242 | ||
4243 | @item | |
4244 | Character code 10 is a newline. | |
4245 | ||
4246 | @item | |
4247 | All other codes in the range 0 through 31, and code 127, display in one | |
78608595 | 4248 | of two ways according to the value of @code{ctl-arrow}. If it is |
42b85554 | 4249 | non-@code{nil}, these codes map to sequences of two glyphs, where the |
ad800164 | 4250 | first glyph is the @acronym{ASCII} code for @samp{^}. (A display table can |
42b85554 RS |
4251 | specify a glyph to use instead of @samp{^}.) Otherwise, these codes map |
4252 | just like the codes in the range 128 to 255. | |
4253 | ||
8241495d RS |
4254 | On MS-DOS terminals, Emacs arranges by default for the character code |
4255 | 127 to be mapped to the glyph code 127, which normally displays as an | |
ad800164 | 4256 | empty polygon. This glyph is used to display non-@acronym{ASCII} characters |
8241495d RS |
4257 | that the MS-DOS terminal doesn't support. @xref{MS-DOS and MULE,,, |
4258 | emacs, The GNU Emacs Manual}. | |
4259 | ||
42b85554 RS |
4260 | @item |
4261 | Character codes 128 through 255 map to sequences of four glyphs, where | |
ad800164 | 4262 | the first glyph is the @acronym{ASCII} code for @samp{\}, and the others are |
a9f0a989 | 4263 | digit characters representing the character code in octal. (A display |
969fe9b5 RS |
4264 | table can specify a glyph to use instead of @samp{\}.) |
4265 | ||
4266 | @item | |
4267 | Multibyte character codes above 256 are displayed as themselves, or as a | |
4268 | question mark or empty box if the terminal cannot display that | |
4269 | character. | |
42b85554 RS |
4270 | @end itemize |
4271 | ||
4272 | The usual display conventions apply even when there is a display | |
4273 | table, for any character whose entry in the active display table is | |
4274 | @code{nil}. Thus, when you set up a display table, you need only | |
969fe9b5 | 4275 | specify the characters for which you want special behavior. |
42b85554 | 4276 | |
b6954afd RS |
4277 | These display rules apply to carriage return (character code 13), when |
4278 | it appears in the buffer. But that character may not appear in the | |
4279 | buffer where you expect it, if it was eliminated as part of end-of-line | |
15da7853 | 4280 | conversion (@pxref{Coding System Basics}). |
b6954afd | 4281 | |
42b85554 RS |
4282 | These variables affect the way certain characters are displayed on the |
4283 | screen. Since they change the number of columns the characters occupy, | |
f9f59935 RS |
4284 | they also affect the indentation functions. These variables also affect |
4285 | how the mode line is displayed; if you want to force redisplay of the | |
4286 | mode line using the new values, call the function | |
4287 | @code{force-mode-line-update} (@pxref{Mode Line Format}). | |
42b85554 RS |
4288 | |
4289 | @defopt ctl-arrow | |
4290 | @cindex control characters in display | |
4291 | This buffer-local variable controls how control characters are | |
4292 | displayed. If it is non-@code{nil}, they are displayed as a caret | |
4293 | followed by the character: @samp{^A}. If it is @code{nil}, they are | |
4294 | displayed as a backslash followed by three octal digits: @samp{\001}. | |
4295 | @end defopt | |
4296 | ||
4297 | @c Following may have overfull hbox. | |
4298 | @defvar default-ctl-arrow | |
4299 | The value of this variable is the default value for @code{ctl-arrow} in | |
4300 | buffers that do not override it. @xref{Default Value}. | |
4301 | @end defvar | |
4302 | ||
2468d0c0 DL |
4303 | @defopt indicate-empty-lines |
4304 | @tindex indicate-empty-lines | |
6e2391a8 | 4305 | @cindex fringes, and empty line indication |
8a6ca431 RS |
4306 | When this is non-@code{nil}, Emacs displays a special glyph in the |
4307 | fringe of each empty line at the end of the buffer, on terminals that | |
4308 | support it (window systems). @xref{Fringes}. | |
2468d0c0 DL |
4309 | @end defopt |
4310 | ||
42b85554 RS |
4311 | @defopt tab-width |
4312 | The value of this variable is the spacing between tab stops used for | |
a40d4712 PR |
4313 | displaying tab characters in Emacs buffers. The value is in units of |
4314 | columns, and the default is 8. Note that this feature is completely | |
4315 | independent of the user-settable tab stops used by the command | |
4316 | @code{tab-to-tab-stop}. @xref{Indent Tabs}. | |
42b85554 RS |
4317 | @end defopt |
4318 | ||
4319 | @node Display Tables | |
4320 | @section Display Tables | |
4321 | ||
4322 | @cindex display table | |
969fe9b5 RS |
4323 | You can use the @dfn{display table} feature to control how all possible |
4324 | character codes display on the screen. This is useful for displaying | |
ad800164 | 4325 | European languages that have letters not in the @acronym{ASCII} character |
969fe9b5 | 4326 | set. |
42b85554 RS |
4327 | |
4328 | The display table maps each character code into a sequence of | |
8241495d | 4329 | @dfn{glyphs}, each glyph being a graphic that takes up one character |
42b85554 RS |
4330 | position on the screen. You can also define how to display each glyph |
4331 | on your terminal, using the @dfn{glyph table}. | |
4332 | ||
f9f59935 RS |
4333 | Display tables affect how the mode line is displayed; if you want to |
4334 | force redisplay of the mode line using a new display table, call | |
4335 | @code{force-mode-line-update} (@pxref{Mode Line Format}). | |
4336 | ||
42b85554 | 4337 | @menu |
02c77ee9 MB |
4338 | * Display Table Format:: What a display table consists of. |
4339 | * Active Display Table:: How Emacs selects a display table to use. | |
4340 | * Glyphs:: How to define a glyph, and what glyphs mean. | |
42b85554 RS |
4341 | @end menu |
4342 | ||
4343 | @node Display Table Format | |
4344 | @subsection Display Table Format | |
4345 | ||
a9f0a989 RS |
4346 | A display table is actually a char-table (@pxref{Char-Tables}) with |
4347 | @code{display-table} as its subtype. | |
42b85554 RS |
4348 | |
4349 | @defun make-display-table | |
4350 | This creates and returns a display table. The table initially has | |
4351 | @code{nil} in all elements. | |
4352 | @end defun | |
4353 | ||
f9f59935 RS |
4354 | The ordinary elements of the display table are indexed by character |
4355 | codes; the element at index @var{c} says how to display the character | |
4356 | code @var{c}. The value should be @code{nil} or a vector of glyph | |
4357 | values (@pxref{Glyphs}). If an element is @code{nil}, it says to | |
4358 | display that character according to the usual display conventions | |
4359 | (@pxref{Usual Display}). | |
22697dac KH |
4360 | |
4361 | If you use the display table to change the display of newline | |
4362 | characters, the whole buffer will be displayed as one long ``line.'' | |
42b85554 | 4363 | |
f9f59935 | 4364 | The display table also has six ``extra slots'' which serve special |
969fe9b5 RS |
4365 | purposes. Here is a table of their meanings; @code{nil} in any slot |
4366 | means to use the default for that slot, as stated below. | |
42b85554 RS |
4367 | |
4368 | @table @asis | |
f9f59935 | 4369 | @item 0 |
42b85554 | 4370 | The glyph for the end of a truncated screen line (the default for this |
8241495d RS |
4371 | is @samp{$}). @xref{Glyphs}. Newer Emacs versions, on some platforms, |
4372 | display arrows to indicate truncation---the display table has no effect | |
4373 | in these situations. | |
f9f59935 | 4374 | @item 1 |
42b85554 | 4375 | The glyph for the end of a continued line (the default is @samp{\}). |
8241495d RS |
4376 | Newer Emacs versions, on some platforms, display curved arrows to |
4377 | indicate truncation---the display table has no effect in these | |
4378 | situations. | |
f9f59935 | 4379 | @item 2 |
42b85554 RS |
4380 | The glyph for indicating a character displayed as an octal character |
4381 | code (the default is @samp{\}). | |
f9f59935 | 4382 | @item 3 |
42b85554 | 4383 | The glyph for indicating a control character (the default is @samp{^}). |
f9f59935 | 4384 | @item 4 |
42b85554 RS |
4385 | A vector of glyphs for indicating the presence of invisible lines (the |
4386 | default is @samp{...}). @xref{Selective Display}. | |
f9f59935 | 4387 | @item 5 |
50b04c36 | 4388 | The glyph used to draw the border between side-by-side windows (the |
8241495d RS |
4389 | default is @samp{|}). @xref{Splitting Windows}. This takes effect only |
4390 | when there are no scroll bars; if scroll bars are supported and in use, | |
4391 | a scroll bar separates the two windows. | |
42b85554 RS |
4392 | @end table |
4393 | ||
4394 | For example, here is how to construct a display table that mimics the | |
4395 | effect of setting @code{ctl-arrow} to a non-@code{nil} value: | |
4396 | ||
4397 | @example | |
4398 | (setq disptab (make-display-table)) | |
4399 | (let ((i 0)) | |
4400 | (while (< i 32) | |
4401 | (or (= i ?\t) (= i ?\n) | |
4402 | (aset disptab i (vector ?^ (+ i 64)))) | |
4403 | (setq i (1+ i))) | |
4404 | (aset disptab 127 (vector ?^ ??))) | |
4405 | @end example | |
4406 | ||
f9f59935 RS |
4407 | @defun display-table-slot display-table slot |
4408 | This function returns the value of the extra slot @var{slot} of | |
4409 | @var{display-table}. The argument @var{slot} may be a number from 0 to | |
4410 | 5 inclusive, or a slot name (symbol). Valid symbols are | |
4411 | @code{truncation}, @code{wrap}, @code{escape}, @code{control}, | |
4412 | @code{selective-display}, and @code{vertical-border}. | |
4413 | @end defun | |
4414 | ||
f9f59935 RS |
4415 | @defun set-display-table-slot display-table slot value |
4416 | This function stores @var{value} in the extra slot @var{slot} of | |
4417 | @var{display-table}. The argument @var{slot} may be a number from 0 to | |
4418 | 5 inclusive, or a slot name (symbol). Valid symbols are | |
4419 | @code{truncation}, @code{wrap}, @code{escape}, @code{control}, | |
4420 | @code{selective-display}, and @code{vertical-border}. | |
4421 | @end defun | |
4422 | ||
8241495d RS |
4423 | @defun describe-display-table display-table |
4424 | @tindex describe-display-table | |
4425 | This function displays a description of the display table | |
4426 | @var{display-table} in a help buffer. | |
4427 | @end defun | |
4428 | ||
4429 | @deffn Command describe-current-display-table | |
4430 | @tindex describe-current-display-table | |
4431 | This command displays a description of the current display table in a | |
4432 | help buffer. | |
4433 | @end deffn | |
4434 | ||
42b85554 RS |
4435 | @node Active Display Table |
4436 | @subsection Active Display Table | |
4437 | @cindex active display table | |
4438 | ||
4439 | Each window can specify a display table, and so can each buffer. When | |
4440 | a buffer @var{b} is displayed in window @var{w}, display uses the | |
4441 | display table for window @var{w} if it has one; otherwise, the display | |
4442 | table for buffer @var{b} if it has one; otherwise, the standard display | |
4443 | table if any. The display table chosen is called the @dfn{active} | |
4444 | display table. | |
4445 | ||
4446 | @defun window-display-table window | |
4447 | This function returns @var{window}'s display table, or @code{nil} | |
4448 | if @var{window} does not have an assigned display table. | |
4449 | @end defun | |
4450 | ||
4451 | @defun set-window-display-table window table | |
4452 | This function sets the display table of @var{window} to @var{table}. | |
4453 | The argument @var{table} should be either a display table or | |
4454 | @code{nil}. | |
4455 | @end defun | |
4456 | ||
4457 | @defvar buffer-display-table | |
969fe9b5 RS |
4458 | This variable is automatically buffer-local in all buffers; its value in |
4459 | a particular buffer specifies the display table for that buffer. If it | |
4460 | is @code{nil}, that means the buffer does not have an assigned display | |
4461 | table. | |
42b85554 RS |
4462 | @end defvar |
4463 | ||
4464 | @defvar standard-display-table | |
4465 | This variable's value is the default display table, used whenever a | |
4466 | window has no display table and neither does the buffer displayed in | |
4467 | that window. This variable is @code{nil} by default. | |
4468 | @end defvar | |
4469 | ||
4470 | If there is no display table to use for a particular window---that is, | |
f9f59935 RS |
4471 | if the window specifies none, its buffer specifies none, and |
4472 | @code{standard-display-table} is @code{nil}---then Emacs uses the usual | |
42b85554 RS |
4473 | display conventions for all character codes in that window. @xref{Usual |
4474 | Display}. | |
4475 | ||
8241495d RS |
4476 | A number of functions for changing the standard display table |
4477 | are defined in the library @file{disp-table}. | |
4478 | ||
42b85554 RS |
4479 | @node Glyphs |
4480 | @subsection Glyphs | |
4481 | ||
4482 | @cindex glyph | |
4483 | A @dfn{glyph} is a generalization of a character; it stands for an | |
4484 | image that takes up a single character position on the screen. Glyphs | |
bbf77fe8 RS |
4485 | are represented in Lisp as integers, just as characters are. Normally |
4486 | Emacs finds glyphs in the display table (@pxref{Display Tables}). | |
4487 | ||
4488 | A glyph can be @dfn{simple} or it can be defined by the @dfn{glyph | |
4489 | table}. A simple glyph is just a way of specifying a character and a | |
4490 | face to output it in. The glyph code for a simple glyph, mod 524288, | |
4491 | is the character to output, and the glyph code divided by 524288 | |
4492 | specifies the face number (@pxref{Face Functions}) to use while | |
4493 | outputting it. (524288 is | |
4494 | @ifnottex | |
4495 | 2**19.) | |
4496 | @end ifnottex | |
4497 | @tex | |
4498 | $2^{19}$.) | |
4499 | @end tex | |
4500 | @xref{Faces}. | |
42b85554 | 4501 | |
bbf77fe8 RS |
4502 | On character terminals, you can set up a @dfn{glyph table} to define |
4503 | the meaning of glyph codes. The glyph codes is the value of the | |
4504 | variable @code{glyph-table}. | |
42b85554 RS |
4505 | |
4506 | @defvar glyph-table | |
4507 | The value of this variable is the current glyph table. It should be a | |
177c0ea7 | 4508 | vector; the @var{g}th element defines glyph code @var{g}. |
bbf77fe8 RS |
4509 | |
4510 | If a glyph code is greater than or equal to the length of the glyph | |
4511 | table, that code is automatically simple. If the value of | |
4512 | @code{glyph-table} is @code{nil} instead of a vector, then all glyphs | |
4513 | are simple. The glyph table is not used on graphical displays, only | |
4514 | on character terminals. On graphical displays, all glyphs are simple. | |
42b85554 RS |
4515 | @end defvar |
4516 | ||
4517 | Here are the possible types of elements in the glyph table: | |
4518 | ||
1911e6e5 RS |
4519 | @table @asis |
4520 | @item @var{string} | |
42b85554 RS |
4521 | Send the characters in @var{string} to the terminal to output |
4522 | this glyph. This alternative is available on character terminals, | |
969fe9b5 | 4523 | but not under a window system. |
42b85554 | 4524 | |
1911e6e5 | 4525 | @item @var{integer} |
969fe9b5 | 4526 | Define this glyph code as an alias for glyph code @var{integer}. You |
bbf77fe8 RS |
4527 | can use an alias to specify a face code for the glyph and use a small |
4528 | number as its code. | |
42b85554 RS |
4529 | |
4530 | @item @code{nil} | |
bbf77fe8 | 4531 | This glyph is simple. |
42b85554 RS |
4532 | @end table |
4533 | ||
8241495d RS |
4534 | @defun create-glyph string |
4535 | @tindex create-glyph | |
4536 | This function returns a newly-allocated glyph code which is set up to | |
4537 | display by sending @var{string} to the terminal. | |
4538 | @end defun | |
4539 | ||
42b85554 RS |
4540 | @node Beeping |
4541 | @section Beeping | |
4542 | @cindex beeping | |
4543 | @cindex bell | |
4544 | ||
f9f59935 RS |
4545 | This section describes how to make Emacs ring the bell (or blink the |
4546 | screen) to attract the user's attention. Be conservative about how | |
4547 | often you do this; frequent bells can become irritating. Also be | |
4548 | careful not to use just beeping when signaling an error is more | |
4549 | appropriate. (@xref{Errors}.) | |
42b85554 | 4550 | |
a9f0a989 | 4551 | @defun ding &optional do-not-terminate |
42b85554 RS |
4552 | @cindex keyboard macro termination |
4553 | This function beeps, or flashes the screen (see @code{visible-bell} below). | |
4554 | It also terminates any keyboard macro currently executing unless | |
a9f0a989 | 4555 | @var{do-not-terminate} is non-@code{nil}. |
42b85554 RS |
4556 | @end defun |
4557 | ||
a9f0a989 | 4558 | @defun beep &optional do-not-terminate |
42b85554 RS |
4559 | This is a synonym for @code{ding}. |
4560 | @end defun | |
4561 | ||
1911e6e5 | 4562 | @defopt visible-bell |
42b85554 RS |
4563 | This variable determines whether Emacs should flash the screen to |
4564 | represent a bell. Non-@code{nil} means yes, @code{nil} means no. This | |
969fe9b5 RS |
4565 | is effective on a window system, and on a character-only terminal |
4566 | provided the terminal's Termcap entry defines the visible bell | |
4567 | capability (@samp{vb}). | |
1911e6e5 | 4568 | @end defopt |
42b85554 | 4569 | |
f9f59935 RS |
4570 | @defvar ring-bell-function |
4571 | If this is non-@code{nil}, it specifies how Emacs should ``ring the | |
a40d4712 PR |
4572 | bell.'' Its value should be a function of no arguments. If this is |
4573 | non-@code{nil}, it takes precedence over the @code{visible-bell} | |
4574 | variable. | |
f9f59935 RS |
4575 | @end defvar |
4576 | ||
42b85554 RS |
4577 | @node Window Systems |
4578 | @section Window Systems | |
4579 | ||
4580 | Emacs works with several window systems, most notably the X Window | |
4581 | System. Both Emacs and X use the term ``window'', but use it | |
4582 | differently. An Emacs frame is a single window as far as X is | |
4583 | concerned; the individual Emacs windows are not known to X at all. | |
4584 | ||
4585 | @defvar window-system | |
42b85554 | 4586 | This variable tells Lisp programs what window system Emacs is running |
1911e6e5 RS |
4587 | under. The possible values are |
4588 | ||
4589 | @table @code | |
4590 | @item x | |
4591 | @cindex X Window System | |
4592 | Emacs is displaying using X. | |
4593 | @item pc | |
8241495d | 4594 | Emacs is displaying using MS-DOS. |
1911e6e5 | 4595 | @item w32 |
05aea714 | 4596 | Emacs is displaying using Windows. |
8241495d RS |
4597 | @item mac |
4598 | Emacs is displaying using a Macintosh. | |
1911e6e5 RS |
4599 | @item nil |
4600 | Emacs is using a character-based terminal. | |
4601 | @end table | |
42b85554 RS |
4602 | @end defvar |
4603 | ||
42b85554 | 4604 | @defvar window-setup-hook |
f9f59935 RS |
4605 | This variable is a normal hook which Emacs runs after handling the |
4606 | initialization files. Emacs runs this hook after it has completed | |
a40d4712 | 4607 | loading your init file, the default initialization file (if |
a9f0a989 | 4608 | any), and the terminal-specific Lisp code, and running the hook |
42b85554 RS |
4609 | @code{term-setup-hook}. |
4610 | ||
4611 | This hook is used for internal purposes: setting up communication with | |
4612 | the window system, and creating the initial window. Users should not | |
4613 | interfere with it. | |
4614 | @end defvar | |
ab5796a9 MB |
4615 | |
4616 | @ignore | |
4617 | arch-tag: ffdf5714-7ecf-415b-9023-fbc6b409c2c6 | |
4618 | @end ignore |