comparison etc/news.texi @ 0:376386a54a3c r19-14

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