2 @c This is part of the XEmacs Lisp Reference Manual.
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
4 @c See the file lispref.texi for copying conditions.
5 @setfilename ../../info/os.info
6 @node System Interface, X-Windows, Processes, Top
7 @chapter Operating System Interface
9 This chapter is about starting and getting out of Emacs, access to
10 values in the operating system environment, and terminal input, output,
13 @xref{Building XEmacs}, for related information. See also
14 @ref{Display}, for additional operating system status information
15 pertaining to the terminal and the screen.
18 * Starting Up:: Customizing XEmacs 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.
23 * Time Conversion:: Converting a time from numeric form to a string, or
24 to calendrical data (or vice versa).
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 * Flow Control:: How to turn output flow control on or off.
29 * Batch Mode:: Running XEmacs without terminal interaction.
32 * Special Keysyms:: Defining system-specific key symbols for X windows.
36 @section Starting Up XEmacs
38 This section describes what XEmacs does when it is started, and how you
39 can customize these actions.
42 * Start-up Summary:: Sequence of actions XEmacs performs at start-up.
43 * Init File:: Details on reading the init file (@file{.emacs}).
44 * Terminal-Specific:: How the terminal-specific Lisp file is read.
45 * Command Line Arguments:: How command line arguments are processed,
46 and how you can customize them.
49 @node Start-up Summary
50 @subsection Summary: Sequence of Actions at Start Up
51 @cindex initialization
52 @cindex start up of XEmacs
53 @cindex @file{startup.el}
55 The order of operations performed (in @file{startup.el}) by XEmacs when
56 it is started up is as follows:
60 It loads the initialization library for the window system, if you are
61 using a window system. This library's name is
62 @file{term/@var{windowsystem}-win.el}.
65 It processes the initial options. (Some of them are handled
66 even earlier than this.)
69 It initializes the X window frame and faces, if appropriate.
72 It runs the normal hook @code{before-init-hook}.
75 It loads the library @file{site-start}, unless the option
76 @samp{-no-site-file} was specified. The library's file name is usually
78 @cindex @file{site-start.el}
81 It loads the file @file{~/.emacs} unless @samp{-q} was specified on
82 the command line. (This is not done in @samp{-batch} mode.) The @samp{-u}
83 option can specify the user name whose home directory should be used
87 It loads the library @file{default} unless @code{inhibit-default-init}
88 is non-@code{nil}. (This is not done in @samp{-batch} mode or if
89 @samp{-q} was specified on the command line.) The library's file name
90 is usually @file{default.el}.
91 @cindex @file{default.el}
94 It runs the normal hook @code{after-init-hook}.
97 It sets the major mode according to @code{initial-major-mode}, provided
98 the buffer @samp{*scratch*} is still current and still in Fundamental
102 It loads the terminal-specific Lisp file, if any, except when in batch
103 mode or using a window system.
106 It displays the initial echo area message, unless you have suppressed
107 that with @code{inhibit-startup-echo-area-message}.
110 It processes the action arguments from the command line.
113 It runs @code{term-setup-hook}.
116 It calls @code{frame-notice-user-settings}, which modifies the
117 parameters of the selected frame according to whatever the init files
121 It runs @code{window-setup-hook}. @xref{Terminal-Specific}.
124 It displays copyleft, nonwarranty, and basic use information, provided
125 there were no remaining command line arguments (a few steps above) and
126 the value of @code{inhibit-startup-message} is @code{nil}.
129 @defopt inhibit-startup-message
130 This variable inhibits the initial startup messages (the nonwarranty,
131 etc.). If it is non-@code{nil}, then the messages are not printed.
133 This variable exists so you can set it in your personal init file, once
134 you are familiar with the contents of the startup message. Do not set
135 this variable in the init file of a new user, or in a way that affects
136 more than one user, because that would prevent new users from receiving
137 the information they are supposed to see.
140 @defopt inhibit-startup-echo-area-message
141 This variable controls the display of the startup echo area message.
142 You can suppress the startup echo area message by adding text with this
143 form to your @file{.emacs} file:
146 (setq inhibit-startup-echo-area-message
147 "@var{your-login-name}")
150 Simply setting @code{inhibit-startup-echo-area-message} to your login
151 name is not sufficient to inhibit the message; Emacs explicitly checks
152 whether @file{.emacs} contains an expression as shown above. Your login
153 name must appear in the expression as a Lisp string constant.
155 This way, you can easily inhibit the message for yourself if you wish,
156 but thoughtless copying of your @file{.emacs} file will not inhibit the
157 message for someone else.
161 @subsection The Init File: @file{.emacs}
163 @cindex @file{.emacs}
165 When you start XEmacs, it normally attempts to load the file
166 @file{.emacs} from your home directory. This file, if it exists, must
167 contain Lisp code. It is called your @dfn{init file}. The command line
168 switches @samp{-q} and @samp{-u} affect the use of the init file;
169 @samp{-q} says not to load an init file, and @samp{-u} says to load a
170 specified user's init file instead of yours. @xref{Entering XEmacs,,,
171 xemacs, The XEmacs User's Manual}.
173 @cindex default init file
174 A site may have a @dfn{default init file}, which is the library named
175 @file{default.el}. XEmacs finds the @file{default.el} file through the
176 standard search path for libraries (@pxref{How Programs Do Loading}).
177 The XEmacs distribution does not come with this file; sites may provide
178 one for local customizations. If the default init file exists, it is
179 loaded whenever you start Emacs, except in batch mode or if @samp{-q} is
180 specified. But your own personal init file, if any, is loaded first; if
181 it sets @code{inhibit-default-init} to a non-@code{nil} value, then
182 XEmacs does not subsequently load the @file{default.el} file.
184 Another file for site-customization is @file{site-start.el}. Emacs
185 loads this @emph{before} the user's init file. You can inhibit the
186 loading of this file with the option @samp{-no-site-file}.
188 @defvar site-run-file
189 This variable specifies the site-customization file to load
190 before the user's init file. Its normal value is @code{"site-start"}.
193 If there is a great deal of code in your @file{.emacs} file, you
194 should move it into another file named @file{@var{something}.el},
195 byte-compile it (@pxref{Byte Compilation}), and make your @file{.emacs}
196 file load the other file using @code{load} (@pxref{Loading}).
198 @xref{Init File Examples,,, xemacs, The XEmacs User's Manual}, for
199 examples of how to make various commonly desired customizations in your
202 @defopt inhibit-default-init
203 This variable prevents XEmacs from loading the default initialization
204 library file for your session of XEmacs. If its value is non-@code{nil},
205 then the default library is not loaded. The default value is
209 @defvar before-init-hook
210 @defvarx after-init-hook
211 These two normal hooks are run just before, and just after, loading of
212 the user's init file, @file{default.el}, and/or @file{site-start.el}.
215 @node Terminal-Specific
216 @subsection Terminal-Specific Initialization
217 @cindex terminal-specific initialization
219 Each terminal type can have its own Lisp library that XEmacs loads when
220 run on that type of terminal. For a terminal type named @var{termtype},
221 the library is called @file{term/@var{termtype}}. XEmacs finds the file
222 by searching the @code{load-path} directories as it does for other
223 files, and trying the @samp{.elc} and @samp{.el} suffixes. Normally,
224 terminal-specific Lisp library is located in @file{emacs/lisp/term}, a
225 subdirectory of the @file{emacs/lisp} directory in which most XEmacs Lisp
226 libraries are kept.@refill
228 The library's name is constructed by concatenating the value of the
229 variable @code{term-file-prefix} and the terminal type. Normally,
230 @code{term-file-prefix} has the value @code{"term/"}; changing this
233 The usual function of a terminal-specific library is to enable special
234 keys to send sequences that XEmacs can recognize. It may also need to
235 set or add to @code{function-key-map} if the Termcap entry does not
236 specify all the terminal's function keys. @xref{Terminal Input}.
239 When the name of the terminal type contains a hyphen, only the part of
240 the name before the first hyphen is significant in choosing the library
241 name. Thus, terminal types @samp{aaa-48} and @samp{aaa-30-rv} both use
242 the @file{term/aaa} library. If necessary, the library can evaluate
243 @code{(getenv "TERM")} to find the full name of the terminal
246 Your @file{.emacs} file can prevent the loading of the
247 terminal-specific library by setting the variable
248 @code{term-file-prefix} to @code{nil}. This feature is useful when
249 experimenting with your own peculiar customizations.
251 You can also arrange to override some of the actions of the
252 terminal-specific library by setting the variable
253 @code{term-setup-hook}. This is a normal hook which XEmacs runs using
254 @code{run-hooks} at the end of XEmacs initialization, after loading both
255 your @file{.emacs} file and any terminal-specific libraries. You can
256 use this variable to define initializations for terminals that do not
257 have their own libraries. @xref{Hooks}.
259 @defvar term-file-prefix
260 @cindex @code{TERM} environment variable
261 If the @code{term-file-prefix} variable is non-@code{nil}, XEmacs loads
262 a terminal-specific initialization file as follows:
265 (load (concat term-file-prefix (getenv "TERM")))
269 You may set the @code{term-file-prefix} variable to @code{nil} in your
270 @file{.emacs} file if you do not wish to load the
271 terminal-initialization file. To do this, put the following in
272 your @file{.emacs} file: @code{(setq term-file-prefix nil)}.
275 @defvar term-setup-hook
276 This variable is a normal hook that XEmacs runs after loading your
277 @file{.emacs} file, the default initialization file (if any) and the
278 terminal-specific Lisp file.
280 You can use @code{term-setup-hook} to override the definitions made by a
281 terminal-specific file.
284 @defvar window-setup-hook
285 This variable is a normal hook which XEmacs runs after loading your
286 @file{.emacs} file and the default initialization file (if any), after
287 loading terminal-specific Lisp code, and after running the hook
288 @code{term-setup-hook}.
291 @node Command Line Arguments
292 @subsection Command Line Arguments
293 @cindex command line arguments
295 You can use command line arguments to request various actions when you
296 start XEmacs. Since you do not need to start XEmacs more than once per
297 day, and will often leave your XEmacs session running longer than that,
298 command line arguments are hardly ever used. As a practical matter, it
299 is best to avoid making the habit of using them, since this habit would
300 encourage you to kill and restart XEmacs unnecessarily often. These
301 options exist for two reasons: to be compatible with other editors (for
302 invocation by other programs) and to enable shell scripts to run
303 specific Lisp programs.
305 This section describes how Emacs processes command line arguments,
306 and how you can customize them.
309 (Note that some other editors require you to start afresh each time
310 you want to edit a file. With this kind of editor, you will probably
311 specify the file as a command line argument. The recommended way to
312 use XEmacs is to start it only once, just after you log in, and do
313 all your editing in the same XEmacs process. Each time you want to edit
314 a different file, you visit it with the existing XEmacs, which eventually
315 comes to have many files in it ready for editing. Usually you do not
316 kill the XEmacs until you are about to log out.)
320 This function parses the command line that XEmacs was called with,
321 processes it, loads the user's @file{.emacs} file and displays the
325 @defvar command-line-processed
326 The value of this variable is @code{t} once the command line has been
329 If you redump XEmacs by calling @code{dump-emacs}, you may wish to set
330 this variable to @code{nil} first in order to cause the new dumped XEmacs
331 to process its new command line arguments.
334 @defvar command-switch-alist
335 @cindex switches on command line
336 @cindex options on command line
337 @cindex command line options
338 The value of this variable is an alist of user-defined command-line
339 options and associated handler functions. This variable exists so you
340 can add elements to it.
342 A @dfn{command line option} is an argument on the command line of the
349 The elements of the @code{command-switch-alist} look like this:
352 (@var{option} . @var{handler-function})
355 The @var{handler-function} is called to handle @var{option} and receives
356 the option name as its sole argument.
358 In some cases, the option is followed in the command line by an
359 argument. In these cases, the @var{handler-function} can find all the
360 remaining command-line arguments in the variable
361 @code{command-line-args-left}. (The entire list of command-line
362 arguments is in @code{command-line-args}.)
364 The command line arguments are parsed by the @code{command-line-1}
365 function in the @file{startup.el} file. See also @ref{Command
366 Switches, , Command Line Switches and Arguments, xemacs, The XEmacs
370 @defvar command-line-args
371 The value of this variable is the list of command line arguments passed
375 @defvar command-line-functions
376 This variable's value is a list of functions for handling an
377 unrecognized command-line argument. Each time the next argument to be
378 processed has no special meaning, the functions in this list are called,
379 in order of appearance, until one of them returns a non-@code{nil}
382 These functions are called with no arguments. They can access the
383 command-line argument under consideration through the variable
384 @code{argi}. The remaining arguments (not including the current one)
385 are in the variable @code{command-line-args-left}.
387 When a function recognizes and processes the argument in @code{argi}, it
388 should return a non-@code{nil} value to say it has dealt with that
389 argument. If it has also dealt with some of the following arguments, it
390 can indicate that by deleting them from @code{command-line-args-left}.
392 If all of these functions return @code{nil}, then the argument is used
393 as a file name to visit.
397 @section Getting out of XEmacs
398 @cindex exiting XEmacs
400 There are two ways to get out of XEmacs: you can kill the XEmacs job,
401 which exits permanently, or you can suspend it, which permits you to
402 reenter the XEmacs process later. As a practical matter, you seldom kill
403 XEmacs---only when you are about to log out. Suspending is much more
407 * Killing XEmacs:: Exiting XEmacs irreversibly.
408 * Suspending XEmacs:: Exiting XEmacs reversibly.
412 @subsection Killing XEmacs
413 @cindex killing XEmacs
415 Killing XEmacs means ending the execution of the XEmacs process. The
416 parent process normally resumes control. The low-level primitive for
417 killing XEmacs is @code{kill-emacs}.
419 @deffn Command kill-emacs &optional exit-data
420 This function exits the XEmacs process and kills it.
422 If @var{exit-data} is an integer, then it is used as the exit status
423 of the XEmacs process. (This is useful primarily in batch operation; see
426 If @var{exit-data} is a string, its contents are stuffed into the
427 terminal input buffer so that the shell (or whatever program next reads
428 input) can read them.
431 All the information in the XEmacs process, aside from files that have
432 been saved, is lost when the XEmacs is killed. Because killing XEmacs
433 inadvertently can lose a lot of work, XEmacs queries for confirmation
434 before actually terminating if you have buffers that need saving or
435 subprocesses that are running. This is done in the function
436 @code{save-buffers-kill-emacs}.
438 @defvar kill-emacs-query-functions
439 After asking the standard questions, @code{save-buffers-kill-emacs}
440 calls the functions in the list @code{kill-buffer-query-functions}, in
441 order of appearance, with no arguments. These functions can ask for
442 additional confirmation from the user. If any of them returns
443 non-@code{nil}, XEmacs is not killed.
446 @defvar kill-emacs-hook
447 This variable is a normal hook; once @code{save-buffers-kill-emacs} is
448 finished with all file saving and confirmation, it runs the functions in
452 @node Suspending XEmacs
453 @subsection Suspending XEmacs
454 @cindex suspending XEmacs
456 @dfn{Suspending XEmacs} means stopping XEmacs temporarily and returning
457 control to its superior process, which is usually the shell. This
458 allows you to resume editing later in the same XEmacs process, with the
459 same buffers, the same kill ring, the same undo history, and so on. To
460 resume XEmacs, use the appropriate command in the parent shell---most
463 Some operating systems do not support suspension of jobs; on these
464 systems, ``suspension'' actually creates a new shell temporarily as a
465 subprocess of XEmacs. Then you would exit the shell to return to XEmacs.
467 Suspension is not useful with window systems such as X, because the
468 XEmacs job may not have a parent that can resume it again, and in any
469 case you can give input to some other job such as a shell merely by
470 moving to a different window. Therefore, suspending is not allowed
471 when XEmacs is an X client.
473 @deffn Command suspend-emacs &optional stuffstring
474 This function stops XEmacs and returns control to the superior process.
475 If and when the superior process resumes XEmacs, @code{suspend-emacs}
476 returns @code{nil} to its caller in Lisp.
478 If optional arg @var{stuffstring} is non-@code{nil}, its characters are
479 sent to be read as terminal input by XEmacs's superior shell. The
480 characters in @var{stuffstring} are not echoed by the superior shell;
481 only the results appear.
483 Before suspending, @code{suspend-emacs} runs the normal hook
484 @code{suspend-hook}. In Emacs version 18, @code{suspend-hook} was not a
485 normal hook; its value was a single function, and if its value was
486 non-@code{nil}, then @code{suspend-emacs} returned immediately without
487 actually suspending anything.
489 After the user resumes XEmacs, @code{suspend-emacs} runs the normal hook
490 @code{suspend-resume-hook}. @xref{Hooks}.
492 The next redisplay after resumption will redraw the entire screen,
493 unless the variable @code{no-redraw-on-reenter} is non-@code{nil}
494 (@pxref{Refresh Screen}).
496 In the following example, note that @samp{pwd} is not echoed after
497 XEmacs is suspended. But it is read and executed by the shell.
506 (add-hook 'suspend-hook
510 (error "Suspend cancelled")))))
511 @result{} (lambda nil
512 (or (y-or-n-p "Really suspend? ")
513 (error "Suspend cancelled")))
516 (add-hook 'suspend-resume-hook
517 (function (lambda () (message "Resumed!"))))
518 @result{} (lambda nil (message "Resumed!"))
521 (suspend-emacs "pwd")
525 ---------- Buffer: Minibuffer ----------
526 Really suspend? @kbd{y}
527 ---------- Buffer: Minibuffer ----------
531 ---------- Parent Shell ----------
532 lewis@@slug[23] % /user/lewis/manual
537 ---------- Echo Area ----------
544 This variable is a normal hook run before suspending.
547 @defvar suspend-resume-hook
548 This variable is a normal hook run after suspending.
551 @node System Environment
552 @section Operating System Environment
553 @cindex operating system environment
555 XEmacs provides access to variables in the operating system environment
556 through various functions. These variables include the name of the
557 system, the user's @sc{uid}, and so on.
560 The value of this variable is a symbol indicating the type of operating
561 system XEmacs is operating on. Here is a table of the possible values:
571 Data General DGUX operating system.
574 A GNU system using the GNU HURD and Mach.
577 Hewlett-Packard HPUX operating system.
580 Silicon Graphics Irix system.
583 A GNU system using the Linux kernel.
586 Microsoft MS-DOS ``operating system.''
589 NeXT Mach-based system.
592 Masscomp RTU, UCB universe.
601 Microsoft windows NT.
607 We do not wish to add new symbols to make finer distinctions unless it
608 is absolutely necessary! In fact, we hope to eliminate some of these
609 alternatives in the future. We recommend using
610 @code{system-configuration} to distinguish between different operating
614 @defvar system-configuration
615 This variable holds the three-part configuration name for the
616 hardware/software configuration of your system, as a string. The
617 convenient way to test parts of this string is with @code{string-match}.
621 This function returns the name of the machine you are running on.
624 @result{} "prep.ai.mit.edu"
629 The symbol @code{system-name} is a variable as well as a function. In
630 fact, the function returns whatever value the variable
631 @code{system-name} currently holds. Thus, you can set the variable
632 @code{system-name} in case Emacs is confused about the name of your
633 system. The variable is also useful for constructing frame titles
634 (@pxref{Frame Titles}).
636 @defvar mail-host-address
637 If this variable is non-@code{nil}, it is used instead of
638 @code{system-name} for purposes of generating email addresses. For
639 example, it is used when constructing the default value of
640 @code{user-mail-address}. @xref{User Identification}. (Since this is
641 done when XEmacs starts up, the value actually used is the one saved when
642 XEmacs was dumped. @xref{Building XEmacs}.)
645 @deffn Command getenv var &optional interactivep
646 @cindex environment variable access
647 This function returns the value of the environment variable @var{var},
648 as a string. Within XEmacs, the environment variable values are kept in
649 the Lisp variable @code{process-environment}.
651 When invoked interactively, @code{getenv} prints the value in the echo area.
660 lewis@@slug[10] % printenv
661 PATH=.:/user/lewis/bin:/usr/bin:/usr/local/bin
672 @deffn Command setenv variable &optional value unset
673 This command sets the value of the environment variable named
674 @var{variable} to @var{value}. Both arguments should be strings. This
675 function works by modifying @code{process-environment}; binding that
676 variable with @code{let} is also reasonable practice.
679 @defvar process-environment
680 This variable is a list of strings, each describing one environment
681 variable. The functions @code{getenv} and @code{setenv} work by
682 manipulating this variable.
687 @result{} ("l=/usr/stanford/lib/gnuemacs/lisp"
688 "PATH=.:/user/lewis/bin:/usr/class:/nfsusr/local/bin"
699 @defvar path-separator
700 This variable holds a string which says which character separates
701 directories in a search path (as found in an environment variable). Its
702 value is @code{":"} for Unix and GNU systems, and @code{";"} for MS-DOS
706 @defvar invocation-name
707 This variable holds the program name under which Emacs was invoked. The
708 value is a string, and does not include a directory name.
711 @defvar invocation-directory
712 This variable holds the directory from which the Emacs executable was
713 invoked, or perhaps @code{nil} if that directory cannot be determined.
716 @defvar installation-directory
717 If non-@code{nil}, this is a directory within which to look for the
718 @file{lib-src} and @file{etc} subdirectories. This is non-@code{nil}
719 when Emacs can't find those directories in their standard installed
720 locations, but can find them in a directory related somehow to the one
721 containing the Emacs executable.
724 @defun load-average &optional use-floats
725 This function returns a list of the current 1-minute, 5-minute and
726 15-minute load averages. The values are integers that are 100 times the
727 system load averages. (The load averages indicate the number of
728 processes trying to run.)
730 When @var{use-floats} is non-@code{nil}, floats will be returned instead
731 of integers. These floats are not multiplied by 100.
736 @result{} (169 158 164)
738 @result{} (1.69921875 1.58984375 1.640625)
742 lewis@@rocky[5] % uptime
743 8:06pm up 16 day(s), 21:57, 40 users,
744 load average: 1.68, 1.59, 1.64
748 If the 5-minute or 15-minute load averages are not available, return a
749 shortened list, containing only those averages which are available.
751 On some systems, this function may require special privileges to run, or
752 it may be unimplemented for the particular system type. In that case,
753 the function will signal an error.
757 This function returns the process @sc{id} of the Emacs process.
760 @node User Identification
761 @section User Identification
763 @defvar user-mail-address
764 This holds the nominal email address of the user who is using Emacs.
765 When Emacs starts up, it computes a default value that is usually right,
766 but users often set this themselves when the default value is not right.
769 @defun user-login-name &optional uid
770 If you don't specify @var{uid}, this function returns the name under
771 which the user is logged in. If the environment variable @code{LOGNAME}
772 is set, that value is used. Otherwise, if the environment variable
773 @code{USER} is set, that value is used. Otherwise, the value is based
774 on the effective @sc{uid}, not the real @sc{uid}.
776 If you specify @var{uid}, the value is the user name that corresponds
777 to @var{uid} (which should be an integer).
787 @defun user-real-login-name
788 This function returns the user name corresponding to Emacs's real
789 @sc{uid}. This ignores the effective @sc{uid} and ignores the
790 environment variables @code{LOGNAME} and @code{USER}.
793 @defvar user-full-name
794 This variable holds the name of the user running this Emacs. It is
795 initialized at startup time from the value of @code{NAME} environment
796 variable. You can change the value of this variable to alter the result
797 of the @code{user-full-name} function.
800 @defun user-full-name &optional user
801 This function returns the full name of @var{user}. If @var{user} is
802 @code{nil}, it defaults to the user running this Emacs. In that case,
803 the value of @code{user-full-name} variable, if non-@code{nil}, will be
806 If @var{user} is specified explicitly, @code{user-full-name} variable is
812 @result{} "Hrvoje Niksic"
813 (setq user-full-name "Hrvoje \"Niksa\" Niksic")
815 @result{} "Hrvoje \"Niksa\" Niksic"
816 (user-full-name "hniksic")
817 @result{} "Hrvoje Niksic"
822 @vindex user-full-name
823 @vindex user-real-login-name
824 @vindex user-login-name
825 The symbols @code{user-login-name}, @code{user-real-login-name} and
826 @code{user-full-name} are variables as well as functions. The functions
827 return the same values that the variables hold. These variables allow
828 you to ``fake out'' Emacs by telling the functions what to return. The
829 variables are also useful for constructing frame titles (@pxref{Frame
833 This function returns the real @sc{uid} of the user.
844 This function returns the effective @sc{uid} of the user.
847 @defun user-home-directory
848 This function returns the ``@code{HOME}'' directory of the user, and is
849 intended to replace occurrences of ``@code{(getenv "HOME")}''. Under
850 Unix systems, the following is done:
854 Return the value of ``@code{(getenv "HOME")}'', if set.
857 Return ``/'', as a fallback, but issue a warning. (Future versions of
858 XEmacs will also attempt to lookup the @code{HOME} directory via
859 @code{getpwent()}, but this has not yet been implemented.)
862 Under MS Windows, this is done:
866 Return the value of ``@code{(getenv "HOME")}'', if set.
869 If the environment variables @code{HOMEDRIVE} and @code{HOMEDIR} are
870 both set, return the concatenation (the following description uses MS
871 Windows environment variable substitution syntax):
872 @code{%HOMEDRIVE%%HOMEDIR%}.
875 Return ``C:\'', as a fallback, but issue a warning.
882 This section explains how to determine the current time and the time
885 @defun current-time-string &optional time-value
886 This function returns the current time and date as a humanly-readable
887 string. The format of the string is unvarying; the number of characters
888 used for each part is always the same, so you can reliably use
889 @code{substring} to extract pieces of it. It is wise to count the
890 characters from the beginning of the string rather than from the end, as
891 additional information may be added at the end.
894 The argument @var{time-value}, if given, specifies a time to format
895 instead of the current time. The argument should be a list whose first
896 two elements are integers. Thus, you can use times obtained from
897 @code{current-time} (see below) and from @code{file-attributes}
898 (@pxref{File Attributes}).
902 (current-time-string)
903 @result{} "Wed Oct 14 22:21:05 1987"
910 This function returns the system's time value as a list of three
911 integers: @code{(@var{high} @var{low} @var{microsec})}. The integers
912 @var{high} and @var{low} combine to give the number of seconds since
913 0:00 January 1, 1970, which is
915 @var{high} * 2**16 + @var{low}.
921 The third element, @var{microsec}, gives the microseconds since the
922 start of the current second (or 0 for systems that return time only on
923 the resolution of a second).
925 The first two elements can be compared with file time values such as you
926 get with the function @code{file-attributes}. @xref{File Attributes}.
930 @defun current-time-zone &optional time-value
931 This function returns a list describing the time zone that the user is
934 The value has the form @code{(@var{offset} @var{name})}. Here
935 @var{offset} is an integer giving the number of seconds ahead of UTC
936 (east of Greenwich). A negative value means west of Greenwich. The
937 second element, @var{name} is a string giving the name of the time
938 zone. Both elements change when daylight savings time begins or ends;
939 if the user has specified a time zone that does not use a seasonal time
940 adjustment, then the value is constant through time.
942 If the operating system doesn't supply all the information necessary to
943 compute the value, both elements of the list are @code{nil}.
945 The argument @var{time-value}, if given, specifies a time to analyze
946 instead of the current time. The argument should be a cons cell
947 containing two integers, or a list whose first two elements are
948 integers. Thus, you can use times obtained from @code{current-time}
949 (see above) and from @code{file-attributes} (@pxref{File Attributes}).
952 @node Time Conversion
953 @section Time Conversion
955 These functions convert time values (lists of two or three integers)
956 to strings or to calendrical information. There is also a function to
957 convert calendrical information to a time value. You can get time
958 values from the functions @code{current-time} (@pxref{Time of Day}) and
959 @code{file-attributes} (@pxref{File Attributes}).
961 @defun format-time-string format-string &optional time
962 This function converts @var{time} to a string according to
963 @var{format-string}. If @var{time} is omitted, it defaults to the
964 current time. The argument @var{format-string} may contain
965 @samp{%}-sequences which say to substitute parts of the time. Here is a
966 table of what the @samp{%}-sequences mean:
970 This stands for the abbreviated name of the day of week.
972 This stands for the full name of the day of week.
974 This stands for the abbreviated name of the month.
976 This stands for the full name of the month.
978 This is a synonym for @samp{%x %X}.
980 This has a locale-specific meaning. In the default locale (named C), it
981 is equivalent to @samp{%A, %B %e, %Y}.
983 This stands for the day of month, zero-padded.
985 This is a synonym for @samp{%m/%d/%y}.
987 This stands for the day of month, blank-padded.
989 This is a synonym for @samp{%b}.
991 This stands for the hour (00-23).
993 This stands for the hour (00-12).
995 This stands for the day of the year (001-366).
997 This stands for the hour (0-23), blank padded.
999 This stands for the hour (1-12), blank padded.
1001 This stands for the month (01-12).
1003 This stands for the minute (00-59).
1005 This stands for a newline.
1007 This stands for @samp{AM} or @samp{PM}, as appropriate.
1009 This is a synonym for @samp{%I:%M:%S %p}.
1011 This is a synonym for @samp{%H:%M}.
1013 This stands for the seconds (00-60).
1015 This stands for a tab character.
1017 This is a synonym for @samp{%H:%M:%S}.
1019 This stands for the week of the year (01-52), assuming that weeks
1022 This stands for the numeric day of week (0-6). Sunday is day 0.
1024 This stands for the week of the year (01-52), assuming that weeks
1027 This has a locale-specific meaning. In the default locale (named C), it
1028 is equivalent to @samp{%D}.
1030 This has a locale-specific meaning. In the default locale (named C), it
1031 is equivalent to @samp{%T}.
1033 This stands for the year without century (00-99).
1035 This stands for the year with century.
1037 This stands for the time zone abbreviation.
1041 @defun decode-time &optional specified-time
1042 This function converts a time value into calendrical information. The
1043 optional @var{specified-time} should be a list of
1044 (@var{high} @var{low} . @var{ignored}) or (@var{high} . @var{low}), as from
1045 @code{current-time} and @code{file-attributes}, or @code{nil} to use the
1048 The return value is a list of nine elements, as follows:
1051 (@var{seconds} @var{minutes} @var{hour} @var{day} @var{month} @var{year} @var{dow} @var{dst} @var{zone})
1054 Here is what the elements mean:
1058 The number of seconds past the minute, as an integer between 0 and 59.
1060 The number of minutes past the hour, as an integer between 0 and 59.
1062 The hour of the day, as an integer between 0 and 23.
1064 The day of the month, as an integer between 1 and 31.
1066 The month of the year, as an integer between 1 and 12.
1068 The year, an integer typically greater than 1900.
1070 The day of week, as an integer between 0 and 6, where 0 stands for
1073 @code{t} if daylight savings time is effect, otherwise @code{nil}.
1075 An integer indicating the time zone, as the number of seconds east of
1079 Note that Common Lisp has different meanings for @var{dow} and
1083 @defun encode-time seconds minutes hour day month year &optional zone
1084 This function is the inverse of @code{decode-time}. It converts seven
1085 items of calendrical data into a time value. For the meanings of the
1086 arguments, see the table above under @code{decode-time}.
1088 Year numbers less than 100 are treated just like other year numbers. If
1089 you want them to stand for years above 1900, you must alter them yourself
1090 before you call @code{encode-time}.
1092 The optional argument @var{zone} defaults to the current time zone and
1093 its daylight savings time rules. If specified, it can be either a list
1094 (as you would get from @code{current-time-zone}) or an integer (as you
1095 would get from @code{decode-time}). The specified zone is used without
1096 any further alteration for daylight savings time.
1100 @section Timers for Delayed Execution
1102 You can set up a timer to call a function at a specified future time.
1104 @c All different in FSF 19
1105 @defun add-timeout secs function object &optional resignal
1106 This function adds a timeout, to be signaled after the timeout period
1107 has elapsed. @var{secs} is a number of seconds, expressed as an integer
1108 or a float. @var{function} will be called after that many seconds have
1109 elapsed, with one argument, the given @var{object}. If the optional
1110 @var{resignal} argument is provided, then after this timeout expires,
1111 @code{add-timeout} will automatically be called again with
1112 @var{resignal} as the first argument.
1114 This function returns an object which is the @dfn{id} of this particular
1115 timeout. You can pass that object to @code{disable-timeout} to turn off
1116 the timeout before it has been signalled.
1118 The number of seconds may be expressed as a floating-point number, in which
1119 case some fractional part of a second will be used. Caveat: the usable
1120 timeout granularity will vary from system to system.
1122 Adding a timeout causes a timeout event to be returned by
1123 @code{next-event}, and the function will be invoked by
1124 @code{dispatch-event}, so if XEmacs is in a tight loop, the function will
1125 not be invoked until the next call to sit-for or until the return to
1126 top-level (the same is true of process filters).
1128 WARNING: if you are thinking of calling add-timeout from inside of a
1129 callback function as a way of resignalling a timeout, think again. There
1130 is a race condition. That's why the @var{resignal} argument exists.
1132 (NOTE: In FSF Emacs, this function is called @code{run-at-time} and
1133 has different semantics.)
1136 @defun disable-timeout id
1137 Cancel the requested action for @var{id}, which should be a value
1138 previously returned by @code{add-timeout}. This cancels the effect of
1139 that call to @code{add-timeout}; the arrival of the specified time will
1140 not cause anything special to happen.
1141 (NOTE: In FSF Emacs, this function is called @code{cancel-timer}.)
1144 @node Terminal Input
1145 @section Terminal Input
1146 @cindex terminal input
1148 This section describes functions and variables for recording or
1149 manipulating terminal input. See @ref{Display}, for related
1153 * Input Modes:: Options for how input is processed.
1154 * Translating Input:: Low level conversion of some characters or events
1156 * Recording Input:: Saving histories of recent or all input events.
1160 @subsection Input Modes
1162 @cindex terminal input modes
1164 @defun set-input-mode interrupt flow meta &optional quit-char console
1165 This function sets the mode for reading keyboard input. If
1166 @var{interrupt} is non-null, then XEmacs uses input interrupts. If it is
1167 @code{nil}, then it uses @sc{cbreak} mode. When XEmacs communicates
1168 directly with X, it ignores this argument and uses interrupts if that is
1169 the way it knows how to communicate.
1171 If @var{flow} is non-@code{nil}, then XEmacs uses @sc{xon/xoff} (@kbd{C-q},
1172 @kbd{C-s}) flow control for output to the terminal. This has no effect except
1173 in @sc{cbreak} mode. @xref{Flow Control}.
1175 The default setting is system dependent. Some systems always use
1176 @sc{cbreak} mode regardless of what is specified.
1179 The argument @var{meta} controls support for input character codes
1180 above 127. If @var{meta} is @code{t}, XEmacs converts characters with
1181 the 8th bit set into Meta characters. If @var{meta} is @code{nil},
1182 XEmacs disregards the 8th bit; this is necessary when the terminal uses
1183 it as a parity bit. If @var{meta} is neither @code{t} nor @code{nil},
1184 XEmacs uses all 8 bits of input unchanged. This is good for terminals
1185 using European 8-bit character sets.
1188 If @var{quit-char} is non-@code{nil}, it specifies the character to
1189 use for quitting. Normally this character is @kbd{C-g}.
1193 The @code{current-input-mode} function returns the input mode settings
1194 XEmacs is currently using.
1197 @defun current-input-mode &optional console
1198 This function returns current mode for reading keyboard input. It
1199 returns a list, corresponding to the arguments of @code{set-input-mode},
1200 of the form @code{(@var{interrupt} @var{flow} @var{meta} @var{quit})} in
1204 is non-@code{nil} when XEmacs is using interrupt-driven input. If
1205 @code{nil}, Emacs is using @sc{cbreak} mode.
1207 is non-@code{nil} if XEmacs uses @sc{xon/xoff} (@kbd{C-q}, @kbd{C-s})
1208 flow control for output to the terminal. This value has no effect
1209 unless @var{interrupt} is non-@code{nil}.
1211 is @code{t} if XEmacs treats the eighth bit of input characters as
1212 the meta bit; @code{nil} means XEmacs clears the eighth bit of every
1213 input character; any other value means XEmacs uses all eight bits as the
1214 basic character code.
1216 is the character XEmacs currently uses for quitting, usually @kbd{C-g}.
1220 @node Translating Input
1221 @subsection Translating Input Events
1222 @cindex translating input events
1224 This section describes features for translating input events into other
1225 input events before they become part of key sequences.
1227 @ignore Not in XEmacs yet.
1229 @defvar extra-keyboard-modifiers
1230 This variable lets Lisp programs ``press'' the modifier keys on the
1231 keyboard. The value is a bit mask:
1235 The @key{SHIFT} key.
1244 Each time the user types a keyboard key, it is altered as if the
1245 modifier keys specified in the bit mask were held down.
1247 When using X windows, the program can ``press'' any of the modifier
1248 keys in this way. Otherwise, only the @key{CTL} and @key{META} keys can
1249 be virtually pressed.
1252 @defvar keyboard-translate-table
1253 This variable is the translate table for keyboard characters. It lets
1254 you reshuffle the keys on the keyboard without changing any command
1255 bindings. Its value must be a string or @code{nil}.
1257 If @code{keyboard-translate-table} is a string, then each character read
1258 from the keyboard is looked up in this string and the character in the
1259 string is used instead. If the string is of length @var{n}, character codes
1260 @var{n} and up are untranslated.
1262 In the example below, we set @code{keyboard-translate-table} to a
1263 string of 128 characters. Then we fill it in to swap the characters
1264 @kbd{C-s} and @kbd{C-\} and the characters @kbd{C-q} and @kbd{C-^}.
1265 Subsequently, typing @kbd{C-\} has all the usual effects of typing
1266 @kbd{C-s}, and vice versa. (@xref{Flow Control} for more information on
1269 @cindex flow control example
1272 (defun evade-flow-control ()
1273 "Replace C-s with C-\ and C-q with C-^."
1277 (let ((the-table (make-string 128 0)))
1280 (aset the-table i i)
1283 ;; @r{Swap @kbd{C-s} and @kbd{C-\}.}
1284 (aset the-table ?\034 ?\^s)
1285 (aset the-table ?\^s ?\034)
1287 ;; @r{Swap @kbd{C-q} and @kbd{C-^}.}
1288 (aset the-table ?\036 ?\^q)
1289 (aset the-table ?\^q ?\036)
1290 (setq keyboard-translate-table the-table)))
1294 Note that this translation is the first thing that happens to a
1295 character after it is read from the terminal. Record-keeping features
1296 such as @code{recent-keys} and dribble files record the characters after
1300 @defun keyboard-translate &rest pairs
1301 This function modifies @code{keyboard-translate-table} to translate
1302 character code @var{from} into character code @var{to}. It creates
1303 or enlarges the translate table if necessary. Multiple
1304 @var{from}-@var{to} pairs may be specified.
1308 @defvar function-key-map
1309 This variable holds a keymap that describes the character sequences
1310 sent by function keys on an ordinary character terminal. This keymap
1311 uses the same data structure as other keymaps, but is used differently: it
1312 specifies translations to make while reading events.
1314 If @code{function-key-map} ``binds'' a key sequence @var{k} to a vector
1315 @var{v}, then when @var{k} appears as a subsequence @emph{anywhere} in a
1316 key sequence, it is replaced with the events in @var{v}.
1318 For example, VT100 terminals send @kbd{@key{ESC} O P} when the
1319 keypad PF1 key is pressed. Therefore, we want XEmacs to translate
1320 that sequence of events into the single event @code{pf1}. We accomplish
1321 this by ``binding'' @kbd{@key{ESC} O P} to @code{[pf1]} in
1322 @code{function-key-map}, when using a VT100.
1324 Thus, typing @kbd{C-c @key{PF1}} sends the character sequence @kbd{C-c
1325 @key{ESC} O P}; later the function @code{read-key-sequence} translates
1326 this back into @kbd{C-c @key{PF1}}, which it returns as the vector
1329 Entries in @code{function-key-map} are ignored if they conflict with
1330 bindings made in the minor mode, local, or global keymaps. The intent
1331 is that the character sequences that function keys send should not have
1332 command bindings in their own right.
1334 The value of @code{function-key-map} is usually set up automatically
1335 according to the terminal's Terminfo or Termcap entry, but sometimes
1336 those need help from terminal-specific Lisp files. XEmacs comes with
1337 terminal-specific files for many common terminals; their main purpose is
1338 to make entries in @code{function-key-map} beyond those that can be
1339 deduced from Termcap and Terminfo. @xref{Terminal-Specific}.
1341 Emacs versions 18 and earlier used totally different means of detecting
1342 the character sequences that represent function keys.
1345 @defvar key-translation-map
1346 This variable is another keymap used just like @code{function-key-map}
1347 to translate input events into other events. It differs from
1348 @code{function-key-map} in two ways:
1352 @code{key-translation-map} goes to work after @code{function-key-map} is
1353 finished; it receives the results of translation by
1354 @code{function-key-map}.
1357 @code{key-translation-map} overrides actual key bindings.
1360 The intent of @code{key-translation-map} is for users to map one
1361 character set to another, including ordinary characters normally bound
1362 to @code{self-insert-command}.
1365 @cindex key translation function
1366 You can use @code{function-key-map} or @code{key-translation-map} for
1367 more than simple aliases, by using a function, instead of a key
1368 sequence, as the ``translation'' of a key. Then this function is called
1369 to compute the translation of that key.
1371 The key translation function receives one argument, which is the prompt
1372 that was specified in @code{read-key-sequence}---or @code{nil} if the
1373 key sequence is being read by the editor command loop. In most cases
1374 you can ignore the prompt value.
1376 If the function reads input itself, it can have the effect of altering
1377 the event that follows. For example, here's how to define @kbd{C-c h}
1378 to turn the character that follows into a Hyper character:
1382 (defun hyperify (prompt)
1383 (let ((e (read-event)))
1384 (vector (if (numberp e)
1385 (logior (lsh 1 20) e)
1386 (if (memq 'hyper (event-modifiers e))
1388 (add-event-modifier "H-" e))))))
1390 (defun add-event-modifier (string e)
1391 (let ((symbol (if (symbolp e) e (car e))))
1392 (setq symbol (intern (concat string
1393 (symbol-name symbol))))
1398 (cons symbol (cdr e)))))
1400 (define-key function-key-map "\C-ch" 'hyperify)
1405 @cindex Latin-1 character set (input)
1406 @cindex ISO Latin-1 characters (input)
1407 The @file{iso-transl} library uses this feature to provide a way of
1408 inputting non-ASCII Latin-1 characters.
1410 @node Recording Input
1411 @subsection Recording Input
1413 @defun recent-keys &optional number
1414 This function returns a vector containing recent input events from the
1415 keyboard or mouse. By default, 100 events are recorded, which is how
1416 many @code{recent-keys} returns.
1418 All input events are included, whether or not they were used as parts of
1419 key sequences. Thus, you always get the last 100 inputs, not counting
1420 keyboard macros. (Events from keyboard macros are excluded because they
1421 are less interesting for debugging; it should be enough to see the
1422 events that invoked the macros.)
1424 If @var{number} is specified, not more than @var{number} events will be
1425 returned. You may change the number of stored events using
1426 @code{set-recent-keys-ring-size}.
1429 @defun recent-keys-ring-size
1430 This function returns the number of recent events stored internally.
1431 This is also the maximum number of events @code{recent-keys} can
1432 return. By default, 100 events are stored.
1435 @defun set-recent-keys-ring-size size
1436 This function changes the number of events stored by XEmacs and returned
1437 by @code{recent-keys}.
1439 For example, @code{(set-recent-keys-ring-size 250)} will make XEmacs
1440 remember last 250 events and will make @code{recent-keys} return last
1441 250 events by default.
1444 @deffn Command open-dribble-file filename
1445 @cindex dribble file
1446 This function opens a @dfn{dribble file} named @var{filename}. When a
1447 dribble file is open, each input event from the keyboard or mouse (but
1448 not those from keyboard macros) is written in that file. A
1449 non-character event is expressed using its printed representation
1450 surrounded by @samp{<@dots{}>}.
1452 You close the dribble file by calling this function with an argument
1455 This function is normally used to record the input necessary to
1456 trigger an XEmacs bug, for the sake of a bug report.
1460 (open-dribble-file "~/dribble")
1466 See also the @code{open-termscript} function (@pxref{Terminal Output}).
1468 @node Terminal Output
1469 @section Terminal Output
1470 @cindex terminal output
1472 The terminal output functions send output to the terminal or keep
1473 track of output sent to the terminal. The function
1474 @code{device-baud-rate} tells you what XEmacs thinks is the output speed
1477 @defun device-baud-rate &optional device
1478 This function's value is the output speed of the terminal associated
1479 with @var{device}, as far as XEmacs knows. @var{device} defaults to the
1480 selected device (usually the only device) if omitted. Changing this
1481 value does not change the speed of actual data transmission, but the
1482 value is used for calculations such as padding. This value has no
1483 effect for window-system devices. (This is different in FSF Emacs, where
1484 the baud rate also affects decisions about whether to scroll part of the
1485 screen or repaint, even when using a window system.)
1487 The value is measured in bits per second.
1490 XEmacs attempts to automatically initialize the baud rate by querying
1491 the terminal. If you are running across a network, however, and
1492 different parts of the network work are at different baud rates, the
1493 value returned by XEmacs may be different from the value used by your
1494 local terminal. Some network protocols communicate the local terminal
1495 speed to the remote machine, so that XEmacs and other programs can get
1496 the proper value, but others do not. If XEmacs has the wrong value, it
1497 makes decisions that are less than optimal. To fix the problem, use
1498 @code{set-device-baud-rate}.
1500 @defun set-device-baud-rate device baud-rate
1501 This function sets the output speed of @var{device}. See
1502 @code{device-baud-rate}. @var{device} defaults to the selected device
1503 (usually the only device) if @code{nil}.
1506 @defun send-string-to-terminal char-or-string &optional stdout-p device
1507 This function sends @var{char-or-string} to the terminal without
1508 alteration. Control characters in @var{char-or-string} have
1509 terminal-dependent effects.
1511 If @var{device} is @code{nil}, this function writes to XEmacs's
1512 stderr, or to stdout if @var{stdout-p} is non-@code{nil}. Otherwise,
1513 @var{device} should be a tty or stream device, and the function writes
1514 to the device's normal or error output, according to @var{stdout-p}.
1516 One use of this function is to define function keys on terminals that
1517 have downloadable function key definitions. For example, this is how on
1518 certain terminals to define function key 4 to move forward four
1519 characters (by transmitting the characters @kbd{C-u C-f} to the
1524 (send-string-to-terminal "\eF4\^U\^F")
1530 @deffn Command open-termscript filename
1531 @cindex termscript file
1532 This function is used to open a @dfn{termscript file} that will record
1533 all the characters sent by XEmacs to the terminal. (If there are
1534 multiple tty or stream devices, all characters sent to all such devices
1535 are recorded.) The function returns @code{nil}. Termscript files are
1536 useful for investigating problems where XEmacs garbles the screen,
1537 problems that are due to incorrect Termcap entries or to undesirable
1538 settings of terminal options more often than to actual XEmacs bugs.
1539 Once you are certain which characters were actually output, you can
1540 determine reliably whether they correspond to the Termcap specifications
1543 A @code{nil} value for @var{filename} stops recording terminal output.
1545 See also @code{open-dribble-file} in @ref{Terminal Input}.
1549 (open-termscript "../junk/termscript")
1555 @ignore Not in XEmacs
1556 @node Special Keysyms
1557 @section System-Specific X11 Keysyms
1559 To define system-specific X11 keysyms, set the variable
1560 @code{system-key-alist}.
1562 @defvar system-key-alist
1563 This variable's value should be an alist with one element for each
1564 system-specific keysym. An element has this form: @code{(@var{code}
1565 . @var{symbol})}, where @var{code} is the numeric keysym code (not
1566 including the ``vendor specific'' bit, 1 << 28), and @var{symbol} is the
1567 name for the function key.
1569 For example @code{(168 . mute-acute)} defines a system-specific key used
1570 by HP X servers whose numeric code is (1 << 28) + 168.
1572 It is not a problem if the alist defines keysyms for other X servers, as
1573 long as they don't conflict with the ones used by the X server actually
1576 The variable is always local to the current X terminal and cannot be
1577 buffer-local. @xref{Multiple Displays}.
1582 @section Flow Control
1583 @cindex flow control characters
1585 This section attempts to answer the question ``Why does XEmacs choose
1586 to use flow-control characters in its command character set?'' For a
1587 second view on this issue, read the comments on flow control in the
1588 @file{emacs/INSTALL} file from the distribution; for help with Termcap
1589 entries and DEC terminal concentrators, see @file{emacs/etc/TERMS}.
1593 At one time, most terminals did not need flow control, and none used
1594 @code{C-s} and @kbd{C-q} for flow control. Therefore, the choice of
1595 @kbd{C-s} and @kbd{C-q} as command characters was uncontroversial.
1596 XEmacs, for economy of keystrokes and portability, used nearly all the
1597 @sc{ascii} control characters, with mnemonic meanings when possible;
1598 thus, @kbd{C-s} for search and @kbd{C-q} for quote.
1600 Later, some terminals were introduced which required these characters
1601 for flow control. They were not very good terminals for full-screen
1602 editing, so XEmacs maintainers did not pay attention. In later years,
1603 flow control with @kbd{C-s} and @kbd{C-q} became widespread among
1604 terminals, but by this time it was usually an option. And the majority
1605 of users, who can turn flow control off, were unwilling to switch to
1606 less mnemonic key bindings for the sake of flow control.
1608 So which usage is ``right'', XEmacs's or that of some terminal and
1609 concentrator manufacturers? This question has no simple answer.
1611 One reason why we are reluctant to cater to the problems caused by
1612 @kbd{C-s} and @kbd{C-q} is that they are gratuitous. There are other
1613 techniques (albeit less common in practice) for flow control that
1614 preserve transparency of the character stream. Note also that their use
1615 for flow control is not an official standard. Interestingly, on the
1616 model 33 teletype with a paper tape punch (which is very old), @kbd{C-s}
1617 and @kbd{C-q} were sent by the computer to turn the punch on and off!
1619 As X servers and other window systems replace character-only
1620 terminals, this problem is gradually being cured. For the mean time,
1621 XEmacs provides a convenient way of enabling flow control if you want it:
1622 call the function @code{enable-flow-control}.
1624 @deffn Command enable-flow-control &optional argument
1625 This function enables use of @kbd{C-s} and @kbd{C-q} for output flow
1626 control, and provides the characters @kbd{C-\} and @kbd{C-^} as aliases
1627 for them using @code{keyboard-translate-table} (@pxref{Translating Input}).
1629 With optional argument @var{argument} (interactively the prefix
1630 argument), enable flow control mode if @var{argument} is positive; else
1634 You can use the function @code{enable-flow-control-on} in your
1635 @file{.emacs} file to enable flow control automatically on certain
1638 @defun enable-flow-control-on &rest termtypes
1639 This function enables flow control, and the aliases @kbd{C-\} and @kbd{C-^},
1640 if the terminal type is one of @var{termtypes}. For example:
1643 (enable-flow-control-on "vt200" "vt300" "vt101" "vt131")
1647 Here is how @code{enable-flow-control} does its job:
1652 It sets @sc{cbreak} mode for terminal input, and tells the operating
1653 system to handle flow control, with @code{(set-input-mode nil t)}.
1656 It sets up @code{keyboard-translate-table} to translate @kbd{C-\} and
1657 @kbd{C-^} into @kbd{C-s} and @kbd{C-q}. Except at its very
1658 lowest level, XEmacs never knows that the characters typed were anything
1659 but @kbd{C-s} and @kbd{C-q}, so you can in effect type them as @kbd{C-\}
1660 and @kbd{C-^} even when they are input for other commands.
1661 @xref{Translating Input}.
1664 If the terminal is the source of the flow control characters, then once
1665 you enable kernel flow control handling, you probably can make do with
1666 less padding than normal for that terminal. You can reduce the amount
1667 of padding by customizing the Termcap entry. You can also reduce it by
1668 setting @code{baud-rate} to a smaller value so that XEmacs uses a smaller
1669 speed when calculating the padding needed. @xref{Terminal Output}.
1674 @cindex noninteractive use
1676 The command line option @samp{-batch} causes XEmacs to run
1677 noninteractively. In this mode, XEmacs does not read commands from the
1678 terminal, it does not alter the terminal modes, and it does not expect
1679 to be outputting to an erasable screen. The idea is that you specify
1680 Lisp programs to run; when they are finished, XEmacs should exit. The
1681 way to specify the programs to run is with @samp{-l @var{file}}, which
1682 loads the library named @var{file}, and @samp{-f @var{function}}, which
1683 calls @var{function} with no arguments.
1685 Any Lisp program output that would normally go to the echo area,
1686 either using @code{message} or using @code{prin1}, etc., with @code{t}
1687 as the stream, goes instead to XEmacs's standard error descriptor when
1688 in batch mode. Thus, XEmacs behaves much like a noninteractive
1689 application program. (The echo area output that XEmacs itself normally
1690 generates, such as command echoing, is suppressed entirely.)
1692 @defun noninteractive
1693 This function returns non-@code{nil} when XEmacs is running in batch mode.
1696 @defvar noninteractive
1697 This variable is non-@code{nil} when XEmacs is running in batch mode.
1698 Setting this variable to @code{nil}, however, will not change whether
1699 XEmacs is running in batch mode, and will not change the return value
1700 of the @code{noninteractive} function.