Mercurial > emacs
annotate lispref/os.texi @ 12090:73e305c8239b
(Fvertical_motion): Add cast.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 06 Jun 1995 01:44:34 +0000 |
parents | 73dc8205d259 |
children | a6eb5f12b0f3 |
rev | line source |
---|---|
6558 | 1 @c -*-texinfo-*- |
2 @c This is part of the GNU Emacs Lisp Reference Manual. | |
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. | |
4 @c See the file elisp.texi for copying conditions. | |
5 @setfilename ../info/os | |
6 @node System Interface, Display, Processes, Top | |
7 @chapter Operating System Interface | |
8 | |
9 This chapter is about starting and getting out of Emacs, access to | |
9009 | 10 values in the operating system environment, and terminal input, output, |
6558 | 11 and flow control. |
12 | |
13 @xref{Building Emacs}, for related information. See also | |
14 @ref{Display}, for additional operating system status information | |
15 pertaining to the terminal and the screen. | |
16 | |
17 @menu | |
18 * Starting Up:: Customizing Emacs start-up processing. | |
19 * Getting Out:: How exiting works (permanent or temporary). | |
20 * System Environment:: Distinguish the name and kind of system. | |
21 * User Identification:: Finding the name and user id of the user. | |
22 * Time of Day:: Getting the current time. | |
12067 | 23 * Time Conversion:: Converting a time from numeric form to a string, or |
24 to calendrical data (or vice versa). | |
6558 | 25 * Timers:: Setting a timer to call a function at a certain time. |
26 * Terminal Input:: Recording terminal input for debugging. | |
27 * Terminal Output:: Recording terminal output for debugging. | |
28 * Special Keysyms:: Defining system-specific key symbols for X windows. | |
29 * Flow Control:: How to turn output flow control on or off. | |
30 * Batch Mode:: Running Emacs without terminal interaction. | |
31 @end menu | |
32 | |
33 @node Starting Up | |
34 @section Starting Up Emacs | |
35 | |
36 This section describes what Emacs does when it is started, and how you | |
37 can customize these actions. | |
38 | |
39 @menu | |
40 * Start-up Summary:: Sequence of actions Emacs performs at start-up. | |
41 * Init File:: Details on reading the init file (@file{.emacs}). | |
42 * Terminal-Specific:: How the terminal-specific Lisp file is read. | |
43 * Command Line Arguments:: How command line arguments are processed, | |
44 and how you can customize them. | |
45 @end menu | |
46 | |
47 @node Start-up Summary | |
48 @subsection Summary: Sequence of Actions at Start Up | |
49 @cindex initialization | |
50 @cindex start up of Emacs | |
51 @cindex @file{startup.el} | |
52 | |
53 The order of operations performed (in @file{startup.el}) by Emacs when | |
54 it is started up is as follows: | |
55 | |
56 @enumerate | |
57 @item | |
58 It loads the initialization library for the window system, if you are | |
59 using a window system. This library's name is | |
60 @file{term/@var{windowsystem}-win.el}. | |
61 | |
62 @item | |
63 It initializes the X window frame and faces, if appropriate. | |
64 | |
65 @item | |
66 It runs the normal hook @code{before-init-hook}. | |
67 | |
68 @item | |
69 It loads the library @file{site-start}, unless the option | |
70 @samp{-no-site-file} was specified. The library's file name is usually | |
71 @file{site-start.el}. | |
72 @cindex @file{site-start.el} | |
73 | |
74 @item | |
75 It loads the file @file{~/.emacs} unless @samp{-q} was specified on | |
9009 | 76 the command line. (This is not done in @samp{-batch} mode.) The @samp{-u} |
6558 | 77 option can specify the user name whose home directory should be used |
78 instead of @file{~}. | |
79 | |
80 @item | |
81 It loads the library @file{default} unless @code{inhibit-default-init} | |
82 is non-@code{nil}. (This is not done in @samp{-batch} mode or if | |
9009 | 83 @samp{-q} was specified on the command line.) The library's file name |
84 is usually @file{default.el}. | |
6558 | 85 @cindex @file{default.el} |
86 | |
87 @item | |
88 It runs the normal hook @code{after-init-hook}. | |
89 | |
90 @item | |
91 It sets the major mode according to @code{initial-major-mode}, provided | |
92 the buffer @samp{*scratch*} is still current and still in Fundamental | |
93 mode. | |
94 | |
95 @item | |
96 It loads the terminal-specific Lisp file, if any, except when in batch | |
97 mode or using a window system. | |
98 | |
99 @item | |
100 It displays the initial echo area message, unless you have suppressed | |
101 that with @code{inhibit-startup-echo-area-message}. | |
102 | |
103 @item | |
104 It processes any remaining command line arguments. | |
105 | |
106 @item | |
107 It runs @code{term-setup-hook}. | |
108 | |
109 @item | |
110 It calls @code{frame-notice-user-settings}, which modifies the | |
111 parameters of the selected frame according to whatever the init files | |
112 specify. | |
113 | |
114 @item | |
115 It runs @code{window-setup-hook}. @xref{Window Systems}. | |
116 | |
117 @item | |
9009 | 118 It displays copyleft, nonwarranty, and basic use information, provided |
6558 | 119 there were no remaining command line arguments (a few steps above) and |
120 the value of @code{inhibit-startup-message} is @code{nil}. | |
121 @end enumerate | |
122 | |
123 @defopt inhibit-startup-message | |
124 This variable inhibits the initial startup messages (the nonwarranty, | |
125 etc.). If it is non-@code{nil}, then the messages are not printed. | |
126 | |
127 This variable exists so you can set it in your personal init file, once | |
128 you are familiar with the contents of the startup message. Do not set | |
129 this variable in the init file of a new user, or in a way that affects | |
130 more than one user, because that would prevent new users from receiving | |
131 the information they are supposed to see. | |
132 @end defopt | |
133 | |
134 @defopt inhibit-startup-echo-area-message | |
135 This variable controls the display of the startup echo area message. | |
136 You can suppress the startup echo area message by adding text with this | |
137 form to your @file{.emacs} file: | |
138 | |
139 @example | |
140 (setq inhibit-startup-echo-area-message | |
141 "@var{your-login-name}") | |
142 @end example | |
143 | |
144 Simply setting @code{inhibit-startup-echo-area-message} to your login | |
145 name is not sufficient to inhibit the message; Emacs explicitly checks | |
146 whether @file{.emacs} contains an expression as shown above. Your login | |
147 name must appear in the expression as a Lisp string constant. | |
148 | |
149 This way, you can easily inhibit the message for yourself if you wish, | |
150 but thoughtless copying of your @file{.emacs} file will not inhibit the | |
151 message for someone else. | |
152 @end defopt | |
153 | |
154 @node Init File | |
155 @subsection The Init File: @file{.emacs} | |
156 @cindex init file | |
157 @cindex @file{.emacs} | |
158 | |
159 When you start Emacs, it normally attempts to load the file | |
160 @file{.emacs} from your home directory. This file, if it exists, must | |
161 contain Lisp code. It is called your @dfn{init file}. The command line | |
162 switches @samp{-q} and @samp{-u} affect the use of the init file; | |
163 @samp{-q} says not to load an init file, and @samp{-u} says to load a | |
7086
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
164 specified user's init file instead of yours. @xref{Entering Emacs,,, |
6558 | 165 emacs, The GNU Emacs Manual}. |
166 | |
167 @cindex default init file | |
168 A site may have a @dfn{default init file}, which is the library named | |
169 @file{default.el}. Emacs finds the @file{default.el} file through the | |
170 standard search path for libraries (@pxref{How Programs Do Loading}). | |
171 The Emacs distribution does not come with this file; sites may provide | |
172 one for local customizations. If the default init file exists, it is | |
173 loaded whenever you start Emacs, except in batch mode or if @samp{-q} is | |
174 specified. But your own personal init file, if any, is loaded first; if | |
175 it sets @code{inhibit-default-init} to a non-@code{nil} value, then | |
176 Emacs does not subsequently load the @file{default.el} file. | |
177 | |
178 Another file for site-customization is @file{site-start.el}. Emacs | |
179 loads this @emph{before} the user's init file. You can inhibit the | |
180 loading of this file with the option @samp{-no-site-file}. | |
181 | |
182 If there is a great deal of code in your @file{.emacs} file, you | |
183 should move it into another file named @file{@var{something}.el}, | |
184 byte-compile it (@pxref{Byte Compilation}), and make your @file{.emacs} | |
185 file load the other file using @code{load} (@pxref{Loading}). | |
186 | |
7086
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
187 @xref{Init File Examples,,, emacs, The GNU Emacs Manual}, for |
6558 | 188 examples of how to make various commonly desired customizations in your |
189 @file{.emacs} file. | |
190 | |
191 @defopt inhibit-default-init | |
192 This variable prevents Emacs from loading the default initialization | |
193 library file for your session of Emacs. If its value is non-@code{nil}, | |
194 then the default library is not loaded. The default value is | |
195 @code{nil}. | |
196 @end defopt | |
197 | |
198 @defvar before-init-hook | |
199 @defvarx after-init-hook | |
200 These two normal hooks are run just before, and just after, loading of | |
201 the user's init file, @file{default.el}, and/or @file{site-start.el}. | |
202 @end defvar | |
203 | |
204 @node Terminal-Specific | |
205 @subsection Terminal-Specific Initialization | |
206 @cindex terminal-specific initialization | |
207 | |
208 Each terminal type can have its own Lisp library that Emacs loads when | |
209 run on that type of terminal. For a terminal type named @var{termtype}, | |
210 the library is called @file{term/@var{termtype}}. Emacs finds the file | |
211 by searching the @code{load-path} directories as it does for other | |
212 files, and trying the @samp{.elc} and @samp{.el} suffixes. Normally, | |
213 terminal-specific Lisp library is located in @file{emacs/lisp/term}, a | |
214 subdirectory of the @file{emacs/lisp} directory in which most Emacs Lisp | |
215 libraries are kept.@refill | |
216 | |
217 The library's name is constructed by concatenating the value of the | |
218 variable @code{term-file-prefix} and the terminal type. Normally, | |
219 @code{term-file-prefix} has the value @code{"term/"}; changing this | |
220 is not recommended. | |
221 | |
222 The usual function of a terminal-specific library is to enable special | |
223 keys to send sequences that Emacs can recognize. It may also need to | |
224 set or add to @code{function-key-map} if the Termcap entry does not | |
225 specify all the terminal's function keys. @xref{Terminal Input}. | |
226 | |
227 @cindex Termcap | |
228 When the name of the terminal type contains a hyphen, only the part of | |
229 the name before the first hyphen is significant in choosing the library | |
230 name. Thus, terminal types @samp{aaa-48} and @samp{aaa-30-rv} both use | |
231 the @file{term/aaa} library. If necessary, the library can evaluate | |
232 @code{(getenv "TERM")} to find the full name of the terminal | |
233 type.@refill | |
234 | |
235 Your @file{.emacs} file can prevent the loading of the | |
236 terminal-specific library by setting the variable | |
237 @code{term-file-prefix} to @code{nil}. This feature is useful when | |
238 experimenting with your own peculiar customizations. | |
239 | |
240 You can also arrange to override some of the actions of the | |
241 terminal-specific library by setting the variable | |
242 @code{term-setup-hook}. This is a normal hook which Emacs runs using | |
243 @code{run-hooks} at the end of Emacs initialization, after loading both | |
244 your @file{.emacs} file and any terminal-specific libraries. You can | |
245 use this variable to define initializations for terminals that do not | |
246 have their own libraries. @xref{Hooks}. | |
247 | |
248 @defvar term-file-prefix | |
249 @cindex @code{TERM} environment variable | |
250 If the @code{term-file-prefix} variable is non-@code{nil}, Emacs loads | |
251 a terminal-specific initialization file as follows: | |
252 | |
253 @example | |
254 (load (concat term-file-prefix (getenv "TERM"))) | |
255 @end example | |
256 | |
257 @noindent | |
258 You may set the @code{term-file-prefix} variable to @code{nil} in your | |
259 @file{.emacs} file if you do not wish to load the | |
260 terminal-initialization file. To do this, put the following in | |
261 your @file{.emacs} file: @code{(setq term-file-prefix nil)}. | |
262 @end defvar | |
263 | |
264 @defvar term-setup-hook | |
9009 | 265 This variable is a normal hook that Emacs runs after loading your |
6558 | 266 @file{.emacs} file, the default initialization file (if any) and the |
267 terminal-specific Lisp file. | |
268 | |
269 You can use @code{term-setup-hook} to override the definitions made by a | |
270 terminal-specific file. | |
271 @end defvar | |
272 | |
273 See @code{window-setup-hook} in @ref{Window Systems}, for a related | |
274 feature. | |
275 | |
276 @node Command Line Arguments | |
277 @subsection Command Line Arguments | |
278 @cindex command line arguments | |
279 | |
280 You can use command line arguments to request various actions when you | |
281 start Emacs. Since you do not need to start Emacs more than once per | |
282 day, and will often leave your Emacs session running longer than that, | |
283 command line arguments are hardly ever used. As a practical matter, it | |
284 is best to avoid making the habit of using them, since this habit would | |
285 encourage you to kill and restart Emacs unnecessarily often. These | |
286 options exist for two reasons: to be compatible with other editors (for | |
287 invocation by other programs) and to enable shell scripts to run | |
288 specific Lisp programs. | |
289 | |
290 This section describes how Emacs processes command line arguments, | |
291 and how you can customize them. | |
292 | |
293 @ignore | |
294 (Note that some other editors require you to start afresh each time | |
295 you want to edit a file. With this kind of editor, you will probably | |
296 specify the file as a command line argument. The recommended way to | |
297 use GNU Emacs is to start it only once, just after you log in, and do | |
298 all your editing in the same Emacs process. Each time you want to edit | |
299 a different file, you visit it with the existing Emacs, which eventually | |
300 comes to have many files in it ready for editing. Usually you do not | |
301 kill the Emacs until you are about to log out.) | |
302 @end ignore | |
303 | |
304 @defun command-line | |
9009 | 305 This function parses the command line that Emacs was called with, |
6558 | 306 processes it, loads the user's @file{.emacs} file and displays the |
9009 | 307 startup messages. |
6558 | 308 @end defun |
309 | |
310 @defvar command-line-processed | |
311 The value of this variable is @code{t} once the command line has been | |
312 processed. | |
313 | |
314 If you redump Emacs by calling @code{dump-emacs}, you may wish to set | |
315 this variable to @code{nil} first in order to cause the new dumped Emacs | |
316 to process its new command line arguments. | |
317 @end defvar | |
318 | |
319 @defvar command-switch-alist | |
320 @cindex switches on command line | |
321 @cindex options on command line | |
322 @cindex command line options | |
323 The value of this variable is an alist of user-defined command-line | |
324 options and associated handler functions. This variable exists so you | |
325 can add elements to it. | |
326 | |
327 A @dfn{command line option} is an argument on the command line of the | |
328 form: | |
329 | |
330 @example | |
331 -@var{option} | |
332 @end example | |
333 | |
334 The elements of the @code{command-switch-alist} look like this: | |
335 | |
336 @example | |
337 (@var{option} . @var{handler-function}) | |
338 @end example | |
339 | |
340 The @var{handler-function} is called to handle @var{option} and receives | |
341 the option name as its sole argument. | |
342 | |
343 In some cases, the option is followed in the command line by an | |
344 argument. In these cases, the @var{handler-function} can find all the | |
345 remaining command-line arguments in the variable | |
346 @code{command-line-args-left}. (The entire list of command-line | |
347 arguments is in @code{command-line-args}.) | |
348 | |
349 The command line arguments are parsed by the @code{command-line-1} | |
350 function in the @file{startup.el} file. See also @ref{Command | |
351 Switches, , Command Line Switches and Arguments, emacs, The GNU Emacs | |
352 Manual}. | |
353 @end defvar | |
354 | |
355 @defvar command-line-args | |
356 The value of this variable is the list of command line arguments passed | |
357 to Emacs. | |
358 @end defvar | |
359 | |
360 @defvar command-line-functions | |
361 This variable's value is a list of functions for handling an | |
362 unrecognized command-line argument. Each time the next argument to be | |
363 processed has no special meaning, the functions in this list are called, | |
9009 | 364 in order of appearance, until one of them returns a non-@code{nil} |
6558 | 365 value. |
366 | |
367 These functions are called with no arguments. They can access the | |
368 command-line argument under consideration through the variable | |
369 @code{argi}. The remaining arguments (not including the current one) | |
370 are in the variable @code{command-line-args-left}. | |
371 | |
372 When a function recognizes and processes the argument in @code{argi}, it | |
373 should return a non-@code{nil} value to say it has dealt with that | |
374 argument. If it has also dealt with some of the following arguments, it | |
375 can indicate that by deleting them from @code{command-line-args-left}. | |
376 | |
377 If all of these functions return @code{nil}, then the argument is used | |
378 as a file name to visit. | |
379 @end defvar | |
380 | |
381 @node Getting Out | |
382 @section Getting Out of Emacs | |
383 @cindex exiting Emacs | |
384 | |
385 There are two ways to get out of Emacs: you can kill the Emacs job, | |
386 which exits permanently, or you can suspend it, which permits you to | |
387 reenter the Emacs process later. As a practical matter, you seldom kill | |
388 Emacs---only when you are about to log out. Suspending is much more | |
389 common. | |
390 | |
391 @menu | |
392 * Killing Emacs:: Exiting Emacs irreversibly. | |
393 * Suspending Emacs:: Exiting Emacs reversibly. | |
394 @end menu | |
395 | |
396 @node Killing Emacs | |
397 @comment node-name, next, previous, up | |
398 @subsection Killing Emacs | |
399 @cindex killing Emacs | |
400 | |
401 Killing Emacs means ending the execution of the Emacs process. The | |
402 parent process normally resumes control. The low-level primitive for | |
403 killing Emacs is @code{kill-emacs}. | |
404 | |
405 @defun kill-emacs &optional exit-data | |
406 This function exits the Emacs process and kills it. | |
407 | |
408 If @var{exit-data} is an integer, then it is used as the exit status | |
409 of the Emacs process. (This is useful primarily in batch operation; see | |
410 @ref{Batch Mode}.) | |
411 | |
412 If @var{exit-data} is a string, its contents are stuffed into the | |
413 terminal input buffer so that the shell (or whatever program next reads | |
414 input) can read them. | |
415 @end defun | |
416 | |
417 All the information in the Emacs process, aside from files that have | |
418 been saved, is lost when the Emacs is killed. Because killing Emacs | |
419 inadvertently can lose a lot of work, Emacs queries for confirmation | |
420 before actually terminating if you have buffers that need saving or | |
421 subprocesses that are running. This is done in the function | |
422 @code{save-buffers-kill-emacs}. | |
423 | |
424 @defvar kill-emacs-query-functions | |
425 After asking the standard questions, @code{save-buffers-kill-emacs} | |
426 calls the functions in the list @code{kill-buffer-query-functions}, in | |
427 order of appearance, with no arguments. These functions can ask for | |
428 additional confirmation from the user. If any of them returns | |
429 non-@code{nil}, Emacs is not killed. | |
430 @end defvar | |
431 | |
432 @defvar kill-emacs-hook | |
433 This variable is a normal hook; once @code{save-buffers-kill-emacs} is | |
434 finished with all file saving and confirmation, it runs the functions in | |
435 this hook. | |
436 @end defvar | |
437 | |
438 @node Suspending Emacs | |
439 @subsection Suspending Emacs | |
440 @cindex suspending Emacs | |
441 | |
442 @dfn{Suspending Emacs} means stopping Emacs temporarily and returning | |
443 control to its superior process, which is usually the shell. This | |
444 allows you to resume editing later in the same Emacs process, with the | |
445 same buffers, the same kill ring, the same undo history, and so on. To | |
446 resume Emacs, use the appropriate command in the parent shell---most | |
447 likely @code{fg}. | |
448 | |
449 Some operating systems do not support suspension of jobs; on these | |
450 systems, ``suspension'' actually creates a new shell temporarily as a | |
451 subprocess of Emacs. Then you would exit the shell to return to Emacs. | |
452 | |
453 Suspension is not useful with window systems such as X, because the | |
454 Emacs job may not have a parent that can resume it again, and in any | |
455 case you can give input to some other job such as a shell merely by | |
456 moving to a different window. Therefore, suspending is not allowed | |
457 when Emacs is an X client. | |
458 | |
459 @defun suspend-emacs string | |
460 This function stops Emacs and returns control to the superior process. | |
461 If and when the superior process resumes Emacs, @code{suspend-emacs} | |
462 returns @code{nil} to its caller in Lisp. | |
463 | |
464 If @var{string} is non-@code{nil}, its characters are sent to be read | |
465 as terminal input by Emacs's superior shell. The characters in | |
466 @var{string} are not echoed by the superior shell; only the results | |
467 appear. | |
468 | |
469 Before suspending, @code{suspend-emacs} runs the normal hook | |
470 @code{suspend-hook}. In Emacs version 18, @code{suspend-hook} was not a | |
471 normal hook; its value was a single function, and if its value was | |
472 non-@code{nil}, then @code{suspend-emacs} returned immediately without | |
473 actually suspending anything. | |
474 | |
9009 | 475 After the user resumes Emacs, @code{suspend-emacs} runs the normal hook |
6558 | 476 @code{suspend-resume-hook}. @xref{Hooks}. |
477 | |
478 The next redisplay after resumption will redraw the entire screen, | |
479 unless the variable @code{no-redraw-on-reenter} is non-@code{nil} | |
480 (@pxref{Refresh Screen}). | |
481 | |
482 In the following example, note that @samp{pwd} is not echoed after | |
483 Emacs is suspended. But it is read and executed by the shell. | |
484 | |
485 @smallexample | |
486 @group | |
487 (suspend-emacs) | |
488 @result{} nil | |
489 @end group | |
490 | |
491 @group | |
492 (add-hook 'suspend-hook | |
493 (function (lambda () | |
494 (or (y-or-n-p | |
495 "Really suspend? ") | |
496 (error "Suspend cancelled"))))) | |
497 @result{} (lambda nil | |
498 (or (y-or-n-p "Really suspend? ") | |
499 (error "Suspend cancelled"))) | |
500 @end group | |
501 @group | |
502 (add-hook 'suspend-resume-hook | |
503 (function (lambda () (message "Resumed!")))) | |
504 @result{} (lambda nil (message "Resumed!")) | |
505 @end group | |
506 @group | |
507 (suspend-emacs "pwd") | |
508 @result{} nil | |
509 @end group | |
510 @group | |
511 ---------- Buffer: Minibuffer ---------- | |
512 Really suspend? @kbd{y} | |
513 ---------- Buffer: Minibuffer ---------- | |
514 @end group | |
515 | |
516 @group | |
517 ---------- Parent Shell ---------- | |
518 lewis@@slug[23] % /user/lewis/manual | |
519 lewis@@slug[24] % fg | |
520 @end group | |
521 | |
522 @group | |
523 ---------- Echo Area ---------- | |
524 Resumed! | |
525 @end group | |
526 @end smallexample | |
527 @end defun | |
528 | |
529 @defvar suspend-hook | |
530 This variable is a normal hook run before suspending. | |
531 @end defvar | |
532 | |
533 @defvar suspend-resume-hook | |
534 This variable is a normal hook run after suspending. | |
535 @end defvar | |
536 | |
537 @node System Environment | |
538 @section Operating System Environment | |
539 @cindex operating system environment | |
540 | |
541 Emacs provides access to variables in the operating system environment | |
542 through various functions. These variables include the name of the | |
543 system, the user's @sc{uid}, and so on. | |
544 | |
545 @defvar system-type | |
546 The value of this variable is a symbol indicating the type of | |
547 operating system Emacs is operating on. Here is a table of the symbols | |
548 for the operating systems that Emacs can run on up to version 19.1. | |
549 | |
550 @table @code | |
551 @item aix-v3 | |
552 AIX. | |
553 | |
554 @item berkeley-unix | |
555 Berkeley BSD. | |
556 | |
557 @item hpux | |
558 Hewlett-Packard operating system. | |
559 | |
560 @item irix | |
561 Silicon Graphics Irix system. | |
562 | |
7277
6a2af30d33fe
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7086
diff
changeset
|
563 @item linux |
6a2af30d33fe
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7086
diff
changeset
|
564 The free Linux operating system. |
6a2af30d33fe
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7086
diff
changeset
|
565 |
6558 | 566 @item rtu |
567 Masscomp RTU, UCB universe. | |
568 | |
569 @item unisoft-unix | |
570 UniSoft UniPlus. | |
571 | |
572 @item usg-unix-v | |
573 AT&T System V. | |
574 | |
575 @item vax-vms | |
576 VAX VMS. | |
577 | |
578 @item xenix | |
579 SCO Xenix 386. | |
580 @end table | |
581 | |
582 We do not wish to add new symbols to make finer distinctions unless it | |
583 is absolutely necessary! In fact, we hope to eliminate some of these | |
584 alternatives in the future. We recommend using | |
585 @code{system-configuration} to distinguish between different operating | |
586 systems. | |
587 @end defvar | |
588 | |
589 @defvar system-configuration | |
590 This variable holds the three-part configuration name for the | |
591 hardware/software configuration of your system, as a string. The | |
592 convenient way to test parts of this string is with @code{string-match}. | |
593 @end defvar | |
594 | |
595 @defun system-name | |
596 This function returns the name of the machine you are running on. | |
597 @example | |
598 (system-name) | |
599 @result{} "prep.ai.mit.edu" | |
600 @end example | |
601 @end defun | |
602 | |
12067 | 603 @vindex system-name |
604 The symbol @code{system-name} is a variable as well as a function. In | |
605 fact, the function returns whatever value the variable | |
606 @code{system-name} currently holds. Thus, you can set the variable | |
607 @code{system-name} in case Emacs is confused about the name of your | |
608 system. The variable is also useful for constructing frame titles | |
609 (@pxref{Frame Titles}). | |
610 | |
611 @defvar mail-host-address | |
612 If this variable is non-@code{nil}, it is used instead of | |
613 @code{system-name} for purposes of generating email addresses. For | |
614 example, it is used when constructing the default value of | |
615 @code{user-mail-address}. @xref{User Identification}. (Since this is | |
616 done when Emacs starts up, the value actually used is the one saved when | |
617 Emacs was dumped. @xref{Building Emacs}.) | |
618 @end defvar | |
619 | |
6558 | 620 @defun getenv var |
621 @cindex environment variable access | |
622 This function returns the value of the environment variable @var{var}, | |
623 as a string. Within Emacs, the environment variable values are kept in | |
624 the Lisp variable @code{process-environment}. | |
625 | |
626 @example | |
627 @group | |
628 (getenv "USER") | |
629 @result{} "lewis" | |
630 @end group | |
631 | |
632 @group | |
633 lewis@@slug[10] % printenv | |
634 PATH=.:/user/lewis/bin:/usr/bin:/usr/local/bin | |
635 USER=lewis | |
636 @end group | |
637 @group | |
638 TERM=ibmapa16 | |
639 SHELL=/bin/csh | |
640 HOME=/user/lewis | |
641 @end group | |
642 @end example | |
643 @end defun | |
644 | |
645 @c Emacs 19 feature | |
646 @deffn Command setenv variable value | |
647 This command sets the value of the environment variable named | |
648 @var{variable} to @var{value}. Both arguments should be strings. This | |
649 function works by modifying @code{process-environment}; binding that | |
650 variable with @code{let} is also reasonable practice. | |
651 @end deffn | |
652 | |
12067 | 653 @defvar path-separator |
654 This variable holds a string which says which character separates | |
655 directories in a search path (as found in an environment variable). Its | |
656 value is @code{":"} for Unix and GNU systems, and @code{";"} for MS-DOS | |
657 and Windows NT. | |
658 @end defvar | |
659 | |
6558 | 660 @defvar process-environment |
661 This variable is a list of strings, each describing one environment | |
662 variable. The functions @code{getenv} and @code{setenv} work by means | |
663 of this variable. | |
664 | |
665 @smallexample | |
666 @group | |
667 process-environment | |
668 @result{} ("l=/usr/stanford/lib/gnuemacs/lisp" | |
669 "PATH=.:/user/lewis/bin:/usr/class:/nfsusr/local/bin" | |
670 "USER=lewis" | |
671 @end group | |
672 @group | |
673 "TERM=ibmapa16" | |
674 "SHELL=/bin/csh" | |
675 "HOME=/user/lewis") | |
676 @end group | |
677 @end smallexample | |
678 @end defvar | |
679 | |
7086
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
680 @defvar invocation-name |
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
681 This variable holds the program name under which Emacs was invoked. The |
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
682 value is a string, and does not include a directory name. |
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
683 @end defvar |
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
684 |
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
685 @defvar invocation-directory |
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
686 This variable holds the directory from which the Emacs executable was |
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
687 invoked, or perhaps @code{nil} if that directory cannot be determined. |
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
688 @end defvar |
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
689 |
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
690 @defvar installation-directory |
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
691 If non-@code{nil}, this is a directory within which to look for the |
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
692 @file{lib-src} and @file{etc} subdirectories. This is non-@code{nil} |
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
693 when Emacs can't find those directories in their standard installed |
9009 | 694 locations, but can find them in a directory related somehow to the one |
695 containing the Emacs executable. | |
7086
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
696 @end defvar |
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
697 |
6558 | 698 @defun load-average |
9009 | 699 This function returns the current 1-minute, 5-minute and 15-minute |
6558 | 700 load averages in a list. The values are integers that are 100 times |
701 the system load averages. (The load averages indicate the number of | |
702 processes trying to run.) | |
703 | |
704 @example | |
705 @group | |
706 (load-average) | |
707 @result{} (169 48 36) | |
708 @end group | |
709 | |
710 @group | |
711 lewis@@rocky[5] % uptime | |
712 11:55am up 1 day, 19:37, 3 users, | |
713 load average: 1.69, 0.48, 0.36 | |
714 @end group | |
715 @end example | |
716 @end defun | |
717 | |
718 @defun emacs-pid | |
719 This function returns the process @sc{id} of the Emacs process. | |
720 @end defun | |
721 | |
722 @defun setprv privilege-name &optional setp getprv | |
723 This function sets or resets a VMS privilege. (It does not exist on | |
724 Unix.) The first arg is the privilege name, as a string. The second | |
725 argument, @var{setp}, is @code{t} or @code{nil}, indicating whether the | |
726 privilege is to be turned on or off. Its default is @code{nil}. The | |
727 function returns @code{t} if successful, @code{nil} otherwise. | |
728 | |
729 If the third argument, @var{getprv}, is non-@code{nil}, @code{setprv} | |
730 does not change the privilege, but returns @code{t} or @code{nil} | |
731 indicating whether the privilege is currently enabled. | |
732 @end defun | |
733 | |
734 @node User Identification | |
735 @section User Identification | |
736 | |
12067 | 737 @defvar user-mail-address |
738 This holds the nominal email address of the user who is using Emacs. | |
739 When Emacs starts up, it computes a default value that is usually right, | |
740 but users often set this themselves when the default value is not right. | |
741 @end defvar | |
742 | |
743 @defun user-login-name &optional uid | |
744 If you don't specify @var{uid}, this function returns the name under | |
745 which the user is logged in. If the environment variable @code{LOGNAME} | |
746 is set, that value is used. Otherwise, if the environment variable | |
747 @code{USER} is set, that value is used. Otherwise, the value is based | |
748 on the effective @sc{uid}, not the real @sc{uid}. | |
749 | |
750 If you specify @var{uid}, the value is the user name that corresponds | |
751 to @var{uid} (which should be an integer). | |
6558 | 752 |
753 @example | |
754 @group | |
755 (user-login-name) | |
756 @result{} "lewis" | |
757 @end group | |
758 @end example | |
759 @end defun | |
760 | |
761 @defun user-real-login-name | |
762 This function returns the user name corresponding to Emacs's real | |
763 @sc{uid}. This ignores the effective @sc{uid} and ignores the | |
764 environment variables @code{LOGNAME} and @code{USER}. | |
765 @end defun | |
766 | |
767 @defun user-full-name | |
768 This function returns the full name of the user. | |
769 | |
770 @example | |
771 @group | |
772 (user-full-name) | |
773 @result{} "Bil Lewis" | |
774 @end group | |
775 @end example | |
776 @end defun | |
777 | |
12067 | 778 @vindex user-full-name |
779 @vindex user-real-login-name | |
780 @vindex user-login-name | |
781 The symbols @code{user-login-name}, @code{user-real-login-name} and | |
782 @code{user-full-name} are variables as well as functions. The functions | |
783 return the same values that the variables hold. These variables allow | |
784 you to ``fake out'' Emacs by telling the functions what to return. The | |
785 variables are also useful for constructing frame titles (@pxref{Frame | |
786 Titles}). | |
787 | |
788 @defvar user-real-login-name | |
789 This variable holds the same value that the function | |
790 @code{user-real-login-name} returns. The variable lets you alter the value; | |
791 also, you can use variables for constructing frame titles. | |
792 @end defvar | |
793 | |
794 @defvar user-full-name | |
795 This variable holds the same value that the function | |
796 @code{user-full-name} returns. The variable lets you alter the value; | |
797 also, you can use variables for constructing frame titles. | |
798 @end defvar | |
799 | |
6558 | 800 @defun user-real-uid |
801 This function returns the real @sc{uid} of the user. | |
802 | |
803 @example | |
804 @group | |
805 (user-real-uid) | |
806 @result{} 19 | |
807 @end group | |
808 @end example | |
809 @end defun | |
810 | |
811 @defun user-uid | |
812 This function returns the effective @sc{uid} of the user. | |
813 @end defun | |
814 | |
815 @node Time of Day | |
816 @section Time of Day | |
817 | |
818 This section explains how to determine the current time and the time | |
819 zone. | |
820 | |
821 @defun current-time-string &optional time-value | |
822 This function returns the current time and date as a humanly-readable | |
823 string. The format of the string is unvarying; the number of characters | |
824 used for each part is always the same, so you can reliably use | |
825 @code{substring} to extract pieces of it. However, it would be wise to | |
826 count the characters from the beginning of the string rather than from | |
827 the end, as additional information may be added at the end. | |
828 | |
829 @c Emacs 19 feature | |
830 The argument @var{time-value}, if given, specifies a time to format | |
831 instead of the current time. The argument should be a cons cell | |
832 containing two integers, or a list whose first two elements are | |
833 integers. Thus, you can use times obtained from @code{current-time} | |
834 (see below) and from @code{file-attributes} (@pxref{File Attributes}). | |
835 | |
836 @example | |
837 @group | |
838 (current-time-string) | |
839 @result{} "Wed Oct 14 22:21:05 1987" | |
840 @end group | |
841 @end example | |
842 @end defun | |
843 | |
844 @c Emacs 19 feature | |
845 @defun current-time | |
846 This function returns the system's time value as a list of three | |
847 integers: @code{(@var{high} @var{low} @var{microsec})}. The integers | |
848 @var{high} and @var{low} combine to give the number of seconds since | |
849 0:00 January 1, 1970, which is | |
850 @ifinfo | |
851 @var{high} * 2**16 + @var{low}. | |
852 @end ifinfo | |
853 @tex | |
9009 | 854 $high*2^{16}+low$. |
6558 | 855 @end tex |
856 | |
857 The third element, @var{microsec}, gives the microseconds since the | |
858 start of the current second (or 0 for systems that return time only on | |
859 the resolution of a second). | |
860 | |
861 The first two elements can be compared with file time values such as you | |
862 get with the function @code{file-attributes}. @xref{File Attributes}. | |
863 @end defun | |
864 | |
865 @c Emacs 19 feature | |
866 @defun current-time-zone &optional time-value | |
867 This function returns a list describing the time zone that the user is | |
868 in. | |
869 | |
870 The value has the form @code{(@var{offset} @var{name})}. Here | |
871 @var{offset} is an integer giving the number of seconds ahead of UTC | |
872 (east of Greenwich). A negative value means west of Greenwich. The | |
873 second element, @var{name} is a string giving the name of the time | |
874 zone. Both elements change when daylight savings time begins or ends; | |
875 if the user has specified a time zone that does not use a seasonal time | |
876 adjustment, then the value is constant through time. | |
877 | |
878 If the operating system doesn't supply all the information necessary to | |
879 compute the value, both elements of the list are @code{nil}. | |
880 | |
881 The argument @var{time-value}, if given, specifies a time to analyze | |
882 instead of the current time. The argument should be a cons cell | |
883 containing two integers, or a list whose first two elements are | |
884 integers. Thus, you can use times obtained from @code{current-time} | |
12067 | 885 (see above) and from @code{file-attributes} (@pxref{File Attributes}). |
886 @end defun | |
887 | |
888 @node Time Conversion | |
889 @section Time Conversion | |
890 | |
891 These functions convert time values (lists of two or three integers) | |
892 to strings or to calendrical information. There is also a function to | |
893 convert calendrical information to a time value. You can get time | |
894 values from the functions @code{current-time} (@pxref{Time of Day}) and | |
895 @code{file-attributes} (@pxref{File Attributes}). | |
896 | |
897 @defun format-time-string format-string time | |
898 This function converts @var{time} to a string according to | |
899 @var{format-string}. The argument @var{format-string} may contain | |
900 @samp{%}-sequences which say to substitute parts of the time. Here is a | |
901 table of what the @samp{%}-sequences mean: | |
902 | |
903 @table @samp | |
904 @item %a | |
905 This stands for the abbreviated name of the day of week. | |
906 @item %A | |
907 This stands for the full name of the day of week. | |
908 @item %b | |
909 This stands for the abbreviated name of the month. | |
910 @item %B | |
911 This stands for the full name of the month. | |
912 @item %c | |
913 This is a synonym for @samp{%x %X}. | |
914 @item %C | |
915 This has a locale-specific meaning. In the C locale, it is equivalent | |
916 to @samp{%A, %B %e, %Y}. | |
917 @item %d | |
918 This stands for the day of month, zero-padded. | |
919 @item %D | |
920 This is a synonym for @samp{%m/%d/%y}. | |
921 @item %e | |
922 This stands for the day of month, blank-padded. | |
923 @item %h | |
924 This is a synonym for @samp{%b}. | |
925 @item %H | |
926 This stands for the hour (00-23). | |
927 @item %I | |
928 This stands for the hour (00-12). | |
929 @item %j | |
930 This stands for the day of the year (001-366). | |
931 @item %k | |
932 This stands for the hour (0-23), blank padded. | |
933 @item %l | |
934 This stands for the hour (1-12), blank padded. | |
935 @item %m | |
936 This stands for the month (01-12). | |
937 @item %M | |
938 This stands for the minute (00-59). | |
939 @item %n | |
940 This stands for a newline. | |
941 @item %p | |
942 This stands for @samp{AM} or @samp{PM}, as appropriate. | |
943 @item %r | |
944 This is a synonym for @samp{%I:%M:%S %p}. | |
945 @item %R | |
946 This is a synonym for @samp{%H:%M}. | |
947 @item %S | |
948 This stands for the seconds (00-60). | |
949 @item %t | |
950 This stands for a tab character. | |
951 @item %T | |
952 This is a synonym for @samp{%H:%M:%S}. | |
953 @item %U | |
954 This stands for the week of the year (01-52), assuming that weeks | |
955 start on Sunday. | |
956 @item %w | |
957 This stands for the numeric day of week (0-6). Sunday is day 0. | |
958 @item %W | |
959 This stands for the week of the year (01-52), assuming that weeks | |
960 start on Monday. | |
961 @item %x | |
962 This has a locale-specific meaning. In the C locale, it is equivalent | |
963 to @samp{%D}. | |
964 @item %X | |
965 This has a locale-specific meaning. In the C locale, it is equivalent | |
966 to @samp{%T}. | |
967 @item %y | |
968 This stands for the year without century (00-99). | |
969 @item %Y | |
970 This stands for the year with century. | |
971 @item %Z | |
972 This stands for the time zone abbreviation. | |
973 @end table | |
974 @end defun | |
975 | |
976 @defun decode-time time | |
977 This function converts a time value into calendrical form. The return | |
978 value is a list of nine elements, as follows: | |
979 | |
980 @example | |
981 (@var{seconds} @var{minutes} @var{hour} @var{day} @var{month} @var{year} @var{dow} @var{dst} @var{zone}) | |
982 @end example | |
983 | |
984 Here is what the elements mean: | |
985 | |
986 @table @var | |
987 @item sec | |
988 The number of seconds past the minute, as an integer between 0 and 59. | |
989 @item minute | |
990 The number of minutes past the hour, as an integer between 0 and 59. | |
991 @item hour | |
992 The hour of the day, as an integer between 0 and 23. | |
993 @item day | |
994 The day of the month, as an integer between 1 and 31. | |
995 @item month | |
996 The month of the year, as an integer between 1 and 12. | |
997 @item year | |
998 The year, an integer typically greater than 1900. | |
999 @item dow | |
1000 The day of week, as an integer between 0 and 6, where 0 stands for | |
1001 Sunday. | |
1002 @item dst | |
1003 @code{t} if daylight savings time is effect, otherwise @code{nil}. | |
1004 @item zone | |
1005 An integer indicating the number of seconds east of Greenwich. | |
1006 @end table | |
1007 | |
1008 Note that Common Lisp has different meanings for @var{dow} and | |
1009 @var{zone}. | |
1010 @end defun | |
1011 | |
1012 @defun encode-time seconds minutes hour day month year &optional zone | |
1013 This function is the inverse of @code{decode-time}. It converts seven | |
1014 items of calendrical data into a time value. | |
1015 | |
1016 For the meanings of the arguments, see the table above under | |
1017 @code{decode-time}. | |
1018 | |
1019 Year numbers less than 100 are treated just like other year numbers. If | |
1020 you them to stand for years above 1900, you must alter them yourself | |
1021 before you call @code{encode-time}. | |
1022 | |
1023 The optional argument @var{zone} defaults to the current time zone and | |
1024 its daylight savings time rules. If specified, it can be either a list | |
1025 (as you would get from @code{current-time-zone}) or an integer (as you | |
1026 would get from @code{decode-time}). The specified zone is used without | |
1027 any further alteration for daylight savings time. | |
6558 | 1028 @end defun |
1029 | |
1030 @node Timers | |
1031 @section Timers | |
1032 | |
1033 You can set up a timer to call a function at a specified future time. | |
1034 | |
1035 @defun run-at-time time repeat function &rest args | |
1036 This function arranges to call @var{function} with arguments @var{args} | |
1037 at time @var{time}. The argument @var{function} is a function to call | |
1038 later, and @var{args} are the arguments to give it when it is called. | |
1039 The time @var{time} is specified as a string. | |
1040 | |
1041 Absolute times may be specified in a wide variety of formats; The form | |
1042 @samp{@var{hour}:@var{min}:@var{sec} @var{timezone} | |
1043 @var{month}/@var{day}/@var{year}}, where all fields are numbers, works; | |
1044 the format that @code{current-time-string} returns is also allowed. | |
1045 | |
1046 To specify a relative time, use numbers followed by units. | |
1047 For example: | |
1048 | |
1049 @table @samp | |
1050 @item 1 min | |
1051 denotes 1 minute from now. | |
1052 @item 1 min 5 sec | |
1053 denotes 65 seconds from now. | |
1054 @item 1 min 2 sec 3 hour 4 day 5 week 6 fortnight 7 month 8 year | |
1055 denotes exactly 103 months, 123 days, and 10862 seconds from now. | |
1056 @end table | |
1057 | |
1058 If @var{time} is an integer, that specifies a relative time measured in | |
1059 seconds. | |
1060 | |
1061 The argument @var{repeat} specifies how often to repeat the call. If | |
1062 @var{repeat} is @code{nil}, there are no repetitions; @var{function} is | |
1063 called just once, at @var{time}. If @var{repeat} is an integer, it | |
9009 | 1064 specifies a repetition period measured in seconds. In any case, @var{repeat} |
1065 has no effect on when @emph{first} call takes place---@var{time} specifies | |
1066 that. | |
1067 | |
1068 The function @code{run-at-time} returns a timer value that identifies | |
1069 the particular scheduled future action. You can use this value to call | |
1070 @code{cancel-timer}. | |
6558 | 1071 @end defun |
1072 | |
1073 @defun cancel-timer timer | |
1074 Cancel the requested action for @var{timer}, which should be a value | |
1075 previously returned by @code{run-at-time}. This cancels the effect of | |
1076 that call to @code{run-at-time}; the arrival of the specified time will | |
1077 not cause anything special to happen. | |
1078 @end defun | |
1079 | |
1080 @node Terminal Input | |
1081 @section Terminal Input | |
1082 @cindex terminal input | |
1083 | |
1084 This section describes functions and variables for recording or | |
1085 manipulating terminal input. See @ref{Display}, for related | |
1086 functions. | |
1087 | |
1088 @menu | |
1089 * Input Modes:: Options for how input is processed. | |
1090 * Translating Input:: Low level conversion of some characters or events | |
1091 into others. | |
1092 * Recording Input:: Saving histories of recent or all input events. | |
1093 @end menu | |
1094 | |
1095 @node Input Modes | |
1096 @subsection Input Modes | |
1097 @cindex input modes | |
1098 @cindex terminal input modes | |
1099 | |
1100 @defun set-input-mode interrupt flow meta quit-char | |
1101 This function sets the mode for reading keyboard input. If | |
1102 @var{interrupt} is non-null, then Emacs uses input interrupts. If it is | |
1103 @code{nil}, then it uses @sc{cbreak} mode. | |
1104 | |
1105 If @var{flow} is non-@code{nil}, then Emacs uses @sc{xon/xoff} (@kbd{C-q}, | |
9009 | 1106 @kbd{C-s}) flow control for output to the terminal. This has no effect except |
6558 | 1107 in @sc{cbreak} mode. @xref{Flow Control}. |
1108 | |
1109 The default setting is system dependent. Some systems always use | |
1110 @sc{cbreak} mode regardless of what is specified. | |
1111 | |
1112 @c Emacs 19 feature | |
1113 The argument @var{meta} controls support for input character codes | |
1114 above 127. If @var{meta} is @code{t}, Emacs converts characters with | |
1115 the 8th bit set into Meta characters. If @var{meta} is @code{nil}, | |
1116 Emacs disregards the 8th bit; this is necessary when the terminal uses | |
1117 it as a parity bit. If @var{meta} is neither @code{t} nor @code{nil}, | |
1118 Emacs uses all 8 bits of input unchanged. This is good for terminals | |
1119 using European 8-bit character sets. | |
1120 | |
1121 @c Emacs 19 feature | |
1122 If @var{quit-char} is non-@code{nil}, it specifies the character to | |
1123 use for quitting. Normally this character is @kbd{C-g}. | |
1124 @xref{Quitting}. | |
1125 @end defun | |
1126 | |
1127 The @code{current-input-mode} function returns the input mode settings | |
1128 Emacs is currently using. | |
1129 | |
1130 @c Emacs 19 feature | |
1131 @defun current-input-mode | |
1132 This function returns current mode for reading keyboard input. It | |
1133 returns a list, corresponding to the arguments of @code{set-input-mode}, | |
1134 of the form @code{(@var{interrupt} @var{flow} @var{meta} @var{quit})} in | |
1135 which: | |
1136 @table @var | |
1137 @item interrupt | |
1138 is non-@code{nil} when Emacs is using interrupt-driven input. If | |
1139 @code{nil}, Emacs is using @sc{cbreak} mode. | |
1140 @item flow | |
1141 is non-@code{nil} if Emacs uses @sc{xon/xoff} (@kbd{C-q}, @kbd{C-s}) | |
1142 flow control for output to the terminal. This value has no effect | |
1143 unless @var{interrupt} is non-@code{nil}. | |
1144 @item meta | |
1145 is non-@code{t} if Emacs treats the eighth bit of input characters as | |
1146 the meta bit; @code{nil} means Emacs clears the eighth bit of every | |
1147 input character; any other value means Emacs uses all eight bits as the | |
1148 basic character code. | |
1149 @item quit | |
1150 is the character Emacs currently uses for quitting, usually @kbd{C-g}. | |
1151 @end table | |
1152 @end defun | |
1153 | |
1154 @defvar meta-flag | |
1155 This variable used to control whether to treat the eight bit in keyboard | |
1156 input characters as the @key{Meta} bit. @code{nil} meant no, and | |
1157 anything else meant yes. This variable existed in Emacs versions 18 and | |
1158 earlier but no longer exists in Emacs 19; use @code{set-input-mode} | |
1159 instead. | |
1160 @end defvar | |
1161 | |
1162 @node Translating Input | |
1163 @subsection Translating Input Events | |
1164 @cindex translating input events | |
1165 | |
1166 This section describes features for translating input events into other | |
1167 input events before they become part of key sequences. | |
1168 | |
1169 @c Emacs 19 feature | |
1170 @defvar extra-keyboard-modifiers | |
1171 This variable lets Lisp programs ``press'' the modifier keys on the | |
1172 keyboard. The value is a bit mask: | |
1173 | |
1174 @table @asis | |
1175 @item 1 | |
1176 The @key{SHIFT} key. | |
1177 @item 2 | |
1178 The @key{LOCK} key. | |
1179 @item 4 | |
1180 The @key{CTL} key. | |
1181 @item 8 | |
1182 The @key{META} key. | |
1183 @end table | |
1184 | |
1185 Each time the user types a keyboard key, it is altered as if the | |
1186 modifier keys specified in the bit mask were held down. | |
1187 | |
1188 When you use X windows, the program can ``press'' any of the modifier | |
1189 keys in this way. Otherwise, only the @key{CTL} and @key{META} keys can | |
1190 be virtually pressed. | |
1191 @end defvar | |
1192 | |
1193 @defvar keyboard-translate-table | |
1194 This variable is the translate table for keyboard characters. It lets | |
1195 you reshuffle the keys on the keyboard without changing any command | |
1196 bindings. Its value must be a string or @code{nil}. | |
1197 | |
1198 If @code{keyboard-translate-table} is a string, then each character read | |
1199 from the keyboard is looked up in this string and the character in the | |
1200 string is used instead. If the string is of length @var{n}, character codes | |
1201 @var{n} and up are untranslated. | |
1202 | |
1203 In the example below, we set @code{keyboard-translate-table} to a | |
1204 string of 128 characters. Then we fill it in to swap the characters | |
1205 @kbd{C-s} and @kbd{C-\} and the characters @kbd{C-q} and @kbd{C-^}. | |
1206 Subsequently, typing @kbd{C-\} has all the usual effects of typing | |
1207 @kbd{C-s}, and vice versa. (@xref{Flow Control} for more information on | |
1208 this subject.) | |
1209 | |
1210 @cindex flow control example | |
1211 @example | |
1212 @group | |
1213 (defun evade-flow-control () | |
1214 "Replace C-s with C-\ and C-q with C-^." | |
1215 (interactive) | |
1216 @end group | |
1217 @group | |
1218 (let ((the-table (make-string 128 0))) | |
1219 (let ((i 0)) | |
1220 (while (< i 128) | |
1221 (aset the-table i i) | |
1222 (setq i (1+ i)))) | |
1223 @end group | |
1224 ;; @r{Swap @kbd{C-s} and @kbd{C-\}.} | |
1225 (aset the-table ?\034 ?\^s) | |
1226 (aset the-table ?\^s ?\034) | |
1227 @group | |
1228 ;; @r{Swap @kbd{C-q} and @kbd{C-^}.} | |
1229 (aset the-table ?\036 ?\^q) | |
1230 (aset the-table ?\^q ?\036) | |
1231 (setq keyboard-translate-table the-table))) | |
1232 @end group | |
1233 @end example | |
1234 | |
1235 Note that this translation is the first thing that happens to a | |
1236 character after it is read from the terminal. Record-keeping features | |
1237 such as @code{recent-keys} and dribble files record the characters after | |
1238 translation. | |
1239 @end defvar | |
1240 | |
1241 @defun keyboard-translate from to | |
1242 This function modifies @code{keyboard-translate-table} to translate | |
1243 character code @var{from} into character code @var{to}. It creates | |
1244 or enlarges the translate table if necessary. | |
1245 @end defun | |
1246 | |
1247 @defvar function-key-map | |
9009 | 1248 This variable holds a keymap that describes the character sequences |
6558 | 1249 sent by function keys on an ordinary character terminal. This keymap |
9009 | 1250 uses the same data structure as other keymaps, but is used differently: it |
6558 | 1251 specifies translations to make while reading events. |
1252 | |
1253 If @code{function-key-map} ``binds'' a key sequence @var{k} to a vector | |
1254 @var{v}, then when @var{k} appears as a subsequence @emph{anywhere} in a | |
1255 key sequence, it is replaced with the events in @var{v}. | |
1256 | |
1257 For example, VT100 terminals send @kbd{@key{ESC} O P} when the | |
1258 keypad PF1 key is pressed. Therefore, we want Emacs to translate | |
1259 that sequence of events into the single event @code{pf1}. We accomplish | |
1260 this by ``binding'' @kbd{@key{ESC} O P} to @code{[pf1]} in | |
1261 @code{function-key-map}, when using a VT100. | |
1262 | |
1263 Thus, typing @kbd{C-c @key{PF1}} sends the character sequence @kbd{C-c | |
1264 @key{ESC} O P}; later the function @code{read-key-sequence} translates | |
1265 this back into @kbd{C-c @key{PF1}}, which it returns as the vector | |
1266 @code{[?\C-c pf1]}. | |
1267 | |
1268 Entries in @code{function-key-map} are ignored if they conflict with | |
1269 bindings made in the minor mode, local, or global keymaps. The intent | |
1270 is that the character sequences that function keys send should not have | |
1271 command bindings in their own right. | |
1272 | |
1273 The value of @code{function-key-map} is usually set up automatically | |
1274 according to the terminal's Terminfo or Termcap entry, but sometimes | |
1275 those need help from terminal-specific Lisp files. Emacs comes with | |
1276 terminal-specific files for many common terminals; their main purpose is | |
1277 to make entries in @code{function-key-map} beyond those that can be | |
1278 deduced from Termcap and Terminfo. @xref{Terminal-Specific}. | |
1279 | |
1280 Emacs versions 18 and earlier used totally different means of detecting | |
1281 the character sequences that represent function keys. | |
1282 @end defvar | |
1283 | |
1284 @defvar key-translation-map | |
1285 This variable is another keymap used just like @code{function-key-map} | |
1286 to translate input events into other events. It differs from | |
1287 @code{function-key-map} in two ways: | |
1288 | |
1289 @itemize @bullet | |
1290 @item | |
1291 @code{key-translation-map} goes to work after @code{function-key-map} is | |
1292 finished; it receives the results of translation by | |
1293 @code{function-key-map}. | |
1294 | |
1295 @item | |
1296 @code{key-translation-map} overrides actual key bindings. | |
1297 @end itemize | |
1298 | |
1299 The intent of @code{key-translation-map} is for users to map one | |
1300 character set to another, including ordinary characters normally bound | |
1301 to @code{self-insert-command}. | |
1302 @end defvar | |
1303 | |
1304 @cindex key translation function | |
1305 You can use @code{function-key-map} or @code{key-translation-map} for | |
1306 more than simple aliases, by using a function, instead of a key | |
1307 sequence, as the ``translation'' of a key. Then this function is called | |
1308 to compute the translation of that key. | |
1309 | |
1310 The key translation function receives one argument, which is the prompt | |
1311 that was specified in @code{read-key-sequence}---or @code{nil} if the | |
1312 key sequence is being read by the editor command loop. In most cases | |
1313 you can ignore the prompt value. | |
1314 | |
1315 If the function reads input itself, it can have the effect of altering | |
1316 the event that follows. For example, here's how to define @kbd{C-c h} | |
1317 to turn the character that follows into a Hyper character: | |
1318 | |
1319 @example | |
1320 (defun hyperify (prompt) | |
1321 (let ((e (read-event))) | |
1322 (vector (if (numberp e) | |
1323 (logior (lsh 1 20) e) | |
1324 (if (memq 'hyper (event-modifiers e)) | |
1325 e | |
1326 (add-event-modifier "H-" e)))))) | |
1327 | |
1328 (defun add-event-modifier (string e) | |
1329 (let ((symbol (if (symbolp e) e (car e)))) | |
1330 (setq symbol (intern (concat string | |
1331 (symbol-name symbol)))) | |
1332 (if (symbolp e) | |
1333 symbol | |
1334 (cons symbol (cdr e))))) | |
1335 | |
1336 (define-key function-key-map "\C-ch" 'hyperify) | |
1337 @end example | |
1338 | |
1339 @pindex iso-transl | |
1340 @cindex Latin-1 character set (input) | |
1341 @cindex ISO Latin-1 characters (input) | |
1342 The @file{iso-transl} library uses this feature to provide a way of | |
1343 inputting non-ASCII Latin-1 characters. | |
1344 | |
1345 @node Recording Input | |
1346 @subsection Recording Input | |
1347 | |
1348 @defun recent-keys | |
1349 This function returns a vector containing the last 100 input events | |
1350 from the keyboard or mouse. All input events are included, whether or | |
1351 not they were used as parts of key sequences. Thus, you always get the | |
1352 last 100 inputs, not counting keyboard macros. (Events from keyboard | |
1353 macros are excluded because they are less interesting for debugging; it | |
9009 | 1354 should be enough to see the events that invoked the macros.) |
6558 | 1355 @end defun |
1356 | |
1357 @deffn Command open-dribble-file filename | |
1358 @cindex dribble file | |
1359 This function opens a @dfn{dribble file} named @var{filename}. When a | |
1360 dribble file is open, each input event from the keyboard or mouse (but | |
1361 not those from keyboard macros) is written in that file. A | |
1362 non-character event is expressed using its printed representation | |
1363 surrounded by @samp{<@dots{}>}. | |
1364 | |
1365 You close the dribble file by calling this function with an argument | |
1366 of @code{nil}. | |
1367 | |
1368 This function is normally used to record the input necessary to | |
1369 trigger an Emacs bug, for the sake of a bug report. | |
1370 | |
1371 @example | |
1372 @group | |
1373 (open-dribble-file "~/dribble") | |
1374 @result{} nil | |
1375 @end group | |
1376 @end example | |
1377 @end deffn | |
1378 | |
1379 See also the @code{open-termscript} function (@pxref{Terminal Output}). | |
1380 | |
1381 @node Terminal Output | |
1382 @section Terminal Output | |
1383 @cindex terminal output | |
1384 | |
1385 The terminal output functions send output to the terminal or keep | |
1386 track of output sent to the terminal. The variable @code{baud-rate} | |
1387 tells you what Emacs thinks is the output speed of the terminal. | |
1388 | |
1389 @defvar baud-rate | |
1390 This variable's value is the output speed of the terminal, as far as | |
1391 Emacs knows. Setting this variable does not change the speed of actual | |
1392 data transmission, but the value is used for calculations such as | |
1393 padding. It also affects decisions about whether to scroll part of the | |
9009 | 1394 screen or repaint---even when using a window system. (We designed it |
6558 | 1395 this way despite the fact that a window system has no true ``output |
1396 speed'', to give you a way to tune these decisions.) | |
1397 | |
1398 The value is measured in baud. | |
1399 @end defvar | |
1400 | |
1401 If you are running across a network, and different parts of the | |
1402 network work at different baud rates, the value returned by Emacs may be | |
1403 different from the value used by your local terminal. Some network | |
1404 protocols communicate the local terminal speed to the remote machine, so | |
1405 that Emacs and other programs can get the proper value, but others do | |
1406 not. If Emacs has the wrong value, it makes decisions that are less | |
1407 than optimal. To fix the problem, set @code{baud-rate}. | |
1408 | |
1409 @defun baud-rate | |
1410 This function returns the value of the variable @code{baud-rate}. In | |
1411 Emacs versions 18 and earlier, this was the only way to find out the | |
1412 terminal speed. | |
1413 @end defun | |
1414 | |
1415 @defun send-string-to-terminal string | |
1416 This function sends @var{string} to the terminal without alteration. | |
1417 Control characters in @var{string} have terminal-dependent effects. | |
1418 | |
1419 One use of this function is to define function keys on terminals that | |
1420 have downloadable function key definitions. For example, this is how on | |
1421 certain terminals to define function key 4 to move forward four | |
1422 characters (by transmitting the characters @kbd{C-u C-f} to the | |
1423 computer): | |
1424 | |
1425 @example | |
1426 @group | |
1427 (send-string-to-terminal "\eF4\^U\^F") | |
1428 @result{} nil | |
1429 @end group | |
1430 @end example | |
1431 @end defun | |
1432 | |
1433 @deffn Command open-termscript filename | |
1434 @cindex termscript file | |
1435 This function is used to open a @dfn{termscript file} that will record | |
1436 all the characters sent by Emacs to the terminal. It returns | |
1437 @code{nil}. Termscript files are useful for investigating problems | |
1438 where Emacs garbles the screen, problems that are due to incorrect | |
1439 Termcap entries or to undesirable settings of terminal options more | |
1440 often than to actual Emacs bugs. Once you are certain which characters | |
1441 were actually output, you can determine reliably whether they correspond | |
1442 to the Termcap specifications in use. | |
1443 | |
1444 See also @code{open-dribble-file} in @ref{Terminal Input}. | |
1445 | |
1446 @example | |
1447 @group | |
1448 (open-termscript "../junk/termscript") | |
1449 @result{} nil | |
1450 @end group | |
1451 @end example | |
1452 @end deffn | |
1453 | |
1454 @node Special Keysyms | |
1455 @section System-Specific X11 Keysyms | |
1456 | |
1457 To define system-specific X11 keysyms, set the variable | |
1458 @code{system-key-alist}. | |
1459 | |
1460 @defvar system-key-alist | |
1461 This variable's value should be an alist with one element for each | |
1462 system-specific keysym. An element has this form: @code{(@var{code} | |
1463 . @var{symbol})}, where @var{code} is the numeric keysym code (not | |
1464 including the ``vendor specific'' bit, 1 << 28), and @var{symbol} is the | |
1465 name for the function key. | |
1466 | |
1467 For example @code{(168 . mute-acute)} defines a system-specific key used | |
1468 by HP X servers whose numeric code is (1 << 28) + 168. | |
1469 | |
1470 It is not a problem if the alist defines keysyms for other X servers, as | |
1471 long as they don't conflict with the ones used by the X server actually | |
1472 in use. | |
12067 | 1473 |
1474 The variable is always local to the current X terminal and cannot be | |
1475 buffer-local. @xref{Multiple Displays}. | |
6558 | 1476 @end defvar |
1477 | |
1478 @node Flow Control | |
1479 @section Flow Control | |
1480 @cindex flow control characters | |
1481 | |
1482 This section attempts to answer the question ``Why does Emacs choose | |
1483 to use flow-control characters in its command character set?'' For a | |
1484 second view on this issue, read the comments on flow control in the | |
1485 @file{emacs/INSTALL} file from the distribution; for help with Termcap | |
1486 entries and DEC terminal concentrators, see @file{emacs/etc/TERMS}. | |
1487 | |
1488 @cindex @kbd{C-s} | |
1489 @cindex @kbd{C-q} | |
1490 At one time, most terminals did not need flow control, and none used | |
1491 @code{C-s} and @kbd{C-q} for flow control. Therefore, the choice of | |
1492 @kbd{C-s} and @kbd{C-q} as command characters was uncontroversial. | |
1493 Emacs, for economy of keystrokes and portability, used nearly all the | |
1494 @sc{ASCII} control characters, with mnemonic meanings when possible; | |
1495 thus, @kbd{C-s} for search and @kbd{C-q} for quote. | |
1496 | |
1497 Later, some terminals were introduced which required these characters | |
1498 for flow control. They were not very good terminals for full-screen | |
1499 editing, so Emacs maintainers did not pay attention. In later years, | |
1500 flow control with @kbd{C-s} and @kbd{C-q} became widespread among | |
1501 terminals, but by this time it was usually an option. And the majority | |
1502 of users, who can turn flow control off, were unwilling to switch to | |
1503 less mnemonic key bindings for the sake of flow control. | |
1504 | |
1505 So which usage is ``right'', Emacs's or that of some terminal and | |
1506 concentrator manufacturers? This question has no simple answer. | |
1507 | |
1508 One reason why we are reluctant to cater to the problems caused by | |
1509 @kbd{C-s} and @kbd{C-q} is that they are gratuitous. There are other | |
1510 techniques (albeit less common in practice) for flow control that | |
1511 preserve transparency of the character stream. Note also that their use | |
1512 for flow control is not an official standard. Interestingly, on the | |
1513 model 33 teletype with a paper tape punch (which is very old), @kbd{C-s} | |
1514 and @kbd{C-q} were sent by the computer to turn the punch on and off! | |
1515 | |
1516 GNU Emacs version 19 provides a convenient way of enabling flow | |
1517 control if you want it: call the function @code{enable-flow-control}. | |
1518 | |
1519 @defun enable-flow-control | |
1520 This function enables use of @kbd{C-s} and @kbd{C-q} for output flow | |
1521 control, and provides the characters @kbd{C-\} and @kbd{C-^} as aliases | |
1522 for them using @code{keyboard-translate-table} (@pxref{Translating Input}). | |
1523 @end defun | |
1524 | |
1525 You can use the function @code{enable-flow-control-on} in your | |
1526 @file{.emacs} file to enable flow control automatically on certain | |
1527 terminal types. | |
1528 | |
1529 @defun enable-flow-control-on &rest termtypes | |
1530 This function enables flow control, and the aliases @kbd{C-\} and @kbd{C-^}, | |
1531 if the terminal type is one of @var{termtypes}. For example: | |
1532 | |
1533 @smallexample | |
1534 (enable-flow-control-on "vt200" "vt300" "vt101" "vt131") | |
1535 @end smallexample | |
1536 @end defun | |
1537 | |
1538 Here is how @code{enable-flow-control} does its job: | |
1539 | |
1540 @enumerate | |
1541 @item | |
1542 @cindex @sc{cbreak} | |
1543 It sets @sc{cbreak} mode for terminal input, and tells the operating | |
1544 system to handle flow control, with @code{(set-input-mode nil t)}. | |
1545 | |
1546 @item | |
1547 It sets up @code{keyboard-translate-table} to translate @kbd{C-\} and | |
9009 | 1548 @kbd{C-^} into @kbd{C-s} and @kbd{C-q}. Except at its very |
6558 | 1549 lowest level, Emacs never knows that the characters typed were anything |
1550 but @kbd{C-s} and @kbd{C-q}, so you can in effect type them as @kbd{C-\} | |
1551 and @kbd{C-^} even when they are input for other commands. | |
1552 @xref{Translating Input}. | |
7086
075343a6b32b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6558
diff
changeset
|
1553 @end enumerate |
6558 | 1554 |
1555 If the terminal is the source of the flow control characters, then once | |
1556 you enable kernel flow control handling, you probably can make do with | |
1557 less padding than normal for that terminal. You can reduce the amount | |
1558 of padding by customizing the Termcap entry. You can also reduce it by | |
1559 setting @code{baud-rate} to a smaller value so that Emacs uses a smaller | |
1560 speed when calculating the padding needed. @xref{Terminal Output}. | |
1561 | |
1562 @node Batch Mode | |
1563 @section Batch Mode | |
1564 @cindex batch mode | |
1565 @cindex noninteractive use | |
1566 | |
1567 The command line option @samp{-batch} causes Emacs to run | |
1568 noninteractively. In this mode, Emacs does not read commands from the | |
1569 terminal, it does not alter the terminal modes, and it does not expect | |
1570 to be outputting to an erasable screen. The idea is that you specify | |
1571 Lisp programs to run; when they are finished, Emacs should exit. The | |
1572 way to specify the programs to run is with @samp{-l @var{file}}, which | |
1573 loads the library named @var{file}, and @samp{-f @var{function}}, which | |
1574 calls @var{function} with no arguments. | |
1575 | |
1576 Any Lisp program output that would normally go to the echo area, | |
1577 either using @code{message} or using @code{prin1}, etc., with @code{t} | |
1578 as the stream, goes instead to Emacs's standard output descriptor when | |
1579 in batch mode. Thus, Emacs behaves much like a noninteractive | |
1580 application program. (The echo area output that Emacs itself normally | |
1581 generates, such as command echoing, is suppressed entirely.) | |
1582 | |
1583 @defvar noninteractive | |
1584 This variable is non-@code{nil} when Emacs is running in batch mode. | |
1585 @end defvar |