(Fy_or_n_p): Don't log prompt.
[bpt/emacs.git] / etc / news.texi
1 @setfilename LNEWS
2
3 @section New Features in the Lisp Language
4
5 @end itemize
6 @itemize @bullet
7 @item
8 The new function @code{delete} is a traditional Lisp function. It takes
9 two arguments, @var{elt} and @var{list}, and deletes from @var{list} any
10 elements that are equal to @var{elt}. It uses the function @code{equal}
11 to compare elements with @var{elt}.
12
13 @item
14 The new function @code{member} is a traditional Lisp function. It takes
15 two arguments, @var{elt} and @var{list}, and finds the first element of
16 @var{list} that is equal to @var{elt}. It uses the function
17 @code{equal} to compare each list element with @var{elt}.
18
19 The value is a sublist of @var{list}, whose first element is the one
20 that was found. If no matching element is found, the value is
21 @code{nil}.
22
23 @ignore @c Seems not to be true, from looking at the code.
24 @item
25 The function @code{equal} is now more robust: it does not crash due to
26 circular list structure.
27 @end ignore
28
29 @item
30 The new function @code{indirect-function} finds the effective function
31 definition of an object called as a function. If the object is a
32 symbol, @code{indirect-function} looks in the function definition of the
33 symbol. It keeps doing this until it finds something that is not a
34 symbol.
35
36 @item
37 There are new escape sequences for use in character and string
38 constants. The escape sequence @samp{\a} is equivalent to @samp{\C-g},
39 the @sc{ASCII} @sc{BEL} character (code 7). The escape sequence
40 @samp{\x} followed by a hexidecimal number represents the character
41 whose @sc{ASCII} code is that number. There is no limit on the number
42 of digits in the hexidecimal value.
43
44 @item
45 The function @code{read} when reading from a buffer now does not skip a
46 terminator character that terminates a symbol. It leaves that character
47 to be read (or just skipped, if it is whitespace) next time.
48
49 @item
50 When you use a function @var{function} as the input stream for
51 @code{read}, it is usually called with no arguments, and should return
52 the next character. In Emacs 19, sometimes @var{function} is called
53 with one argument (always a character). When that happens,
54 @var{function} should save the argument and arrange to return it when
55 called next time.
56
57 @item
58 @code{random} with integer argument @var{n} returns a random number
59 between 0 and @var{n}@minus{}1.
60
61 @item
62 The functions @code{documentation} and @code{documentation-property} now
63 take an additional optional argument which, if non-@code{nil}, says to
64 refrain from calling @code{substitute-command-keys}. This way, you get
65 the exact text of the documentation string as written, without the usual
66 substitutions. Make sure to call @code{substitute-command-keys}
67 yourself if you decide to display the string.
68
69 @ignore
70 @item
71 The new function @code{invocation-name} returns as a string the program
72 name that was used to run Emacs, with any directory names discarded.
73 @c ??? This hasn't been written yet. ???
74 @end ignore
75
76 @item
77 The new function @code{map-y-or-n-p} makes it convenient to ask a series
78 of similar questions. The arguments are @var{prompter}, @var{actor},
79 @var{list}, and optional @var{help}.
80
81 The value of @var{list} is a list of objects, or a function of no
82 arguments to return either the next object or @code{nil} meaning there
83 are no more.
84
85 The argument @var{prompter} specifies how to ask each question. If
86 @var{prompter} is a string, the question text is computed like this:
87
88 @example
89 (format @var{prompter} @var{object})
90 @end example
91
92 @noindent
93 where @var{object} is the next object to ask about.
94
95 If not a string, @var{prompter} should be a function of one argument
96 (the next object to ask about) and should return the question text.
97
98 The argument @var{actor} should be a function of one argument, which is
99 called with each object that the user says yes for. Its argument is
100 always one object from @var{list}.
101
102 If @var{help} is given, it is a list @code{(@var{object} @var{objects}
103 @var{action})}, where @var{object} is a string containing a singular
104 noun that describes the objects conceptually being acted on;
105 @var{objects} is the corresponding plural noun and @var{action} is a
106 transitive verb describing @var{actor}. The default is @code{("object"
107 "objects" "act on")}.
108
109 Each time a question is asked, the user may enter @kbd{y}, @kbd{Y}, or
110 @key{SPC} to act on that object; @kbd{n}, @kbd{N}, or @key{DEL} to skip
111 that object; @kbd{!} to act on all following objects; @key{ESC} or
112 @kbd{q} to exit (skip all following objects); @kbd{.} (period) to act on
113 the current object and then exit; or @kbd{C-h} to get help.
114
115 @code{map-y-or-n-p} returns the number of objects acted on.
116
117 @item
118 You can now ``set'' environment variables with the @code{setenv}
119 command. This works by setting the variable @code{process-environment},
120 which @code{getenv} now examines in preference to the environment Emacs
121 received from its parent.
122 @end itemize
123
124 @section New Features for Loading Libraries
125
126 You can now arrange to run a hook if a particular Lisp library is
127 loaded.
128
129 The variable @code{after-load-alist} is an alist of expressions to be
130 evalled when particular files are loaded. Each element looks like
131 @code{(@var{filename} @var{forms}@dots{})}.
132
133 When @code{load} is run and the file name argument equals
134 @var{filename}, the @var{forms} in the corresponding element are
135 executed at the end of loading. @var{filename} must match exactly!
136 Normally @var{filename} is the name of a library, with no directory
137 specified, since that is how @code{load} is normally called.
138
139 An error in @var{forms} does not undo the load, but does prevent
140 execution of the rest of the @var{forms}.
141
142 The function @code{eval-after-load} provides a convenient way to add
143 entries to the alist. Call it with two arguments, @var{file} and a
144 form to execute.
145
146 The function @code{autoload} now supports autoloading a keymap.
147 Use @code{keymap} as the fourth argument if the autoloaded function
148 will become a keymap when loaded.
149
150 There is a new feature for specifying which functions in a library should
151 be autoloaded by writing special ``magic'' comments in that library itself.
152
153 Write @samp{;;;###autoload} on a line by itself before a function
154 definition before the real definition of the function, in its
155 autoloadable source file; then the command @kbd{M-x
156 update-file-autoloads} automatically puts the @code{autoload} call into
157 @file{loaddefs.el}.
158
159 You can also put other kinds of forms into @file{loaddefs.el}, by
160 writing @samp{;;;###autoload} followed on the same line by the form.
161 @kbd{M-x update-file-autoloads} copies the form from that line.
162
163 @section Compilation Features
164
165 @itemize @bullet
166 @item
167 Inline functions.
168
169 You can define an @dfn{inline function} with @code{defsubst}. Use
170 @code{defsubst} just like @code{defun}, and it defines a function which
171 you can call in all the usual ways. Whenever the function thus defined
172 is used in compiled code, the compiler will open code it.
173
174 You can get somewhat the same effects with a macro, but a macro has the
175 limitation that you can use it only explicitly; a macro cannot be called
176 with @code{apply}, @code{mapcar} and so on. Also, it takes some work to
177 convert an ordinary function into a macro. To convert it into an inline
178 function, simply replace @code{defun} with @code{defsubst}.
179
180 Making a function inline makes explicit calls run faster. But it also
181 has disadvantages. For one thing, it reduces flexibility; if you change
182 the definition of the function, calls already inlined still use the old
183 definition until you recompile them.
184
185 Another disadvantage is that making a large function inline can increase
186 the size of compiled code both in files and in memory. Since the
187 advantages of inline functions are greatest for small functions, you
188 generally should not make large functions inline.
189
190 Inline functions can be used and open coded later on in the same file,
191 following the definition, just like macros.
192
193 @item
194 The command @code{byte-compile-file} now offers to save any buffer
195 visiting the file you are compiling.
196
197 @item
198 The new command @code{compile-defun} reads, compiles and executes the
199 defun containing point. If you use this on a defun that is actually a
200 function definition, the effect is to install a compiled version of
201 that function.
202
203 @item
204 Whenever you load a Lisp file or library, you now receive a warning if
205 the directory contains both a @samp{.el} file and a @samp{.elc} file,
206 and the @samp{.el} file is newer. This typically indicates that someone
207 has updated the Lisp code but forgotten to recompile it, so the changes
208 do not take effect. The warning is a reminder to recompile.
209
210 @item
211 The special form @code{eval-when-compile} marks the forms it contains to
212 be evaluated at compile time @emph{only}. At top-level, this is
213 analogous to the Common Lisp idiom @code{(eval-when (compile)
214 @dots{})}. Elsewhere, it is similar to the Common Lisp @samp{#.} reader
215 macro (but not when interpreting).
216
217 If you're thinking of using this feature, we recommend you consider whether
218 @code{provide} and @code{require} might do the job as well.
219
220 @item
221 The special form @code{eval-and-compile} is similar to
222 @code{eval-when-compile}, but the whole form is evaluated both at
223 compile time and at run time.
224
225 If you're thinking of using this feature, we recommend you consider
226 whether @code{provide} and @code{require} might do the job as well.
227
228 @item
229 Emacs Lisp has a new data type for byte-code functions. This makes
230 them faster to call, and also saves space. Internally, a byte-code
231 function object is much like a vector; however, the evaluator handles
232 this data type specially when it appears as a function to be called.
233
234 The printed representation for a byte-code function object is like that
235 for a vector, except that it starts with @samp{#} before the opening
236 @samp{[}. A byte-code function object must have at least four elements;
237 there is no maximum number, but only the first six elements are actually
238 used. They are:
239
240 @table @var
241 @item arglist
242 The list of argument symbols.
243
244 @item byte-code
245 The string containing the byte-code instructions.
246
247 @item constants
248 The vector of constants referenced by the byte code.
249
250 @item stacksize
251 The maximum stack size this function needs.
252
253 @item docstring
254 The documentation string (if any); otherwise, @code{nil}.
255
256 @item interactive
257 The interactive spec (if any). This can be a string or a Lisp
258 expression. It is @code{nil} for a function that isn't interactive.
259 @end table
260
261 The predicate @code{byte-code-function-p} tests whether a given object
262 is a byte-code function.
263
264 You can create a byte-code function object in a Lisp program
265 with the function @code{make-byte-code}. Its arguments are the elements
266 to put in the byte-code function object.
267
268 You should not try to come up with the elements for a byte-code function
269 yourself, because if they are inconsistent, Emacs may crash when you
270 call the function. Always leave it to the byte compiler to create these
271 objects; it, we hope, always makes the elements consistent.
272 @end itemize
273
274 @section Floating Point Numbers
275
276 You can now use floating point numbers in Emacs, if you define the macro
277 @code{LISP_FLOAT_TYPE} when you compile Emacs.
278
279 The printed representation for floating point numbers requires either a
280 decimal point surrounded by digits, or an exponent, or both. For
281 example, @samp{1500.0}, @samp{15e2}, @samp{15.0e2} and @samp{1.5e3} are
282 four ways of writing a floating point number whose value is 1500.
283
284 The existing predicate @code{numberp} now returns @code{t} if the
285 argument is any kind of number---either integer or floating. The new
286 predicates @code{integerp} and @code{floatp} check for specific types of
287 numbers.
288
289 You can do arithmetic on floating point numbers with the ordinary
290 arithmetic functions, @code{+}, @code{-}, @code{*} and @code{/}. If you
291 call one of these functions with both integers and floating point
292 numbers among the arguments, the arithmetic is done in floating point.
293 The same applies to the numeric comparison functions such as @code{=}
294 and @code{<}. The remainder function @code{%} does not accept floating
295 point arguments, and neither do the bitwise boolean operations such as
296 @code{logand} or the shift functions such as @code{ash}.
297
298 There is a new arithmetic function, @code{abs}, which returns the absolute
299 value of its argument. It handles both integers and floating point
300 numbers.
301
302 To convert an integer to floating point, use the function @code{float}.
303 There are four functions to convert floating point numbers to integers;
304 they differ in how they round. @code{truncate} rounds toward 0,
305 @code{floor} rounds down, @code{ceil} rounds up, and @code{round}
306 produces the nearest integer.
307
308 You can use @code{logb} to extract the binary exponent of a floating
309 point number. More precisely, it is the logarithm base 2, rounded down
310 to an integer.
311
312 Emacs has several new mathematical functions that accept any kind of
313 number as argument, but always return floating point numbers.
314
315 @table @code
316 @item cos
317 @findex cos
318 @itemx sin
319 @findex sin
320 @itemx tan
321 @findex tan
322 Trigonometric functions.
323 @item acos
324 @findex acos
325 @itemx asin
326 @findex asin
327 @itemx atan
328 @findex atan
329 Inverse trigonometric functions.
330 @item exp
331 @findex exp
332 The exponential function (power of @var{e}).
333 @item log
334 @findex log
335 Logarithm base @var{e}.
336 @item expm1
337 @findex expm1
338 Power of @var{e}, minus 1.
339 @item log1p
340 @findex log1p
341 Add 1, then take the logarithm.
342 @item log10
343 @findex log10
344 Logarithm base 10
345 @item expt
346 @findex expt
347 Raise @var{x} to power @var{y}.
348 @item sqrt
349 @findex sqrt
350 The square root function.
351 @end table
352
353 The new function @code{string-to-number} now parses a string containing
354 either an integer or a floating point number, returning the number.
355
356 The @code{format} function now handles the specifications @samp{%e},
357 @samp{%f} and @samp{%g} for printing floating point numbers; likewise
358 @code{message}.
359
360 The new variable @code{float-output-format} controls how Lisp prints
361 floating point numbers. Its value should be @code{nil} or a string.
362
363 If it is a string, it should contain a @samp{%}-spec like those accepted
364 by @code{printf} in C, but with some restrictions. It must start with
365 the two characters @samp{%.}. After that comes an integer which is the
366 precision specification, and then a letter which controls the format.
367
368 The letters allowed are @samp{e}, @samp{f} and @samp{g}. Use @samp{e}
369 for exponential notation (@samp{@var{dig}.@var{digits}e@var{expt}}).
370 Use @samp{f} for decimal point notation
371 (@samp{@var{digits}.@var{digits}}). Use @samp{g} to choose the shorter
372 of those two formats for the number at hand.
373
374 The precision in any of these cases is the number of digits following
375 the decimal point. With @samp{f}, a precision of 0 means to omit the
376 decimal point. 0 is not allowed with @samp{f} or @samp{g}.
377
378 A value of @code{nil} means to use the format @samp{%.20g}.
379
380 No matter what the value of @code{float-output-format}, printing ensures
381 that the result fits the syntax rules for a floating point number. If
382 it doesn't fit (for example, if it looks like an integer), it is
383 modified to fit. By contrast, the @code{format} function formats
384 floating point numbers without requiring the output to fit the
385 syntax rules for floating point number.
386
387 @section New Features for Printing And Formatting Output
388
389 @itemize @bullet
390 @item
391 The @code{format} function has a new feature: @samp{%S}. This print
392 spec prints any kind of Lisp object, even a string, using its Lisp
393 printed representation.
394
395 By contrast, @samp{%s} prints everything without quotation.
396
397 @item
398 @code{prin1-to-string} now takes an optional second argument which says
399 not to print the Lisp quotation characters. (In other words, to use
400 @code{princ} instead of @code{prin1}.)
401
402 @item
403 The new variable @code{print-level} specifies the maximum depth of list
404 nesting to print before cutting off all deeper structure. A value of
405 @code{nil} means no limit.
406 @end itemize
407
408 @section Changes in Basic Editing Functions
409
410 @itemize @bullet
411 @item
412 There are two new primitives for putting text in the kill ring:
413 @code{kill-new} and @code{kill-append}.
414
415 The function @code{kill-new} adds a string to the front of the kill ring.
416
417 Use @code{kill-append} to add a string to a previous kill. The second
418 argument @var{before-p}, if non-@code{nil}, says to add the string at
419 the beginning; otherwise, it goes at the end.
420
421 Both of these functions apply @code{interprogram-cut-function} to the
422 entire string of killed text that ends up at the beginning of the kill
423 ring.
424
425 @item
426 The new function @code{current-kill} rotates the yanking pointer in the
427 kill ring by @var{n} places, and returns the text at that place in the
428 ring. If the optional second argument @var{do-not-move} is
429 non-@code{nil}, it doesn't actually move the yanking point; it just
430 returns the @var{n}th kill forward. If @var{n} is zero, indicating a
431 request for the latest kill, @code{current-kill} calls
432 @code{interprogram-paste-function} (documented below) before consulting
433 the kill ring.
434
435 All Emacs Lisp programs should either use @code{current-kill},
436 @code{kill-new}, and @code{kill-append} to manipulate the kill ring, or
437 be sure to call @code{interprogram-paste-function} and
438 @code{interprogram-cut-function} as appropriate.
439
440 @item
441 The variables @code{interprogram-paste-function} and
442 @code{interprogram-cut-function} exist so that you can provide functions
443 to transfer killed text to and from other programs.
444
445 @item
446 The @code{kill-region} function can now be used in read-only buffers.
447 It beeps, but adds the region to the kill ring without deleting it.
448
449 @item
450 The new function @code{compare-buffer-substrings} lets you compare two
451 substrings of the same buffer or two different buffers. Its arguments
452 look like this:
453
454 @example
455 (compare-buffer-substrings @var{buf1} @var{beg1} @var{end1} @var{buf2} @var{beg2} @var{end2})
456 @end example
457
458 The first three arguments specify one substring, giving a buffer and two
459 positions within the buffer. The last three arguments specify the other
460 substring in the same way.
461
462 The value is negative if the first substring is less, positive if the
463 first is greater, and zero if they are equal. The absolute value of
464 the result is one plus the index of the first different characters.
465
466 @item
467 Overwrite mode treats tab and newline characters specially. You can now
468 turn off this special treatment by setting @code{overwrite-binary-mode}
469 to @code{t}.
470
471 @item
472 Once the mark ``exists'' in a buffer, it normally never ceases to
473 exist. However, it may become @dfn{inactive}. The variable
474 @code{mark-active}, which is always local in all buffers, indicates
475 whether the mark is active: non-@code{nil} means yes.
476
477 A command can request deactivation of the mark upon return to the editor
478 command loop by setting @code{deactivate-mark} to a non-@code{nil}
479 value. Transient Mark mode works by causing the buffer modification
480 primitives to set @code{deactivate-mark}.
481
482 The variables @code{activate-mark-hook} and @code{deactivate-mark-hook}
483 are normal hooks run, respectively, when the mark becomes active andwhen
484 it becomes inactive. The hook @code{activate-mark-hook} is also run at
485 the end of a command if the mark is active and the region may have
486 changed.
487
488 @item
489 The function @code{move-to-column} now accepts a second optional
490 argument @var{force}, in addition to @var{column}; if the requested
491 column @var{column} is in the middle of a tab character and @var{force}
492 is non-@code{nil}, @code{move-to-column} replaces the tab with the
493 appropriate sequence of spaces so that it can place point exactly at
494 @var{column}.
495
496 @item
497 The search functions when successful now return the value of point
498 rather than just @code{t}. This affects the functions
499 @code{search-forward}, @code{search-backward},
500 @code{word-search-forward}, @code{word-search-backward},
501 @code{re-search-forward}, and @code{re-search-backward}.
502
503 @item
504 When you do regular expression searching or matching, there is no longer
505 a limit to how many @samp{\(@dots{}\)} pairs you can get information
506 about with @code{match-beginning} and @code{match-end}. Also, these
507 parenthetical groupings may now be nested to any degree.
508
509 @item
510 The new special form @code{save-match-data} preserves the regular
511 expression match status. Usage: @code{(save-match-data
512 @var{body}@dots{})}.
513
514 @item
515 The function @code{translate-region} applies a translation table to the
516 characters in a part of the buffer. Invoke it as
517 @code{(translate-region @var{start} @var{end} @var{table})}; @var{start}
518 and @var{end} bound the region to translate.
519
520 The translation table @var{table} is a string; @code{(aref @var{table}
521 @var{ochar})} gives the translated character corresponding to
522 @var{ochar}. If the length of @var{table} is less than 256, any
523 characters with codes larger than the length of @var{table} are not
524 altered by the translation.
525
526 @code{translate-region} returns the number of characters which were
527 actually changed by the translation. This does not count characters
528 which were mapped into themselves in the translation table.
529
530 @item
531 There are two new hook variables that let you notice all changes in all
532 buffers (or in a particular buffer, if you make them buffer-local):
533 @code{before-change-function} and @code{after-change-function}.
534
535 If @code{before-change-function} is non-@code{nil}, then it is called
536 before any buffer modification. Its arguments are the beginning and end
537 of the region that is going to change, represented as integers. The
538 buffer that's about to change is always the current buffer.
539
540 If @code{after-change-function} is non-@code{nil}, then it is called
541 after any buffer modification. It takes three arguments: the beginning
542 and end of the region just changed, and the length of the text that
543 existed before the change. (To get the current length, subtract the
544 rrgion beginning from the region end.) All three arguments are
545 integers. The buffer that's about to change is always the current
546 buffer.
547
548 Both of these variables are temporarily bound to @code{nil} during the
549 time that either of these hooks is running. This means that if one of
550 these functions changes the buffer, that change won't run these
551 functions. If you do want hooks to be run recursively, write your hook
552 functions to bind these variables back to their usual values.
553
554 @item
555 The hook @code{first-change-hook} is run using @code{run-hooks} whenever
556 a buffer is changed that was previously in the unmodified state.
557
558 @item
559 The second argument to @code{insert-abbrev-table-description} is
560 now optional.
561 @end itemize
562
563 @section Text Properties
564
565 Each character in a buffer or a string can have a @dfn{text property
566 list}, much like the property list of a symbol. The properties belong
567 to a particular character at a particular place, such as, the letter
568 @samp{T} at the beginning of this sentence. Each property has a name,
569 which is usually a symbol, and an associated value, which can be any
570 Lisp object---just as for properties of symbols (@pxref{Property Lists}).
571
572 You can use the property @code{face-code} to control the font and
573 color of text. That is the only property name which currently has a
574 special meaning, but you can create properties of any name and examine
575 them later for your own purposes.
576
577 Copying text between strings and buffers preserves the properties
578 along with the characters; this includes such diverse functions as
579 @code{substring}, @code{insert}, and @code{buffer-substring}.
580
581 Since text properties are considered part of the buffer contents,
582 changing properties in a buffer ``modifies'' the buffer, and you can
583 also undo such changes.
584
585 Strings with text properties have a special printed representation
586 which describes all the properties. This representation is also the
587 read syntax for such a string. It looks like this:
588
589 @example
590 #("@var{characters}" @var{property-data}...)
591 @end example
592
593 @noindent
594 where @var{property-data} is zero or more elements in groups of three as
595 follows:
596
597 @example
598 @var{beg} @var{end} @var{plist}
599 @end example
600
601 @noindent
602 The elements @var{beg} and @var{end} are integers, and together specify
603 a portion of the string; @var{plist} is the property list for that
604 portion.
605
606 @subsection Examining Text Properties
607
608 The simplest way to examine text properties is to ask for the value of
609 a particular property of a particular character. For that, use
610 @code{get-text-property}. Use @code{text-properties-at} to get the
611 entire property list of a character. @xref{Property Search}, for
612 functions to examine the properties of a number of characters at once.
613
614 @code{(get-text-property @var{pos} @var{prop} @var{object})} returns the
615 @var{prop} property of the character after @var{pos} in @var{object} (a
616 buffer or string). The argument @var{object} is optional and defaults
617 to the current buffer.
618
619 @code{(text-properties-at @var{pos} @var{object})} returns the entire
620 property list of the character after @var{pos} in the string or buffer
621 @var{object} (which defaults to the current buffer).
622
623 @subsection Changing Text Properties
624
625 There are three primitives for changing properties of a specified
626 range of text:
627
628 @table @code
629 @item add-text-properties
630 This function puts on specified properties, leaving other existing
631 properties unaltered.
632
633 @item put-text-property
634 This function puts on a single specified property, leaving others
635 unaltered.
636
637 @item remove-text-properties
638 This function removes specified properties, leaving other
639 properties unaltered.
640
641 @item set-text-properties
642 This function replaces the entire property list, leaving no vessage of
643 the properties that that text used to have.
644 @end table
645
646 All these functions take four arguments: @var{start}, @var{end},
647 @var{props}, and @var{object}. The last argument is optional and
648 defaults to the current buffer. The argument @var{props} has the form
649 of a property list.
650
651 @subsection Property Search Functions
652
653 In typical use of text properties, most of the time several or many
654 consecutive characters have the same value for a property. Rather than
655 writing your programs to examine characters one by one, it is much
656 faster to process chunks of text that have the same property value.
657
658 The functions @code{next-property-change} and
659 @code{previous-property-change} scan forward or backward from position
660 @var{pos} in @var{object}, looking for a change in any property between
661 two characters scanned. They returns the position between those two
662 characters, or @code{nil} if no change is found.
663
664 The functions @code{next-single-property-change} and
665 @code{previous-single-property-change} are similar except that you
666 specify a particular property and they look for changes in the value of
667 that property only. The property is the second argument, and
668 @var{object} is third.
669
670 @subsection Special Properties
671
672 If a character has a @code{category} property, we call it the
673 @dfn{category} of the character. It should be a symbol. The properties
674 of the symbol serve as defaults for the properties of the character.
675
676 You can use the property @code{face-code} to control the font and
677 color of text. That is the only property name which currently has a
678 special meaning, but you can create properties of any name and examine
679 them later for your own purposes.
680 about face codes.
681
682 You can specify a different keymap for a portion of the text by means
683 of a @code{local-map} property. The property's value, for the character
684 after point, replaces the buffer's local map.
685
686 If a character has the property @code{read-only}, then modifying that
687 character is not allowed. Any command that would do so gets an error.
688
689 If a character has the property @code{modification-hooks}, then its
690 value should be a list of functions; modifying that character calls all
691 of those functions. Each function receives two arguments: the beginning
692 and end of the part of the buffer being modified. Note that if a
693 particular modification hook function appears on several characters
694 being modified by a single primitive, you can't predict how many times
695 the function will be called.
696
697 Insertion of text does not, strictly speaking, change any existing
698 character, so there is a special rule for insertion. It compares the
699 @code{read-only} properties of the two surrounding characters; if they
700 are @code{eq}, then the insertion is not allowed. Assuming insertion is
701 allowed, it then gets the @code{modification-hooks} properties of those
702 characters and calls all the functions in each of them. (If a function
703 appears on both characters, it may be called once or twice.)
704
705 The special properties @code{point-entered} and @code{point-left}
706 record hook functions that report motion of point. Each time point
707 moves, Emacs compares these two property values:
708
709 @itemize @bullet
710 @item
711 the @code{point-left} property of the character after the old location,
712 and
713 @item
714 the @code{point-entered} property of the character after the new
715 location.
716 @end itemize
717
718 @noindent
719 If these two values differ, each of them is called (if not @code{nil})
720 with two arguments: the old value of point, and the new one.
721
722 The same comparison is made for the characters before the old and new
723 locations. The result may be to execute two @code{point-left} functions
724 (which may be the same function) and/or two @code{point-entered}
725 functions (which may be the same function). The @code{point-left}
726 functions are always called before the @code{point-entered} functions.
727
728 A primitive function may examine characters at various positions
729 without moving point to those positions. Only an actual change in the
730 value of point runs these hook functions.
731
732 @section New Features for Files
733
734 @itemize @bullet
735 @item
736 The new function @code{file-accessible-directory-p} tells you whether
737 you can open files in a particular directory. Specify as an argument
738 either a directory name or a file name which names a directory file.
739 The function returns @code{t} if you can open existing files in that
740 directory.
741
742 @item
743 The new function @code{file-executable-p} returns @code{t} if its
744 argument is the name of a file you have permission to execute.
745
746 @item
747 The function @code{file-truename} returns the ``true name'' of a
748 specified file. This is the name that you get by following symbolic
749 links until none remain. The argument must be an absolute file name.
750
751 @item
752 New functions @code{make-directory} and @code{delete-directory} create and
753 delete directories. They both take one argument, which is the name of
754 the directory as a file.
755
756 @item
757 The function @code{read-file-name} now takes an additional argument
758 which specifies an initial file name. If you specify this argument,
759 @code{read-file-name} inserts it along with the directory name. It puts
760 the cursor between the directory and the initial file name.
761
762 The user can then use the initial file name unchanged, modify it, or
763 simply kill it with @kbd{C-k}.
764
765 If the variable @code{insert-default-directory} is @code{nil}, then the
766 default directory is not inserted, and the new argument is ignored.
767
768 @item
769 The function @code{file-relative-name} does the inverse of
770 expansion---it tries to return a relative name which is equivalent to
771 @var{filename} when interpreted relative to @var{directory}. (If such a
772 relative name would be longer than the absolute name, it returns the
773 absolute name instead.)
774
775 @item
776 The function @code{file-newest-backup} returns the name of the most
777 recent backup file for @var{filename}, or @code{nil} that file has no
778 backup files.
779
780 @item
781 The list returned by @code{file-attributes} now has 12 elements. The
782 12th element is the file system number of the file system that the file
783 is in. This element together with the file's inode number, which is the
784 11th element, give enough information to distinguish any two files on
785 the system---no two files can have the same values for both of these
786 numbers.
787
788 @item
789 The new function @code{set-visited-file-modtime} updates the current
790 buffer's recorded modification time from the visited file's time.
791
792 This is useful if the buffer was not read from the file normally, or
793 if the file itself has been changed for some known benign reason.
794
795 If you give the function an argument, that argument specifies the new
796 value for the recorded modification time. The argument should be a list
797 of the form @code{(@var{high} . @var{low})} or @code{(@var{high}
798 @var{low})} containing two integers, each of which holds 16 bits of the
799 time. (This is the same format that @code[file-attributes} uses to
800 return time values.)
801
802 The new function @code{visited-file-modtime} returns the recorded last
803 modification time, in that same format.
804
805 @item
806 The function @code{directory-files} now takes an optional fourth
807 argument which, if non-@code{nil}, inhibits sorting the file names.
808 Use this if you want the utmost possible speed and don't care what order
809 the files are processed in.
810
811 If the order of processing is at all visible to the user, then the user
812 will probably be happier if you do sort the names.
813
814 @item
815 The variable @code{directory-abbrev-alist} contains an alist of
816 abbreviations to use for file directories. Each element has the form
817 @code{(@var{from} . @var{to})}, and says to replace @var{from} with
818 @var{to} when it appears in a directory name. This replacement is done
819 when setting up the default directory of a newly visited file. The
820 @var{from} string is actually a regular expression; it should always
821 start with @samp{^}.
822
823 You can set this variable in @file{site-init.el} to describe the
824 abbreviations appropriate for your site.
825
826 @item
827 The function @code{abbreviate-file-name} applies abbreviations from
828 @code{directory-abbrev-alist} to its argument, and substitutes @samp{~}
829 for the user's home directory.
830
831 Abbreviated directory names are useful for directories that are normally
832 accessed through symbolic links. If you think of the link's name as
833 ``the name'' of the directory, you can define it as an abbreviation for
834 the directory's official name; then ordinarily Emacs will call that
835 directory by the link name you normally use.
836
837 @item
838 @code{write-region} can write a given string instead of text from the
839 buffer. Use the string as the first argument (in place of the
840 starting character position).
841
842 You can supply a second file name as the fifth argument (@var{visit}).
843 Use this to write the data to one file (the first argument,
844 @var{filename}) while nominally visiting a different file (the fifth
845 argument, @var{visit}). The argument @var{visit} is used in the echo
846 area message and also for file locking; @var{visit} is stored in
847 @code{buffer-file-name}.
848
849 @item
850 The value of @code{write-file-hooks} does not change when you switch to
851 a new major mode. The intention is that these hooks have to do with
852 where the file came from, and not with what it contains.
853
854 @item
855 There is a new hook variable for saving files:
856 @code{write-contents-hooks}. It works just like @code{write-file-hooks}
857 except that switching to a new major mode clears it back to @code{nil}.
858 Major modes should use this hook variable rather than
859 @code{write-file-hooks}.
860
861 @item
862 The hook @code{after-save-hook} runs just after a buffer has been saved
863 in its visited file.
864
865 @item
866 The new function @code{set-default-file-modes} sets the file protection
867 for new files created with Emacs. The argument must be an integer. (It
868 would be better to permit symbolic arguments like the @code{chmod}
869 program, but that would take more work than this function merits.)
870
871 Use the new function @code{default-file-modes} to read the current
872 default file mode.
873
874 @item
875 Call the new function @code{unix-sync} to force all pending disk output
876 to happen as soon as possible.
877 @end itemize
878
879 @section Making Certain File Names ``Magic''
880
881 You can implement special handling for a class of file names. You must
882 supply a regular expression to define the class of names (all those
883 which match the regular expression), plus a handler that implements all
884 the primitive Emacs file operations for file names that do match.
885
886 The value of @code{file-name-handler-alist} is a list of handlers,
887 together with regular expressions that decide when to apply each
888 handler. Each element has the form @code{(@var{regexp}
889 . @var{handler})}. If a file name matches @var{regexp}, then all work
890 on that file is done by calling @var{handler}.
891
892 All the Emacs primitives for file access and file name transformation
893 check the given file name against @code{file-name-handler-alist}, and
894 call @var{handler} to do the work if appropriate. The first argument
895 given to @var{handler} is the name of the primitive; the remaining
896 arguments are the arguments that were passed to that primitive. (The
897 first of these arguments is typically the file name itself.) For
898 example, if you do this:
899
900 @example
901 (file-exists-p @var{filename})
902 @end example
903
904 @noindent
905 and @var{filename} has handler @var{handler}, then @var{handler} is
906 called like this:
907
908 @example
909 (funcall @var{handler} 'file-exists-p @var{filename})
910 @end example
911
912 Here are the primitives that you can handle in this way:
913
914 @quotation
915 @code{add-name-to-file}, @code{copy-file}, @code{delete-directory},
916 @code{delete-file}, @code{directory-file-name}, @code{directory-files},
917 @code{dired-compress-file}, @code{dired-uncache},
918 @code{expand-file-name}, @code{file-accessible-directory-p},
919 @code{file-attributes}, @code{file-directory-p},
920 @code{file-executable-p}, @code{file-exists-p}, @code{file-local-copy},
921 @code{file-modes}, @code{file-name-all-completions},
922 @code{file-name-as-directory}, @code{file-name-completion},
923 @code{file-name-directory}, @code{file-name-nondirectory},
924 @code{file-name-sans-versions}, @code{file-newer-than-file-p},
925 @code{file-readable-p}, @code{file-symlink-p}, @code{file-writable-p},
926 @code{insert-directory}, @code{insert-file-contents},
927 @code{make-directory}, @code{make-symbolic-link}, @code{rename-file},
928 @code{set-file-modes}, @code{verify-visited-file-modtime},
929 @code{write-region}.
930 @end quotation
931
932 The handler function must handle all of the above operations, and
933 possibly others to be added in the future. Therefore, it should always
934 reinvoke the ordinary Lisp primitive when it receives an operation it
935 does not recognize. Here's one way to do this:
936
937 @smallexample
938 (defun my-file-handler (primitive &rest args)
939 ;; @r{First check for the specific operations}
940 ;; @r{that we have special handling for.}
941 (cond ((eq operation 'insert-file-contents) @dots{})
942 ((eq operation 'write-region) @dots{})
943 @dots{}
944 ;; @r{Handle any operation we don't know about.}
945 (t (let (file-name-handler-alist)
946 (apply operation args)))))
947 @end smallexample
948
949 The function @code{file-local-copy} copies file @var{filename} to the
950 local site, if it isn't there already. If @var{filename} specifies a
951 ``magic'' file name which programs outside Emacs cannot directly read or
952 write, this copies the contents to an ordinary file and returns that
953 file's name.
954
955 If @var{filename} is an ordinary file name, not magic, then this function
956 does nothing and returns @code{nil}.
957
958 The function @code{unhandled-file-name-directory} is used to get a
959 non-magic directory name from an arbitrary file name. It uses the
960 directory part of the specified file name if that is not magic.
961 Otherwise, it asks the file name's handler what to do.
962
963 @section Frames
964 @cindex frame
965
966 Emacs now supports multiple X windows via a new data type known as a
967 @dfn{frame}.
968
969 A frame is a rectangle on the screen that contains one or more Emacs
970 windows. Subdividing a frame works just like subdividing the screen in
971 earlier versions of Emacs.
972
973 @cindex terminal frame
974 There are two kinds of frames: terminal frames and X window frames.
975 Emacs creates one terminal frame when it starts up with no X display; it
976 uses Termcap or Terminfo to display using characters. There is no way
977 to create another terminal frame after startup. If Emacs has an X
978 display, it does not make a terminal frame, and there is none.
979
980 @cindex X window frame
981 When you are using X windows, Emacs starts out with a single X window
982 frame. You can create any number of X window frames using
983 @code{make-frame}.
984
985 Use the predicate @code{framep} to determine whether a given Lisp object
986 is a frame.
987
988 The function @code{redraw-frame} redisplays the entire contents of a
989 given frame.
990
991 @subsection Creating and Deleting Frames
992
993 Use @code{make-frame} to create a new frame (supported under X Windows
994 only). This is the only primitive for creating frames.
995
996 @code{make-frame} takes just one argument, which is an alist
997 specifying frame parameters. Any parameters not mentioned in the
998 argument alist default based on the value of @code{default-frame-alist};
999 parameters not specified there default from the standard X defaults file
1000 and X resources.
1001
1002 When you invoke Emacs, if you specify arguments for window appearance
1003 and so forth, these go into @code{default-frame-alist} and that is how
1004 they have their effect.
1005
1006 You can specify the parameters for the initial startup X window frame by
1007 setting @code{initial-frame-alist} in your @file{.emacs} file. If these
1008 parameters specify a separate minibuffer-only frame, and you have not
1009 created one, Emacs creates one for you, using the parameter values
1010 specified in @code{minibuffer-frame-alist}.
1011
1012 You can specify the size and position of a frame using the frame
1013 parameters @code{left}, @code{top}, @code{height} and @code{width}. You
1014 must specify either both size parameters or neither. You must specify
1015 either both position parameters or neither. The geometry parameters
1016 that you don't specify are chosen by the window manager in its usual
1017 fashion.
1018
1019 The function @code{x-parse-geometry} converts a standard X windows
1020 geometry string to an alist which you can use as part of the argument to
1021 @code{make-frame}.
1022
1023 Use the function @code{delete-frame} to eliminate a frame. Frames are
1024 like buffers where deletion is concerned; a frame actually continues to
1025 exist as a Lisp object until it is deleted @emph{and} there are no
1026 references to it, but once it is deleted, it has no further effect on
1027 the screen.
1028
1029 The function @code{frame-live-p} returns non-@code{nil} if the argument
1030 (a frame) has not been deleted.
1031
1032 @subsection Finding All Frames
1033
1034 The function @code{frame-list} returns a list of all the frames that have
1035 not been deleted. It is analogous to @code{buffer-list}. The list that
1036 you get is newly created, so modifying the list doesn't have any effect
1037 on the internals of Emacs. The function @code{visible-frame-list} returns
1038 the list of just the frames that are visible.
1039
1040 @code{next-frame} lets you cycle conveniently through all the frames from an
1041 arbitrary starting point. Its first argument is a frame. Its second
1042 argument @var{minibuf} says what to do about minibuffers:
1043
1044 @table @asis
1045 @item @code{nil}
1046 Exclude minibuffer-only frames.
1047 @item a window
1048 Consider only the frames using that particular window as their
1049 minibuffer.
1050 @item anything else
1051 Consider all frames.
1052 @end table
1053
1054 @subsection Frames and Windows
1055
1056 All the non-minibuffer windows in a frame are arranged in a tree of
1057 subdivisions; the root of this tree is available via the function
1058 @code{frame-root-window}. Each window is part of one and only one
1059 frame; you can get the frame with @code{window-frame}.
1060
1061 At any time, exactly one window on any frame is @dfn{selected within the
1062 frame}. You can get the frame's current selected window with
1063 @code{frame-selected-window}. The significance of this designation is
1064 that selecting the frame selects for Emacs as a whole the window
1065 currently selected within that frame.
1066
1067 Conversely, selecting a window for Emacs with @code{select-window} also
1068 makes that window selected within its frame.
1069
1070 @subsection Frame Visibility
1071
1072 A frame may be @dfn{visible}, @dfn{invisible}, or @dfn{iconified}. If
1073 it is invisible, it doesn't show in the screen, not even as an icon.
1074 You can set the visibility status of a frame with
1075 @code{make-frame-visible}, @code{make-frame-invisible}, and
1076 @code{iconify-frame}. You can examine the visibility status with
1077 @code{frame-visible-p}---it returns @code{t} for a visible frame,
1078 @code{nil} for an invisible frame, and @code{icon} for an iconified
1079 frame.
1080
1081 @subsection Selected Frame
1082
1083 At any time, one frame in Emacs is the @dfn{selected frame}. The selected
1084 window always resides on the selected frame.
1085
1086 @defun selected-frame
1087 This function returns the selected frame.
1088 @end defun
1089
1090 The X server normally directs keyboard input to the X window that the
1091 mouse is in. Some window managers use mouse clicks or keyboard events
1092 to @dfn{shift the focus} to various X windows, overriding the normal
1093 behavior of the server.
1094
1095 Lisp programs can switch frames ``temporarily'' by calling the function
1096 @code{select-frame}. This does not override the window manager; rather,
1097 it escapes from the window manager's control until that control is
1098 somehow reasserted. The function takes one argument, a frame, and
1099 selects that frame. The selection lasts until the next time the user
1100 does something to select a different frame, or until the next time this
1101 function is called.
1102
1103 Emacs cooperates with the X server and the window managers by arranging
1104 to select frames according to what the server and window manager ask
1105 for. It does so by generating a special kind of input event, called a
1106 @dfn{focus} event. The command loop handles a focus event by calling
1107 @code{internal-select-frame}. @xref{Focus Events}.
1108
1109 @subsection Frame Size and Position
1110
1111 The new functions @code{frame-height} and @code{frame-width} return the
1112 height and width of a specified frame (or of the selected frame),
1113 measured in characters.
1114
1115 The new functions @code{frame-pixel-height} and @code{frame-pixel-width}
1116 return the height and width of a specified frame (or of the selected
1117 frame), measured in pixels.
1118
1119 The new functions @code{frame-char-height} and @code{frame-char-width}
1120 return the height and width of a character in a specified frame (or in
1121 the selected frame), measured in pixels.
1122
1123 @code{set-frame-size} sets the size of a frame, measured in characters;
1124 its arguments are @var{frame}, @var{cols} and @var{rows}. To set the
1125 size with values measured in pixels, you can use
1126 @code{modify-frame-parameters}.
1127
1128 The function @code{set-frame-position} sets the position of the top left
1129 corner of a frame. Its arguments are @var{frame}, @var{left} and
1130 @var{top}.
1131
1132 @ignore
1133 New functions @code{set-frame-height} and @code{set-frame-width} set the
1134 size of a specified frame. The frame is the first argument; the size is
1135 the second.
1136 @end ignore
1137
1138 @subsection Frame Parameters
1139
1140 A frame has many parameters that affect how it displays. Use the
1141 function @code{frame-parameters} to get an alist of all the parameters
1142 of a given frame. To alter parameters, use
1143 @code{modify-frame-parameters}, which takes two arguments: the frame to
1144 modify, and an alist of parameters to change and their new values. Each
1145 element of @var{alist} has the form @code{(@var{parm} . @var{value})},
1146 where @var{parm} is a symbol. Parameters that aren't meaningful are
1147 ignored. If you don't mention a parameter in @var{alist}, its value
1148 doesn't change.
1149
1150 Just what parameters a frame has depends on what display mechanism it
1151 uses. Here is a table of the parameters of an X
1152 window frame:
1153
1154 @table @code
1155 @item name
1156 The name of the frame.
1157
1158 @item left
1159 The screen position of the left edge.
1160
1161 @item top
1162 The screen position of the top edge.
1163
1164 @item height
1165 The height of the frame contents, in pixels.
1166
1167 @item width
1168 The width of the frame contents, in pixels.
1169
1170 @item window-id
1171 The number of the X window for the frame.
1172
1173 @item minibuffer
1174 Whether this frame has its own minibuffer.
1175 @code{t} means yes, @code{none} means no,
1176 @code{only} means this frame is just a minibuffer,
1177 a minibuffer window (in some other frame)
1178 means the new frame uses that minibuffer.
1179
1180 @item font
1181 The name of the font for the text.
1182
1183 @item foreground-color
1184 The color to use for the inside of a character.
1185 Use strings to designate colors;
1186 X windows defines the meaningful color names.
1187
1188 @item background-color
1189 The color to use for the background of text.
1190
1191 @item mouse-color
1192 The color for the mouse cursor.
1193
1194 @item cursor-color
1195 The color for the cursor that shows point.
1196
1197 @item border-color
1198 The color for the border of the frame.
1199
1200 @item cursor-type
1201 The way to display the cursor. There are two legitimate values:
1202 @code{bar} and @code{box}. The value @code{bar} specifies a vertical
1203 bar between characters as the cursor. The value @code{box} specifies an
1204 ordinary black box overlaying the character after point; that is the
1205 default.
1206
1207 @item icon-type
1208 Non-@code{nil} for a bitmap icon, @code{nil} for a text icon.
1209
1210 @item border-width
1211 The width in pixels of the window border.
1212
1213 @item internal-border-width
1214 The distance in pixels between text and border.
1215
1216 @item auto-raise
1217 Non-@code{nil} means selecting the frame raises it.
1218
1219 @item auto-lower
1220 Non-@code{nil} means deselecting the frame lowers it.
1221
1222 @item vertical-scrollbar
1223 Non-@code{nil} gives the frame a scroll bar
1224 for vertical scrolling.
1225
1226 @item horizontal-scrollbar
1227 Non-@code{nil} gives the frame a scroll bar
1228 for horizontal scrolling.
1229 @end table
1230
1231 @subsection Minibufferless Frames
1232
1233 Normally, each frame has its own minibuffer window at the bottom, which
1234 is used whenever that frame is selected. However, you can also create
1235 frames with no minibuffers. These frames must use the minibuffer window
1236 of some other frame.
1237
1238 The variable @code{default-minibuffer-frame} specifies where to find a
1239 minibuffer for frames created without minibuffers of their own. Its
1240 value should be a frame which does have a minibuffer.
1241
1242 You can also specify a minibuffer window explicitly when you create a
1243 frame; then @code{default-minibuffer-frame} is not used.
1244
1245 @section X Windows Features
1246
1247 @itemize @bullet
1248 @item
1249 The new functions @code{mouse-position} and @code{set-mouse-position} give
1250 access to the current position of the mouse.
1251
1252 @code{mouse-position} returns a description of the position of the mouse.
1253 The value looks like @code{(@var{frame} @var{x} . @var{y})}, where @var{x}
1254 and @var{y} are measured in pixels relative to the top left corner of
1255 the inside of @var{frame}.
1256
1257 @code{set-mouse-position} takes three arguments, @var{frame}, @var{x}
1258 and @var{y}, and warps the mouse cursor to that location on the screen.
1259
1260 @item
1261 @code{track-mouse} is a new special form for tracking mouse motion.
1262 Use it in definitions of mouse clicks that want pay to attention to
1263 the motion of the mouse, not just where the buttons are pressed and
1264 released. Here is how to use it:
1265
1266 @example
1267 (track-mouse @var{body}@dots{})
1268 @end example
1269
1270 While @var{body} executes, mouse motion generates input events just as mouse
1271 clicks do. @var{body} can read them with @code{read-event} or
1272 @code{read-key-sequence}.
1273
1274 @code{track-mouse} returns the value of the last form in @var{body}.
1275
1276 The format of these events is described under ``New features for key
1277 bindings and input.''
1278 @c ???
1279
1280 @item
1281 @code{x-set-selection} sets a ``selection'' in the X Windows server.
1282 It takes two arguments: a selection type @var{type}, and the value to
1283 assign to it, @var{data}. If @var{data} is @code{nil}, it means to
1284 clear out the selection. Otherwise, @var{data} may be a string, a
1285 symbol, an integer (or a cons of two integers or list of two integers),
1286 or a cons of two markers pointing to the same buffer. In the last case,
1287 the selection is considered to be the text between the markers. The
1288 data may also be a vector of valid non-vector selection values.
1289
1290 Each possible @var{type} has its own selection value, which changes
1291 independently. The usual values of @var{type} are @code{PRIMARY} and
1292 @code{SECONDARY}; these are symbols with upper-case names, in accord
1293 with X Windows conventions. The default is @code{PRIMARY}.
1294
1295 To get the value of the selection, call @code{x-get-selection}. This
1296 function accesses selections set up by Emacs and those set up by other X
1297 clients. It takes two optional arguments, @var{type} and
1298 @var{data-type}. The default for @var{type} is @code{PRIMARY}.
1299
1300 The @var{data-type} argument specifies the form of data conversion to
1301 use; meaningful values include @code{TEXT}, @code{STRING},
1302 @code{TARGETS}, @code{LENGTH}, @code{DELETE}, @code{FILE_NAME},
1303 @code{CHARACTER_POSITION}, @code{LINE_NUMBER}, @code{COLUMN_NUMBER},
1304 @code{OWNER_OS}, @code{HOST_NAME}, @code{USER}, @code{CLASS},
1305 @code{NAME}, @code{ATOM}, and @code{INTEGER}. (These are symbols with
1306 upper-case names in accord with X Windows conventions.)
1307 The default for @var{data-type} is @code{STRING}.
1308
1309 @item
1310 X Windows has a set of numbered @dfn{cut buffers} which can store text
1311 or other data being moved between applications. Use
1312 @code{x-get-cut-buffer} to get the contents of a cut buffer; specify the
1313 cut buffer number as argument. Use @code{x-set-cut-buffer} with
1314 argument @var{string} to store a new string into the first cut buffer
1315 (moving the other values down through the series of cut buffers,
1316 kill-ring-style).
1317
1318 Cut buffers are considered obsolete in X Windows, but Emacs supports
1319 them for the sake of X clients that still use them.
1320
1321 @item
1322 You can close the connection with the X Windows server with
1323 the function @code{x-close-current-connection}. This takes no arguments.
1324
1325 Then you can connect to a different X Windows server with
1326 @code{x-open-connection}. The first argument, @var{display}, is the
1327 name of the display to connect to.
1328
1329 The optional second argument @var{xrm-string} is a string of resource
1330 names and values, in the same format used in the @file{.Xresources}
1331 file. The values you specify override the resource values recorded in
1332 the X Windows server itself. Here's an example of what this string
1333 might look like:
1334
1335 @example
1336 "*BorderWidth: 3\n*InternalBorder: 2\n"
1337 @end example
1338
1339 @item
1340 A series of new functions give you information about the X server and
1341 the screen you are using.
1342
1343 @table @code
1344 @item x-display-screens
1345 The number of screens associated with the current display.
1346
1347 @item x-server-version
1348 The version numbers of the X server in use.
1349
1350 @item x-server-vendor
1351 The vendor supporting the X server in use.
1352
1353 @item x-display-pixel-height
1354 The height of this X screen in pixels.
1355
1356 @item x-display-mm-height
1357 The height of this X screen in millimeters.
1358
1359 @item x-display-pixel-width
1360 The width of this X screen in pixels.
1361
1362 @item x-display-mm-width
1363 The width of this X screen in millimeters.
1364
1365 @item x-display-backing-store
1366 The backing store capability of this screen. Values can be the symbols
1367 @code{always}, @code{when-mapped}, or @code{not-useful}.
1368
1369 @item x-display-save-under
1370 Non-@code{nil} if this X screen supports the SaveUnder feature.
1371
1372 @item x-display-planes
1373 The number of planes this display supports.
1374
1375 @item x-display-visual-class
1376 The visual class for this X screen. The value is one of the symbols
1377 @code{static-gray}, @code{gray-scale}, @code{static-color},
1378 @code{pseudo-color}, @code{true-color}, and @code{direct-color}.
1379
1380 @item x-display-color-p
1381 @code{t} if the X screen in use is a color screen.
1382
1383 @item x-display-color-cells
1384 The number of color cells this X screen supports.
1385 @end table
1386
1387 There is also a variable @code{x-no-window-manager}, whose value is
1388 @code{t} if no X window manager is in use.
1389
1390 @item
1391 The function @code{x-synchronize} enables or disables an X Windows
1392 debugging mode: synchronous communication. It takes one argument,
1393 non-@code{nil} to enable the mode and @code{nil} to disable.
1394
1395 In synchronous mode, Emacs waits for a response to each X protocol
1396 command before doing anything else. This means that errors are reported
1397 right away, and you can directly find the erroneous command.
1398 Synchronous mode is not the default because it is much slower.
1399
1400 @item
1401 The function @code{x-get-resource} retrieves a resource value from the X
1402 Windows defaults database. Its three arguments are @var{attribute},
1403 @var{name} and @var{class}. It searches using a key of the form
1404 @samp{@var{instance}.@var{attribute}}, with class @samp{Emacs}, where
1405 @var{instance} is the name under which Emacs was invoked.
1406
1407 The optional arguments @var{component} and @var{subclass} add to the key
1408 and the class, respectively. You must specify both of them or neither.
1409 If you specify them, the key is
1410 @samp{@var{instance}.@var{component}.@var{attribute}}, and the class is
1411 @samp{Emacs.@var{subclass}}.
1412
1413 @item
1414 @code{x-color-display-p} returns @code{t} if you are using an X Window
1415 server with a color display, and @code{nil} otherwise.
1416
1417 @c ??? Name being changed from x-defined-color.
1418 @code{x-color-defined-p} takes as argument a string describing a color; it
1419 returns @code{t} if the display supports that color. (If the color is
1420 @code{"black"} or @code{"white"} then even black-and-white displays
1421 support it.)
1422
1423 @item
1424 @code{x-popup-menu} has been generalized. It now accepts a keymap as
1425 the @var{menu} argument. Then the menu items are the prompt strings of
1426 individual key bindings, and the item values are the keys which have
1427 those bindings.
1428
1429 You can also supply a list of keymaps as the first argument; then each
1430 keymap makes one menu pane (but keymaps that don't provide any menu
1431 items don't appear in the menu at all).
1432
1433 @code{x-popup-menu} also accepts a mouse button event as the
1434 @var{position} argument. Then it displays the menu at the location at
1435 which the event took place. This is convenient for mouse-invoked
1436 commands that pop up menus.
1437
1438 @ignore
1439 @item
1440 x-pointer-shape, x-nontext-pointer-shape, x-mode-pointer-shape.
1441 @end ignore
1442
1443 @item
1444 You can use the function @code{x-rebind-key} to change the sequence
1445 of characters generated by one of the keyboard keys. This works
1446 only with X Windows.
1447
1448 The first two arguments, @var{keycode} and @var{shift-mask}, should be
1449 numbers representing the keyboard code and shift mask respectively.
1450 They specify what key to change.
1451
1452 The third argument, @var{newstring}, is the new definition of the key.
1453 It is a sequence of characters that the key should produce as input.
1454
1455 The shift mask value is a combination of bits according to this table:
1456
1457 @table @asis
1458 @item 8
1459 Control
1460 @item 4
1461 Meta
1462 @item 2
1463 Shift
1464 @item 1
1465 Shift Lock
1466 @end table
1467
1468 If you specify @code{nil} for @var{shift-mask}, then the key specified
1469 by @var{keycode} is redefined for all possible shift combinations.
1470
1471 For the possible values of @var{keycode} and their meanings, see the
1472 file @file{/usr/lib/Xkeymap.txt}. Keep in mind that the codes in that
1473 file are in octal!
1474
1475 @ignore @c Presumably this is already fixed
1476 NOTE: due to an X bug, this function will not take effect unless the
1477 user has a @file{~/.Xkeymap} file. (See the documentation for the
1478 @code{keycomp} program.) This problem will be fixed in X version 11.
1479 @end ignore
1480
1481 The related function @code{x-rebind-keys} redefines a single keyboard
1482 key, specifying the behavior for each of the 16 shift masks
1483 independently. The first argument is @var{keycode}, as in
1484 @code{x-rebind-key}. The second argument @var{strings} is a list of 16
1485 elements, one for each possible shift mask value; each element says how
1486 to redefine the key @var{keycode} with the corresponding shift mask
1487 value. If an element is a string, it is the new definition. If an
1488 element is @code{nil}, the definition does not change for that shift
1489 mask.
1490
1491 @item
1492 The function @code{x-geometry} parses a string specifying window size
1493 and position in the usual fashion for X windows. It returns an alist
1494 describing which parameters were specified, and the values that were
1495 given for them.
1496
1497 The elements of the alist look like @code{(@var{parameter} .
1498 @var{value})}. The possible @var{parameter} values are @code{left},
1499 @code{top}, @code{width}, and @code{height}.
1500 @end itemize
1501
1502 @section New Window Features
1503
1504 @itemize @bullet
1505 @item
1506 The new function @code{window-at} tells you which window contains a
1507 given horizontal and vertical position on a specified frame. Call it
1508 with three arguments, like this:
1509
1510 @example
1511 (window-at @var{x} @var{column} @var{frame})
1512 @end example
1513
1514 The function returns the window which contains that cursor position in
1515 the frame @var{frame}. If you omit @var{frame}, the selected frame is
1516 used.
1517
1518 @item
1519 The function @code{coordinates-in-window-p} takes two arguments and
1520 checks whether a particular frame position falls within a particular
1521 window.
1522
1523 @example
1524 (coordinates-in-window-p @var{coordinates} @var{window})
1525 @end example
1526
1527 The argument @var{coordinates} is a cons cell of this form:
1528
1529 @example
1530 (@var{x} . @var{y})
1531 @end example
1532
1533 @noindent
1534 The two coordinates are measured in characters, and count from the top
1535 left corner of the screen or frame.
1536
1537 The value of the function tells you what part of the window the position
1538 is in. The possible values are:
1539
1540 @table @code
1541 @item (@var{relx} . @var{rely})
1542 The coordinates are inside @var{window}. The numbers @var{relx} and
1543 @var{rely} are equivalent window-relative coordinates, counting from 0
1544 at the top left corner of the window.
1545
1546 @item mode-line
1547 The coordinates are in the mode line of @var{window}.
1548
1549 @item vertical-split
1550 The coordinates are in the vertical line between @var{window} and its
1551 neighbor to the right.
1552
1553 @item nil
1554 The coordinates are not in any sense within @var{window}.
1555 @end table
1556
1557 You need not specify a frame when you call
1558 @code{coordinates-in-window-p}, because it assumes you mean the frame
1559 which window @var{window} is on.
1560
1561 @item
1562 The function @code{minibuffer-window} now accepts a frame as argument
1563 and returns the minibuffer window used for that frame. If you don't
1564 specify a frame, the currently selected frame is used. The minibuffer
1565 window may be on the frame in question, but if that frame has no
1566 minibuffer of its own, it uses the minibuffer window of some other
1567 frame, and @code{minibuffer-window} returns that window.
1568
1569 @item
1570 Use @code{window-live-p} to test whether a window is still alive (that
1571 is, not deleted).
1572
1573 @item
1574 Use @code{window-minibuffer-p} to determine whether a given window is a
1575 minibuffer or not. It no longer works to do this by comparing the
1576 window with the result of @code{(minibuffer-window)}, because there can
1577 be more than one minibuffer window at a time (if you have multiple
1578 frames).
1579
1580 @item
1581 If you set the variable @code{pop-up-frames} non-@code{nil}, then the
1582 functions to show something ``in another window'' actually create a new
1583 frame for the new window. Thus, you will tend to have a frame for each
1584 window, and you can easily have a frame for each buffer.
1585
1586 The value of the variable @code{pop-up-frame-function} controls how new
1587 frames are made. The value should be a function which takes no
1588 arguments and returns a frame. The default value is a function which
1589 creates a frame using parameters from @code{pop-up-frame-alist}.
1590
1591 @item
1592 @code{display-buffer} is the basic primitive for finding a way to show a
1593 buffer on the screen. You can customize its behavior by storing a
1594 function in the variable @code{display-buffer-function}. If this
1595 variable is non-@code{nil}, then @code{display-buffer} calls it to do
1596 the work. Your function should accept two arguments, as follows:
1597
1598 @table @var
1599 @item buffer
1600 The buffer to be displayed.
1601
1602 @item flag
1603 A flag which, if non-@code{nil}, means you should find another window to
1604 display @var{buffer} in, even if it is already visible in the selected
1605 window.
1606 @end table
1607
1608 The function you supply will be used by commands such as
1609 @code{switch-to-buffer-other-window} and @code{find-file-other-window}
1610 as well as for your own calls to @code{display-buffer}.
1611
1612 @item
1613 @code{delete-window} now gives all of the deleted window's screen space
1614 to a single neighboring window. Likewise, @code{enlarge-window} takes
1615 space from only one neighboring window until that window disappears;
1616 only then does it take from another window.
1617
1618 @item
1619 @code{next-window} and @code{previous-window} accept another argument,
1620 @var{all-frames}.
1621
1622 These functions now take three optional arguments: @var{window},
1623 @var{minibuf} and @var{all-frames}. @var{window} is the window to start
1624 from (@code{nil} means use the selected window). @var{minibuf} says
1625 whether to include the minibuffer in the windows to cycle through:
1626 @code{t} means yes, @code{nil} means yes if it is active, and anything
1627 else means no.
1628
1629 Normally, these functions cycle through all the windows in the
1630 selected frame, plus the minibuffer used by the selected frame even if
1631 it lies in some other frame.
1632
1633 If @var{all-frames} is @code{t}, then these functions cycle through
1634 all the windows in all the frames that currently exist. If
1635 @var{all-frames} is neither @code{t} nor @code{nil}, then they limit
1636 themselves strictly to the windows in the selected frame, excluding the
1637 minibuffer in use if it lies in some other frame.
1638
1639 @item
1640 The functions @code{get-lru-window} and @code{get-largest-window} now
1641 take an optional argument @var{all-frames}. If it is non-@code{nil},
1642 the functions consider all windows on all frames. Otherwise, they
1643 consider just the windows on the selected frame.
1644
1645 Likewise, @code{get-buffer-window} takes an optional second argument
1646 @var{all-frames}.
1647
1648 @item
1649 The variable @code{other-window-scroll-buffer} specifies which buffer
1650 @code{scroll-other-window} should scroll.
1651
1652 @item
1653 You can now mark a window as ``dedicated'' to its buffer.
1654 Then Emacs will not try to use that window for any other buffer
1655 unless you explicitly request it.
1656
1657 Use the new function @code{set-window-dedicated-p} to set the dedication
1658 flag of a window @var{window} to the value @var{flag}. If @var{flag} is
1659 @code{t}, this makes the window dedicated. If @var{flag} is
1660 @code{nil}, this makes the window non-dedicated.
1661
1662 Use @code{window-dedicated-p} to examine the dedication flag of a
1663 specified window.
1664
1665 @item
1666 The new function @code{walk-windows} cycles through all visible
1667 windows, calling @code{proc} once for each window with the window as
1668 its sole argument.
1669
1670 The optional second argument @var{minibuf} says whether to include minibuffer
1671 windows. A value of @code{t} means count the minibuffer window even if
1672 not active. A value of @code{nil} means count it only if active. Any
1673 other value means not to count the minibuffer even if it is active.
1674
1675 If the optional third argument @var{all-frames} is @code{t}, that means
1676 include all windows in all frames. If @var{all-frames} is @code{nil},
1677 it means to cycle within the selected frame, but include the minibuffer
1678 window (if @var{minibuf} says so) that that frame uses, even if it is on
1679 another frame. If @var{all-frames} is neither @code{nil} nor @code{t},
1680 @code{walk-windows} sticks strictly to the selected frame.
1681
1682 @item
1683 The function @code{window-end} is a counterpart to @code{window-start}:
1684 it returns the buffer position of the end of the display in a given
1685 window (or the selected window).
1686
1687 @item
1688 The function @code{window-configuration-p} returns non-@code{nil} when
1689 given an object that is a window configuration (such as is returned by
1690 @code{current-window-configuration}).
1691 @end itemize
1692
1693 @section Display Features
1694
1695 @itemize @bullet
1696 @item
1697 @samp{%l} as a mode line item displays the current line number.
1698
1699 If the buffer is longer than @code{line-number-display-limit}
1700 characters, or if lines are too long in the viscinity of the current
1701 displayed text, then line number display is inhibited to save time.
1702
1703 The default contents of the mode line include the line number if
1704 @code{line-number-mode} is non-@code{nil}.
1705
1706 @item
1707 @code{baud-rate} is now a variable rather than a function. This is so
1708 you can set it to reflect the effective speed of your terminal, when the
1709 system doesn't accurately know the speed.
1710
1711 @item
1712 You can now remove any echo area message and make the minibuffer
1713 visible. To do this, call @code{message} with @code{nil} as the only
1714 argument. This clears any existing message, and lets the current
1715 minibuffer contents show through. Previously, there was no reliable way
1716 to make sure that the minibuffer contents were visible.
1717
1718 @item
1719 The variable @code{temp-buffer-show-hook} has been renamed
1720 @code{temp-buffer-show-function}, because its value is a single function
1721 (of one argument), not a normal hook.
1722
1723 @item
1724 The new function @code{force-mode-line-update} causes redisplay
1725 of the current buffer's mode line.
1726 @end itemize
1727
1728 @section Display Tables
1729
1730 @cindex display table
1731 You can use the @dfn{display table} feature to control how all 256
1732 possible character codes display on the screen. This is useful for
1733 displaying European languages that have letters not in the ASCII
1734 character set.
1735
1736 The display table maps each character code into a sequence of
1737 @dfn{glyphs}, each glyph being an image that takes up one character
1738 position on the screen. You can also define how to display each glyph
1739 on your terminal, using the @dfn{glyph table}.
1740
1741 @subsection Display Tables
1742
1743 Use @code{make-display-table} to create a display table. The table
1744 initially has @code{nil} in all elements.
1745
1746 A display table is actually an array of 261 elements. The first 256
1747 elements of a display table control how to display each possible text
1748 character. The value should be @code{nil} or a vector (which is a
1749 sequence of glyphs; see below). @code{nil} as an element means to
1750 display that character following the usual display conventions.
1751
1752 The remaining five elements of a display table serve special purposes
1753 (@code{nil} means use the default stated below):
1754
1755 @table @asis
1756 @item 256
1757 The glyph for the end of a truncated screen line (the default for this
1758 is @samp{\}).
1759 @item 257
1760 The glyph for the end of a continued line (the default is @samp{$}).
1761 @item 258
1762 The glyph for the indicating an octal character code (the default is
1763 @samp{\}).
1764 @item 259
1765 The glyph for indicating a control characters (the default is @samp{^}).
1766 @item 260
1767 The vector of glyphs for indicating the presence of invisible lines (the
1768 default is @samp{...}).
1769 @end table
1770
1771 Each buffer typically has its own display table. The display table for
1772 the current buffer is stored in @code{buffer-display-table}. (This
1773 variable automatically becomes local if you set it.) If this variable
1774 is @code{nil}, the value of @code{standard-display-table} is used in
1775 that buffer.
1776
1777 Each window can have its own display table, which overrides the display
1778 table of the buffer it is showing.
1779
1780 If neither the selected window nor the current buffer has a display
1781 table, and if @code{standard-display-table} is @code{nil}, then Emacs
1782 uses the usual display conventions:
1783
1784 @itemize @bullet
1785 @item
1786 Character codes 32 through 127 map to glyph codes 32 through 127.
1787 @item
1788 Codes 0 through 31 map to sequences of two glyphs, where the first glyph
1789 is the ASCII code for @samp{^}.
1790 @item
1791 Character codes 128 through 255 map to sequences of four glyphs, where
1792 the first glyph is the ASCII code for @samp{\}, and the others represent
1793 digits.
1794 @end itemize
1795
1796 The usual display conventions are also used for any character whose
1797 entry in the active display table is @code{nil}. This means that when
1798 you set up a display table, you need not specify explicitly what to do
1799 with each character, only the characters for which you want unusual
1800 behavior.
1801
1802 @subsection Glyphs
1803
1804 @cindex glyph
1805 A glyph stands for an image that takes up a single character position on
1806 the screen. A glyph is represented in Lisp as an integer.
1807
1808 @cindex glyph table
1809 The meaning of each integer, as a glyph, is defined by the glyph table,
1810 which is the value of the variable @code{glyph-table}. It should be a
1811 vector; the @var{g}th element defines glyph code @var{g}. The possible
1812 definitions of a glyph code are:
1813
1814 @table @var
1815 @item integer
1816 Define this glyph code as an alias for code @var{integer}.
1817 This is used with X windows to specify a face code.
1818
1819 @item string
1820 Send the characters in @var{string} to the terminal to output
1821 this glyph. This alternative is not available with X Windows.
1822
1823 @item @code{nil}
1824 This glyph is simple. On an ordinary terminal, the glyph code mod 256
1825 is the character to output. With X, the glyph code mod 256 is character
1826 to output, and the glyph code divided by 256 specifies the @dfn{face
1827 code} to use while outputting it.
1828 @end table
1829
1830 Any glyph code beyond the length of the glyph table is automatically simple.
1831
1832 A face code for X windows is the combination of a font and a color.
1833 Emacs uses integers to identify face codes. You can define a new face
1834 code with @code{(x-set-face @var{face-code} @var{font} @var{foreground}
1835 @var{background})}. @var{face-code} is an integer from 0 to 255; it
1836 specifies which face to define. The other three arguments are strings:
1837 @var{font} is the name of the font to use, and @var{foreground} and
1838 @var{background} specify the colors to use.
1839
1840 If @code{glyph-table} is @code{nil}, then all possible glyph codes are
1841 simple.
1842
1843 @subsection ISO Latin 1
1844
1845 If you have a terminal that can handle the entire ISO Latin 1 character
1846 set, you can arrange to use that character set as follows:
1847
1848 @example
1849 (require 'disp-table)
1850 (standard-display-8bit 0 255)
1851 @end example
1852
1853 If you are editing buffers written in the ISO Latin 1 character set and
1854 your terminal doesn't handle anything but ASCII, you can load the file
1855 @code{iso-ascii} to set up a display table which makes the other ISO
1856 characters display as sequences of ASCII characters. For example, the
1857 character ``o with umlaut'' displays as @samp{@{"o@}}.
1858
1859 Some European countries have terminals that don't support ISO Latin 1
1860 but do support the special characters for that country's language. You
1861 can define a display table to work one language using such terminals.
1862 For an example, see @file{lisp/iso-swed.el}, which handles certain
1863 Swedish terminals.
1864
1865 You can load the appropriate display table for your terminal
1866 automatically by writing a terminal-specific Lisp file for the terminal
1867 type.
1868
1869 @section New Input Event Formats
1870
1871 Mouse clicks, mouse movements and function keys no longer appear in the
1872 input stream as characters; instead, other kinds of Lisp objects
1873 represent them as input.
1874
1875 @itemize @bullet
1876 @item
1877 An ordinary input character event consists of a @dfn{basic code} between
1878 0 and 255, plus any or all of these @dfn{modifier bits}:
1879
1880 @table @asis
1881 @item meta
1882 The 2**23 bit in the character code indicates a character
1883 typed with the meta key held down.
1884
1885 @item control
1886 The 2**22 bit in the character code indicates a non-@sc{ASCII}
1887 control character.
1888
1889 @sc{ASCII} control characters such as @kbd{C-a} have special basic
1890 codes of their own, so Emacs needs no special bit to indicate them.
1891 Thus, the code for @kbd{C-a} is just 1.
1892
1893 But if you type a control combination not in @sc{ASCII}, such as
1894 @kbd{%} with the control key, the numeric value you get is the code
1895 for @kbd{%} plus 2**22 (assuming the terminal supports non-@sc{ASCII}
1896 control characters).
1897
1898 @item shift
1899 The 2**21 bit in the character code indicates an @sc{ASCII} control
1900 character typed with the shift key held down.
1901
1902 For letters, the basic code indicates upper versus lower case; for
1903 digits and punctuation, the shift key selects an entirely different
1904 character with a different basic code. In order to keep within
1905 the @sc{ASCII} character set whenever possible, Emacs avoids using
1906 the 2**21 bit for those characters.
1907
1908 However, @sc{ASCII} provides no way to distinguish @kbd{C-A} from
1909 @kbd{C-A}, so Emacs uses the 2**21 bit in @kbd{C-A} and not in
1910 @kbd{C-a}.
1911
1912 @item hyper
1913 The 2**20 bit in the character code indicates a character
1914 typed with the hyper key held down.
1915
1916 @item super
1917 The 2**19 bit in the character code indicates a character
1918 typed with the super key held down.
1919
1920 @item alt
1921 The 2**18 bit in the character code indicates a character typed with
1922 the alt key held down. (On some terminals, the key labeled @key{ALT}
1923 is actually the meta key.)
1924 @end table
1925
1926 In the future, Emacs may support a larger range of basic codes. We may
1927 also move the modifier bits to larger bit numbers. Therefore, you
1928 should avoid mentioning specific bit numbers in your program. Instead,
1929 the way to test the modifier bits of a character is with the function
1930 @code{event-modifiers} (see below).
1931
1932 @item
1933 Function keys are represented as symbols. The symbol's name is
1934 the function key's label. For example, pressing a key labeled @key{F1}
1935 places the symbol @code{f1} in the input stream.
1936
1937 There are a few exceptions to the symbol naming convention:
1938
1939 @table @asis
1940 @item @code{kp-add}, @code{kp-decimal}, @code{kp-divide}, @dots{}
1941 Keypad keys (to the right of the regular keyboard).
1942 @item @code{kp-0}, @code{kp-1}, @dots{}
1943 Keypad keys with digits.
1944 @item @code{kp-f1}, @code{kp-f2}, @code{kp-f3}, @code{kp-f4}
1945 Keypad PF keys.
1946 @item @code{left}, @code{up}, @code{right}, @code{down}
1947 Cursor arrow keys
1948 @end table
1949
1950 You can use the modifier keys @key{CTRL}, @key{META}, @key{HYPER},
1951 @key{SUPER}, @key{ALT} and @key{SHIFT} with function keys. The way
1952 to represent them is with prefixes in the symbol name:
1953
1954 @table @samp
1955 @item A-
1956 The alt modifier.
1957 @item C-
1958 The control modifier.
1959 @item H-
1960 The hyper modifier.
1961 @item M-
1962 The meta modifier.
1963 @item s-
1964 The super modifier.
1965 @item S-
1966 The shift modifier.
1967 @end table
1968
1969 Thus, the symbol for the key @key{F3} with @key{META} held down is
1970 kbd{M-@key{F3}}. When you use more than one prefix, we recommend you
1971 write them in alphabetical order (though the order does not matter in
1972 arguments to the key-binding lookup and modification functions).
1973
1974 @item
1975 Mouse events are represented as lists.
1976
1977 If you press a mouse button and release it at the same location, this
1978 generates a ``click'' event. Mouse click events have this form:
1979
1980 @example
1981 (@var{button-symbol}
1982 (@var{window} (@var{column} . @var{row})
1983 @var{buffer-pos} @var{timestamp}))
1984 @end example
1985
1986 Here is what the elements normally mean:
1987
1988 @table @var
1989 @item button-symbol
1990 indicates which mouse button was used. It is one of the symbols
1991 @code{mouse-1}, @code{mouse-2}, @dots{}, where the buttons are numbered
1992 numbered left to right.
1993
1994 You can also use prefixes @samp{A-}, @samp{C-}, @samp{H-}, @samp{M-},
1995 @samp{S-} and @samp{s-} for modifiers alt, control, hyper, meta, shift
1996 and super, just as you would with function keys.
1997
1998 @item window
1999 is the window in which the click occurred.
2000
2001 @item column
2002 @itemx row
2003 are the column and row of the click, relative to the top left corner of
2004 @var{window}, which is @code{(0 . 0)}.
2005
2006 @item buffer-pos
2007 is the buffer position of the character clicked on.
2008
2009 @item timestamp
2010 is the time at which the event occurred, in milliseconds. (Since this
2011 value wraps around the entire range of Emacs Lisp integers in about five
2012 hours, it is useful only for relating the times of nearby events.)
2013 @end table
2014
2015 The meanings of @var{buffer-pos}, @var{row} and @var{column} are
2016 somewhat different when the event location is in a special part of the
2017 screen, such as the mode line or a scroll bar.
2018
2019 If the position is in the window's scroll bar, then @var{buffer-pos} is
2020 the symbol @code{vertical-scrollbar} or @code{horizontal-scrollbar}, and
2021 the pair @code{(@var{column} . @var{row})} is instead a pair
2022 @code{(@var{portion} . @var{whole})}, where @var{portion} is the
2023 distance of the click from the top or left end of the scroll bar, and
2024 @var{whole} is the length of the entire scroll bar.
2025
2026 If the position is on a mode line or the vertical line separating
2027 @var{window} from its neighbor to the right, then @var{buffer-pos} is
2028 the symbol @code{mode-line} or @code{vertical-line}. In this case
2029 @var{row} and @var{column} do not have meaningful data.
2030
2031 @item
2032 Releasing a mouse button above a different character position
2033 generates a ``drag'' event, which looks like this:
2034
2035 @example
2036 (@var{button-symbol}
2037 (@var{window1} (@var{column1} . @var{row1})
2038 @var{buffer-pos1} @var{timestamp1})
2039 (@var{window2} (@var{column2} . @var{row2})
2040 @var{buffer-pos2} @var{timestamp2}))
2041 @end example
2042
2043 The name of @var{button-symbol} contains the prefix @samp{drag-}. The
2044 second and third elements of the event give the starting and ending
2045 position of the drag.
2046
2047 The @samp{drag-} prefix follows the modifier key prefixes such as
2048 @samp{C-} and @samp{M-}.
2049
2050 If @code{read-key-sequence} receives a drag event which has no key
2051 binding, and the corresponding click event does have a binding, it
2052 changes the drag event into a click event at the drag's starting
2053 position. This means that you don't have to distinguish between click
2054 and drag events unless you want to.
2055
2056 @item
2057 Click and drag events happen when you release a mouse button. Another
2058 kind of event happens when you press a button. It looks just like a
2059 click event, except that the name of @var{button-symbol} contains the
2060 prefix @samp{down-}. The @samp{down-} prefix follows the modifier key
2061 prefixes such as @samp{C-} and @samp{M-}.
2062
2063 The function @code{read-key-sequence}, and the Emacs command loop,
2064 ignore any down events that don't have command bindings. This means
2065 that you need not worry about defining down events unless you want them
2066 to do something. The usual reason to define a down event is so that you
2067 can track mouse motion until the button is released.
2068
2069 @item
2070 For example, if the user presses and releases the left mouse button over
2071 the same location, Emacs generates a sequence of events like this:
2072
2073 @smallexample
2074 (down-mouse-1 (#<window 18 on NEWS> 2613 (0 . 38) -864320))
2075 (mouse-1 (#<window 18 on NEWS> 2613 (0 . 38) -864180))
2076 @end smallexample
2077
2078 Or, while holding the control key down, the user might hold down the
2079 second mouse button, and drag the mouse from one line to the next.
2080 That produces two events, as shown here:
2081
2082 @smallexample
2083 (C-down-mouse-2 (#<window 18 on NEWS> 3440 (0 . 27) -731219))
2084 (C-drag-mouse-2 (#<window 18 on NEWS> 3440 (0 . 27) -731219)
2085 (#<window 18 on NEWS> 3510 (0 . 28) -729648))
2086 @end smallexample
2087
2088 Or, while holding down the meta and shift keys, the user might press
2089 the second mouse button on the window's mode line, and then drag the
2090 mouse into another window. That produces an event like this:
2091
2092 @smallexample
2093 (M-S-down-mouse-2 (#<window 18 on NEWS> mode-line (33 . 31) -457844))
2094 (M-S-drag-mouse-2 (#<window 18 on NEWS> mode-line (33 . 31) -457844)
2095 (#<window 20 on carlton-sanskrit.tex> 161 (33 . 3)
2096 -453816))
2097 @end smallexample
2098
2099 @item
2100 A key sequence that starts with a mouse click is read using the keymaps
2101 of the buffer in the window clicked on, not the current buffer.
2102
2103 This does not imply that clicking in a window selects that window or its
2104 buffer. The execution of the command begins with no change in the
2105 selected window or current buffer. However, the command can switch
2106 windows or buffers if programmed to do so.
2107
2108 @item
2109 Mouse motion events are represented by lists. During the execution of
2110 the body of a @code{track-mouse} form, moving the mouse generates events
2111 that look like this:
2112
2113 @example
2114 (mouse-movement (@var{window} (@var{column} . @var{row})
2115 @var{buffer-pos} @var{timestamp}))
2116 @end example
2117
2118 The second element of the list describes the current position of the
2119 mouse, just as in a mouse click event.
2120
2121 Outside of @code{track-mouse} forms, Emacs does not generate events for
2122 mere motion of the mouse, and these events do not appear.
2123
2124 @item
2125 Focus shifts between frames are represented by lists.
2126
2127 When the mouse shifts temporary input focus from one frame to another,
2128 Emacs generates an event like this:
2129
2130 @example
2131 (switch-frame @var{new-frame})
2132 @end example
2133
2134 @noindent
2135 where @var{new-frame} is the frame switched to.
2136
2137 In X windows, most window managers are set up so that just moving the
2138 mouse into a window is enough to set the focus there. As far as the
2139 user concern, Emacs behaves consistently with this. However, there is
2140 no need for the Lisp program to know about the focus change until some
2141 other kind of input arrives. So Emacs generates the focus event only
2142 when the user actually types a keyboard key or presses a mouse button in
2143 the new frame; just moving the mouse between frames does not generate a
2144 focus event.
2145
2146 The global key map usually binds this event to the
2147 @code{internal-select-frame} function, so that characters typed at a
2148 frame apply to that frame's selected window.
2149
2150 If the user switches frames in the middle of a key sequence, then Emacs
2151 delays the @code{switch-frame} event until the key sequence is over.
2152 For example, suppose @kbd{C-c C-a} is a key sequence in the current
2153 buffer's keymaps. If the user types @kbd{C-c}, moves the mouse to
2154 another frame, and then types @kbd{C-a}, @code{read-key-sequence}
2155 returns the sequence @code{"\C-c\C-a"}, and the next call to
2156 @code{read-event} or @code{read-key-sequence} will return the
2157 @code{switch-frame} event.
2158 @end itemize
2159
2160 @section Working with Input Events
2161
2162 @itemize @bullet
2163 @item
2164 Functions which work with key sequences now handle non-character
2165 events. Functions like @code{define-key}, @code{global-set-key}, and
2166 @code{local-set-key} used to accept strings representing key sequences;
2167 now, since events may be arbitrary lisp objects, they also accept
2168 vectors. The function @code{read-key-sequence} may return a string or a
2169 vector, depending on whether or not the sequence read contains only
2170 characters.
2171
2172 List events may be represented by the symbols at their head; to bind
2173 clicks of the left mouse button, you need only present the symbol
2174 @code{mouse-1}, not an entire mouse click event. If you do put an event
2175 which is a list in a key sequence, only the event's head symbol is used
2176 in key lookups.
2177
2178 For example, to globally bind the left mouse button to the function
2179 @code{mouse-set-point}, you could evaluate this:
2180
2181 @example
2182 (global-set-key [mouse-1] 'mouse-set-point)
2183 @end example
2184
2185 To bind the sequence @kbd{C-c @key{F1}} to the command @code{tex-view}
2186 in @code{tex-mode-map}, you could evaluate this:
2187
2188 @example
2189 (define-key tex-mode-map [?\C-c f1] 'tex-view)
2190 @end example
2191
2192 To find the binding for the function key labeled @key{NEXT} in
2193 @code{minibuffer-local-map}, you could evaluate this:
2194
2195 @example
2196 (lookup-key minibuffer-local-map [next])
2197 @result{} next-history-element
2198 @end example
2199
2200 If you call the function @code{read-key-sequence} and then press
2201 @kbd{C-x C-@key{F5}}, here is how it behaves:
2202
2203 @example
2204 (read-key-sequence "Press `C-x C-F5': ")
2205 @result{} [24 C-f5]
2206 @end example
2207
2208 Note that @samp{24} is the character @kbd{C-x}.
2209
2210 @item
2211 The documentation functions (@code{single-key-description},
2212 @code{key-description}, etc.) now handle the new event types. Wherever
2213 a string of keyboard input characters was acceptable in previous
2214 versions of Emacs, a vector of events should now work.
2215
2216 @item
2217 Special parts of a window can have their own bindings for mouse events.
2218
2219 When mouse events occur in special parts of a window, such as a mode
2220 line or a scroll bar, the event itself shows nothing special---only the
2221 symbol that would normally represent that mouse button and modifier
2222 keys. The information about the screen region is kept in other parts
2223 of the event list. But @code{read-key-sequence} translates this
2224 information into imaginary prefix keys, all of which are symbols:
2225 @code{mode-line}, @code{vertical-line}, @code{horizontal-scrollbar} and
2226 @code{vertical-scrollbar}.
2227
2228 For example, if you call @code{read-key-sequence} and then click the
2229 mouse on the window's mode line, this is what happens:
2230
2231 @smallexample
2232 (read-key-sequence "Click on the mode line: ")
2233 @result{} [mode-line (mouse-1 (#<window 6 on NEWS> mode-line
2234 (40 . 63) 5959987))]
2235 @end smallexample
2236
2237 You can define meanings for mouse clicks in special window regions by
2238 defining key sequences using these imaginary prefix keys. For example,
2239 here is how to bind the third mouse button on a window's mode line
2240 delete the window:
2241
2242 @example
2243 (global-set-key [mode-line mouse-3] 'mouse-delete-window)
2244 @end example
2245
2246 Here's how to bind the middle button (modified by @key{META}) on the
2247 vertical line at the right of a window to scroll the window to the
2248 left.
2249
2250 @example
2251 (global-set-key [vertical-line M-mouse-2] 'scroll-left)
2252 @end example
2253
2254 @item
2255 Decomposing an event symbol.
2256
2257 Each symbol used to identify a function key or mouse button has a
2258 property named @code{event-symbol-elements}, which is a list containing
2259 an unmodified version of the symbol, followed by modifiers the symbol
2260 name contains. The modifiers are symbols; they include @code{shift},
2261 @code{control}, and @code{meta}. In addition, a mouse event symbol has
2262 one of @code{click}, @code{drag}, and @code{down}. For example:
2263
2264 @example
2265 (get 'f5 'event-symbol-elements)
2266 @result{} (f5)
2267 (get 'C-f5 'event-symbol-elements)
2268 @result{} (f5 control)
2269 (get 'M-S-f5 'event-symbol-elements)
2270 @result{} (f5 meta shift)
2271 (get 'mouse-1 'event-symbol-elements)
2272 @result{} (mouse-1 click)
2273 (get 'down-mouse-1 'event-symbol-elements)
2274 @result{} (mouse-1 down)
2275 @end example
2276
2277 Note that the @code{event-symbol-elements} property for a mouse click
2278 explicitly contains @code{click}, but the event symbol name itself does
2279 not contain @samp{click}.
2280
2281 @item
2282 Use @code{read-event} to read input if you want to accept any kind of
2283 event. The old function @code{read-char} now discards events other than
2284 keyboard characters.
2285
2286 @item
2287 @code{last-command-char} and @code{last-input-char} can now hold any
2288 kind of event.
2289
2290 @item
2291 The new variable @code{unread-command-events} is much like
2292 @code{unread-command-char}. Its value is a list of events of any type,
2293 to be processed as command input in order of appearance in the list.
2294
2295 @item
2296 The function @code{this-command-keys} may return a string or a vector,
2297 depending on whether or not the sequence read contains only characters.
2298 You may need to upgrade code which uses this function.
2299
2300 The function @code{recent-keys} now returns a vector of events.
2301 You may need to upgrade code which uses this function.
2302
2303 @item
2304 A keyboard macro's definition can now be either a string or a vector.
2305 All that really matters is what elements it has. If the elements are
2306 all characters, then the macro can be a string; otherwise, it has to be
2307 a vector.
2308
2309 @item
2310 The variable @code{last-event-frame} records which frame the last input
2311 event was directed to. Usually this is the frame that was selected when
2312 the event was generated, but if that frame has redirected input focus to
2313 another frame, @code{last-event-frame} is the frame to which the event
2314 was redirected.
2315
2316 @item
2317 The interactive specification now allows a new code letter @samp{e} to
2318 simplify commands bound to events which are lists. This code supplies
2319 as an argument the complete event object.
2320
2321 You can use @samp{e} more than once in a single command's interactive
2322 specification. If the key sequence which invoked the command has
2323 @var{n} events with parameters, the @var{n}th @samp{e} provides the
2324 @var{n}th parameterized event. Events which are not lists, such as
2325 function keys and ASCII keystrokes, do not count where @samp{e} is
2326 concerned.
2327
2328 @item
2329 You can extract the starting and ending position values from a mouse
2330 button or motion event using the two functions @code{event-start} and
2331 @code{event-end}. These two functions return different values for drag
2332 and motion events; for click and button-down events, they both return
2333 the position of the event.
2334
2335 @item
2336 The position, a returned by @code{event-start} and @code{event-end}, is
2337 a list of this form:
2338
2339 @example
2340 (@var{window} @var{buffer-position} (@var{col} . @var{row}) @var{timestamp})
2341 @end example
2342
2343 You can extract parts of this list with the functions
2344 @code{posn-window}, @code{posn-point}, @code{posn-col-row}, and
2345 @code{posn-timestamp}.
2346
2347 @item
2348 The function @code{scroll-bar-scale} is useful for computing where to
2349 scroll to in response to a mouse button event from a scroll bar. It
2350 takes two arguments, @var{ratio} and @var{total}, and in effect
2351 multiplies them. We say ``in effect'' because @var{ratio} is not a
2352 number; rather a pair @code{(@var{num} . @var{denom}).
2353
2354 Here's the usual way to use @code{scroll-bar-scale}:
2355
2356 @example
2357 (scroll-bar-scale (posn-col-row (event-start event))
2358 (buffer-size))
2359 @end example
2360 @end itemize
2361
2362 @section Putting Keyboard Events in Strings
2363
2364 In most of the places where strings are used, we conceptualize the
2365 string as containing text characters---the same kind of characters found
2366 in buffers or files. Occasionally Lisp programs use strings which
2367 conceptually contain keyboard characters; for example, they may be key
2368 sequences or keyboard macro definitions. There are special rules for
2369 how to put keyboard characters into a string, because they are not
2370 limited to the range of 0 to 255 as text characters are.
2371
2372 A keyboard character typed using the @key{META} key is called a
2373 @dfn{meta character}. The numeric code for such an event includes the
2374 2**23 bit; it does not even come close to fitting in a string. However,
2375 earlier Emacs versions used a different representation for these
2376 characters, which gave them codes in the range of 128 to 255. That did
2377 fit in a string, and many Lisp programs contain string constants that
2378 use @samp{\M-} to express meta characters, especially as the argument to
2379 @code{define-key} and similar functions.
2380
2381 We provide backward compatibility to run those programs with special
2382 rules for how to put a keyboard character event in a string. Here are
2383 the rules:
2384
2385 @itemize @bullet
2386 @item
2387 If the keyboard event value is in the range of 0 to 127, it can go in the
2388 string unchanged.
2389
2390 @item
2391 The meta variants of those events, with codes in the range of 2**23 to
2392 2**23+127, can also go in the string, but you must change their numeric
2393 values. You must set the 2**7 bit instead of the 2**23 bit, resulting
2394 in a value between 128 and 255.
2395
2396 @item
2397 Other keyboard character events cannot fit in a string. This includes
2398 keyboard events in the range of 128 to 255.
2399 @end itemize
2400
2401 Functions such as @code{read-key-sequence} that can construct strings
2402 containing events follow these rules.
2403
2404 When you use the read syntax @samp{\M-} in a string, it produces a
2405 code in the range of 128 to 255---the same code that you get if you
2406 modify the corresponding keyboard event to put it in the string. Thus,
2407 meta events in strings work consistently regardless of how they get into
2408 the strings.
2409
2410 New programs can avoid dealing with these rules by using vectors
2411 instead of strings for key sequences when there is any possibility that
2412 these issues might arise.
2413
2414 The reason we changed the representation of meta characters as
2415 keyboard events is to make room for basic character codes beyond 127,
2416 and support meta variants of such larger character codes.
2417
2418 @section Menus
2419
2420 You can now define menus conveniently as keymaps. Menus are normally
2421 used with the mouse, but they can work with the keyboard also.
2422
2423 @subsection Defining Menus
2424
2425 A keymap is suitable for menu use if it has an @dfn{overall prompt
2426 string}, which is a string that appears as an element of the keymap. It
2427 should describes the purpose of the menu. The easiest way to construct
2428 a keymap with a prompt string is to specify the string as an argument
2429 when you run @code{make-keymap} or @code{make-sparse-keymap}.
2430
2431 The individual bindings in the menu keymap should also have prompt
2432 strings; these strings are the items in the menu. A binding with a
2433 prompt string looks like this:
2434
2435 @example
2436 (@var{char} @var{string} . @var{real-binding})
2437 @end example
2438
2439 As far as @code{define-key} is concerned, the string is part of the
2440 character's binding---the binding looks like this:
2441
2442 @example
2443 (@var{string} . @var{real-binding}).
2444 @end example
2445
2446 However, only @var{real-binding} is used for executing the key.
2447
2448 You can also supply a second string, called the help string, as follows:
2449
2450 @example
2451 (@var{char} @var{string} @var{help-string} . @var{real-binding})
2452 @end example
2453
2454 Currently Emacs does not actually use @var{help-string}; it knows only
2455 how to ignore @var{help-string} in order to extract @var{real-binding}.
2456 In the future we hope to make @var{help-string} serve as longer
2457 documentation for the menu item, available on request.
2458
2459 The prompt string for a binding should be short---one or two words. Its
2460 meaning should describe the command it corresponds to.
2461
2462 If @var{real-binding} is @code{nil}, then @var{string} appears in the
2463 menu but cannot be selected.
2464
2465 If @var{real-binding} is a symbol, and has a non-@code{nil}
2466 @code{menu-enable} property, that property is an expression which
2467 controls whether the menu item is enabled. Every time the keymap is
2468 used to display a menu, Emacs evaluates the expression, and it enables
2469 the menu item only if the expression's value is non-@code{nil}. When a
2470 menu item is disabled, it is displayed in a ``fuzzy'' fashion, and
2471 cannot be selected with the mouse.
2472
2473 @subsection Menus and the Mouse
2474
2475 The way to make a menu keymap produce a menu is to make it the
2476 definition of a prefix key.
2477
2478 When the prefix key ends with a mouse event, Emacs handles the menu
2479 keymap by popping up a visible menu that you can select from with the
2480 mouse. When you click on a menu item, the event generated is whatever
2481 character or symbol has the binding which brought about that menu item.
2482
2483 A single keymap can appear as multiple panes, if you explicitly
2484 arrange for this. The way to do this is to make a keymap for each
2485 pane, then create a binding for each of those maps in the main keymap
2486 of the menu. Give each of these bindings a prompt string that starts
2487 with @samp{@@}. The rest of the prompt string becomes the name of the
2488 pane. See the file @file{lisp/mouse.el} for an example of this. Any
2489 ordinary bindings with prompt strings are grouped into one pane, which
2490 appears along with the other panes explicitly created for the
2491 submaps.
2492
2493 You can also get multiple panes from separate keymaps. The full
2494 definition of a prefix key always comes from merging the definitions
2495 supplied by the various active keymaps (minor modes, local, and
2496 global). When more than one of these keymaps is a menu, each of them
2497 makes a separate pane or panes.
2498
2499 @subsection Menus and the Keyboard
2500
2501 When a prefix key ending with a keyboard event (a character or function
2502 key) has a definition that is a menu keymap, you can use the keyboard
2503 to choose a menu item.
2504
2505 Emacs displays the menu alternatives in the echo area. If they don't
2506 all fit at once, type @key{SPC} to see the next line of alternatives.
2507 If you keep typing @key{SPC}, you eventually get to the end of the menu
2508 and then cycle around to the beginning again.
2509
2510 When you have found the alternative you want, type the corresponding
2511 character---the one whose binding is that alternative.
2512
2513 In a menu intended for keyboard use, each menu item must clearly
2514 indicate what character to type. The best convention to use is to make
2515 the character the first letter of the menu item prompt string. That is
2516 something users will understand without being told.
2517
2518 @subsection The Menu Bar
2519
2520 Under X Windows, each frame can have a @dfn{menu bar}---a permanently
2521 displayed menu stretching horizontally across the top of the frame. The
2522 items of the menu bar are the subcommands of the fake ``function key''
2523 @code{menu-bar}, as defined by all the active keymaps.
2524
2525 To add an item to the menu bar, invent a fake ``function key'' of your
2526 own (let's call it @var{key}), and make a binding for the key sequence
2527 @code{[menu-bar @var{key}]}. Most often, the binding is a menu keymap,
2528 so that pressing a button on the menu bar item leads to another menu.
2529
2530 In order for a frame to display a menu bar, its @code{menu-bar-lines}
2531 property must be greater than zero. Emacs uses just one line for the
2532 menu bar itself; if you specify more than one line, the other lines
2533 serve to separate the menu bar from the windows in the frame. We
2534 recommend you try one or two as the @code{menu-bar-lines} value.
2535
2536 @section Keymaps
2537
2538 @itemize @bullet
2539 @item
2540 The representation of keymaps has changed to support the new event
2541 types. All keymaps now have the form @code{(keymap @var{element}
2542 @var{element} @dots{})}. Each @var{element} takes one of the following
2543 forms:
2544
2545 @table @asis
2546 @item @var{prompt-string}
2547 A string as an element of the keymap marks the keymap as a menu, and
2548 serves as the overal prompt string for it.
2549
2550 @item @code{(@var{key} . @var{binding})}
2551 A cons cell binds @var{key} to @var{definition}. Here @var{key} may be
2552 any sort of event head---a character, a function key symbol, or a mouse
2553 button symbol.
2554
2555 @item @var{vector}
2556 A vector of 128 elements binds all the ASCII characters; the @var{n}th
2557 element holds the binding for character number @var{n}.
2558
2559 @item @code{(t . @var{binding})}
2560 A cons cell whose @sc{car} is @code{t} is a default binding; anything
2561 not bound by previous keymap elements is given @var{binding} as its
2562 binding.
2563
2564 Default bindings are important because they allow a keymap to bind all
2565 possible events without having to enumerate all the possible function
2566 keys and mouse clicks, with all possible modifier prefixes.
2567
2568 The function @code{lookup-key} (and likewise other functions for
2569 examining a key binding) normally report only explicit bindings of the
2570 specified key sequence; if there is none, they return @code{nil}, even
2571 if there is a default binding that would apply to that key sequence if
2572 it were actually typed in. However, these functions now take an
2573 optional argument @var{accept-defaults} which, if non-@code{nil}, says
2574 to consider default bindings.
2575
2576 Note that if a vector in the keymap binds an ASCII character to
2577 @code{nil} (thus making it ``unbound''), the default binding does not
2578 apply to the character. Think of the vector element as an explicit
2579 binding of @code{nil}.
2580
2581 Note also that if the keymap for a minor or major mode contains a
2582 default binding, it completely masks out any lower-priority keymaps.
2583 @end table
2584
2585 @item
2586 A keymap can now inherit from another keymap. Do do this, make the
2587 latter keymap the ``tail'' of the new one. Such a keymap looks like
2588 this:
2589
2590 @example
2591 (keymap @var{bindings}@dots{} . @var{other-keymap})
2592 @end example
2593
2594 The effect is that this keymap inherits all the bindings of
2595 @var{other-keymap}, but can add to them or override them with
2596 @var{bindings}. Subsequent changes in the bindings of
2597 @var{other-keymap} @emph{do} affect this keymap.
2598
2599 For example,
2600
2601 @example
2602 (setq my-mode-map (cons 'keymap text-mode-map))
2603 @end example
2604
2605 @noindent
2606 makes a keymap that by default inherits all the bindings of Text
2607 mode---whatever they may be at the time a key is looked up. Any
2608 bindings made explicitly in @code{my-mode-map} override the bindings
2609 inherited from Text mode, however.
2610
2611 @item
2612 Minor modes can now have local keymaps. Thus, a key can act a special
2613 way when a minor mode is in effect, and then revert to the major mode or
2614 global definition when the minor mode is no longer in effect. The
2615 precedence of keymaps is now: minor modes (in no particular order), then
2616 major mode, and lastly the global map.
2617
2618 The new @code{current-minor-mode-maps} function returns a list of all
2619 the keymaps of currently enabled minor modes, in the other that they
2620 apply.
2621
2622 To set up a keymap for a minor mode, add an element to the alist
2623 @code{minor-mode-map-alist}. Its elements look like this:
2624
2625 @example
2626 (@var{symbol} . @var{keymap})
2627 @end example
2628
2629 The keymap @var{keymap} is active whenever @var{symbol} has a
2630 non-@code{nil} value. Use for @var{symbol} the variable which indicates
2631 whether the minor mode is enabled.
2632
2633 When more than one minor mode keymap is active, their order of
2634 precedence is the order of @code{minor-mode-map-alist}. But you should
2635 design minor modes so that they don't interfere with each other, and if
2636 you do this properly, the order will not matter.
2637
2638 The function @code{minor-mode-key-binding} returns a list of all the
2639 active minor mode bindings of @var{key}. More precisely, it returns an
2640 alist of pairs @code{(@var{modename} . @var{binding})}, where
2641 @var{modename} is the the variable which enables the minor mode, and
2642 @var{binding} is @var{key}'s definition in that mode. If @var{key} has
2643 no minor-mode bindings, the value is @code{nil}.
2644
2645 If the first binding is a non-prefix, all subsequent bindings from other
2646 minor modes are omitted, since they would be completely shadowed.
2647 Similarly, the list omits non-prefix bindings that follow prefix
2648 bindings.
2649
2650 @item
2651 The new function @code{copy-keymap} copies a keymap, producing a new
2652 keymap with the same key bindings in it. If the keymap contains other
2653 keymaps directly, these subkeymaps are copied recursively.
2654
2655 If you want to, you can define a prefix key with a binding that is a
2656 symbol whose function definition is another keymap. In this case,
2657 @code{copy-keymap} does not look past the symbol; it doesn't copy the
2658 keymap inside the symbol.
2659
2660 @item
2661 @code{substitute-key-definition} now accepts an optional fourth
2662 argument, which is a keymap to use as a template.
2663
2664 @example
2665 (substitute-key-definition olddef newdef keymap oldmap)
2666 @end example
2667
2668 @noindent
2669 finds all characters defined in @var{oldmap} as @var{olddef},
2670 and defines them in @var{keymap} as @var{newdef}.
2671
2672 In addition, this function now operates recursively on the keymaps that
2673 define prefix keys within @var{keymap} and @var{oldmap}.
2674 @end itemize
2675
2676 @section Minibuffer Features
2677
2678 The minibuffer input functions @code{read-from-minibuffer} and
2679 @code{completing-read} have new features.
2680
2681 @subsection Minibuffer History
2682
2683 A new optional argument @var{hist} specifies which history list to use.
2684 If you specify a variable (a symbol), that variable is the history
2685 list. If you specify a cons cell @code{(@var{variable}
2686 . @var{startpos})}, then @var{variable} is the history list variable,
2687 and @var{startpos} specifies the initial history position (an integer,
2688 counting from zero which specifies the most recent element of the
2689 history).
2690
2691 If you specify @var{startpos}, then you should also specify that element
2692 of the history as @var{initial-input}, for consistency.
2693
2694 If you don't specify @var{hist}, then the default history list
2695 @code{minibuffer-history} is used. Other standard history lists that
2696 you can use when appropriate include @code{query-replace-history},
2697 @code{command-history}, and @code{file-name-history}.
2698
2699 The value of the history list variable is a list of strings, most recent
2700 first. You should set a history list variable to @code{nil} before
2701 using it for the first time.
2702
2703 @code{read-from-minibuffer} and @code{completing-read} add new elements
2704 to the history list automatically, and provide commands to allow the
2705 user to reuse items on the list. The only thing your program needs to
2706 do to use a history list is to initialize it and to pass its name to the
2707 input functions when you wish. But it is safe to modify the list by
2708 hand when the minibuffer input functions are not using it.
2709
2710 @subsection Other Minibuffer Features
2711
2712 The @var{initial} argument to @code{read-from-minibufer} and other
2713 minibuffer input functions can now be a cons cell @code{(@var{string}
2714 . @var{position})}. This means to start off with @var{string} in the
2715 minibuffer, but put the cursor @var{position} characters from the
2716 beginning, rather than at the end.
2717
2718 In @code{read-no-blanks-input}, the @var{initial} argument is now
2719 optional; if it is omitted, the initial input string is the empty
2720 string.
2721
2722 @section New Features for Defining Commands
2723
2724 @itemize @bullet
2725 @item
2726 If the interactive specification begins with @samp{@@}, this means to
2727 select the window under the mouse. This selection takes place before
2728 doing anything else with the command.
2729
2730 You can use both @samp{@@} and @samp{*} together in one command; they
2731 are processed in order of appearance.
2732
2733 @item
2734 Prompts in an interactive specification can incorporate the values of
2735 the preceding arguments. Emacs replaces @samp{%}-sequences (as used
2736 with the @code{format} function) in the prompt with the interactive
2737 arguments that have been read so far. For example, a command with this
2738 interactive specification
2739
2740 @example
2741 (interactive "sReplace: \nsReplace %s with: ")
2742 @end example
2743
2744 @noindent
2745 prompts for the first argument with @samp{Replace: }, and then prompts
2746 for the second argument with @samp{Replace @var{foo} with: }, where
2747 @var{foo} is the string read as the first argument.
2748
2749 @item
2750 If a command name has a property @code{enable-recursive-minibuffers}
2751 which is non-@code{nil}, then the command can use the minibuffer to read
2752 arguments even if it is invoked from the minibuffer. The minibuffer
2753 command @code{next-matching-history-element} (normally bound to
2754 @kbd{M-s} in the minibuffer) uses this feature.
2755 @end itemize
2756
2757 @section New Features for Reading Input
2758
2759 @itemize @bullet
2760 @item
2761 The function @code{set-input-mode} now takes four arguments. The last
2762 argument is optional. Their names are @var{interrupt}, @var{flow},
2763 @var{meta} and @var{quit}.
2764
2765 The argument @var{interrupt} says whether to use interrupt-driven
2766 input. Non-@code{nil} means yes, and @code{nil} means no (use CBREAK
2767 mode).
2768
2769 The argument @var{flow} says whether to enable terminal flow control.
2770 Non-@code{nil} means yes.
2771
2772 The argument @var{meta} says whether to enable the use of a Meta key.
2773 Non-@code{nil} means yes.
2774
2775 If @var{quit} non-@code{nil}, it is the character to use for quitting.
2776 (Normally this is @kbd{C-g}.)
2777
2778 @item
2779 The variable @code{meta-flag} has been deleted; use
2780 @code{set-input-mode} to enable or disable support for a @key{META}
2781 key. This change was made because @code{set-input-mode} can send the
2782 terminal the appropriate commands to enable or disable operation of the
2783 @key{META} key.
2784
2785 @item
2786 The new variable @code{extra-keyboard-modifiers} lets Lisp programs
2787 ``press'' the modifier keys on the keyboard.
2788 The value is a bit mask:
2789
2790 @table @asis
2791 @item 1
2792 The @key{SHIFT} key.
2793 @item 2
2794 The @key{LOCK} key.
2795 @item 4
2796 The @key{CTL} key.
2797 @item 8
2798 The @key{META} key.
2799 @end table
2800
2801 When you use X windows, the program can press any of the modifier keys
2802 in this way. Otherwise, only the @key{CTL} and @key{META} keys can be
2803 virtually pressed.
2804
2805 @item
2806 You can use the new function @code{keyboard-translate} to set up
2807 @code{keyboard-translate-table} conveniently.
2808
2809 @item
2810 Y-or-n questions using the @code{y-or-n-p} function now accept @kbd{C-]}
2811 (usually mapped to @code{abort-recursive-edit}) as well as @kbd{C-g} to
2812 quit.
2813
2814 @item
2815 The variable @code{num-input-keys} is the total number of key sequences
2816 that the user has typed during this Emacs session.
2817
2818 @item
2819 A new Lisp variable, @code{function-key-map}, holds a keymap which
2820 describes the character sequences sent by function keys on an ordinary
2821 character terminal. This uses the same keymap data structure that is
2822 used to hold bindings of key sequences, but it has a different meaning:
2823 it specifies translations to make while reading a key sequence.
2824
2825 If @code{function-key-map} ``binds'' a key sequence @var{k} to a vector
2826 @var{v}, then when @var{k} appears as a subsequence @emph{anywhere} in a
2827 key sequence, it is replaced with @var{v}.
2828
2829 For example, VT100 terminals send @kbd{@key{ESC} O P} when the ``keypad''
2830 PF1 key is pressed. Thus, on a VT100, @code{function-key-map} should
2831 ``bind'' that sequence to @code{[pf1]}. This specifies translation of
2832 @kbd{@key{ESC} O P} into @key{PF1} anywhere in a key sequence.
2833
2834 Thus, typing @kbd{C-c @key{PF1}} sends the character sequence @kbd{C-c
2835 @key{ESC} O P}, but @code{read-key-sequence} translates this back into
2836 @kbd{C-c @key{PF1}}, which it returns as the vector @code{[?\C-c PF1]}.
2837
2838 Entries in @code{function-key-map} are ignored if they conflict with
2839 bindings made in the minor mode, local, or global keymaps.
2840
2841 The value of @code{function-key-map} is usually set up automatically
2842 according to the terminal's Terminfo or Termcap entry, and the
2843 terminal-specific Lisp files. Emacs comes with a number of
2844 terminal-specific files for many common terminals; their main purpose is
2845 to make entries in @code{function-key-map} beyond those that can be
2846 deduced from Termcap and Terminfo.
2847
2848 @item
2849 The variable @code{key-translation-map} works like @code{function-key-map}
2850 except for two things:
2851
2852 @itemize @bullet
2853 @item
2854 @code{key-translation-map} goes to work after @code{function-key-map} is
2855 finished; it receives the results of translation by
2856 @code{function-key-map}.
2857
2858 @item
2859 @code{key-translation-map} overrides actual key bindings.
2860 @end itemize
2861
2862 The intent of @code{key-translation-map} is for users to map one
2863 character set to another, including ordinary characters normally bound
2864 to @code{self-insert-command}.
2865 @end itemize
2866
2867 @section New Syntax Table Features
2868
2869 @itemize @bullet
2870 @item
2871 You can use two new functions to move across characters in certain
2872 syntax classes.
2873
2874 @code{skip-syntax-forward} moves point forward across characters whose
2875 syntax classes are mentioned in its first argument, a string. It stops
2876 when it encounters the end of the buffer, or position @var{lim} (the
2877 optional second argument), or a character it is not supposed to skip.
2878 The function @code{skip-syntax-backward} is similar but moves backward.
2879
2880 @item
2881 The new function @code{forward-comment} moves point by comments. It
2882 takes one argument, @var{count}; it moves point forward across
2883 @var{count} comments (backward, if @var{count} is negative). If it
2884 finds anything other than a comment or whitespace, it stops, leaving
2885 point at the far side of the last comment found. It also stops after
2886 satisfying @var{count}.
2887
2888 @item
2889 The new variable @code{words-include-escapes} affects the behavior of
2890 @code{forward-word} and everything that uses it. If it is
2891 non-@code{nil}, then characters in the ``escape'' and ``character
2892 quote'' syntax classes count as part of words.
2893
2894 @item
2895 There are two new syntax flags for use in syntax tables.
2896
2897 @itemize -
2898 @item
2899 The prefix flag.
2900
2901 The @samp{p} flag identifies additional ``prefix characters'' in Lisp
2902 syntax. You can set this flag with @code{modify-syntax-entry} by
2903 including the letter @samp{p} in the syntax specification.
2904
2905 These characters are treated as whitespace when they appear between
2906 expressions. When they appear withing an expression, they are handled
2907 according to their usual syntax codes.
2908
2909 The function @code{backward-prefix-chars} moves back over these
2910 characters, as well as over characters whose primary syntax class is
2911 prefix (@samp{'}).
2912
2913 @item
2914 The @samp{b} comment style flag.
2915
2916 Emacs can now supports two comment styles simultaneously. (This is for
2917 the sake of C++.) More specifically, it can recognize two different
2918 comment-start sequences. Both must share the same first character; only
2919 the second character may differ. Mark the second character of the
2920 @samp{b}-style comment start sequence with the @samp{b} flag. You can
2921 set this flag with @code{modify-syntax-entry} by including the letter
2922 @samp{b} in the syntax specification.
2923
2924 The two styles of comment can have different comment-end sequences. A
2925 comment-end sequence (one or two characters) applies to the @samp{b}
2926 style if its first character has the @samp{b} flag set; otherwise, it
2927 applies to the @samp{a} style.
2928
2929 The appropriate comment syntax settings for C++ are as follows:
2930
2931 @table @asis
2932 @item @samp{/}
2933 @samp{124b}
2934 @item @samp{*}
2935 @samp{23}
2936 @item newline
2937 @samp{>b}
2938 @end table
2939
2940 Thus @samp{/*} is a comment-start sequence for @samp{a} style, @samp{//}
2941 is a comment-start sequence for @samp{b} style, @samp{*/} is a
2942 comment-end sequence for @samp{a} style, and newline is a comment-end
2943 sequence for @samp{b} style.
2944 @end itemize
2945 @end itemize
2946
2947 @section The Case Table
2948
2949 You can customize case conversion using the new case table feature. A
2950 case table is a collection of strings that specifies the mapping between
2951 upper case and lower case letters. Each buffer has its own case table.
2952 You need a case table if you are using a language which has letters that
2953 are not standard ASCII letters.
2954
2955 A case table is a list of this form:
2956
2957 @example
2958 (@var{downcase} @var{upcase} @var{canonicalize} @var{equivalences})
2959 @end example
2960
2961 @noindent
2962 where each element is either @code{nil} or a string of length 256. The
2963 element @var{downcase} says how to map each character to its lower-case
2964 equivalent. The element @var{upcase} maps each character to its
2965 upper-case equivalent. If lower and upper case characters are in 1-1
2966 correspondence, use @code{nil} for @var{upcase}; then Emacs deduces the
2967 upcase table from @var{downcase}.
2968
2969 For some languages, upper and lower case letters are not in 1-1
2970 correspondence. There may be two different lower case letters with the
2971 same upper case equivalent. In these cases, you need to specify the
2972 maps for both directions.
2973
2974 The element @var{canonicalize} maps each character to a canonical
2975 equivalent; any two characters that are related by case-conversion have
2976 the same canonical equivalent character.
2977
2978 The element @var{equivalences} is a map that cyclicly permutes each
2979 equivalence class (of characters with the same canonical equivalent).
2980
2981 You can provide @code{nil} for both @var{canonicalize} and
2982 @var{equivalences}, in which case both are deduced from @var{downcase}
2983 and @var{upcase}.
2984
2985 Here are the functions for working with case tables:
2986
2987 @code{case-table-p} is a predicate that says whether a Lisp object is a
2988 valid case table.
2989
2990 @code{set-standard-case-table} takes one argument and makes that
2991 argument the case table for new buffers created subsequently.
2992 @code{standard-case-table} returns the current value of the new buffer
2993 case table.
2994
2995 @code{current-case-table} returns the case table of the current buffer.
2996 @code{set-case-table} sets the current buffer's case table to the
2997 argument.
2998
2999 @code{set-case-syntax-pair} is a convenient function for specifying a
3000 pair of letters, upper case and lower case. Call it with two arguments,
3001 the upper case letter and the lower case letter. It modifies the
3002 standard case table and a few syntax tables that are predefined in
3003 Emacs. This function is intended as a subroutine for packages that
3004 define non-ASCII character sets.
3005
3006 Load the library @file{iso-syntax} to set up the syntax and case table for
3007 the 256 bit ISO Latin 1 character set.
3008
3009 @section New Features for Dealing with Buffers
3010
3011 @itemize @bullet
3012 @item
3013 The new function @code{buffer-modified-tick} returns a buffer's
3014 modification-count that ticks every time the buffer is modified. It
3015 takes one optional argument, which is the buffer you want to examine.
3016 If the argument is @code{nil} (or omitted), the current buffer is used.
3017
3018 @item
3019 @code{buffer-disable-undo} is a new name for the function
3020 formerly known as @code{buffer-flush-undo}. This turns off recording
3021 of undo information in the buffer given as argument.
3022
3023 @item
3024 The new function @code{generate-new-buffer-name} chooses a name that
3025 would be unique for a new buffer---but does not create the buffer. Give
3026 it one argument, a starting name. It produces a name not in use for a
3027 buffer by appending a number inside of @samp{<@dots{}>}.
3028
3029 @item
3030 The function @code{rename-buffer} now takes an option second argument
3031 which tells it that if the specified new name corresponds to an existing
3032 buffer, it should use @code{generate-new-buffer-name} to modify the name
3033 to be unique, rather than signaling an error.
3034
3035 @code{rename-buffer} now returns the name to which the buffer was
3036 renamed.
3037
3038 @item
3039 The function @code{list-buffers} now looks at the local variable
3040 @code{list-buffers-directory} in each non-file-visiting buffer, and
3041 shows its value where the file would normally go. Dired sets this
3042 variable in each Dired buffer, so the buffer list now shows which
3043 directory each Dired buffer is editing.
3044
3045 @item
3046 The function @code{other-buffer} now takes an optional second argument
3047 @var{visible-ok} which, if non-@code{nil}, indicates that buffers
3048 currently being displayed in windows may be returned even if there are
3049 other buffers not visible. Normally, @code{other-buffer} returns a
3050 currently visible buffer only as a last resort, if there are no suitable
3051 nonvisible buffers.
3052
3053 @item
3054 The hook @code{kill-buffer-hook} now runs whenever a buffer is killed.
3055 @end itemize
3056
3057 @section Local Variables Features
3058
3059 @itemize @bullet
3060 @item
3061 If a local variable name has a non-@code{nil} @code{permanent-local}
3062 property, then @code{kill-all-local-variables} does not kill it. Such
3063 local variables are ``permanent''---they remain unchanged even if you
3064 select a different major mode.
3065
3066 Permanent locals are useful when they have to do with where the file
3067 came from or how to save it, rather than with how to edit the contents.
3068
3069 @item
3070 The function @code{make-local-variable} now never changes the value of the variable
3071 that it makes local. If the variable had no value before, it still has
3072 no value after becoming local.
3073
3074 @item
3075 The new function @code{default-boundp} tells you whether a variable has
3076 a default value (as opposed to being unbound in its default value). If
3077 @code{(default-boundp 'foo)} returns @code{nil}, then
3078 @code{(default-value 'foo)} would get an error.
3079
3080 @code{default-boundp} is to @code{default-value} as @code{boundp} is to
3081 @code{symbol-value}.
3082
3083 @item
3084 The special forms @code{defconst} and @code{defvar}, when the variable
3085 is local in the current buffer, now set the variable's default value
3086 rather than its local value.
3087 @end itemize
3088
3089 @section New Features for Subprocesses
3090
3091 @itemize @bullet
3092 @item
3093 @code{call-process} and @code{call-process-region} now return a value
3094 that indicates how the synchronous subprocess terminated. It is either
3095 a number, which is the exit status of a process, or a signal name
3096 represented as a string.
3097
3098 @item
3099 @code{process-status} now returns @code{open} and @code{closed} as the
3100 status values for network connections.
3101
3102 @item
3103 The standard asynchronous subprocess features work on VMS now,
3104 and the special VMS asynchronous subprocess functions have been deleted.
3105
3106 @item
3107 You can use the transaction queue feature for more convenient
3108 communication with subprocesses using transactions.
3109
3110 Call @code{tq-create} to create a transaction queue communicating with a
3111 specified process. Then you can call @code{tq-enqueue} to send a
3112 transaction. @code{tq-enqueue} takes these five arguments:
3113
3114 @example
3115 (tq-enqueue @var{tq} @var{question} @var{regexp} @var{closure} @var{fn})
3116 @end example
3117
3118 @var{tq} is the queue to use. (Specifying the queue has the effect of
3119 specifying the process to talk to.) The argument @var{question} is the
3120 outgoing message which starts the transaction. The argument @var{fn} is
3121 the function to call when the corresponding answer comes back; it is
3122 called with two arguments: @var{closure}, and the answer received.
3123
3124 The argument @var{regexp} is a regular expression to match the entire
3125 answer; that's how @code{tq-enqueue} tells where the answer ends.
3126
3127 Call @code{tq-close} to shut down a transaction queue and terminate its
3128 subprocess.
3129
3130 @item
3131 The function @code{signal-process} sends a signal to process @var{pid},
3132 which need not be a child of Emacs. The second argument @var{signal}
3133 specifies which signal to send; it should be an integer.
3134 @end itemize
3135
3136 @section New Features for Dealing with Times And Time Delays
3137
3138 @itemize @bullet
3139 @item
3140 The new function @code{current-time} returns the system's time value as
3141 a list of three integers: @code{(@var{high} @var{low} @var{microsec})}.
3142 The integers @var{high} and @var{low} combine to give the number of
3143 seconds since 0:00 January 1, 1970, which is @var{high} * 2**16 +
3144 @var{low}.
3145
3146 @var{microsec} gives the microseconds since the start of the current
3147 second (or 0 for systems that return time only on the resolution of a
3148 second).
3149
3150 @item
3151 The function @code{current-time-string} accepts an optional argument
3152 @var{time-value}. If given, this specifies a time to format instead of
3153 the current time. The argument should be a cons cell containing two
3154 integers, or a list whose first two elements are integers. Thus, you
3155 can use times obtained from @code{current-time} (see above) and from
3156 @code{file-attributes}.
3157
3158 @item
3159 You can now find out the user's time zone using @code{current-time-zone}.
3160 It takes no arguments, and returns a list of this form:
3161
3162 @example
3163 (@var{offset} @var{savings-flag} @var{standard} @var{savings})
3164 @end example
3165
3166 @var{offset} is an integer specifying how many minutes east of Greenwich
3167 the current time zone is located. A negative value means west of
3168 Greenwich. Note that this describes the standard time; if daylight
3169 savings time is in effect, it does not affect this value.
3170
3171 @var{savings-flag} is non-@code{nil} iff daylight savings time or some other
3172 sort of seasonal time adjustment is in effect.
3173
3174 @var{standard} is a string giving the name of the time zone when no
3175 seasonal time adjustment is in effect.
3176
3177 @var{savings} is a string giving the name of the time zone when there is a
3178 seasonal time adjustment in effect.
3179
3180 If the user has specified a region that does not use a seasonal time
3181 adjustment, @var{savings-flag} is always @code{nil}, and @var{standard}
3182 and @var{savings} are equal.
3183
3184 @item
3185 @code{sit-for}, @code{sleep-for} now let you specify the time period in
3186 milliseconds as well as in seconds. The first argument gives the number
3187 of seconds, as before, and the optional second argument gives additional
3188 milliseconds. The time periods specified by these two arguments are
3189 added together.
3190
3191 Not all systems support this; you get an error if you specify nonzero
3192 milliseconds and it isn't supported.
3193
3194 @code{sit-for} also accepts an optional third argument @var{nodisp}. If
3195 this is non-@code{nil}, @code{sit-for} does not redisplay. It still
3196 waits for the specified time or until input is available.
3197
3198 @item
3199 @code{accept-process-output} now accepts a timeout specified by optional
3200 second and third arguments. The second argument specifies the number of
3201 seconds, while the third specifies the number of milliseconds. The time
3202 periods specified by these two arguments are added together.
3203
3204 Not all systems support this; you get an error if you specify nonzero
3205 milliseconds and it isn't supported.
3206
3207 The function returns @code{nil} if the timeout expired before output
3208 arrived, or non-@code{nil} if it did get some output.
3209
3210 @item
3211 You can set up a timer to call a function at a specified future time.
3212 To do so, call @code{run-at-time}, like this:
3213
3214 @example
3215 (run-at-time @var{time} @var{repeat} @var{function} @var{args}@dots{})
3216 @end example
3217
3218 Here, @var{time} is a string saying when to call the function. The
3219 argument @var{function} is the function to call later, and @var{args}
3220 are the arguments to give it when it is called.
3221
3222 The argument @var{repeat} specifies how often to repeat the call. If
3223 @var{repeat} is @code{nil}, there are no repetitions; @var{function} is
3224 called just once, at @var{time}. If @var{repeat} is an integer, it
3225 specifies a repetition period measured in seconds.
3226
3227 Absolute times may be specified in a wide variety of formats; The form
3228 @samp{@var{hour}:@var{min}:@var{sec} @var{timezone}
3229 @var{month}/@var{day}/@var{year}}, where all fields are numbers, works;
3230 the format that @code{current-time-string} returns is also allowed.
3231
3232 To specify a relative time, use numbers followed by units.
3233 For example:
3234
3235 @table @samp
3236 @item 1 min
3237 denotes 1 minute from now.
3238 @item 1 min 5 sec
3239 denotes 65 seconds from now.
3240 @item 1 min 2 sec 3 hour 4 day 5 week 6 fortnight 7 month 8 year
3241 denotes exactly 103 months, 123 days, and 10862 seconds from now.
3242 @end table
3243
3244 If @var{time} is an integer, that specifies a relative time measured in
3245 seconds.
3246 @end itemize
3247
3248 To cancel the requested future action, pass the value that @code{run-at-time}
3249 returned to the function @code{cancel-timer}.
3250
3251 @section Profiling Lisp Programs
3252
3253 You can now make execution-time profiles of Emacs Lisp programs using
3254 the @file{profile} library. See the file @file{profile.el} for
3255 instructions; if you have written a Lisp program big enough to be worth
3256 profiling, you can surely understand them.
3257
3258 @section New Features for Lisp Debuggers
3259
3260 @itemize @bullet
3261 @item
3262 You can now specify which kinds of errors should invoke the Lisp
3263 debugger by setting the variable @code{debug-on-error} to a list of error
3264 conditions. For example, if you set it to the list @code{(void-variable)},
3265 then only errors about a variable that has no value invoke the
3266 debugger.
3267
3268 @item
3269 The variable @code{command-debug-status} is used by Lisp debuggers. It
3270 records the debugging status of current interactive command. Each time
3271 a command is called interactively, this variable is bound to
3272 @code{nil}. The debugger can set this variable to leave information for
3273 future debugger invocations during the same command.
3274
3275 The advantage of this variable over some other variable in the debugger
3276 itself is that the data will not be visible for any other command
3277 invocation.
3278
3279 @item
3280 The function @code{backtrace-frame} is intended for use in Lisp
3281 debuggers. It returns information about what a frame on the Lisp call
3282 stack is doing. You specify one argument, which is the number of stack
3283 frames to count up from the current execution point.
3284
3285 If that stack frame has not evaluated the arguments yet (or is a special
3286 form), the value is @code{(nil @var{function} @var{arg-forms}@dots{})}.
3287
3288 If that stack frame has evaluated its arguments and called its function
3289 already, the value is @code{(t @var{function}
3290 @var{arg-values}@dots{})}.
3291
3292 In the return value, @var{function} is whatever was supplied as @sc{car}
3293 of evaluated list, or a @code{lambda} expression in the case of a macro
3294 call. If the function has a @code{&rest} argument, that is represented
3295 as the tail of the list @var{arg-values}.
3296
3297 If the argument is out of range, @code{backtrace-frame} returns
3298 @code{nil}.
3299 @end itemize
3300
3301 @ignore
3302
3303 @item
3304 @code{kill-ring-save} now gives visual feedback to indicate the region
3305 of text being added to the kill ring. If the opposite end of the
3306 region is visible in the current window, the cursor blinks there.
3307 Otherwise, some text from the other end of the region is displayed in
3308 the message area.
3309 @end ignore
3310
3311 @section Memory Allocation Changes
3312
3313 The list that @code{garbage-collect} returns now has one additional
3314 element. This is a cons cell containing two numbers. It gives
3315 information about the number of used and free floating point numbers,
3316 much as the first element gives such information about the number of
3317 used and free cons cells.
3318
3319 The new function @code{memory-limit} returns an indication of the last
3320 address allocated by Emacs. More precisely, it returns that address
3321 divided by 1024. You can use this to get a general idea of how your
3322 actions affect the memory usage.
3323
3324 @section Hook Changes
3325
3326 @itemize @bullet
3327 @item
3328 Expanding an abbrev first runs the new hook
3329 @code{pre-abbrev-expand-hook}.
3330
3331 @item
3332 The editor command loop runs the normal hook @code{pre-command-hook}
3333 before each command, and runs @code{post-command-hook} after each
3334 command.
3335
3336 @item
3337 Auto-saving runs the new hook @code{auto-save-hook} before actually
3338 starting to save any files.
3339
3340 @item
3341 The new variable @code{revert-buffer-insert-file-contents-function}
3342 holds a function that @code{revert-buffer} now uses to read in the
3343 contents of the reverted buffer---instead of calling
3344 @code{insert-file-contents}.
3345
3346 @item
3347 The variable @code{lisp-indent-hook} has been renamed to
3348 @code{lisp-indent-function}.
3349
3350 @item
3351 The variable @code{auto-fill-hook} has been renamed to
3352 @code{auto-fill-function}.
3353
3354 @item
3355 The variable @code{blink-paren-hook} has been renamed to
3356 @code{blink-paren-function}.
3357
3358 @item
3359 The variable @code{temp-buffer-show-hook} has been renamed to
3360 @code{temp-buffer-show-function}.
3361
3362 @item
3363 The variable @code{suspend-hook} has been renamed to
3364 @code{suspend-hooks}, because it is a list of functions but is not a
3365 normal hook.
3366
3367 @item
3368 The new function @code{add-hook} provides a handy way to add a function
3369 to a hook variable. For example,
3370
3371 @example
3372 (add-hook 'text-mode-hook 'my-text-hook-function)
3373 @end example
3374
3375 @noindent
3376 arranges to call @code{my-text-hook-function}
3377 when entering Text mode or related modes.
3378 @end itemize
3379
3380 @bye