annotate etc/=news.texi @ 36564:427c9eef0c0c

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Tue, 06 Mar 2001 02:54:50 +0000
parents 58b646d9fefc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2316
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1 @setfilename LNEWS
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3 @section New Features in the Lisp Language
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
4
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
5 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
6 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
7 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
8 The new function @code{delete} is a traditional Lisp function. It takes
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
9 two arguments, @var{elt} and @var{list}, and deletes from @var{list} any
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
10 elements that are equal to @var{elt}. It uses the function @code{equal}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
11 to compare elements with @var{elt}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
12
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
13 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
14 The new function @code{member} is a traditional Lisp function. It takes
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
15 two arguments, @var{elt} and @var{list}, and finds the first element of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
16 @var{list} that is equal to @var{elt}. It uses the function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
17 @code{equal} to compare each list element with @var{elt}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
18
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
19 The value is a sublist of @var{list}, whose first element is the one
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
20 that was found. If no matching element is found, the value is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21 @code{nil}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
22
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
23 @ignore @c Seems not to be true, from looking at the code.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
24 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
25 The function @code{equal} is now more robust: it does not crash due to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
26 circular list structure.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
27 @end ignore
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
28
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
29 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
30 The new function @code{indirect-function} finds the effective function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
31 definition of an object called as a function. If the object is a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
32 symbol, @code{indirect-function} looks in the function definition of the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
33 symbol. It keeps doing this until it finds something that is not a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
34 symbol.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
35
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
36 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
37 There are new escape sequences for use in character and string
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
38 constants. The escape sequence @samp{\a} is equivalent to @samp{\C-g},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
39 the @sc{ASCII} @sc{BEL} character (code 7). The escape sequence
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
40 @samp{\x} followed by a hexidecimal number represents the character
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
41 whose @sc{ASCII} code is that number. There is no limit on the number
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
42 of digits in the hexidecimal value.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
43
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
44 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
45 The function @code{read} when reading from a buffer now does not skip a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
46 terminator character that terminates a symbol. It leaves that character
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
47 to be read (or just skipped, if it is whitespace) next time.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
48
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
49 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
50 When you use a function @var{function} as the input stream for
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
51 @code{read}, it is usually called with no arguments, and should return
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
52 the next character. In Emacs 19, sometimes @var{function} is called
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
53 with one argument (always a character). When that happens,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
54 @var{function} should save the argument and arrange to return it when
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
55 called next time.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
56
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
57 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
58 @code{random} with integer argument @var{n} returns a random number
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
59 between 0 and @var{n}@minus{}1.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
60
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
61 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
62 The functions @code{documentation} and @code{documentation-property} now
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
63 take an additional optional argument which, if non-@code{nil}, says to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
64 refrain from calling @code{substitute-command-keys}. This way, you get
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
65 the exact text of the documentation string as written, without the usual
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
66 substitutions. Make sure to call @code{substitute-command-keys}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
67 yourself if you decide to display the string.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
68
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
69 @ignore
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
70 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
71 The new function @code{invocation-name} returns as a string the program
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
72 name that was used to run Emacs, with any directory names discarded.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
73 @c ??? This hasn't been written yet. ???
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
74 @end ignore
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
75
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
76 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
77 The new function @code{map-y-or-n-p} makes it convenient to ask a series
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
78 of similar questions. The arguments are @var{prompter}, @var{actor},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
79 @var{list}, and optional @var{help}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
80
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
81 The value of @var{list} is a list of objects, or a function of no
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
82 arguments to return either the next object or @code{nil} meaning there
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
83 are no more.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
84
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
85 The argument @var{prompter} specifies how to ask each question. If
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
86 @var{prompter} is a string, the question text is computed like this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
87
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
88 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
89 (format @var{prompter} @var{object})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
90 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
91
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
92 @noindent
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
93 where @var{object} is the next object to ask about.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
94
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
95 If not a string, @var{prompter} should be a function of one argument
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
96 (the next object to ask about) and should return the question text.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
97
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
98 The argument @var{actor} should be a function of one argument, which is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
99 called with each object that the user says yes for. Its argument is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
100 always one object from @var{list}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
101
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
102 If @var{help} is given, it is a list @code{(@var{object} @var{objects}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
103 @var{action})}, where @var{object} is a string containing a singular
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
104 noun that describes the objects conceptually being acted on;
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
105 @var{objects} is the corresponding plural noun and @var{action} is a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
106 transitive verb describing @var{actor}. The default is @code{("object"
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
107 "objects" "act on")}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
108
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
109 Each time a question is asked, the user may enter @kbd{y}, @kbd{Y}, or
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
110 @key{SPC} to act on that object; @kbd{n}, @kbd{N}, or @key{DEL} to skip
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
111 that object; @kbd{!} to act on all following objects; @key{ESC} or
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
112 @kbd{q} to exit (skip all following objects); @kbd{.} (period) to act on
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
113 the current object and then exit; or @kbd{C-h} to get help.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
114
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
115 @code{map-y-or-n-p} returns the number of objects acted on.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
116
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
117 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
118 You can now ``set'' environment variables with the @code{setenv}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
119 command. This works by setting the variable @code{process-environment},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
120 which @code{getenv} now examines in preference to the environment Emacs
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
121 received from its parent.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
122 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
123
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
124 @section New Features for Loading Libraries
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
125
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
126 You can now arrange to run a hook if a particular Lisp library is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
127 loaded.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
128
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
129 The variable @code{after-load-alist} is an alist of expressions to be
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
130 evalled when particular files are loaded. Each element looks like
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
131 @code{(@var{filename} @var{forms}@dots{})}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
132
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
133 When @code{load} is run and the file name argument equals
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
134 @var{filename}, the @var{forms} in the corresponding element are
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
135 executed at the end of loading. @var{filename} must match exactly!
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
136 Normally @var{filename} is the name of a library, with no directory
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
137 specified, since that is how @code{load} is normally called.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
138
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
139 An error in @var{forms} does not undo the load, but does prevent
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
140 execution of the rest of the @var{forms}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
141
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
142 The function @code{eval-after-load} provides a convenient way to add
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
143 entries to the alist. Call it with two arguments, @var{file} and a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
144 form to execute.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
145
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
146 The function @code{autoload} now supports autoloading a keymap.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
147 Use @code{keymap} as the fourth argument if the autoloaded function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
148 will become a keymap when loaded.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
149
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
150 There is a new feature for specifying which functions in a library should
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
151 be autoloaded by writing special ``magic'' comments in that library itself.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
152
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
153 Write @samp{;;;###autoload} on a line by itself before a function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
154 definition before the real definition of the function, in its
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
155 autoloadable source file; then the command @kbd{M-x
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
156 update-file-autoloads} automatically puts the @code{autoload} call into
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
157 @file{loaddefs.el}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
158
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
159 You can also put other kinds of forms into @file{loaddefs.el}, by
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
160 writing @samp{;;;###autoload} followed on the same line by the form.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
161 @kbd{M-x update-file-autoloads} copies the form from that line.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
162
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
163 @section Compilation Features
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
164
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
165 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
166 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
167 Inline functions.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
168
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
169 You can define an @dfn{inline function} with @code{defsubst}. Use
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
170 @code{defsubst} just like @code{defun}, and it defines a function which
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
171 you can call in all the usual ways. Whenever the function thus defined
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
172 is used in compiled code, the compiler will open code it.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
173
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
174 You can get somewhat the same effects with a macro, but a macro has the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
175 limitation that you can use it only explicitly; a macro cannot be called
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
176 with @code{apply}, @code{mapcar} and so on. Also, it takes some work to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
177 convert an ordinary function into a macro. To convert it into an inline
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
178 function, simply replace @code{defun} with @code{defsubst}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
179
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
180 Making a function inline makes explicit calls run faster. But it also
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
181 has disadvantages. For one thing, it reduces flexibility; if you change
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
182 the definition of the function, calls already inlined still use the old
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
183 definition until you recompile them.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
184
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
185 Another disadvantage is that making a large function inline can increase
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
186 the size of compiled code both in files and in memory. Since the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
187 advantages of inline functions are greatest for small functions, you
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
188 generally should not make large functions inline.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
189
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
190 Inline functions can be used and open coded later on in the same file,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
191 following the definition, just like macros.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
192
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
193 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
194 The command @code{byte-compile-file} now offers to save any buffer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
195 visiting the file you are compiling.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
196
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
197 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
198 The new command @code{compile-defun} reads, compiles and executes the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
199 defun containing point. If you use this on a defun that is actually a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
200 function definition, the effect is to install a compiled version of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
201 that function.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
202
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
203 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
204 Whenever you load a Lisp file or library, you now receive a warning if
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
205 the directory contains both a @samp{.el} file and a @samp{.elc} file,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
206 and the @samp{.el} file is newer. This typically indicates that someone
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
207 has updated the Lisp code but forgotten to recompile it, so the changes
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
208 do not take effect. The warning is a reminder to recompile.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
209
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
210 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
211 The special form @code{eval-when-compile} marks the forms it contains to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
212 be evaluated at compile time @emph{only}. At top-level, this is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
213 analogous to the Common Lisp idiom @code{(eval-when (compile)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
214 @dots{})}. Elsewhere, it is similar to the Common Lisp @samp{#.} reader
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
215 macro (but not when interpreting).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
216
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
217 If you're thinking of using this feature, we recommend you consider whether
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
218 @code{provide} and @code{require} might do the job as well.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
219
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
220 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
221 The special form @code{eval-and-compile} is similar to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
222 @code{eval-when-compile}, but the whole form is evaluated both at
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
223 compile time and at run time.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
224
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
225 If you're thinking of using this feature, we recommend you consider
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
226 whether @code{provide} and @code{require} might do the job as well.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
227
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
228 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
229 Emacs Lisp has a new data type for byte-code functions. This makes
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
230 them faster to call, and also saves space. Internally, a byte-code
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
231 function object is much like a vector; however, the evaluator handles
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
232 this data type specially when it appears as a function to be called.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
233
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
234 The printed representation for a byte-code function object is like that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
235 for a vector, except that it starts with @samp{#} before the opening
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
236 @samp{[}. A byte-code function object must have at least four elements;
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
237 there is no maximum number, but only the first six elements are actually
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
238 used. They are:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
239
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
240 @table @var
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
241 @item arglist
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
242 The list of argument symbols.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
243
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
244 @item byte-code
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
245 The string containing the byte-code instructions.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
246
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
247 @item constants
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
248 The vector of constants referenced by the byte code.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
249
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
250 @item stacksize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
251 The maximum stack size this function needs.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
252
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
253 @item docstring
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
254 The documentation string (if any); otherwise, @code{nil}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
255
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
256 @item interactive
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
257 The interactive spec (if any). This can be a string or a Lisp
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
258 expression. It is @code{nil} for a function that isn't interactive.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
259 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
260
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
261 The predicate @code{byte-code-function-p} tests whether a given object
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
262 is a byte-code function.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
263
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
264 You can create a byte-code function object in a Lisp program
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
265 with the function @code{make-byte-code}. Its arguments are the elements
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
266 to put in the byte-code function object.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
267
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
268 You should not try to come up with the elements for a byte-code function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
269 yourself, because if they are inconsistent, Emacs may crash when you
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
270 call the function. Always leave it to the byte compiler to create these
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
271 objects; it, we hope, always makes the elements consistent.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
272 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
273
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
274 @section Floating Point Numbers
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
275
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
276 You can now use floating point numbers in Emacs, if you define the macro
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
277 @code{LISP_FLOAT_TYPE} when you compile Emacs.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
278
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
279 The printed representation for floating point numbers requires either a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
280 decimal point surrounded by digits, or an exponent, or both. For
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
281 example, @samp{1500.0}, @samp{15e2}, @samp{15.0e2} and @samp{1.5e3} are
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
282 four ways of writing a floating point number whose value is 1500.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
283
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
284 The existing predicate @code{numberp} now returns @code{t} if the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
285 argument is any kind of number---either integer or floating. The new
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
286 predicates @code{integerp} and @code{floatp} check for specific types of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
287 numbers.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
288
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
289 You can do arithmetic on floating point numbers with the ordinary
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
290 arithmetic functions, @code{+}, @code{-}, @code{*} and @code{/}. If you
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
291 call one of these functions with both integers and floating point
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
292 numbers among the arguments, the arithmetic is done in floating point.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
293 The same applies to the numeric comparison functions such as @code{=}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
294 and @code{<}. The remainder function @code{%} does not accept floating
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
295 point arguments, and neither do the bitwise boolean operations such as
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
296 @code{logand} or the shift functions such as @code{ash}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
297
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
298 There is a new arithmetic function, @code{abs}, which returns the absolute
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
299 value of its argument. It handles both integers and floating point
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
300 numbers.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
301
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
302 To convert an integer to floating point, use the function @code{float}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
303 There are four functions to convert floating point numbers to integers;
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
304 they differ in how they round. @code{truncate} rounds toward 0,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
305 @code{floor} rounds down, @code{ceil} rounds up, and @code{round}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
306 produces the nearest integer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
307
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
308 You can use @code{logb} to extract the binary exponent of a floating
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
309 point number. More precisely, it is the logarithm base 2, rounded down
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
310 to an integer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
311
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
312 Emacs has several new mathematical functions that accept any kind of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
313 number as argument, but always return floating point numbers.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
314
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
315 @table @code
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
316 @item cos
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
317 @findex cos
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
318 @itemx sin
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
319 @findex sin
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
320 @itemx tan
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
321 @findex tan
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
322 Trigonometric functions.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
323 @item acos
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
324 @findex acos
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
325 @itemx asin
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
326 @findex asin
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
327 @itemx atan
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
328 @findex atan
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
329 Inverse trigonometric functions.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
330 @item exp
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
331 @findex exp
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
332 The exponential function (power of @var{e}).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
333 @item log
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
334 @findex log
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
335 Logarithm base @var{e}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
336 @item expm1
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
337 @findex expm1
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
338 Power of @var{e}, minus 1.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
339 @item log1p
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
340 @findex log1p
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
341 Add 1, then take the logarithm.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
342 @item log10
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
343 @findex log10
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
344 Logarithm base 10
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
345 @item expt
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
346 @findex expt
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
347 Raise @var{x} to power @var{y}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
348 @item sqrt
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
349 @findex sqrt
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
350 The square root function.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
351 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
352
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
353 The new function @code{string-to-number} now parses a string containing
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
354 either an integer or a floating point number, returning the number.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
355
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
356 The @code{format} function now handles the specifications @samp{%e},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
357 @samp{%f} and @samp{%g} for printing floating point numbers; likewise
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
358 @code{message}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
359
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
360 The new variable @code{float-output-format} controls how Lisp prints
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
361 floating point numbers. Its value should be @code{nil} or a string.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
362
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
363 If it is a string, it should contain a @samp{%}-spec like those accepted
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
364 by @code{printf} in C, but with some restrictions. It must start with
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
365 the two characters @samp{%.}. After that comes an integer which is the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
366 precision specification, and then a letter which controls the format.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
367
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
368 The letters allowed are @samp{e}, @samp{f} and @samp{g}. Use @samp{e}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
369 for exponential notation (@samp{@var{dig}.@var{digits}e@var{expt}}).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
370 Use @samp{f} for decimal point notation
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
371 (@samp{@var{digits}.@var{digits}}). Use @samp{g} to choose the shorter
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
372 of those two formats for the number at hand.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
373
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
374 The precision in any of these cases is the number of digits following
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
375 the decimal point. With @samp{f}, a precision of 0 means to omit the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
376 decimal point. 0 is not allowed with @samp{f} or @samp{g}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
377
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
378 A value of @code{nil} means to use the format @samp{%.20g}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
379
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
380 No matter what the value of @code{float-output-format}, printing ensures
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
381 that the result fits the syntax rules for a floating point number. If
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
382 it doesn't fit (for example, if it looks like an integer), it is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
383 modified to fit. By contrast, the @code{format} function formats
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
384 floating point numbers without requiring the output to fit the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
385 syntax rules for floating point number.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
386
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
387 @section New Features for Printing And Formatting Output
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
388
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
389 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
390 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
391 The @code{format} function has a new feature: @samp{%S}. This print
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
392 spec prints any kind of Lisp object, even a string, using its Lisp
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
393 printed representation.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
394
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
395 By contrast, @samp{%s} prints everything without quotation.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
396
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
397 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
398 @code{prin1-to-string} now takes an optional second argument which says
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
399 not to print the Lisp quotation characters. (In other words, to use
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
400 @code{princ} instead of @code{prin1}.)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
401
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
402 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
403 The new variable @code{print-level} specifies the maximum depth of list
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
404 nesting to print before cutting off all deeper structure. A value of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
405 @code{nil} means no limit.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
406 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
407
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
408 @section Changes in Basic Editing Functions
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
409
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
410 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
411 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
412 There are two new primitives for putting text in the kill ring:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
413 @code{kill-new} and @code{kill-append}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
414
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
415 The function @code{kill-new} adds a string to the front of the kill ring.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
416
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
417 Use @code{kill-append} to add a string to a previous kill. The second
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
418 argument @var{before-p}, if non-@code{nil}, says to add the string at
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
419 the beginning; otherwise, it goes at the end.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
420
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
421 Both of these functions apply @code{interprogram-cut-function} to the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
422 entire string of killed text that ends up at the beginning of the kill
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
423 ring.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
424
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
425 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
426 The new function @code{current-kill} rotates the yanking pointer in the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
427 kill ring by @var{n} places, and returns the text at that place in the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
428 ring. If the optional second argument @var{do-not-move} is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
429 non-@code{nil}, it doesn't actually move the yanking point; it just
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
430 returns the @var{n}th kill forward. If @var{n} is zero, indicating a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
431 request for the latest kill, @code{current-kill} calls
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
432 @code{interprogram-paste-function} (documented below) before consulting
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
433 the kill ring.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
434
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
435 All Emacs Lisp programs should either use @code{current-kill},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
436 @code{kill-new}, and @code{kill-append} to manipulate the kill ring, or
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
437 be sure to call @code{interprogram-paste-function} and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
438 @code{interprogram-cut-function} as appropriate.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
439
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
440 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
441 The variables @code{interprogram-paste-function} and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
442 @code{interprogram-cut-function} exist so that you can provide functions
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
443 to transfer killed text to and from other programs.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
444
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
445 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
446 The @code{kill-region} function can now be used in read-only buffers.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
447 It beeps, but adds the region to the kill ring without deleting it.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
448
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
449 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
450 The new function @code{compare-buffer-substrings} lets you compare two
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
451 substrings of the same buffer or two different buffers. Its arguments
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
452 look like this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
453
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
454 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
455 (compare-buffer-substrings @var{buf1} @var{beg1} @var{end1} @var{buf2} @var{beg2} @var{end2})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
456 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
457
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
458 The first three arguments specify one substring, giving a buffer and two
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
459 positions within the buffer. The last three arguments specify the other
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
460 substring in the same way.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
461
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
462 The value is negative if the first substring is less, positive if the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
463 first is greater, and zero if they are equal. The absolute value of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
464 the result is one plus the index of the first different characters.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
465
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
466 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
467 Overwrite mode treats tab and newline characters specially. You can now
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
468 turn off this special treatment by setting @code{overwrite-binary-mode}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
469 to @code{t}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
470
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
471 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
472 Once the mark ``exists'' in a buffer, it normally never ceases to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
473 exist. However, it may become @dfn{inactive}. The variable
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
474 @code{mark-active}, which is always local in all buffers, indicates
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
475 whether the mark is active: non-@code{nil} means yes.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
476
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
477 A command can request deactivation of the mark upon return to the editor
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
478 command loop by setting @code{deactivate-mark} to a non-@code{nil}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
479 value. Transient Mark mode works by causing the buffer modification
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
480 primitives to set @code{deactivate-mark}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
481
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
482 The variables @code{activate-mark-hook} and @code{deactivate-mark-hook}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
483 are normal hooks run, respectively, when the mark becomes active andwhen
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
484 it becomes inactive. The hook @code{activate-mark-hook} is also run at
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
485 the end of a command if the mark is active and the region may have
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
486 changed.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
487
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
488 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
489 The function @code{move-to-column} now accepts a second optional
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
490 argument @var{force}, in addition to @var{column}; if the requested
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
491 column @var{column} is in the middle of a tab character and @var{force}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
492 is non-@code{nil}, @code{move-to-column} replaces the tab with the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
493 appropriate sequence of spaces so that it can place point exactly at
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
494 @var{column}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
495
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
496 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
497 The search functions when successful now return the value of point
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
498 rather than just @code{t}. This affects the functions
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
499 @code{search-forward}, @code{search-backward},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
500 @code{word-search-forward}, @code{word-search-backward},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
501 @code{re-search-forward}, and @code{re-search-backward}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
502
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
503 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
504 When you do regular expression searching or matching, there is no longer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
505 a limit to how many @samp{\(@dots{}\)} pairs you can get information
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
506 about with @code{match-beginning} and @code{match-end}. Also, these
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
507 parenthetical groupings may now be nested to any degree.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
508
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
509 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
510 The new special form @code{save-match-data} preserves the regular
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
511 expression match status. Usage: @code{(save-match-data
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
512 @var{body}@dots{})}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
513
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
514 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
515 The function @code{translate-region} applies a translation table to the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
516 characters in a part of the buffer. Invoke it as
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
517 @code{(translate-region @var{start} @var{end} @var{table})}; @var{start}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
518 and @var{end} bound the region to translate.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
519
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
520 The translation table @var{table} is a string; @code{(aref @var{table}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
521 @var{ochar})} gives the translated character corresponding to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
522 @var{ochar}. If the length of @var{table} is less than 256, any
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
523 characters with codes larger than the length of @var{table} are not
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
524 altered by the translation.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
525
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
526 @code{translate-region} returns the number of characters which were
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
527 actually changed by the translation. This does not count characters
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
528 which were mapped into themselves in the translation table.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
529
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
530 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
531 There are two new hook variables that let you notice all changes in all
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
532 buffers (or in a particular buffer, if you make them buffer-local):
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
533 @code{before-change-function} and @code{after-change-function}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
534
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
535 If @code{before-change-function} is non-@code{nil}, then it is called
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
536 before any buffer modification. Its arguments are the beginning and end
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
537 of the region that is going to change, represented as integers. The
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
538 buffer that's about to change is always the current buffer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
539
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
540 If @code{after-change-function} is non-@code{nil}, then it is called
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
541 after any buffer modification. It takes three arguments: the beginning
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
542 and end of the region just changed, and the length of the text that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
543 existed before the change. (To get the current length, subtract the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
544 rrgion beginning from the region end.) All three arguments are
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
545 integers. The buffer that's about to change is always the current
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
546 buffer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
547
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
548 Both of these variables are temporarily bound to @code{nil} during the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
549 time that either of these hooks is running. This means that if one of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
550 these functions changes the buffer, that change won't run these
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
551 functions. If you do want hooks to be run recursively, write your hook
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
552 functions to bind these variables back to their usual values.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
553
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
554 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
555 The hook @code{first-change-hook} is run using @code{run-hooks} whenever
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
556 a buffer is changed that was previously in the unmodified state.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
557
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
558 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
559 The second argument to @code{insert-abbrev-table-description} is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
560 now optional.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
561 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
562
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
563 @section Text Properties
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
564
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
565 Each character in a buffer or a string can have a @dfn{text property
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
566 list}, much like the property list of a symbol. The properties belong
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
567 to a particular character at a particular place, such as, the letter
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
568 @samp{T} at the beginning of this sentence. Each property has a name,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
569 which is usually a symbol, and an associated value, which can be any
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
570 Lisp object---just as for properties of symbols (@pxref{Property Lists}).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
571
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
572 You can use the property @code{face-code} to control the font and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
573 color of text. That is the only property name which currently has a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
574 special meaning, but you can create properties of any name and examine
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
575 them later for your own purposes.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
576
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
577 Copying text between strings and buffers preserves the properties
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
578 along with the characters; this includes such diverse functions as
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
579 @code{substring}, @code{insert}, and @code{buffer-substring}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
580
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
581 Since text properties are considered part of the buffer contents,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
582 changing properties in a buffer ``modifies'' the buffer, and you can
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
583 also undo such changes.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
584
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
585 Strings with text properties have a special printed representation
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
586 which describes all the properties. This representation is also the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
587 read syntax for such a string. It looks like this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
588
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
589 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
590 #("@var{characters}" @var{property-data}...)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
591 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
592
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
593 @noindent
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
594 where @var{property-data} is zero or more elements in groups of three as
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
595 follows:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
596
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
597 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
598 @var{beg} @var{end} @var{plist}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
599 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
600
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
601 @noindent
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
602 The elements @var{beg} and @var{end} are integers, and together specify
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
603 a portion of the string; @var{plist} is the property list for that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
604 portion.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
605
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
606 @subsection Examining Text Properties
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
607
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
608 The simplest way to examine text properties is to ask for the value of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
609 a particular property of a particular character. For that, use
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
610 @code{get-text-property}. Use @code{text-properties-at} to get the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
611 entire property list of a character. @xref{Property Search}, for
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
612 functions to examine the properties of a number of characters at once.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
613
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
614 @code{(get-text-property @var{pos} @var{prop} @var{object})} returns the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
615 @var{prop} property of the character after @var{pos} in @var{object} (a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
616 buffer or string). The argument @var{object} is optional and defaults
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
617 to the current buffer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
618
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
619 @code{(text-properties-at @var{pos} @var{object})} returns the entire
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
620 property list of the character after @var{pos} in the string or buffer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
621 @var{object} (which defaults to the current buffer).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
622
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
623 @subsection Changing Text Properties
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
624
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
625 There are three primitives for changing properties of a specified
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
626 range of text:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
627
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
628 @table @code
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
629 @item add-text-properties
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
630 This function puts on specified properties, leaving other existing
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
631 properties unaltered.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
632
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
633 @item put-text-property
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
634 This function puts on a single specified property, leaving others
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
635 unaltered.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
636
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
637 @item remove-text-properties
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
638 This function removes specified properties, leaving other
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
639 properties unaltered.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
640
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
641 @item set-text-properties
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
642 This function replaces the entire property list, leaving no vessage of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
643 the properties that that text used to have.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
644 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
645
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
646 All these functions take four arguments: @var{start}, @var{end},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
647 @var{props}, and @var{object}. The last argument is optional and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
648 defaults to the current buffer. The argument @var{props} has the form
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
649 of a property list.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
650
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
651 @subsection Property Search Functions
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
652
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
653 In typical use of text properties, most of the time several or many
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
654 consecutive characters have the same value for a property. Rather than
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
655 writing your programs to examine characters one by one, it is much
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
656 faster to process chunks of text that have the same property value.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
657
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
658 The functions @code{next-property-change} and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
659 @code{previous-property-change} scan forward or backward from position
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
660 @var{pos} in @var{object}, looking for a change in any property between
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
661 two characters scanned. They returns the position between those two
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
662 characters, or @code{nil} if no change is found.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
663
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
664 The functions @code{next-single-property-change} and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
665 @code{previous-single-property-change} are similar except that you
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
666 specify a particular property and they look for changes in the value of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
667 that property only. The property is the second argument, and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
668 @var{object} is third.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
669
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
670 @subsection Special Properties
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
671
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
672 If a character has a @code{category} property, we call it the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
673 @dfn{category} of the character. It should be a symbol. The properties
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
674 of the symbol serve as defaults for the properties of the character.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
675
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
676 You can use the property @code{face-code} to control the font and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
677 color of text. That is the only property name which currently has a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
678 special meaning, but you can create properties of any name and examine
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
679 them later for your own purposes.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
680 about face codes.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
681
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
682 You can specify a different keymap for a portion of the text by means
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
683 of a @code{local-map} property. The property's value, for the character
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
684 after point, replaces the buffer's local map.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
685
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
686 If a character has the property @code{read-only}, then modifying that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
687 character is not allowed. Any command that would do so gets an error.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
688
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
689 If a character has the property @code{modification-hooks}, then its
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
690 value should be a list of functions; modifying that character calls all
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
691 of those functions. Each function receives two arguments: the beginning
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
692 and end of the part of the buffer being modified. Note that if a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
693 particular modification hook function appears on several characters
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
694 being modified by a single primitive, you can't predict how many times
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
695 the function will be called.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
696
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
697 Insertion of text does not, strictly speaking, change any existing
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
698 character, so there is a special rule for insertion. It compares the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
699 @code{read-only} properties of the two surrounding characters; if they
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
700 are @code{eq}, then the insertion is not allowed. Assuming insertion is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
701 allowed, it then gets the @code{modification-hooks} properties of those
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
702 characters and calls all the functions in each of them. (If a function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
703 appears on both characters, it may be called once or twice.)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
704
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
705 The special properties @code{point-entered} and @code{point-left}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
706 record hook functions that report motion of point. Each time point
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
707 moves, Emacs compares these two property values:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
708
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
709 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
710 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
711 the @code{point-left} property of the character after the old location,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
712 and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
713 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
714 the @code{point-entered} property of the character after the new
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
715 location.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
716 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
717
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
718 @noindent
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
719 If these two values differ, each of them is called (if not @code{nil})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
720 with two arguments: the old value of point, and the new one.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
721
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
722 The same comparison is made for the characters before the old and new
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
723 locations. The result may be to execute two @code{point-left} functions
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
724 (which may be the same function) and/or two @code{point-entered}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
725 functions (which may be the same function). The @code{point-left}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
726 functions are always called before the @code{point-entered} functions.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
727
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
728 A primitive function may examine characters at various positions
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
729 without moving point to those positions. Only an actual change in the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
730 value of point runs these hook functions.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
731
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
732 @section New Features for Files
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
733
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
734 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
735 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
736 The new function @code{file-accessible-directory-p} tells you whether
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
737 you can open files in a particular directory. Specify as an argument
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
738 either a directory name or a file name which names a directory file.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
739 The function returns @code{t} if you can open existing files in that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
740 directory.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
741
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
742 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
743 The new function @code{file-executable-p} returns @code{t} if its
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
744 argument is the name of a file you have permission to execute.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
745
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
746 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
747 The function @code{file-truename} returns the ``true name'' of a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
748 specified file. This is the name that you get by following symbolic
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
749 links until none remain. The argument must be an absolute file name.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
750
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
751 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
752 New functions @code{make-directory} and @code{delete-directory} create and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
753 delete directories. They both take one argument, which is the name of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
754 the directory as a file.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
755
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
756 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
757 The function @code{read-file-name} now takes an additional argument
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
758 which specifies an initial file name. If you specify this argument,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
759 @code{read-file-name} inserts it along with the directory name. It puts
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
760 the cursor between the directory and the initial file name.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
761
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
762 The user can then use the initial file name unchanged, modify it, or
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
763 simply kill it with @kbd{C-k}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
764
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
765 If the variable @code{insert-default-directory} is @code{nil}, then the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
766 default directory is not inserted, and the new argument is ignored.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
767
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
768 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
769 The function @code{file-relative-name} does the inverse of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
770 expansion---it tries to return a relative name which is equivalent to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
771 @var{filename} when interpreted relative to @var{directory}. (If such a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
772 relative name would be longer than the absolute name, it returns the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
773 absolute name instead.)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
774
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
775 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
776 The function @code{file-newest-backup} returns the name of the most
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
777 recent backup file for @var{filename}, or @code{nil} that file has no
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
778 backup files.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
779
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
780 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
781 The list returned by @code{file-attributes} now has 12 elements. The
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
782 12th element is the file system number of the file system that the file
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
783 is in. This element together with the file's inode number, which is the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
784 11th element, give enough information to distinguish any two files on
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
785 the system---no two files can have the same values for both of these
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
786 numbers.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
787
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
788 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
789 The new function @code{set-visited-file-modtime} updates the current
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
790 buffer's recorded modification time from the visited file's time.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
791
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
792 This is useful if the buffer was not read from the file normally, or
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
793 if the file itself has been changed for some known benign reason.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
794
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
795 If you give the function an argument, that argument specifies the new
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
796 value for the recorded modification time. The argument should be a list
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
797 of the form @code{(@var{high} . @var{low})} or @code{(@var{high}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
798 @var{low})} containing two integers, each of which holds 16 bits of the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
799 time. (This is the same format that @code[file-attributes} uses to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
800 return time values.)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
801
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
802 The new function @code{visited-file-modtime} returns the recorded last
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
803 modification time, in that same format.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
804
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
805 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
806 The function @code{directory-files} now takes an optional fourth
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
807 argument which, if non-@code{nil}, inhibits sorting the file names.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
808 Use this if you want the utmost possible speed and don't care what order
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
809 the files are processed in.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
810
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
811 If the order of processing is at all visible to the user, then the user
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
812 will probably be happier if you do sort the names.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
813
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
814 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
815 The variable @code{directory-abbrev-alist} contains an alist of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
816 abbreviations to use for file directories. Each element has the form
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
817 @code{(@var{from} . @var{to})}, and says to replace @var{from} with
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
818 @var{to} when it appears in a directory name. This replacement is done
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
819 when setting up the default directory of a newly visited file. The
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
820 @var{from} string is actually a regular expression; it should always
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
821 start with @samp{^}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
822
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
823 You can set this variable in @file{site-init.el} to describe the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
824 abbreviations appropriate for your site.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
825
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
826 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
827 The function @code{abbreviate-file-name} applies abbreviations from
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
828 @code{directory-abbrev-alist} to its argument, and substitutes @samp{~}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
829 for the user's home directory.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
830
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
831 Abbreviated directory names are useful for directories that are normally
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
832 accessed through symbolic links. If you think of the link's name as
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
833 ``the name'' of the directory, you can define it as an abbreviation for
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
834 the directory's official name; then ordinarily Emacs will call that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
835 directory by the link name you normally use.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
836
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
837 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
838 @code{write-region} can write a given string instead of text from the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
839 buffer. Use the string as the first argument (in place of the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
840 starting character position).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
841
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
842 You can supply a second file name as the fifth argument (@var{visit}).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
843 Use this to write the data to one file (the first argument,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
844 @var{filename}) while nominally visiting a different file (the fifth
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
845 argument, @var{visit}). The argument @var{visit} is used in the echo
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
846 area message and also for file locking; @var{visit} is stored in
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
847 @code{buffer-file-name}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
848
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
849 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
850 The value of @code{write-file-hooks} does not change when you switch to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
851 a new major mode. The intention is that these hooks have to do with
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
852 where the file came from, and not with what it contains.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
853
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
854 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
855 There is a new hook variable for saving files:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
856 @code{write-contents-hooks}. It works just like @code{write-file-hooks}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
857 except that switching to a new major mode clears it back to @code{nil}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
858 Major modes should use this hook variable rather than
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
859 @code{write-file-hooks}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
860
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
861 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
862 The hook @code{after-save-hook} runs just after a buffer has been saved
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
863 in its visited file.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
864
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
865 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
866 The new function @code{set-default-file-modes} sets the file protection
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
867 for new files created with Emacs. The argument must be an integer. (It
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
868 would be better to permit symbolic arguments like the @code{chmod}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
869 program, but that would take more work than this function merits.)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
870
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
871 Use the new function @code{default-file-modes} to read the current
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
872 default file mode.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
873
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
874 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
875 Call the new function @code{unix-sync} to force all pending disk output
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
876 to happen as soon as possible.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
877 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
878
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
879 @section Making Certain File Names ``Magic''
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
880
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
881 You can implement special handling for a class of file names. You must
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
882 supply a regular expression to define the class of names (all those
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
883 which match the regular expression), plus a handler that implements all
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
884 the primitive Emacs file operations for file names that do match.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
885
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
886 The value of @code{file-name-handler-alist} is a list of handlers,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
887 together with regular expressions that decide when to apply each
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
888 handler. Each element has the form @code{(@var{regexp}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
889 . @var{handler})}. If a file name matches @var{regexp}, then all work
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
890 on that file is done by calling @var{handler}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
891
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
892 All the Emacs primitives for file access and file name transformation
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
893 check the given file name against @code{file-name-handler-alist}, and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
894 call @var{handler} to do the work if appropriate. The first argument
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
895 given to @var{handler} is the name of the primitive; the remaining
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
896 arguments are the arguments that were passed to that primitive. (The
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
897 first of these arguments is typically the file name itself.) For
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
898 example, if you do this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
899
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
900 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
901 (file-exists-p @var{filename})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
902 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
903
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
904 @noindent
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
905 and @var{filename} has handler @var{handler}, then @var{handler} is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
906 called like this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
907
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
908 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
909 (funcall @var{handler} 'file-exists-p @var{filename})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
910 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
911
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
912 Here are the primitives that you can handle in this way:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
913
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
914 @quotation
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
915 @code{add-name-to-file}, @code{copy-file}, @code{delete-directory},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
916 @code{delete-file}, @code{directory-file-name}, @code{directory-files},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
917 @code{dired-compress-file}, @code{dired-uncache},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
918 @code{expand-file-name}, @code{file-accessible-directory-p},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
919 @code{file-attributes}, @code{file-directory-p},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
920 @code{file-executable-p}, @code{file-exists-p}, @code{file-local-copy},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
921 @code{file-modes}, @code{file-name-all-completions},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
922 @code{file-name-as-directory}, @code{file-name-completion},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
923 @code{file-name-directory}, @code{file-name-nondirectory},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
924 @code{file-name-sans-versions}, @code{file-newer-than-file-p},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
925 @code{file-readable-p}, @code{file-symlink-p}, @code{file-writable-p},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
926 @code{insert-directory}, @code{insert-file-contents},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
927 @code{make-directory}, @code{make-symbolic-link}, @code{rename-file},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
928 @code{set-file-modes}, @code{verify-visited-file-modtime},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
929 @code{write-region}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
930 @end quotation
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
931
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
932 The handler function must handle all of the above operations, and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
933 possibly others to be added in the future. Therefore, it should always
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
934 reinvoke the ordinary Lisp primitive when it receives an operation it
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
935 does not recognize. Here's one way to do this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
936
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
937 @smallexample
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
938 (defun my-file-handler (primitive &rest args)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
939 ;; @r{First check for the specific operations}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
940 ;; @r{that we have special handling for.}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
941 (cond ((eq operation 'insert-file-contents) @dots{})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
942 ((eq operation 'write-region) @dots{})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
943 @dots{}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
944 ;; @r{Handle any operation we don't know about.}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
945 (t (let (file-name-handler-alist)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
946 (apply operation args)))))
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
947 @end smallexample
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
948
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
949 The function @code{file-local-copy} copies file @var{filename} to the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
950 local site, if it isn't there already. If @var{filename} specifies a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
951 ``magic'' file name which programs outside Emacs cannot directly read or
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
952 write, this copies the contents to an ordinary file and returns that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
953 file's name.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
954
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
955 If @var{filename} is an ordinary file name, not magic, then this function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
956 does nothing and returns @code{nil}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
957
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
958 The function @code{unhandled-file-name-directory} is used to get a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
959 non-magic directory name from an arbitrary file name. It uses the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
960 directory part of the specified file name if that is not magic.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
961 Otherwise, it asks the file name's handler what to do.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
962
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
963 @section Frames
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
964 @cindex frame
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
965
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
966 Emacs now supports multiple X windows via a new data type known as a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
967 @dfn{frame}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
968
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
969 A frame is a rectangle on the screen that contains one or more Emacs
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
970 windows. Subdividing a frame works just like subdividing the screen in
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
971 earlier versions of Emacs.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
972
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
973 @cindex terminal frame
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
974 There are two kinds of frames: terminal frames and X window frames.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
975 Emacs creates one terminal frame when it starts up with no X display; it
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
976 uses Termcap or Terminfo to display using characters. There is no way
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
977 to create another terminal frame after startup. If Emacs has an X
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
978 display, it does not make a terminal frame, and there is none.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
979
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
980 @cindex X window frame
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
981 When you are using X windows, Emacs starts out with a single X window
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
982 frame. You can create any number of X window frames using
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
983 @code{make-frame}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
984
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
985 Use the predicate @code{framep} to determine whether a given Lisp object
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
986 is a frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
987
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
988 The function @code{redraw-frame} redisplays the entire contents of a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
989 given frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
990
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
991 @subsection Creating and Deleting Frames
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
992
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
993 Use @code{make-frame} to create a new frame (supported under X Windows
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
994 only). This is the only primitive for creating frames.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
995
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
996 @code{make-frame} takes just one argument, which is an alist
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
997 specifying frame parameters. Any parameters not mentioned in the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
998 argument alist default based on the value of @code{default-frame-alist};
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
999 parameters not specified there default from the standard X defaults file
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1000 and X resources.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1001
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1002 When you invoke Emacs, if you specify arguments for window appearance
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1003 and so forth, these go into @code{default-frame-alist} and that is how
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1004 they have their effect.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1005
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1006 You can specify the parameters for the initial startup X window frame by
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1007 setting @code{initial-frame-alist} in your @file{.emacs} file. If these
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1008 parameters specify a separate minibuffer-only frame, and you have not
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1009 created one, Emacs creates one for you, using the parameter values
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1010 specified in @code{minibuffer-frame-alist}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1011
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1012 You can specify the size and position of a frame using the frame
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1013 parameters @code{left}, @code{top}, @code{height} and @code{width}. You
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1014 must specify either both size parameters or neither. You must specify
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1015 either both position parameters or neither. The geometry parameters
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1016 that you don't specify are chosen by the window manager in its usual
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1017 fashion.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1018
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1019 The function @code{x-parse-geometry} converts a standard X windows
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1020 geometry string to an alist which you can use as part of the argument to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1021 @code{make-frame}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1022
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1023 Use the function @code{delete-frame} to eliminate a frame. Frames are
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1024 like buffers where deletion is concerned; a frame actually continues to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1025 exist as a Lisp object until it is deleted @emph{and} there are no
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1026 references to it, but once it is deleted, it has no further effect on
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1027 the screen.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1028
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1029 The function @code{frame-live-p} returns non-@code{nil} if the argument
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1030 (a frame) has not been deleted.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1031
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1032 @subsection Finding All Frames
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1033
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1034 The function @code{frame-list} returns a list of all the frames that have
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1035 not been deleted. It is analogous to @code{buffer-list}. The list that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1036 you get is newly created, so modifying the list doesn't have any effect
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1037 on the internals of Emacs. The function @code{visible-frame-list} returns
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1038 the list of just the frames that are visible.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1039
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1040 @code{next-frame} lets you cycle conveniently through all the frames from an
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1041 arbitrary starting point. Its first argument is a frame. Its second
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1042 argument @var{minibuf} says what to do about minibuffers:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1043
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1044 @table @asis
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1045 @item @code{nil}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1046 Exclude minibuffer-only frames.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1047 @item a window
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1048 Consider only the frames using that particular window as their
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1049 minibuffer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1050 @item anything else
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1051 Consider all frames.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1052 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1053
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1054 @subsection Frames and Windows
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1055
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1056 All the non-minibuffer windows in a frame are arranged in a tree of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1057 subdivisions; the root of this tree is available via the function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1058 @code{frame-root-window}. Each window is part of one and only one
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1059 frame; you can get the frame with @code{window-frame}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1060
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1061 At any time, exactly one window on any frame is @dfn{selected within the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1062 frame}. You can get the frame's current selected window with
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1063 @code{frame-selected-window}. The significance of this designation is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1064 that selecting the frame selects for Emacs as a whole the window
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1065 currently selected within that frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1066
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1067 Conversely, selecting a window for Emacs with @code{select-window} also
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1068 makes that window selected within its frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1069
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1070 @subsection Frame Visibility
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1071
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1072 A frame may be @dfn{visible}, @dfn{invisible}, or @dfn{iconified}. If
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1073 it is invisible, it doesn't show in the screen, not even as an icon.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1074 You can set the visibility status of a frame with
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1075 @code{make-frame-visible}, @code{make-frame-invisible}, and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1076 @code{iconify-frame}. You can examine the visibility status with
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1077 @code{frame-visible-p}---it returns @code{t} for a visible frame,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1078 @code{nil} for an invisible frame, and @code{icon} for an iconified
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1079 frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1080
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1081 @subsection Selected Frame
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1082
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1083 At any time, one frame in Emacs is the @dfn{selected frame}. The selected
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1084 window always resides on the selected frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1085
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1086 @defun selected-frame
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1087 This function returns the selected frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1088 @end defun
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1089
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1090 The X server normally directs keyboard input to the X window that the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1091 mouse is in. Some window managers use mouse clicks or keyboard events
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1092 to @dfn{shift the focus} to various X windows, overriding the normal
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1093 behavior of the server.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1094
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1095 Lisp programs can switch frames ``temporarily'' by calling the function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1096 @code{select-frame}. This does not override the window manager; rather,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1097 it escapes from the window manager's control until that control is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1098 somehow reasserted. The function takes one argument, a frame, and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1099 selects that frame. The selection lasts until the next time the user
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1100 does something to select a different frame, or until the next time this
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1101 function is called.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1102
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1103 Emacs cooperates with the X server and the window managers by arranging
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1104 to select frames according to what the server and window manager ask
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1105 for. It does so by generating a special kind of input event, called a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1106 @dfn{focus} event. The command loop handles a focus event by calling
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1107 @code{internal-select-frame}. @xref{Focus Events}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1108
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1109 @subsection Frame Size and Position
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1110
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1111 The new functions @code{frame-height} and @code{frame-width} return the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1112 height and width of a specified frame (or of the selected frame),
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1113 measured in characters.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1114
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1115 The new functions @code{frame-pixel-height} and @code{frame-pixel-width}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1116 return the height and width of a specified frame (or of the selected
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1117 frame), measured in pixels.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1118
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1119 The new functions @code{frame-char-height} and @code{frame-char-width}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1120 return the height and width of a character in a specified frame (or in
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1121 the selected frame), measured in pixels.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1122
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1123 @code{set-frame-size} sets the size of a frame, measured in characters;
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1124 its arguments are @var{frame}, @var{cols} and @var{rows}. To set the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1125 size with values measured in pixels, you can use
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1126 @code{modify-frame-parameters}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1127
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1128 The function @code{set-frame-position} sets the position of the top left
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1129 corner of a frame. Its arguments are @var{frame}, @var{left} and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1130 @var{top}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1131
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1132 @ignore
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1133 New functions @code{set-frame-height} and @code{set-frame-width} set the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1134 size of a specified frame. The frame is the first argument; the size is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1135 the second.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1136 @end ignore
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1137
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1138 @subsection Frame Parameters
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1139
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1140 A frame has many parameters that affect how it displays. Use the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1141 function @code{frame-parameters} to get an alist of all the parameters
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1142 of a given frame. To alter parameters, use
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1143 @code{modify-frame-parameters}, which takes two arguments: the frame to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1144 modify, and an alist of parameters to change and their new values. Each
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1145 element of @var{alist} has the form @code{(@var{parm} . @var{value})},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1146 where @var{parm} is a symbol. Parameters that aren't meaningful are
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1147 ignored. If you don't mention a parameter in @var{alist}, its value
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1148 doesn't change.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1149
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1150 Just what parameters a frame has depends on what display mechanism it
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1151 uses. Here is a table of the parameters of an X
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1152 window frame:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1153
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1154 @table @code
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1155 @item name
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1156 The name of the frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1157
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1158 @item left
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1159 The screen position of the left edge.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1160
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1161 @item top
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1162 The screen position of the top edge.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1163
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1164 @item height
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1165 The height of the frame contents, in pixels.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1166
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1167 @item width
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1168 The width of the frame contents, in pixels.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1169
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1170 @item window-id
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1171 The number of the X window for the frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1172
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1173 @item minibuffer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1174 Whether this frame has its own minibuffer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1175 @code{t} means yes, @code{none} means no,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1176 @code{only} means this frame is just a minibuffer,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1177 a minibuffer window (in some other frame)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1178 means the new frame uses that minibuffer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1179
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1180 @item font
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1181 The name of the font for the text.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1182
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1183 @item foreground-color
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1184 The color to use for the inside of a character.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1185 Use strings to designate colors;
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1186 X windows defines the meaningful color names.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1187
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1188 @item background-color
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1189 The color to use for the background of text.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1190
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1191 @item mouse-color
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1192 The color for the mouse cursor.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1193
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1194 @item cursor-color
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1195 The color for the cursor that shows point.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1196
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1197 @item border-color
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1198 The color for the border of the frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1199
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1200 @item cursor-type
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1201 The way to display the cursor. There are two legitimate values:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1202 @code{bar} and @code{box}. The value @code{bar} specifies a vertical
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1203 bar between characters as the cursor. The value @code{box} specifies an
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1204 ordinary black box overlaying the character after point; that is the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1205 default.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1206
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1207 @item icon-type
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1208 Non-@code{nil} for a bitmap icon, @code{nil} for a text icon.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1209
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1210 @item border-width
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1211 The width in pixels of the window border.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1212
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1213 @item internal-border-width
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1214 The distance in pixels between text and border.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1215
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1216 @item auto-raise
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1217 Non-@code{nil} means selecting the frame raises it.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1218
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1219 @item auto-lower
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1220 Non-@code{nil} means deselecting the frame lowers it.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1221
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1222 @item vertical-scrollbar
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1223 Non-@code{nil} gives the frame a scroll bar
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1224 for vertical scrolling.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1225
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1226 @item horizontal-scrollbar
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1227 Non-@code{nil} gives the frame a scroll bar
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1228 for horizontal scrolling.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1229 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1230
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1231 @subsection Minibufferless Frames
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1232
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1233 Normally, each frame has its own minibuffer window at the bottom, which
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1234 is used whenever that frame is selected. However, you can also create
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1235 frames with no minibuffers. These frames must use the minibuffer window
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1236 of some other frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1237
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1238 The variable @code{default-minibuffer-frame} specifies where to find a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1239 minibuffer for frames created without minibuffers of their own. Its
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1240 value should be a frame which does have a minibuffer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1241
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1242 You can also specify a minibuffer window explicitly when you create a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1243 frame; then @code{default-minibuffer-frame} is not used.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1244
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1245 @section X Windows Features
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1246
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1247 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1248 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1249 The new functions @code{mouse-position} and @code{set-mouse-position} give
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1250 access to the current position of the mouse.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1251
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1252 @code{mouse-position} returns a description of the position of the mouse.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1253 The value looks like @code{(@var{frame} @var{x} . @var{y})}, where @var{x}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1254 and @var{y} are measured in pixels relative to the top left corner of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1255 the inside of @var{frame}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1256
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1257 @code{set-mouse-position} takes three arguments, @var{frame}, @var{x}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1258 and @var{y}, and warps the mouse cursor to that location on the screen.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1259
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1260 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1261 @code{track-mouse} is a new special form for tracking mouse motion.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1262 Use it in definitions of mouse clicks that want pay to attention to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1263 the motion of the mouse, not just where the buttons are pressed and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1264 released. Here is how to use it:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1265
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1266 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1267 (track-mouse @var{body}@dots{})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1268 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1269
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1270 While @var{body} executes, mouse motion generates input events just as mouse
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1271 clicks do. @var{body} can read them with @code{read-event} or
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1272 @code{read-key-sequence}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1273
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1274 @code{track-mouse} returns the value of the last form in @var{body}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1275
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1276 The format of these events is described under ``New features for key
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1277 bindings and input.''
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1278 @c ???
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1279
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1280 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1281 @code{x-set-selection} sets a ``selection'' in the X Windows server.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1282 It takes two arguments: a selection type @var{type}, and the value to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1283 assign to it, @var{data}. If @var{data} is @code{nil}, it means to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1284 clear out the selection. Otherwise, @var{data} may be a string, a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1285 symbol, an integer (or a cons of two integers or list of two integers),
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1286 or a cons of two markers pointing to the same buffer. In the last case,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1287 the selection is considered to be the text between the markers. The
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1288 data may also be a vector of valid non-vector selection values.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1289
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1290 Each possible @var{type} has its own selection value, which changes
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1291 independently. The usual values of @var{type} are @code{PRIMARY} and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1292 @code{SECONDARY}; these are symbols with upper-case names, in accord
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1293 with X Windows conventions. The default is @code{PRIMARY}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1294
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1295 To get the value of the selection, call @code{x-get-selection}. This
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1296 function accesses selections set up by Emacs and those set up by other X
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1297 clients. It takes two optional arguments, @var{type} and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1298 @var{data-type}. The default for @var{type} is @code{PRIMARY}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1299
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1300 The @var{data-type} argument specifies the form of data conversion to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1301 use; meaningful values include @code{TEXT}, @code{STRING},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1302 @code{TARGETS}, @code{LENGTH}, @code{DELETE}, @code{FILE_NAME},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1303 @code{CHARACTER_POSITION}, @code{LINE_NUMBER}, @code{COLUMN_NUMBER},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1304 @code{OWNER_OS}, @code{HOST_NAME}, @code{USER}, @code{CLASS},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1305 @code{NAME}, @code{ATOM}, and @code{INTEGER}. (These are symbols with
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1306 upper-case names in accord with X Windows conventions.)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1307 The default for @var{data-type} is @code{STRING}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1308
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1309 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1310 X Windows has a set of numbered @dfn{cut buffers} which can store text
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1311 or other data being moved between applications. Use
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1312 @code{x-get-cut-buffer} to get the contents of a cut buffer; specify the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1313 cut buffer number as argument. Use @code{x-set-cut-buffer} with
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1314 argument @var{string} to store a new string into the first cut buffer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1315 (moving the other values down through the series of cut buffers,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1316 kill-ring-style).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1317
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1318 Cut buffers are considered obsolete in X Windows, but Emacs supports
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1319 them for the sake of X clients that still use them.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1320
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1321 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1322 You can close the connection with the X Windows server with
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1323 the function @code{x-close-current-connection}. This takes no arguments.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1324
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1325 Then you can connect to a different X Windows server with
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1326 @code{x-open-connection}. The first argument, @var{display}, is the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1327 name of the display to connect to.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1328
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1329 The optional second argument @var{xrm-string} is a string of resource
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1330 names and values, in the same format used in the @file{.Xresources}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1331 file. The values you specify override the resource values recorded in
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1332 the X Windows server itself. Here's an example of what this string
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1333 might look like:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1334
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1335 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1336 "*BorderWidth: 3\n*InternalBorder: 2\n"
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1337 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1338
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1339 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1340 A series of new functions give you information about the X server and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1341 the screen you are using.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1342
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1343 @table @code
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1344 @item x-display-screens
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1345 The number of screens associated with the current display.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1346
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1347 @item x-server-version
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1348 The version numbers of the X server in use.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1349
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1350 @item x-server-vendor
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1351 The vendor supporting the X server in use.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1352
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1353 @item x-display-pixel-height
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1354 The height of this X screen in pixels.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1355
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1356 @item x-display-mm-height
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1357 The height of this X screen in millimeters.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1358
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1359 @item x-display-pixel-width
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1360 The width of this X screen in pixels.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1361
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1362 @item x-display-mm-width
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1363 The width of this X screen in millimeters.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1364
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1365 @item x-display-backing-store
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1366 The backing store capability of this screen. Values can be the symbols
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1367 @code{always}, @code{when-mapped}, or @code{not-useful}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1368
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1369 @item x-display-save-under
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1370 Non-@code{nil} if this X screen supports the SaveUnder feature.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1371
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1372 @item x-display-planes
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1373 The number of planes this display supports.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1374
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1375 @item x-display-visual-class
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1376 The visual class for this X screen. The value is one of the symbols
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1377 @code{static-gray}, @code{gray-scale}, @code{static-color},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1378 @code{pseudo-color}, @code{true-color}, and @code{direct-color}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1379
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1380 @item x-display-color-p
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1381 @code{t} if the X screen in use is a color screen.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1382
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1383 @item x-display-color-cells
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1384 The number of color cells this X screen supports.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1385 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1386
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1387 There is also a variable @code{x-no-window-manager}, whose value is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1388 @code{t} if no X window manager is in use.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1389
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1390 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1391 The function @code{x-synchronize} enables or disables an X Windows
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1392 debugging mode: synchronous communication. It takes one argument,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1393 non-@code{nil} to enable the mode and @code{nil} to disable.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1394
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1395 In synchronous mode, Emacs waits for a response to each X protocol
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1396 command before doing anything else. This means that errors are reported
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1397 right away, and you can directly find the erroneous command.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1398 Synchronous mode is not the default because it is much slower.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1399
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1400 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1401 The function @code{x-get-resource} retrieves a resource value from the X
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1402 Windows defaults database. Its three arguments are @var{attribute},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1403 @var{name} and @var{class}. It searches using a key of the form
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1404 @samp{@var{instance}.@var{attribute}}, with class @samp{Emacs}, where
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1405 @var{instance} is the name under which Emacs was invoked.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1406
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1407 The optional arguments @var{component} and @var{subclass} add to the key
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1408 and the class, respectively. You must specify both of them or neither.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1409 If you specify them, the key is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1410 @samp{@var{instance}.@var{component}.@var{attribute}}, and the class is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1411 @samp{Emacs.@var{subclass}}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1412
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1413 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1414 @code{x-color-display-p} returns @code{t} if you are using an X Window
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1415 server with a color display, and @code{nil} otherwise.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1416
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1417 @c ??? Name being changed from x-defined-color.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1418 @code{x-color-defined-p} takes as argument a string describing a color; it
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1419 returns @code{t} if the display supports that color. (If the color is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1420 @code{"black"} or @code{"white"} then even black-and-white displays
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1421 support it.)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1422
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1423 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1424 @code{x-popup-menu} has been generalized. It now accepts a keymap as
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1425 the @var{menu} argument. Then the menu items are the prompt strings of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1426 individual key bindings, and the item values are the keys which have
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1427 those bindings.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1428
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1429 You can also supply a list of keymaps as the first argument; then each
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1430 keymap makes one menu pane (but keymaps that don't provide any menu
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1431 items don't appear in the menu at all).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1432
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1433 @code{x-popup-menu} also accepts a mouse button event as the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1434 @var{position} argument. Then it displays the menu at the location at
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1435 which the event took place. This is convenient for mouse-invoked
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1436 commands that pop up menus.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1437
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1438 @ignore
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1439 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1440 x-pointer-shape, x-nontext-pointer-shape, x-mode-pointer-shape.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1441 @end ignore
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1442
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1443 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1444 You can use the function @code{x-rebind-key} to change the sequence
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1445 of characters generated by one of the keyboard keys. This works
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1446 only with X Windows.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1447
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1448 The first two arguments, @var{keycode} and @var{shift-mask}, should be
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1449 numbers representing the keyboard code and shift mask respectively.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1450 They specify what key to change.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1451
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1452 The third argument, @var{newstring}, is the new definition of the key.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1453 It is a sequence of characters that the key should produce as input.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1454
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1455 The shift mask value is a combination of bits according to this table:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1456
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1457 @table @asis
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1458 @item 8
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1459 Control
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1460 @item 4
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1461 Meta
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1462 @item 2
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1463 Shift
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1464 @item 1
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1465 Shift Lock
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1466 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1467
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1468 If you specify @code{nil} for @var{shift-mask}, then the key specified
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1469 by @var{keycode} is redefined for all possible shift combinations.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1470
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1471 For the possible values of @var{keycode} and their meanings, see the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1472 file @file{/usr/lib/Xkeymap.txt}. Keep in mind that the codes in that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1473 file are in octal!
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1474
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1475 @ignore @c Presumably this is already fixed
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1476 NOTE: due to an X bug, this function will not take effect unless the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1477 user has a @file{~/.Xkeymap} file. (See the documentation for the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1478 @code{keycomp} program.) This problem will be fixed in X version 11.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1479 @end ignore
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1480
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1481 The related function @code{x-rebind-keys} redefines a single keyboard
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1482 key, specifying the behavior for each of the 16 shift masks
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1483 independently. The first argument is @var{keycode}, as in
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1484 @code{x-rebind-key}. The second argument @var{strings} is a list of 16
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1485 elements, one for each possible shift mask value; each element says how
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1486 to redefine the key @var{keycode} with the corresponding shift mask
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1487 value. If an element is a string, it is the new definition. If an
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1488 element is @code{nil}, the definition does not change for that shift
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1489 mask.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1490
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1491 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1492 The function @code{x-geometry} parses a string specifying window size
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1493 and position in the usual fashion for X windows. It returns an alist
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1494 describing which parameters were specified, and the values that were
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1495 given for them.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1496
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1497 The elements of the alist look like @code{(@var{parameter} .
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1498 @var{value})}. The possible @var{parameter} values are @code{left},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1499 @code{top}, @code{width}, and @code{height}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1500 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1501
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1502 @section New Window Features
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1503
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1504 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1505 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1506 The new function @code{window-at} tells you which window contains a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1507 given horizontal and vertical position on a specified frame. Call it
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1508 with three arguments, like this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1509
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1510 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1511 (window-at @var{x} @var{column} @var{frame})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1512 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1513
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1514 The function returns the window which contains that cursor position in
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1515 the frame @var{frame}. If you omit @var{frame}, the selected frame is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1516 used.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1517
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1518 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1519 The function @code{coordinates-in-window-p} takes two arguments and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1520 checks whether a particular frame position falls within a particular
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1521 window.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1522
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1523 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1524 (coordinates-in-window-p @var{coordinates} @var{window})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1525 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1526
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1527 The argument @var{coordinates} is a cons cell of this form:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1528
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1529 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1530 (@var{x} . @var{y})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1531 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1532
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1533 @noindent
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1534 The two coordinates are measured in characters, and count from the top
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1535 left corner of the screen or frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1536
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1537 The value of the function tells you what part of the window the position
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1538 is in. The possible values are:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1539
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1540 @table @code
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1541 @item (@var{relx} . @var{rely})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1542 The coordinates are inside @var{window}. The numbers @var{relx} and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1543 @var{rely} are equivalent window-relative coordinates, counting from 0
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1544 at the top left corner of the window.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1545
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1546 @item mode-line
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1547 The coordinates are in the mode line of @var{window}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1548
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1549 @item vertical-split
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1550 The coordinates are in the vertical line between @var{window} and its
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1551 neighbor to the right.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1552
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1553 @item nil
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1554 The coordinates are not in any sense within @var{window}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1555 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1556
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1557 You need not specify a frame when you call
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1558 @code{coordinates-in-window-p}, because it assumes you mean the frame
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1559 which window @var{window} is on.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1560
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1561 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1562 The function @code{minibuffer-window} now accepts a frame as argument
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1563 and returns the minibuffer window used for that frame. If you don't
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1564 specify a frame, the currently selected frame is used. The minibuffer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1565 window may be on the frame in question, but if that frame has no
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1566 minibuffer of its own, it uses the minibuffer window of some other
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1567 frame, and @code{minibuffer-window} returns that window.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1568
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1569 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1570 Use @code{window-live-p} to test whether a window is still alive (that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1571 is, not deleted).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1572
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1573 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1574 Use @code{window-minibuffer-p} to determine whether a given window is a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1575 minibuffer or not. It no longer works to do this by comparing the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1576 window with the result of @code{(minibuffer-window)}, because there can
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1577 be more than one minibuffer window at a time (if you have multiple
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1578 frames).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1579
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1580 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1581 If you set the variable @code{pop-up-frames} non-@code{nil}, then the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1582 functions to show something ``in another window'' actually create a new
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1583 frame for the new window. Thus, you will tend to have a frame for each
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1584 window, and you can easily have a frame for each buffer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1585
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1586 The value of the variable @code{pop-up-frame-function} controls how new
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1587 frames are made. The value should be a function which takes no
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1588 arguments and returns a frame. The default value is a function which
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1589 creates a frame using parameters from @code{pop-up-frame-alist}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1590
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1591 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1592 @code{display-buffer} is the basic primitive for finding a way to show a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1593 buffer on the screen. You can customize its behavior by storing a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1594 function in the variable @code{display-buffer-function}. If this
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1595 variable is non-@code{nil}, then @code{display-buffer} calls it to do
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1596 the work. Your function should accept two arguments, as follows:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1597
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1598 @table @var
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1599 @item buffer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1600 The buffer to be displayed.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1601
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1602 @item flag
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1603 A flag which, if non-@code{nil}, means you should find another window to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1604 display @var{buffer} in, even if it is already visible in the selected
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1605 window.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1606 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1607
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1608 The function you supply will be used by commands such as
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1609 @code{switch-to-buffer-other-window} and @code{find-file-other-window}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1610 as well as for your own calls to @code{display-buffer}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1611
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1612 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1613 @code{delete-window} now gives all of the deleted window's screen space
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1614 to a single neighboring window. Likewise, @code{enlarge-window} takes
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1615 space from only one neighboring window until that window disappears;
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1616 only then does it take from another window.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1617
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1618 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1619 @code{next-window} and @code{previous-window} accept another argument,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1620 @var{all-frames}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1621
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1622 These functions now take three optional arguments: @var{window},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1623 @var{minibuf} and @var{all-frames}. @var{window} is the window to start
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1624 from (@code{nil} means use the selected window). @var{minibuf} says
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1625 whether to include the minibuffer in the windows to cycle through:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1626 @code{t} means yes, @code{nil} means yes if it is active, and anything
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1627 else means no.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1628
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1629 Normally, these functions cycle through all the windows in the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1630 selected frame, plus the minibuffer used by the selected frame even if
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1631 it lies in some other frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1632
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1633 If @var{all-frames} is @code{t}, then these functions cycle through
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1634 all the windows in all the frames that currently exist. If
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1635 @var{all-frames} is neither @code{t} nor @code{nil}, then they limit
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1636 themselves strictly to the windows in the selected frame, excluding the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1637 minibuffer in use if it lies in some other frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1638
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1639 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1640 The functions @code{get-lru-window} and @code{get-largest-window} now
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1641 take an optional argument @var{all-frames}. If it is non-@code{nil},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1642 the functions consider all windows on all frames. Otherwise, they
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1643 consider just the windows on the selected frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1644
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1645 Likewise, @code{get-buffer-window} takes an optional second argument
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1646 @var{all-frames}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1647
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1648 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1649 The variable @code{other-window-scroll-buffer} specifies which buffer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1650 @code{scroll-other-window} should scroll.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1651
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1652 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1653 You can now mark a window as ``dedicated'' to its buffer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1654 Then Emacs will not try to use that window for any other buffer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1655 unless you explicitly request it.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1656
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1657 Use the new function @code{set-window-dedicated-p} to set the dedication
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1658 flag of a window @var{window} to the value @var{flag}. If @var{flag} is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1659 @code{t}, this makes the window dedicated. If @var{flag} is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1660 @code{nil}, this makes the window non-dedicated.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1661
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1662 Use @code{window-dedicated-p} to examine the dedication flag of a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1663 specified window.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1664
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1665 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1666 The new function @code{walk-windows} cycles through all visible
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1667 windows, calling @code{proc} once for each window with the window as
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1668 its sole argument.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1669
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1670 The optional second argument @var{minibuf} says whether to include minibuffer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1671 windows. A value of @code{t} means count the minibuffer window even if
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1672 not active. A value of @code{nil} means count it only if active. Any
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1673 other value means not to count the minibuffer even if it is active.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1674
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1675 If the optional third argument @var{all-frames} is @code{t}, that means
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1676 include all windows in all frames. If @var{all-frames} is @code{nil},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1677 it means to cycle within the selected frame, but include the minibuffer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1678 window (if @var{minibuf} says so) that that frame uses, even if it is on
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1679 another frame. If @var{all-frames} is neither @code{nil} nor @code{t},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1680 @code{walk-windows} sticks strictly to the selected frame.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1681
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1682 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1683 The function @code{window-end} is a counterpart to @code{window-start}:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1684 it returns the buffer position of the end of the display in a given
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1685 window (or the selected window).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1686
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1687 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1688 The function @code{window-configuration-p} returns non-@code{nil} when
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1689 given an object that is a window configuration (such as is returned by
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1690 @code{current-window-configuration}).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1691 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1692
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1693 @section Display Features
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1694
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1695 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1696 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1697 @samp{%l} as a mode line item displays the current line number.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1698
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1699 If the buffer is longer than @code{line-number-display-limit}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1700 characters, or if lines are too long in the viscinity of the current
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1701 displayed text, then line number display is inhibited to save time.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1702
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1703 The default contents of the mode line include the line number if
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1704 @code{line-number-mode} is non-@code{nil}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1705
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1706 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1707 @code{baud-rate} is now a variable rather than a function. This is so
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1708 you can set it to reflect the effective speed of your terminal, when the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1709 system doesn't accurately know the speed.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1710
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1711 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1712 You can now remove any echo area message and make the minibuffer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1713 visible. To do this, call @code{message} with @code{nil} as the only
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1714 argument. This clears any existing message, and lets the current
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1715 minibuffer contents show through. Previously, there was no reliable way
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1716 to make sure that the minibuffer contents were visible.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1717
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1718 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1719 The variable @code{temp-buffer-show-hook} has been renamed
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1720 @code{temp-buffer-show-function}, because its value is a single function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1721 (of one argument), not a normal hook.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1722
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1723 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1724 The new function @code{force-mode-line-update} causes redisplay
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1725 of the current buffer's mode line.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1726 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1727
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1728 @section Display Tables
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1729
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1730 @cindex display table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1731 You can use the @dfn{display table} feature to control how all 256
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1732 possible character codes display on the screen. This is useful for
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1733 displaying European languages that have letters not in the ASCII
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1734 character set.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1735
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1736 The display table maps each character code into a sequence of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1737 @dfn{glyphs}, each glyph being an image that takes up one character
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1738 position on the screen. You can also define how to display each glyph
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1739 on your terminal, using the @dfn{glyph table}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1740
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1741 @subsection Display Tables
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1742
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1743 Use @code{make-display-table} to create a display table. The table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1744 initially has @code{nil} in all elements.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1745
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1746 A display table is actually an array of 261 elements. The first 256
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1747 elements of a display table control how to display each possible text
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1748 character. The value should be @code{nil} or a vector (which is a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1749 sequence of glyphs; see below). @code{nil} as an element means to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1750 display that character following the usual display conventions.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1751
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1752 The remaining five elements of a display table serve special purposes
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1753 (@code{nil} means use the default stated below):
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1754
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1755 @table @asis
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1756 @item 256
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1757 The glyph for the end of a truncated screen line (the default for this
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1758 is @samp{\}).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1759 @item 257
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1760 The glyph for the end of a continued line (the default is @samp{$}).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1761 @item 258
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1762 The glyph for the indicating an octal character code (the default is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1763 @samp{\}).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1764 @item 259
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1765 The glyph for indicating a control characters (the default is @samp{^}).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1766 @item 260
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1767 The vector of glyphs for indicating the presence of invisible lines (the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1768 default is @samp{...}).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1769 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1770
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1771 Each buffer typically has its own display table. The display table for
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1772 the current buffer is stored in @code{buffer-display-table}. (This
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1773 variable automatically becomes local if you set it.) If this variable
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1774 is @code{nil}, the value of @code{standard-display-table} is used in
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1775 that buffer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1776
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1777 Each window can have its own display table, which overrides the display
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1778 table of the buffer it is showing.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1779
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1780 If neither the selected window nor the current buffer has a display
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1781 table, and if @code{standard-display-table} is @code{nil}, then Emacs
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1782 uses the usual display conventions:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1783
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1784 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1785 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1786 Character codes 32 through 127 map to glyph codes 32 through 127.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1787 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1788 Codes 0 through 31 map to sequences of two glyphs, where the first glyph
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1789 is the ASCII code for @samp{^}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1790 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1791 Character codes 128 through 255 map to sequences of four glyphs, where
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1792 the first glyph is the ASCII code for @samp{\}, and the others represent
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1793 digits.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1794 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1795
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1796 The usual display conventions are also used for any character whose
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1797 entry in the active display table is @code{nil}. This means that when
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1798 you set up a display table, you need not specify explicitly what to do
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1799 with each character, only the characters for which you want unusual
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1800 behavior.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1801
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1802 @subsection Glyphs
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1803
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1804 @cindex glyph
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1805 A glyph stands for an image that takes up a single character position on
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1806 the screen. A glyph is represented in Lisp as an integer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1807
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1808 @cindex glyph table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1809 The meaning of each integer, as a glyph, is defined by the glyph table,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1810 which is the value of the variable @code{glyph-table}. It should be a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1811 vector; the @var{g}th element defines glyph code @var{g}. The possible
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1812 definitions of a glyph code are:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1813
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1814 @table @var
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1815 @item integer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1816 Define this glyph code as an alias for code @var{integer}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1817 This is used with X windows to specify a face code.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1818
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1819 @item string
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1820 Send the characters in @var{string} to the terminal to output
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1821 this glyph. This alternative is not available with X Windows.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1822
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1823 @item @code{nil}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1824 This glyph is simple. On an ordinary terminal, the glyph code mod 256
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1825 is the character to output. With X, the glyph code mod 256 is character
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1826 to output, and the glyph code divided by 256 specifies the @dfn{face
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1827 code} to use while outputting it.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1828 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1829
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1830 Any glyph code beyond the length of the glyph table is automatically simple.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1831
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1832 A face code for X windows is the combination of a font and a color.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1833 Emacs uses integers to identify face codes. You can define a new face
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1834 code with @code{(x-set-face @var{face-code} @var{font} @var{foreground}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1835 @var{background})}. @var{face-code} is an integer from 0 to 255; it
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1836 specifies which face to define. The other three arguments are strings:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1837 @var{font} is the name of the font to use, and @var{foreground} and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1838 @var{background} specify the colors to use.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1839
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1840 If @code{glyph-table} is @code{nil}, then all possible glyph codes are
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1841 simple.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1842
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1843 @subsection ISO Latin 1
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1844
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1845 If you have a terminal that can handle the entire ISO Latin 1 character
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1846 set, you can arrange to use that character set as follows:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1847
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1848 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1849 (require 'disp-table)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1850 (standard-display-8bit 0 255)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1851 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1852
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1853 If you are editing buffers written in the ISO Latin 1 character set and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1854 your terminal doesn't handle anything but ASCII, you can load the file
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1855 @code{iso-ascii} to set up a display table which makes the other ISO
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1856 characters display as sequences of ASCII characters. For example, the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1857 character ``o with umlaut'' displays as @samp{@{"o@}}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1858
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1859 Some European countries have terminals that don't support ISO Latin 1
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1860 but do support the special characters for that country's language. You
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1861 can define a display table to work one language using such terminals.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1862 For an example, see @file{lisp/iso-swed.el}, which handles certain
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1863 Swedish terminals.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1864
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1865 You can load the appropriate display table for your terminal
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1866 automatically by writing a terminal-specific Lisp file for the terminal
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1867 type.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1868
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1869 @section New Input Event Formats
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1870
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1871 Mouse clicks, mouse movements and function keys no longer appear in the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1872 input stream as characters; instead, other kinds of Lisp objects
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1873 represent them as input.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1874
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1875 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1876 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1877 An ordinary input character event consists of a @dfn{basic code} between
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1878 0 and 255, plus any or all of these @dfn{modifier bits}:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1879
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1880 @table @asis
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1881 @item meta
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1882 The 2**23 bit in the character code indicates a character
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1883 typed with the meta key held down.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1884
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1885 @item control
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1886 The 2**22 bit in the character code indicates a non-@sc{ASCII}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1887 control character.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1888
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1889 @sc{ASCII} control characters such as @kbd{C-a} have special basic
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1890 codes of their own, so Emacs needs no special bit to indicate them.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1891 Thus, the code for @kbd{C-a} is just 1.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1892
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1893 But if you type a control combination not in @sc{ASCII}, such as
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1894 @kbd{%} with the control key, the numeric value you get is the code
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1895 for @kbd{%} plus 2**22 (assuming the terminal supports non-@sc{ASCII}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1896 control characters).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1897
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1898 @item shift
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1899 The 2**21 bit in the character code indicates an @sc{ASCII} control
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1900 character typed with the shift key held down.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1901
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1902 For letters, the basic code indicates upper versus lower case; for
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1903 digits and punctuation, the shift key selects an entirely different
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1904 character with a different basic code. In order to keep within
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1905 the @sc{ASCII} character set whenever possible, Emacs avoids using
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1906 the 2**21 bit for those characters.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1907
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1908 However, @sc{ASCII} provides no way to distinguish @kbd{C-A} from
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1909 @kbd{C-A}, so Emacs uses the 2**21 bit in @kbd{C-A} and not in
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1910 @kbd{C-a}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1911
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1912 @item hyper
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1913 The 2**20 bit in the character code indicates a character
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1914 typed with the hyper key held down.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1915
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1916 @item super
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1917 The 2**19 bit in the character code indicates a character
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1918 typed with the super key held down.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1919
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1920 @item alt
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1921 The 2**18 bit in the character code indicates a character typed with
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1922 the alt key held down. (On some terminals, the key labeled @key{ALT}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1923 is actually the meta key.)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1924 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1925
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1926 In the future, Emacs may support a larger range of basic codes. We may
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1927 also move the modifier bits to larger bit numbers. Therefore, you
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1928 should avoid mentioning specific bit numbers in your program. Instead,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1929 the way to test the modifier bits of a character is with the function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1930 @code{event-modifiers} (see below).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1931
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1932 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1933 Function keys are represented as symbols. The symbol's name is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1934 the function key's label. For example, pressing a key labeled @key{F1}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1935 places the symbol @code{f1} in the input stream.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1936
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1937 There are a few exceptions to the symbol naming convention:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1938
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1939 @table @asis
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1940 @item @code{kp-add}, @code{kp-decimal}, @code{kp-divide}, @dots{}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1941 Keypad keys (to the right of the regular keyboard).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1942 @item @code{kp-0}, @code{kp-1}, @dots{}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1943 Keypad keys with digits.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1944 @item @code{kp-f1}, @code{kp-f2}, @code{kp-f3}, @code{kp-f4}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1945 Keypad PF keys.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1946 @item @code{left}, @code{up}, @code{right}, @code{down}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1947 Cursor arrow keys
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1948 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1949
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1950 You can use the modifier keys @key{CTRL}, @key{META}, @key{HYPER},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1951 @key{SUPER}, @key{ALT} and @key{SHIFT} with function keys. The way
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1952 to represent them is with prefixes in the symbol name:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1953
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1954 @table @samp
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1955 @item A-
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1956 The alt modifier.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1957 @item C-
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1958 The control modifier.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1959 @item H-
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1960 The hyper modifier.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1961 @item M-
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1962 The meta modifier.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1963 @item s-
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1964 The super modifier.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1965 @item S-
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1966 The shift modifier.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1967 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1968
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1969 Thus, the symbol for the key @key{F3} with @key{META} held down is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1970 kbd{M-@key{F3}}. When you use more than one prefix, we recommend you
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1971 write them in alphabetical order (though the order does not matter in
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1972 arguments to the key-binding lookup and modification functions).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1973
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1974 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1975 Mouse events are represented as lists.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1976
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1977 If you press a mouse button and release it at the same location, this
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1978 generates a ``click'' event. Mouse click events have this form:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1979
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1980 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1981 (@var{button-symbol}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1982 (@var{window} (@var{column} . @var{row})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1983 @var{buffer-pos} @var{timestamp}))
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1984 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1985
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1986 Here is what the elements normally mean:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1987
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1988 @table @var
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1989 @item button-symbol
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1990 indicates which mouse button was used. It is one of the symbols
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1991 @code{mouse-1}, @code{mouse-2}, @dots{}, where the buttons are numbered
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1992 numbered left to right.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1993
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1994 You can also use prefixes @samp{A-}, @samp{C-}, @samp{H-}, @samp{M-},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1995 @samp{S-} and @samp{s-} for modifiers alt, control, hyper, meta, shift
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1996 and super, just as you would with function keys.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1997
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1998 @item window
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1999 is the window in which the click occurred.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2000
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2001 @item column
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2002 @itemx row
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2003 are the column and row of the click, relative to the top left corner of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2004 @var{window}, which is @code{(0 . 0)}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2005
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2006 @item buffer-pos
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2007 is the buffer position of the character clicked on.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2008
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2009 @item timestamp
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2010 is the time at which the event occurred, in milliseconds. (Since this
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2011 value wraps around the entire range of Emacs Lisp integers in about five
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2012 hours, it is useful only for relating the times of nearby events.)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2013 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2014
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2015 The meanings of @var{buffer-pos}, @var{row} and @var{column} are
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2016 somewhat different when the event location is in a special part of the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2017 screen, such as the mode line or a scroll bar.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2018
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2019 If the position is in the window's scroll bar, then @var{buffer-pos} is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2020 the symbol @code{vertical-scrollbar} or @code{horizontal-scrollbar}, and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2021 the pair @code{(@var{column} . @var{row})} is instead a pair
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2022 @code{(@var{portion} . @var{whole})}, where @var{portion} is the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2023 distance of the click from the top or left end of the scroll bar, and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2024 @var{whole} is the length of the entire scroll bar.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2025
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2026 If the position is on a mode line or the vertical line separating
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2027 @var{window} from its neighbor to the right, then @var{buffer-pos} is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2028 the symbol @code{mode-line} or @code{vertical-line}. In this case
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2029 @var{row} and @var{column} do not have meaningful data.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2030
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2031 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2032 Releasing a mouse button above a different character position
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2033 generates a ``drag'' event, which looks like this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2034
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2035 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2036 (@var{button-symbol}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2037 (@var{window1} (@var{column1} . @var{row1})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2038 @var{buffer-pos1} @var{timestamp1})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2039 (@var{window2} (@var{column2} . @var{row2})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2040 @var{buffer-pos2} @var{timestamp2}))
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2041 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2042
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2043 The name of @var{button-symbol} contains the prefix @samp{drag-}. The
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2044 second and third elements of the event give the starting and ending
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2045 position of the drag.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2046
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2047 The @samp{drag-} prefix follows the modifier key prefixes such as
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2048 @samp{C-} and @samp{M-}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2049
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2050 If @code{read-key-sequence} receives a drag event which has no key
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2051 binding, and the corresponding click event does have a binding, it
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2052 changes the drag event into a click event at the drag's starting
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2053 position. This means that you don't have to distinguish between click
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2054 and drag events unless you want to.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2055
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2056 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2057 Click and drag events happen when you release a mouse button. Another
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2058 kind of event happens when you press a button. It looks just like a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2059 click event, except that the name of @var{button-symbol} contains the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2060 prefix @samp{down-}. The @samp{down-} prefix follows the modifier key
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2061 prefixes such as @samp{C-} and @samp{M-}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2062
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2063 The function @code{read-key-sequence}, and the Emacs command loop,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2064 ignore any down events that don't have command bindings. This means
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2065 that you need not worry about defining down events unless you want them
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2066 to do something. The usual reason to define a down event is so that you
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2067 can track mouse motion until the button is released.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2068
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2069 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2070 For example, if the user presses and releases the left mouse button over
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2071 the same location, Emacs generates a sequence of events like this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2072
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2073 @smallexample
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2074 (down-mouse-1 (#<window 18 on NEWS> 2613 (0 . 38) -864320))
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2075 (mouse-1 (#<window 18 on NEWS> 2613 (0 . 38) -864180))
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2076 @end smallexample
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2077
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2078 Or, while holding the control key down, the user might hold down the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2079 second mouse button, and drag the mouse from one line to the next.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2080 That produces two events, as shown here:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2081
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2082 @smallexample
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2083 (C-down-mouse-2 (#<window 18 on NEWS> 3440 (0 . 27) -731219))
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2084 (C-drag-mouse-2 (#<window 18 on NEWS> 3440 (0 . 27) -731219)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2085 (#<window 18 on NEWS> 3510 (0 . 28) -729648))
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2086 @end smallexample
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2087
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2088 Or, while holding down the meta and shift keys, the user might press
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2089 the second mouse button on the window's mode line, and then drag the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2090 mouse into another window. That produces an event like this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2091
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2092 @smallexample
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2093 (M-S-down-mouse-2 (#<window 18 on NEWS> mode-line (33 . 31) -457844))
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2094 (M-S-drag-mouse-2 (#<window 18 on NEWS> mode-line (33 . 31) -457844)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2095 (#<window 20 on carlton-sanskrit.tex> 161 (33 . 3)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2096 -453816))
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2097 @end smallexample
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2098
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2099 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2100 A key sequence that starts with a mouse click is read using the keymaps
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2101 of the buffer in the window clicked on, not the current buffer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2102
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2103 This does not imply that clicking in a window selects that window or its
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2104 buffer. The execution of the command begins with no change in the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2105 selected window or current buffer. However, the command can switch
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2106 windows or buffers if programmed to do so.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2107
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2108 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2109 Mouse motion events are represented by lists. During the execution of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2110 the body of a @code{track-mouse} form, moving the mouse generates events
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2111 that look like this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2112
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2113 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2114 (mouse-movement (@var{window} (@var{column} . @var{row})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2115 @var{buffer-pos} @var{timestamp}))
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2116 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2117
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2118 The second element of the list describes the current position of the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2119 mouse, just as in a mouse click event.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2120
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2121 Outside of @code{track-mouse} forms, Emacs does not generate events for
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2122 mere motion of the mouse, and these events do not appear.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2123
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2124 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2125 Focus shifts between frames are represented by lists.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2126
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2127 When the mouse shifts temporary input focus from one frame to another,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2128 Emacs generates an event like this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2129
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2130 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2131 (switch-frame @var{new-frame})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2132 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2133
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2134 @noindent
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2135 where @var{new-frame} is the frame switched to.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2136
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2137 In X windows, most window managers are set up so that just moving the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2138 mouse into a window is enough to set the focus there. As far as the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2139 user concern, Emacs behaves consistently with this. However, there is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2140 no need for the Lisp program to know about the focus change until some
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2141 other kind of input arrives. So Emacs generates the focus event only
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2142 when the user actually types a keyboard key or presses a mouse button in
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2143 the new frame; just moving the mouse between frames does not generate a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2144 focus event.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2145
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2146 The global key map usually binds this event to the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2147 @code{internal-select-frame} function, so that characters typed at a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2148 frame apply to that frame's selected window.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2149
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2150 If the user switches frames in the middle of a key sequence, then Emacs
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2151 delays the @code{switch-frame} event until the key sequence is over.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2152 For example, suppose @kbd{C-c C-a} is a key sequence in the current
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2153 buffer's keymaps. If the user types @kbd{C-c}, moves the mouse to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2154 another frame, and then types @kbd{C-a}, @code{read-key-sequence}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2155 returns the sequence @code{"\C-c\C-a"}, and the next call to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2156 @code{read-event} or @code{read-key-sequence} will return the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2157 @code{switch-frame} event.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2158 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2159
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2160 @section Working with Input Events
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2161
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2162 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2163 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2164 Functions which work with key sequences now handle non-character
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2165 events. Functions like @code{define-key}, @code{global-set-key}, and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2166 @code{local-set-key} used to accept strings representing key sequences;
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2167 now, since events may be arbitrary lisp objects, they also accept
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2168 vectors. The function @code{read-key-sequence} may return a string or a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2169 vector, depending on whether or not the sequence read contains only
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2170 characters.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2171
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2172 List events may be represented by the symbols at their head; to bind
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2173 clicks of the left mouse button, you need only present the symbol
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2174 @code{mouse-1}, not an entire mouse click event. If you do put an event
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2175 which is a list in a key sequence, only the event's head symbol is used
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2176 in key lookups.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2177
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2178 For example, to globally bind the left mouse button to the function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2179 @code{mouse-set-point}, you could evaluate this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2180
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2181 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2182 (global-set-key [mouse-1] 'mouse-set-point)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2183 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2184
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2185 To bind the sequence @kbd{C-c @key{F1}} to the command @code{tex-view}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2186 in @code{tex-mode-map}, you could evaluate this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2187
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2188 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2189 (define-key tex-mode-map [?\C-c f1] 'tex-view)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2190 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2191
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2192 To find the binding for the function key labeled @key{NEXT} in
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2193 @code{minibuffer-local-map}, you could evaluate this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2194
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2195 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2196 (lookup-key minibuffer-local-map [next])
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2197 @result{} next-history-element
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2198 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2199
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2200 If you call the function @code{read-key-sequence} and then press
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2201 @kbd{C-x C-@key{F5}}, here is how it behaves:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2202
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2203 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2204 (read-key-sequence "Press `C-x C-F5': ")
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2205 @result{} [24 C-f5]
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2206 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2207
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2208 Note that @samp{24} is the character @kbd{C-x}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2209
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2210 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2211 The documentation functions (@code{single-key-description},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2212 @code{key-description}, etc.) now handle the new event types. Wherever
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2213 a string of keyboard input characters was acceptable in previous
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2214 versions of Emacs, a vector of events should now work.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2215
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2216 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2217 Special parts of a window can have their own bindings for mouse events.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2218
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2219 When mouse events occur in special parts of a window, such as a mode
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2220 line or a scroll bar, the event itself shows nothing special---only the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2221 symbol that would normally represent that mouse button and modifier
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2222 keys. The information about the screen region is kept in other parts
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2223 of the event list. But @code{read-key-sequence} translates this
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2224 information into imaginary prefix keys, all of which are symbols:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2225 @code{mode-line}, @code{vertical-line}, @code{horizontal-scrollbar} and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2226 @code{vertical-scrollbar}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2227
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2228 For example, if you call @code{read-key-sequence} and then click the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2229 mouse on the window's mode line, this is what happens:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2230
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2231 @smallexample
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2232 (read-key-sequence "Click on the mode line: ")
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2233 @result{} [mode-line (mouse-1 (#<window 6 on NEWS> mode-line
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2234 (40 . 63) 5959987))]
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2235 @end smallexample
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2236
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2237 You can define meanings for mouse clicks in special window regions by
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2238 defining key sequences using these imaginary prefix keys. For example,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2239 here is how to bind the third mouse button on a window's mode line
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2240 delete the window:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2241
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2242 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2243 (global-set-key [mode-line mouse-3] 'mouse-delete-window)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2244 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2245
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2246 Here's how to bind the middle button (modified by @key{META}) on the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2247 vertical line at the right of a window to scroll the window to the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2248 left.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2249
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2250 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2251 (global-set-key [vertical-line M-mouse-2] 'scroll-left)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2252 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2253
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2254 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2255 Decomposing an event symbol.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2256
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2257 Each symbol used to identify a function key or mouse button has a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2258 property named @code{event-symbol-elements}, which is a list containing
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2259 an unmodified version of the symbol, followed by modifiers the symbol
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2260 name contains. The modifiers are symbols; they include @code{shift},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2261 @code{control}, and @code{meta}. In addition, a mouse event symbol has
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2262 one of @code{click}, @code{drag}, and @code{down}. For example:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2263
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2264 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2265 (get 'f5 'event-symbol-elements)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2266 @result{} (f5)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2267 (get 'C-f5 'event-symbol-elements)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2268 @result{} (f5 control)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2269 (get 'M-S-f5 'event-symbol-elements)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2270 @result{} (f5 meta shift)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2271 (get 'mouse-1 'event-symbol-elements)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2272 @result{} (mouse-1 click)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2273 (get 'down-mouse-1 'event-symbol-elements)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2274 @result{} (mouse-1 down)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2275 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2276
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2277 Note that the @code{event-symbol-elements} property for a mouse click
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2278 explicitly contains @code{click}, but the event symbol name itself does
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2279 not contain @samp{click}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2280
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2281 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2282 Use @code{read-event} to read input if you want to accept any kind of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2283 event. The old function @code{read-char} now discards events other than
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2284 keyboard characters.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2285
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2286 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2287 @code{last-command-char} and @code{last-input-char} can now hold any
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2288 kind of event.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2289
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2290 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2291 The new variable @code{unread-command-events} is much like
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2292 @code{unread-command-char}. Its value is a list of events of any type,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2293 to be processed as command input in order of appearance in the list.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2294
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2295 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2296 The function @code{this-command-keys} may return a string or a vector,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2297 depending on whether or not the sequence read contains only characters.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2298 You may need to upgrade code which uses this function.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2299
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2300 The function @code{recent-keys} now returns a vector of events.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2301 You may need to upgrade code which uses this function.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2302
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2303 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2304 A keyboard macro's definition can now be either a string or a vector.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2305 All that really matters is what elements it has. If the elements are
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2306 all characters, then the macro can be a string; otherwise, it has to be
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2307 a vector.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2308
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2309 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2310 The variable @code{last-event-frame} records which frame the last input
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2311 event was directed to. Usually this is the frame that was selected when
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2312 the event was generated, but if that frame has redirected input focus to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2313 another frame, @code{last-event-frame} is the frame to which the event
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2314 was redirected.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2315
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2316 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2317 The interactive specification now allows a new code letter @samp{e} to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2318 simplify commands bound to events which are lists. This code supplies
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2319 as an argument the complete event object.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2320
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2321 You can use @samp{e} more than once in a single command's interactive
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2322 specification. If the key sequence which invoked the command has
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2323 @var{n} events with parameters, the @var{n}th @samp{e} provides the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2324 @var{n}th parameterized event. Events which are not lists, such as
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2325 function keys and ASCII keystrokes, do not count where @samp{e} is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2326 concerned.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2327
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2328 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2329 You can extract the starting and ending position values from a mouse
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2330 button or motion event using the two functions @code{event-start} and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2331 @code{event-end}. These two functions return different values for drag
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2332 and motion events; for click and button-down events, they both return
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2333 the position of the event.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2334
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2335 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2336 The position, a returned by @code{event-start} and @code{event-end}, is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2337 a list of this form:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2338
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2339 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2340 (@var{window} @var{buffer-position} (@var{col} . @var{row}) @var{timestamp})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2341 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2342
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2343 You can extract parts of this list with the functions
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2344 @code{posn-window}, @code{posn-point}, @code{posn-col-row}, and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2345 @code{posn-timestamp}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2346
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2347 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2348 The function @code{scroll-bar-scale} is useful for computing where to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2349 scroll to in response to a mouse button event from a scroll bar. It
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2350 takes two arguments, @var{ratio} and @var{total}, and in effect
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2351 multiplies them. We say ``in effect'' because @var{ratio} is not a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2352 number; rather a pair @code{(@var{num} . @var{denom}).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2353
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2354 Here's the usual way to use @code{scroll-bar-scale}:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2355
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2356 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2357 (scroll-bar-scale (posn-col-row (event-start event))
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2358 (buffer-size))
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2359 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2360 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2361
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2362 @section Putting Keyboard Events in Strings
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2363
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2364 In most of the places where strings are used, we conceptualize the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2365 string as containing text characters---the same kind of characters found
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2366 in buffers or files. Occasionally Lisp programs use strings which
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2367 conceptually contain keyboard characters; for example, they may be key
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2368 sequences or keyboard macro definitions. There are special rules for
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2369 how to put keyboard characters into a string, because they are not
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2370 limited to the range of 0 to 255 as text characters are.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2371
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2372 A keyboard character typed using the @key{META} key is called a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2373 @dfn{meta character}. The numeric code for such an event includes the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2374 2**23 bit; it does not even come close to fitting in a string. However,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2375 earlier Emacs versions used a different representation for these
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2376 characters, which gave them codes in the range of 128 to 255. That did
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2377 fit in a string, and many Lisp programs contain string constants that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2378 use @samp{\M-} to express meta characters, especially as the argument to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2379 @code{define-key} and similar functions.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2380
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2381 We provide backward compatibility to run those programs with special
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2382 rules for how to put a keyboard character event in a string. Here are
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2383 the rules:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2384
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2385 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2386 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2387 If the keyboard event value is in the range of 0 to 127, it can go in the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2388 string unchanged.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2389
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2390 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2391 The meta variants of those events, with codes in the range of 2**23 to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2392 2**23+127, can also go in the string, but you must change their numeric
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2393 values. You must set the 2**7 bit instead of the 2**23 bit, resulting
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2394 in a value between 128 and 255.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2395
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2396 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2397 Other keyboard character events cannot fit in a string. This includes
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2398 keyboard events in the range of 128 to 255.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2399 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2400
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2401 Functions such as @code{read-key-sequence} that can construct strings
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2402 containing events follow these rules.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2403
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2404 When you use the read syntax @samp{\M-} in a string, it produces a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2405 code in the range of 128 to 255---the same code that you get if you
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2406 modify the corresponding keyboard event to put it in the string. Thus,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2407 meta events in strings work consistently regardless of how they get into
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2408 the strings.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2409
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2410 New programs can avoid dealing with these rules by using vectors
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2411 instead of strings for key sequences when there is any possibility that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2412 these issues might arise.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2413
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2414 The reason we changed the representation of meta characters as
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2415 keyboard events is to make room for basic character codes beyond 127,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2416 and support meta variants of such larger character codes.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2417
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2418 @section Menus
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2419
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2420 You can now define menus conveniently as keymaps. Menus are normally
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2421 used with the mouse, but they can work with the keyboard also.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2422
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2423 @subsection Defining Menus
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2424
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2425 A keymap is suitable for menu use if it has an @dfn{overall prompt
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2426 string}, which is a string that appears as an element of the keymap. It
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2427 should describes the purpose of the menu. The easiest way to construct
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2428 a keymap with a prompt string is to specify the string as an argument
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2429 when you run @code{make-keymap} or @code{make-sparse-keymap}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2430
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2431 The individual bindings in the menu keymap should also have prompt
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2432 strings; these strings are the items in the menu. A binding with a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2433 prompt string looks like this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2434
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2435 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2436 (@var{char} @var{string} . @var{real-binding})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2437 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2438
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2439 As far as @code{define-key} is concerned, the string is part of the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2440 character's binding---the binding looks like this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2441
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2442 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2443 (@var{string} . @var{real-binding}).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2444 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2445
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2446 However, only @var{real-binding} is used for executing the key.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2447
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2448 You can also supply a second string, called the help string, as follows:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2449
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2450 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2451 (@var{char} @var{string} @var{help-string} . @var{real-binding})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2452 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2453
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2454 Currently Emacs does not actually use @var{help-string}; it knows only
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2455 how to ignore @var{help-string} in order to extract @var{real-binding}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2456 In the future we hope to make @var{help-string} serve as longer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2457 documentation for the menu item, available on request.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2458
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2459 The prompt string for a binding should be short---one or two words. Its
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2460 meaning should describe the command it corresponds to.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2461
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2462 If @var{real-binding} is @code{nil}, then @var{string} appears in the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2463 menu but cannot be selected.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2464
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2465 If @var{real-binding} is a symbol, and has a non-@code{nil}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2466 @code{menu-enable} property, that property is an expression which
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2467 controls whether the menu item is enabled. Every time the keymap is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2468 used to display a menu, Emacs evaluates the expression, and it enables
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2469 the menu item only if the expression's value is non-@code{nil}. When a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2470 menu item is disabled, it is displayed in a ``fuzzy'' fashion, and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2471 cannot be selected with the mouse.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2472
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2473 @subsection Menus and the Mouse
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2474
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2475 The way to make a menu keymap produce a menu is to make it the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2476 definition of a prefix key.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2477
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2478 When the prefix key ends with a mouse event, Emacs handles the menu
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2479 keymap by popping up a visible menu that you can select from with the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2480 mouse. When you click on a menu item, the event generated is whatever
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2481 character or symbol has the binding which brought about that menu item.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2482
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2483 A single keymap can appear as multiple panes, if you explicitly
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2484 arrange for this. The way to do this is to make a keymap for each
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2485 pane, then create a binding for each of those maps in the main keymap
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2486 of the menu. Give each of these bindings a prompt string that starts
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2487 with @samp{@@}. The rest of the prompt string becomes the name of the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2488 pane. See the file @file{lisp/mouse.el} for an example of this. Any
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2489 ordinary bindings with prompt strings are grouped into one pane, which
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2490 appears along with the other panes explicitly created for the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2491 submaps.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2492
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2493 You can also get multiple panes from separate keymaps. The full
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2494 definition of a prefix key always comes from merging the definitions
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2495 supplied by the various active keymaps (minor modes, local, and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2496 global). When more than one of these keymaps is a menu, each of them
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2497 makes a separate pane or panes.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2498
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2499 @subsection Menus and the Keyboard
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2500
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2501 When a prefix key ending with a keyboard event (a character or function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2502 key) has a definition that is a menu keymap, you can use the keyboard
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2503 to choose a menu item.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2504
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2505 Emacs displays the menu alternatives in the echo area. If they don't
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2506 all fit at once, type @key{SPC} to see the next line of alternatives.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2507 If you keep typing @key{SPC}, you eventually get to the end of the menu
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2508 and then cycle around to the beginning again.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2509
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2510 When you have found the alternative you want, type the corresponding
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2511 character---the one whose binding is that alternative.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2512
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2513 In a menu intended for keyboard use, each menu item must clearly
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2514 indicate what character to type. The best convention to use is to make
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2515 the character the first letter of the menu item prompt string. That is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2516 something users will understand without being told.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2517
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2518 @subsection The Menu Bar
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2519
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2520 Under X Windows, each frame can have a @dfn{menu bar}---a permanently
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2521 displayed menu stretching horizontally across the top of the frame. The
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2522 items of the menu bar are the subcommands of the fake ``function key''
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2523 @code{menu-bar}, as defined by all the active keymaps.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2524
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2525 To add an item to the menu bar, invent a fake ``function key'' of your
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2526 own (let's call it @var{key}), and make a binding for the key sequence
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2527 @code{[menu-bar @var{key}]}. Most often, the binding is a menu keymap,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2528 so that pressing a button on the menu bar item leads to another menu.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2529
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2530 In order for a frame to display a menu bar, its @code{menu-bar-lines}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2531 property must be greater than zero. Emacs uses just one line for the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2532 menu bar itself; if you specify more than one line, the other lines
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2533 serve to separate the menu bar from the windows in the frame. We
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2534 recommend you try one or two as the @code{menu-bar-lines} value.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2535
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2536 @section Keymaps
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2537
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2538 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2539 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2540 The representation of keymaps has changed to support the new event
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2541 types. All keymaps now have the form @code{(keymap @var{element}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2542 @var{element} @dots{})}. Each @var{element} takes one of the following
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2543 forms:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2544
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2545 @table @asis
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2546 @item @var{prompt-string}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2547 A string as an element of the keymap marks the keymap as a menu, and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2548 serves as the overal prompt string for it.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2549
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2550 @item @code{(@var{key} . @var{binding})}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2551 A cons cell binds @var{key} to @var{definition}. Here @var{key} may be
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2552 any sort of event head---a character, a function key symbol, or a mouse
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2553 button symbol.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2554
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2555 @item @var{vector}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2556 A vector of 128 elements binds all the ASCII characters; the @var{n}th
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2557 element holds the binding for character number @var{n}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2558
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2559 @item @code{(t . @var{binding})}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2560 A cons cell whose @sc{car} is @code{t} is a default binding; anything
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2561 not bound by previous keymap elements is given @var{binding} as its
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2562 binding.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2563
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2564 Default bindings are important because they allow a keymap to bind all
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2565 possible events without having to enumerate all the possible function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2566 keys and mouse clicks, with all possible modifier prefixes.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2567
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2568 The function @code{lookup-key} (and likewise other functions for
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2569 examining a key binding) normally report only explicit bindings of the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2570 specified key sequence; if there is none, they return @code{nil}, even
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2571 if there is a default binding that would apply to that key sequence if
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2572 it were actually typed in. However, these functions now take an
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2573 optional argument @var{accept-defaults} which, if non-@code{nil}, says
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2574 to consider default bindings.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2575
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2576 Note that if a vector in the keymap binds an ASCII character to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2577 @code{nil} (thus making it ``unbound''), the default binding does not
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2578 apply to the character. Think of the vector element as an explicit
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2579 binding of @code{nil}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2580
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2581 Note also that if the keymap for a minor or major mode contains a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2582 default binding, it completely masks out any lower-priority keymaps.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2583 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2584
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2585 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2586 A keymap can now inherit from another keymap. Do do this, make the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2587 latter keymap the ``tail'' of the new one. Such a keymap looks like
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2588 this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2589
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2590 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2591 (keymap @var{bindings}@dots{} . @var{other-keymap})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2592 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2593
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2594 The effect is that this keymap inherits all the bindings of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2595 @var{other-keymap}, but can add to them or override them with
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2596 @var{bindings}. Subsequent changes in the bindings of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2597 @var{other-keymap} @emph{do} affect this keymap.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2598
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2599 For example,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2600
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2601 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2602 (setq my-mode-map (cons 'keymap text-mode-map))
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2603 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2604
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2605 @noindent
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2606 makes a keymap that by default inherits all the bindings of Text
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2607 mode---whatever they may be at the time a key is looked up. Any
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2608 bindings made explicitly in @code{my-mode-map} override the bindings
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2609 inherited from Text mode, however.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2610
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2611 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2612 Minor modes can now have local keymaps. Thus, a key can act a special
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2613 way when a minor mode is in effect, and then revert to the major mode or
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2614 global definition when the minor mode is no longer in effect. The
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2615 precedence of keymaps is now: minor modes (in no particular order), then
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2616 major mode, and lastly the global map.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2617
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2618 The new @code{current-minor-mode-maps} function returns a list of all
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2619 the keymaps of currently enabled minor modes, in the other that they
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2620 apply.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2621
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2622 To set up a keymap for a minor mode, add an element to the alist
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2623 @code{minor-mode-map-alist}. Its elements look like this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2624
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2625 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2626 (@var{symbol} . @var{keymap})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2627 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2628
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2629 The keymap @var{keymap} is active whenever @var{symbol} has a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2630 non-@code{nil} value. Use for @var{symbol} the variable which indicates
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2631 whether the minor mode is enabled.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2632
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2633 When more than one minor mode keymap is active, their order of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2634 precedence is the order of @code{minor-mode-map-alist}. But you should
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2635 design minor modes so that they don't interfere with each other, and if
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2636 you do this properly, the order will not matter.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2637
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2638 The function @code{minor-mode-key-binding} returns a list of all the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2639 active minor mode bindings of @var{key}. More precisely, it returns an
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2640 alist of pairs @code{(@var{modename} . @var{binding})}, where
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2641 @var{modename} is the the variable which enables the minor mode, and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2642 @var{binding} is @var{key}'s definition in that mode. If @var{key} has
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2643 no minor-mode bindings, the value is @code{nil}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2644
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2645 If the first binding is a non-prefix, all subsequent bindings from other
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2646 minor modes are omitted, since they would be completely shadowed.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2647 Similarly, the list omits non-prefix bindings that follow prefix
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2648 bindings.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2649
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2650 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2651 The new function @code{copy-keymap} copies a keymap, producing a new
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2652 keymap with the same key bindings in it. If the keymap contains other
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2653 keymaps directly, these subkeymaps are copied recursively.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2654
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2655 If you want to, you can define a prefix key with a binding that is a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2656 symbol whose function definition is another keymap. In this case,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2657 @code{copy-keymap} does not look past the symbol; it doesn't copy the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2658 keymap inside the symbol.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2659
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2660 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2661 @code{substitute-key-definition} now accepts an optional fourth
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2662 argument, which is a keymap to use as a template.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2663
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2664 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2665 (substitute-key-definition olddef newdef keymap oldmap)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2666 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2667
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2668 @noindent
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2669 finds all characters defined in @var{oldmap} as @var{olddef},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2670 and defines them in @var{keymap} as @var{newdef}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2671
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2672 In addition, this function now operates recursively on the keymaps that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2673 define prefix keys within @var{keymap} and @var{oldmap}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2674 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2675
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2676 @section Minibuffer Features
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2677
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2678 The minibuffer input functions @code{read-from-minibuffer} and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2679 @code{completing-read} have new features.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2680
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2681 @subsection Minibuffer History
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2682
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2683 A new optional argument @var{hist} specifies which history list to use.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2684 If you specify a variable (a symbol), that variable is the history
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2685 list. If you specify a cons cell @code{(@var{variable}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2686 . @var{startpos})}, then @var{variable} is the history list variable,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2687 and @var{startpos} specifies the initial history position (an integer,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2688 counting from zero which specifies the most recent element of the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2689 history).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2690
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2691 If you specify @var{startpos}, then you should also specify that element
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2692 of the history as @var{initial-input}, for consistency.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2693
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2694 If you don't specify @var{hist}, then the default history list
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2695 @code{minibuffer-history} is used. Other standard history lists that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2696 you can use when appropriate include @code{query-replace-history},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2697 @code{command-history}, and @code{file-name-history}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2698
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2699 The value of the history list variable is a list of strings, most recent
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2700 first. You should set a history list variable to @code{nil} before
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2701 using it for the first time.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2702
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2703 @code{read-from-minibuffer} and @code{completing-read} add new elements
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2704 to the history list automatically, and provide commands to allow the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2705 user to reuse items on the list. The only thing your program needs to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2706 do to use a history list is to initialize it and to pass its name to the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2707 input functions when you wish. But it is safe to modify the list by
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2708 hand when the minibuffer input functions are not using it.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2709
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2710 @subsection Other Minibuffer Features
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2711
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2712 The @var{initial} argument to @code{read-from-minibufer} and other
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2713 minibuffer input functions can now be a cons cell @code{(@var{string}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2714 . @var{position})}. This means to start off with @var{string} in the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2715 minibuffer, but put the cursor @var{position} characters from the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2716 beginning, rather than at the end.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2717
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2718 In @code{read-no-blanks-input}, the @var{initial} argument is now
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2719 optional; if it is omitted, the initial input string is the empty
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2720 string.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2721
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2722 @section New Features for Defining Commands
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2723
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2724 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2725 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2726 If the interactive specification begins with @samp{@@}, this means to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2727 select the window under the mouse. This selection takes place before
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2728 doing anything else with the command.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2729
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2730 You can use both @samp{@@} and @samp{*} together in one command; they
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2731 are processed in order of appearance.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2732
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2733 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2734 Prompts in an interactive specification can incorporate the values of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2735 the preceding arguments. Emacs replaces @samp{%}-sequences (as used
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2736 with the @code{format} function) in the prompt with the interactive
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2737 arguments that have been read so far. For example, a command with this
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2738 interactive specification
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2739
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2740 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2741 (interactive "sReplace: \nsReplace %s with: ")
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2742 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2743
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2744 @noindent
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2745 prompts for the first argument with @samp{Replace: }, and then prompts
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2746 for the second argument with @samp{Replace @var{foo} with: }, where
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2747 @var{foo} is the string read as the first argument.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2748
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2749 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2750 If a command name has a property @code{enable-recursive-minibuffers}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2751 which is non-@code{nil}, then the command can use the minibuffer to read
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2752 arguments even if it is invoked from the minibuffer. The minibuffer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2753 command @code{next-matching-history-element} (normally bound to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2754 @kbd{M-s} in the minibuffer) uses this feature.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2755 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2756
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2757 @section New Features for Reading Input
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2758
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2759 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2760 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2761 The function @code{set-input-mode} now takes four arguments. The last
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2762 argument is optional. Their names are @var{interrupt}, @var{flow},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2763 @var{meta} and @var{quit}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2764
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2765 The argument @var{interrupt} says whether to use interrupt-driven
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2766 input. Non-@code{nil} means yes, and @code{nil} means no (use CBREAK
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2767 mode).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2768
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2769 The argument @var{flow} says whether to enable terminal flow control.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2770 Non-@code{nil} means yes.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2771
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2772 The argument @var{meta} says whether to enable the use of a Meta key.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2773 Non-@code{nil} means yes.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2774
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2775 If @var{quit} non-@code{nil}, it is the character to use for quitting.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2776 (Normally this is @kbd{C-g}.)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2777
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2778 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2779 The variable @code{meta-flag} has been deleted; use
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2780 @code{set-input-mode} to enable or disable support for a @key{META}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2781 key. This change was made because @code{set-input-mode} can send the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2782 terminal the appropriate commands to enable or disable operation of the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2783 @key{META} key.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2784
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2785 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2786 The new variable @code{extra-keyboard-modifiers} lets Lisp programs
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2787 ``press'' the modifier keys on the keyboard.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2788 The value is a bit mask:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2789
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2790 @table @asis
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2791 @item 1
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2792 The @key{SHIFT} key.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2793 @item 2
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2794 The @key{LOCK} key.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2795 @item 4
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2796 The @key{CTL} key.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2797 @item 8
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2798 The @key{META} key.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2799 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2800
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2801 When you use X windows, the program can press any of the modifier keys
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2802 in this way. Otherwise, only the @key{CTL} and @key{META} keys can be
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2803 virtually pressed.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2804
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2805 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2806 You can use the new function @code{keyboard-translate} to set up
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2807 @code{keyboard-translate-table} conveniently.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2808
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2809 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2810 Y-or-n questions using the @code{y-or-n-p} function now accept @kbd{C-]}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2811 (usually mapped to @code{abort-recursive-edit}) as well as @kbd{C-g} to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2812 quit.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2813
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2814 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2815 The variable @code{num-input-keys} is the total number of key sequences
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2816 that the user has typed during this Emacs session.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2817
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2818 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2819 A new Lisp variable, @code{function-key-map}, holds a keymap which
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2820 describes the character sequences sent by function keys on an ordinary
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2821 character terminal. This uses the same keymap data structure that is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2822 used to hold bindings of key sequences, but it has a different meaning:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2823 it specifies translations to make while reading a key sequence.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2824
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2825 If @code{function-key-map} ``binds'' a key sequence @var{k} to a vector
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2826 @var{v}, then when @var{k} appears as a subsequence @emph{anywhere} in a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2827 key sequence, it is replaced with @var{v}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2828
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2829 For example, VT100 terminals send @kbd{@key{ESC} O P} when the ``keypad''
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2830 PF1 key is pressed. Thus, on a VT100, @code{function-key-map} should
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2831 ``bind'' that sequence to @code{[pf1]}. This specifies translation of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2832 @kbd{@key{ESC} O P} into @key{PF1} anywhere in a key sequence.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2833
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2834 Thus, typing @kbd{C-c @key{PF1}} sends the character sequence @kbd{C-c
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2835 @key{ESC} O P}, but @code{read-key-sequence} translates this back into
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2836 @kbd{C-c @key{PF1}}, which it returns as the vector @code{[?\C-c PF1]}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2837
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2838 Entries in @code{function-key-map} are ignored if they conflict with
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2839 bindings made in the minor mode, local, or global keymaps.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2840
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2841 The value of @code{function-key-map} is usually set up automatically
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2842 according to the terminal's Terminfo or Termcap entry, and the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2843 terminal-specific Lisp files. Emacs comes with a number of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2844 terminal-specific files for many common terminals; their main purpose is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2845 to make entries in @code{function-key-map} beyond those that can be
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2846 deduced from Termcap and Terminfo.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2847
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2848 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2849 The variable @code{key-translation-map} works like @code{function-key-map}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2850 except for two things:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2851
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2852 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2853 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2854 @code{key-translation-map} goes to work after @code{function-key-map} is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2855 finished; it receives the results of translation by
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2856 @code{function-key-map}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2857
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2858 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2859 @code{key-translation-map} overrides actual key bindings.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2860 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2861
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2862 The intent of @code{key-translation-map} is for users to map one
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2863 character set to another, including ordinary characters normally bound
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2864 to @code{self-insert-command}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2865 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2866
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2867 @section New Syntax Table Features
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2868
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2869 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2870 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2871 You can use two new functions to move across characters in certain
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2872 syntax classes.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2873
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2874 @code{skip-syntax-forward} moves point forward across characters whose
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2875 syntax classes are mentioned in its first argument, a string. It stops
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2876 when it encounters the end of the buffer, or position @var{lim} (the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2877 optional second argument), or a character it is not supposed to skip.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2878 The function @code{skip-syntax-backward} is similar but moves backward.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2879
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2880 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2881 The new function @code{forward-comment} moves point by comments. It
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2882 takes one argument, @var{count}; it moves point forward across
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2883 @var{count} comments (backward, if @var{count} is negative). If it
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2884 finds anything other than a comment or whitespace, it stops, leaving
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2885 point at the far side of the last comment found. It also stops after
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2886 satisfying @var{count}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2887
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2888 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2889 The new variable @code{words-include-escapes} affects the behavior of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2890 @code{forward-word} and everything that uses it. If it is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2891 non-@code{nil}, then characters in the ``escape'' and ``character
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2892 quote'' syntax classes count as part of words.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2893
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2894 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2895 There are two new syntax flags for use in syntax tables.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2896
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2897 @itemize -
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2898 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2899 The prefix flag.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2900
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2901 The @samp{p} flag identifies additional ``prefix characters'' in Lisp
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2902 syntax. You can set this flag with @code{modify-syntax-entry} by
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2903 including the letter @samp{p} in the syntax specification.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2904
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2905 These characters are treated as whitespace when they appear between
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2906 expressions. When they appear withing an expression, they are handled
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2907 according to their usual syntax codes.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2908
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2909 The function @code{backward-prefix-chars} moves back over these
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2910 characters, as well as over characters whose primary syntax class is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2911 prefix (@samp{'}).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2912
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2913 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2914 The @samp{b} comment style flag.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2915
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2916 Emacs can now supports two comment styles simultaneously. (This is for
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2917 the sake of C++.) More specifically, it can recognize two different
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2918 comment-start sequences. Both must share the same first character; only
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2919 the second character may differ. Mark the second character of the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2920 @samp{b}-style comment start sequence with the @samp{b} flag. You can
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2921 set this flag with @code{modify-syntax-entry} by including the letter
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2922 @samp{b} in the syntax specification.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2923
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2924 The two styles of comment can have different comment-end sequences. A
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2925 comment-end sequence (one or two characters) applies to the @samp{b}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2926 style if its first character has the @samp{b} flag set; otherwise, it
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2927 applies to the @samp{a} style.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2928
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2929 The appropriate comment syntax settings for C++ are as follows:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2930
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2931 @table @asis
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2932 @item @samp{/}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2933 @samp{124b}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2934 @item @samp{*}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2935 @samp{23}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2936 @item newline
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2937 @samp{>b}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2938 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2939
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2940 Thus @samp{/*} is a comment-start sequence for @samp{a} style, @samp{//}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2941 is a comment-start sequence for @samp{b} style, @samp{*/} is a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2942 comment-end sequence for @samp{a} style, and newline is a comment-end
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2943 sequence for @samp{b} style.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2944 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2945 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2946
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2947 @section The Case Table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2948
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2949 You can customize case conversion using the new case table feature. A
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2950 case table is a collection of strings that specifies the mapping between
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2951 upper case and lower case letters. Each buffer has its own case table.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2952 You need a case table if you are using a language which has letters that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2953 are not standard ASCII letters.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2954
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2955 A case table is a list of this form:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2956
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2957 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2958 (@var{downcase} @var{upcase} @var{canonicalize} @var{equivalences})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2959 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2960
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2961 @noindent
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2962 where each element is either @code{nil} or a string of length 256. The
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2963 element @var{downcase} says how to map each character to its lower-case
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2964 equivalent. The element @var{upcase} maps each character to its
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2965 upper-case equivalent. If lower and upper case characters are in 1-1
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2966 correspondence, use @code{nil} for @var{upcase}; then Emacs deduces the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2967 upcase table from @var{downcase}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2968
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2969 For some languages, upper and lower case letters are not in 1-1
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2970 correspondence. There may be two different lower case letters with the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2971 same upper case equivalent. In these cases, you need to specify the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2972 maps for both directions.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2973
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2974 The element @var{canonicalize} maps each character to a canonical
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2975 equivalent; any two characters that are related by case-conversion have
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2976 the same canonical equivalent character.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2977
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2978 The element @var{equivalences} is a map that cyclicly permutes each
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2979 equivalence class (of characters with the same canonical equivalent).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2980
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2981 You can provide @code{nil} for both @var{canonicalize} and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2982 @var{equivalences}, in which case both are deduced from @var{downcase}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2983 and @var{upcase}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2984
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2985 Here are the functions for working with case tables:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2986
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2987 @code{case-table-p} is a predicate that says whether a Lisp object is a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2988 valid case table.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2989
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2990 @code{set-standard-case-table} takes one argument and makes that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2991 argument the case table for new buffers created subsequently.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2992 @code{standard-case-table} returns the current value of the new buffer
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2993 case table.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2994
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2995 @code{current-case-table} returns the case table of the current buffer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2996 @code{set-case-table} sets the current buffer's case table to the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2997 argument.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2998
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2999 @code{set-case-syntax-pair} is a convenient function for specifying a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3000 pair of letters, upper case and lower case. Call it with two arguments,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3001 the upper case letter and the lower case letter. It modifies the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3002 standard case table and a few syntax tables that are predefined in
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3003 Emacs. This function is intended as a subroutine for packages that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3004 define non-ASCII character sets.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3005
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3006 Load the library @file{iso-syntax} to set up the syntax and case table for
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3007 the 256 bit ISO Latin 1 character set.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3008
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3009 @section New Features for Dealing with Buffers
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3010
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3011 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3012 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3013 The new function @code{buffer-modified-tick} returns a buffer's
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3014 modification-count that ticks every time the buffer is modified. It
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3015 takes one optional argument, which is the buffer you want to examine.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3016 If the argument is @code{nil} (or omitted), the current buffer is used.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3017
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3018 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3019 @code{buffer-disable-undo} is a new name for the function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3020 formerly known as @code{buffer-flush-undo}. This turns off recording
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3021 of undo information in the buffer given as argument.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3022
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3023 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3024 The new function @code{generate-new-buffer-name} chooses a name that
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3025 would be unique for a new buffer---but does not create the buffer. Give
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3026 it one argument, a starting name. It produces a name not in use for a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3027 buffer by appending a number inside of @samp{<@dots{}>}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3028
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3029 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3030 The function @code{rename-buffer} now takes an option second argument
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3031 which tells it that if the specified new name corresponds to an existing
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3032 buffer, it should use @code{generate-new-buffer-name} to modify the name
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3033 to be unique, rather than signaling an error.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3034
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3035 @code{rename-buffer} now returns the name to which the buffer was
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3036 renamed.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3037
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3038 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3039 The function @code{list-buffers} now looks at the local variable
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3040 @code{list-buffers-directory} in each non-file-visiting buffer, and
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3041 shows its value where the file would normally go. Dired sets this
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3042 variable in each Dired buffer, so the buffer list now shows which
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3043 directory each Dired buffer is editing.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3044
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3045 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3046 The function @code{other-buffer} now takes an optional second argument
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3047 @var{visible-ok} which, if non-@code{nil}, indicates that buffers
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3048 currently being displayed in windows may be returned even if there are
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3049 other buffers not visible. Normally, @code{other-buffer} returns a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3050 currently visible buffer only as a last resort, if there are no suitable
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3051 nonvisible buffers.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3052
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3053 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3054 The hook @code{kill-buffer-hook} now runs whenever a buffer is killed.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3055 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3056
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3057 @section Local Variables Features
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3058
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3059 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3060 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3061 If a local variable name has a non-@code{nil} @code{permanent-local}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3062 property, then @code{kill-all-local-variables} does not kill it. Such
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3063 local variables are ``permanent''---they remain unchanged even if you
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3064 select a different major mode.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3065
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3066 Permanent locals are useful when they have to do with where the file
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3067 came from or how to save it, rather than with how to edit the contents.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3068
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3069 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3070 The function @code{make-local-variable} now never changes the value of the variable
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3071 that it makes local. If the variable had no value before, it still has
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3072 no value after becoming local.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3073
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3074 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3075 The new function @code{default-boundp} tells you whether a variable has
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3076 a default value (as opposed to being unbound in its default value). If
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3077 @code{(default-boundp 'foo)} returns @code{nil}, then
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3078 @code{(default-value 'foo)} would get an error.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3079
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3080 @code{default-boundp} is to @code{default-value} as @code{boundp} is to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3081 @code{symbol-value}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3082
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3083 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3084 The special forms @code{defconst} and @code{defvar}, when the variable
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3085 is local in the current buffer, now set the variable's default value
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3086 rather than its local value.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3087 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3088
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3089 @section New Features for Subprocesses
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3090
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3091 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3092 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3093 @code{call-process} and @code{call-process-region} now return a value
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3094 that indicates how the synchronous subprocess terminated. It is either
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3095 a number, which is the exit status of a process, or a signal name
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3096 represented as a string.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3097
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3098 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3099 @code{process-status} now returns @code{open} and @code{closed} as the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3100 status values for network connections.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3101
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3102 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3103 The standard asynchronous subprocess features work on VMS now,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3104 and the special VMS asynchronous subprocess functions have been deleted.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3105
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3106 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3107 You can use the transaction queue feature for more convenient
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3108 communication with subprocesses using transactions.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3109
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3110 Call @code{tq-create} to create a transaction queue communicating with a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3111 specified process. Then you can call @code{tq-enqueue} to send a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3112 transaction. @code{tq-enqueue} takes these five arguments:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3113
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3114 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3115 (tq-enqueue @var{tq} @var{question} @var{regexp} @var{closure} @var{fn})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3116 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3117
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3118 @var{tq} is the queue to use. (Specifying the queue has the effect of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3119 specifying the process to talk to.) The argument @var{question} is the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3120 outgoing message which starts the transaction. The argument @var{fn} is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3121 the function to call when the corresponding answer comes back; it is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3122 called with two arguments: @var{closure}, and the answer received.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3123
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3124 The argument @var{regexp} is a regular expression to match the entire
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3125 answer; that's how @code{tq-enqueue} tells where the answer ends.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3126
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3127 Call @code{tq-close} to shut down a transaction queue and terminate its
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3128 subprocess.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3129
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3130 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3131 The function @code{signal-process} sends a signal to process @var{pid},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3132 which need not be a child of Emacs. The second argument @var{signal}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3133 specifies which signal to send; it should be an integer.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3134 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3135
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3136 @section New Features for Dealing with Times And Time Delays
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3137
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3138 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3139 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3140 The new function @code{current-time} returns the system's time value as
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3141 a list of three integers: @code{(@var{high} @var{low} @var{microsec})}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3142 The integers @var{high} and @var{low} combine to give the number of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3143 seconds since 0:00 January 1, 1970, which is @var{high} * 2**16 +
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3144 @var{low}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3145
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3146 @var{microsec} gives the microseconds since the start of the current
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3147 second (or 0 for systems that return time only on the resolution of a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3148 second).
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3149
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3150 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3151 The function @code{current-time-string} accepts an optional argument
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3152 @var{time-value}. If given, this specifies a time to format instead of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3153 the current time. The argument should be a cons cell containing two
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3154 integers, or a list whose first two elements are integers. Thus, you
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3155 can use times obtained from @code{current-time} (see above) and from
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3156 @code{file-attributes}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3157
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3158 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3159 You can now find out the user's time zone using @code{current-time-zone}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3160 It takes no arguments, and returns a list of this form:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3161
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3162 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3163 (@var{offset} @var{savings-flag} @var{standard} @var{savings})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3164 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3165
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3166 @var{offset} is an integer specifying how many minutes east of Greenwich
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3167 the current time zone is located. A negative value means west of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3168 Greenwich. Note that this describes the standard time; if daylight
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3169 savings time is in effect, it does not affect this value.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3170
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3171 @var{savings-flag} is non-@code{nil} iff daylight savings time or some other
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3172 sort of seasonal time adjustment is in effect.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3173
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3174 @var{standard} is a string giving the name of the time zone when no
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3175 seasonal time adjustment is in effect.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3176
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3177 @var{savings} is a string giving the name of the time zone when there is a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3178 seasonal time adjustment in effect.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3179
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3180 If the user has specified a region that does not use a seasonal time
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3181 adjustment, @var{savings-flag} is always @code{nil}, and @var{standard}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3182 and @var{savings} are equal.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3183
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3184 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3185 @code{sit-for}, @code{sleep-for} now let you specify the time period in
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3186 milliseconds as well as in seconds. The first argument gives the number
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3187 of seconds, as before, and the optional second argument gives additional
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3188 milliseconds. The time periods specified by these two arguments are
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3189 added together.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3190
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3191 Not all systems support this; you get an error if you specify nonzero
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3192 milliseconds and it isn't supported.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3193
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3194 @code{sit-for} also accepts an optional third argument @var{nodisp}. If
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3195 this is non-@code{nil}, @code{sit-for} does not redisplay. It still
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3196 waits for the specified time or until input is available.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3197
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3198 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3199 @code{accept-process-output} now accepts a timeout specified by optional
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3200 second and third arguments. The second argument specifies the number of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3201 seconds, while the third specifies the number of milliseconds. The time
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3202 periods specified by these two arguments are added together.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3203
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3204 Not all systems support this; you get an error if you specify nonzero
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3205 milliseconds and it isn't supported.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3206
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3207 The function returns @code{nil} if the timeout expired before output
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3208 arrived, or non-@code{nil} if it did get some output.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3209
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3210 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3211 You can set up a timer to call a function at a specified future time.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3212 To do so, call @code{run-at-time}, like this:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3213
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3214 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3215 (run-at-time @var{time} @var{repeat} @var{function} @var{args}@dots{})
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3216 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3217
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3218 Here, @var{time} is a string saying when to call the function. The
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3219 argument @var{function} is the function to call later, and @var{args}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3220 are the arguments to give it when it is called.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3221
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3222 The argument @var{repeat} specifies how often to repeat the call. If
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3223 @var{repeat} is @code{nil}, there are no repetitions; @var{function} is
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3224 called just once, at @var{time}. If @var{repeat} is an integer, it
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3225 specifies a repetition period measured in seconds.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3226
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3227 Absolute times may be specified in a wide variety of formats; The form
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3228 @samp{@var{hour}:@var{min}:@var{sec} @var{timezone}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3229 @var{month}/@var{day}/@var{year}}, where all fields are numbers, works;
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3230 the format that @code{current-time-string} returns is also allowed.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3231
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3232 To specify a relative time, use numbers followed by units.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3233 For example:
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3234
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3235 @table @samp
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3236 @item 1 min
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3237 denotes 1 minute from now.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3238 @item 1 min 5 sec
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3239 denotes 65 seconds from now.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3240 @item 1 min 2 sec 3 hour 4 day 5 week 6 fortnight 7 month 8 year
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3241 denotes exactly 103 months, 123 days, and 10862 seconds from now.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3242 @end table
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3243
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3244 If @var{time} is an integer, that specifies a relative time measured in
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3245 seconds.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3246 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3247
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3248 To cancel the requested future action, pass the value that @code{run-at-time}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3249 returned to the function @code{cancel-timer}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3250
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3251 @section Profiling Lisp Programs
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3252
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3253 You can now make execution-time profiles of Emacs Lisp programs using
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3254 the @file{profile} library. See the file @file{profile.el} for
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3255 instructions; if you have written a Lisp program big enough to be worth
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3256 profiling, you can surely understand them.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3257
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3258 @section New Features for Lisp Debuggers
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3259
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3260 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3261 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3262 You can now specify which kinds of errors should invoke the Lisp
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3263 debugger by setting the variable @code{debug-on-error} to a list of error
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3264 conditions. For example, if you set it to the list @code{(void-variable)},
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3265 then only errors about a variable that has no value invoke the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3266 debugger.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3267
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3268 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3269 The variable @code{command-debug-status} is used by Lisp debuggers. It
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3270 records the debugging status of current interactive command. Each time
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3271 a command is called interactively, this variable is bound to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3272 @code{nil}. The debugger can set this variable to leave information for
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3273 future debugger invocations during the same command.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3274
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3275 The advantage of this variable over some other variable in the debugger
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3276 itself is that the data will not be visible for any other command
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3277 invocation.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3278
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3279 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3280 The function @code{backtrace-frame} is intended for use in Lisp
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3281 debuggers. It returns information about what a frame on the Lisp call
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3282 stack is doing. You specify one argument, which is the number of stack
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3283 frames to count up from the current execution point.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3284
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3285 If that stack frame has not evaluated the arguments yet (or is a special
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3286 form), the value is @code{(nil @var{function} @var{arg-forms}@dots{})}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3287
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3288 If that stack frame has evaluated its arguments and called its function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3289 already, the value is @code{(t @var{function}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3290 @var{arg-values}@dots{})}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3291
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3292 In the return value, @var{function} is whatever was supplied as @sc{car}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3293 of evaluated list, or a @code{lambda} expression in the case of a macro
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3294 call. If the function has a @code{&rest} argument, that is represented
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3295 as the tail of the list @var{arg-values}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3296
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3297 If the argument is out of range, @code{backtrace-frame} returns
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3298 @code{nil}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3299 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3300
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3301 @ignore
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3302
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3303 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3304 @code{kill-ring-save} now gives visual feedback to indicate the region
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3305 of text being added to the kill ring. If the opposite end of the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3306 region is visible in the current window, the cursor blinks there.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3307 Otherwise, some text from the other end of the region is displayed in
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3308 the message area.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3309 @end ignore
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3310
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3311 @section Memory Allocation Changes
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3312
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3313 The list that @code{garbage-collect} returns now has one additional
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3314 element. This is a cons cell containing two numbers. It gives
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3315 information about the number of used and free floating point numbers,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3316 much as the first element gives such information about the number of
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3317 used and free cons cells.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3318
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3319 The new function @code{memory-limit} returns an indication of the last
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3320 address allocated by Emacs. More precisely, it returns that address
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3321 divided by 1024. You can use this to get a general idea of how your
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3322 actions affect the memory usage.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3323
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3324 @section Hook Changes
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3325
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3326 @itemize @bullet
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3327 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3328 Expanding an abbrev first runs the new hook
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3329 @code{pre-abbrev-expand-hook}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3330
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3331 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3332 The editor command loop runs the normal hook @code{pre-command-hook}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3333 before each command, and runs @code{post-command-hook} after each
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3334 command.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3335
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3336 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3337 Auto-saving runs the new hook @code{auto-save-hook} before actually
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3338 starting to save any files.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3339
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3340 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3341 The new variable @code{revert-buffer-insert-file-contents-function}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3342 holds a function that @code{revert-buffer} now uses to read in the
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3343 contents of the reverted buffer---instead of calling
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3344 @code{insert-file-contents}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3345
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3346 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3347 The variable @code{lisp-indent-hook} has been renamed to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3348 @code{lisp-indent-function}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3349
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3350 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3351 The variable @code{auto-fill-hook} has been renamed to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3352 @code{auto-fill-function}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3353
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3354 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3355 The variable @code{blink-paren-hook} has been renamed to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3356 @code{blink-paren-function}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3357
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3358 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3359 The variable @code{temp-buffer-show-hook} has been renamed to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3360 @code{temp-buffer-show-function}.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3361
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3362 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3363 The variable @code{suspend-hook} has been renamed to
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3364 @code{suspend-hooks}, because it is a list of functions but is not a
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3365 normal hook.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3366
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3367 @item
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3368 The new function @code{add-hook} provides a handy way to add a function
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3369 to a hook variable. For example,
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3370
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3371 @example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3372 (add-hook 'text-mode-hook 'my-text-hook-function)
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3373 @end example
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3374
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3375 @noindent
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3376 arranges to call @code{my-text-hook-function}
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3377 when entering Text mode or related modes.
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3378 @end itemize
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3379
58b646d9fefc Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3380 @bye