Mercurial > emacs
comparison lispref/os.texi @ 56369:6578797626ea
Various small changes in addition to:
(Killing Emacs): Expand and clarify description of
`kill-emacs-query-functions' and `kill-emacs-hook'.
(System Environment): Expand and clarify description of `getenv' and `setenv'.
(Timers): Clarify description of `run-at-time'.
(Translating Input): Correct description of `extra-keyboard-modifiers'.
(Flow Control): Correct description of `enable-flow-control'.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Wed, 07 Jul 2004 01:12:49 +0000 |
parents | 1468ded18da0 |
children | 8685ad649821 029a652ac817 |
comparison
equal
deleted
inserted
replaced
56368:b752a1228fc1 | 56369:6578797626ea |
---|---|
235 | 235 |
236 @defvar after-init-hook | 236 @defvar after-init-hook |
237 This normal hook is run, once, just after loading all the init files | 237 This normal hook is run, once, just after loading all the init files |
238 (the user's init file, @file{default.el}, and/or @file{site-start.el}), | 238 (the user's init file, @file{default.el}, and/or @file{site-start.el}), |
239 before loading the terminal-specific library and processing the | 239 before loading the terminal-specific library and processing the |
240 command-line arguments. | 240 command-line action arguments. |
241 @end defvar | 241 @end defvar |
242 | 242 |
243 @defvar emacs-startup-hook | 243 @defvar emacs-startup-hook |
244 @tindex emacs-startup-hook | 244 @tindex emacs-startup-hook |
245 This normal hook is run, once, just after handling the command line | 245 This normal hook is run, once, just after handling the command line |
246 arguments, just before @code{term-setup-hook}. | 246 arguments, just before @code{term-setup-hook}. |
247 @end defvar | 247 @end defvar |
248 | 248 |
249 @defvar user-init-file | 249 @defvar user-init-file |
250 @tindex user-init-file | 250 @tindex user-init-file |
251 This variable holds the file name of the user's init file. If the | 251 This variable holds the absolute file name of the user's init file. If the |
252 actual init file loaded is a compiled file, such as @file{.emacs.elc}, | 252 actual init file loaded is a compiled file, such as @file{.emacs.elc}, |
253 the value refers to the corresponding source file. | 253 the value refers to the corresponding source file. |
254 @end defvar | 254 @end defvar |
255 | 255 |
256 @node Terminal-Specific | 256 @node Terminal-Specific |
469 All the information in the Emacs process, aside from files that have | 469 All the information in the Emacs process, aside from files that have |
470 been saved, is lost when the Emacs process is killed. Because killing | 470 been saved, is lost when the Emacs process is killed. Because killing |
471 Emacs inadvertently can lose a lot of work, Emacs queries for | 471 Emacs inadvertently can lose a lot of work, Emacs queries for |
472 confirmation before actually terminating if you have buffers that need | 472 confirmation before actually terminating if you have buffers that need |
473 saving or subprocesses that are running. This is done in the function | 473 saving or subprocesses that are running. This is done in the function |
474 @code{save-buffers-kill-emacs}. | 474 @code{save-buffers-kill-emacs}, the higher level function from which |
475 @code{kill-emacs} is usually called. | |
475 | 476 |
476 @defvar kill-emacs-query-functions | 477 @defvar kill-emacs-query-functions |
477 After asking the standard questions, @code{save-buffers-kill-emacs} | 478 After asking the standard questions, @code{save-buffers-kill-emacs} |
478 calls the functions in the list @code{kill-emacs-query-functions}, in | 479 calls the functions in the list @code{kill-emacs-query-functions}, in |
479 order of appearance, with no arguments. These functions can ask for | 480 order of appearance, with no arguments. These functions can ask for |
480 additional confirmation from the user. If any of them returns | 481 additional confirmation from the user. If any of them returns |
481 @code{nil}, Emacs is not killed. | 482 @code{nil}, @code{save-buffers-kill-emacs} does not kill Emacs, and |
483 does not run the remaining functions in this hook. Calling | |
484 @code{kill-emacs} directly does not run this hook. | |
482 @end defvar | 485 @end defvar |
483 | 486 |
484 @defvar kill-emacs-hook | 487 @defvar kill-emacs-hook |
485 This variable is a normal hook; once @code{save-buffers-kill-emacs} is | 488 This variable is a normal hook; once @code{save-buffers-kill-emacs} is |
486 finished with all file saving and confirmation, it runs the functions in | 489 finished with all file saving and confirmation, it calls |
487 this hook. This hook is not run in batch mode. | 490 @code{kill-emacs} which runs the functions in this hook. |
491 @code{kill-emacs} does not run this hook in batch mode. | |
492 | |
493 @code{kill-emacs} may be invoked directly (that is not via | |
494 @code{save-buffers-kill-emacs}) if the terminal is disconnected, or in | |
495 similar situations where interaction with the user is not possible. | |
496 Thus, if your hook needs to interact with the user, put it on | |
497 @code{kill-emacs-query-functions}; if it needs to run regardless of | |
498 how Emacs is killed, put it on @code{kill-emacs-hook}. | |
488 @end defvar | 499 @end defvar |
489 | 500 |
490 @node Suspending Emacs | 501 @node Suspending Emacs |
491 @subsection Suspending Emacs | 502 @subsection Suspending Emacs |
492 @cindex suspending Emacs | 503 @cindex suspending Emacs |
506 may not have a parent that can resume it again, and in any case you can | 517 may not have a parent that can resume it again, and in any case you can |
507 give input to some other job such as a shell merely by moving to a | 518 give input to some other job such as a shell merely by moving to a |
508 different window. Therefore, suspending is not allowed when Emacs is using | 519 different window. Therefore, suspending is not allowed when Emacs is using |
509 a window system (X or MS Windows). | 520 a window system (X or MS Windows). |
510 | 521 |
511 @defun suspend-emacs string | 522 @defun suspend-emacs &optional string |
512 This function stops Emacs and returns control to the superior process. | 523 This function stops Emacs and returns control to the superior process. |
513 If and when the superior process resumes Emacs, @code{suspend-emacs} | 524 If and when the superior process resumes Emacs, @code{suspend-emacs} |
514 returns @code{nil} to its caller in Lisp. | 525 returns @code{nil} to its caller in Lisp. |
515 | 526 |
516 If @var{string} is non-@code{nil}, its characters are sent to be read | 527 If @var{string} is non-@code{nil}, its characters are sent to be read |
540 @group | 551 @group |
541 (add-hook 'suspend-hook | 552 (add-hook 'suspend-hook |
542 (function (lambda () | 553 (function (lambda () |
543 (or (y-or-n-p | 554 (or (y-or-n-p |
544 "Really suspend? ") | 555 "Really suspend? ") |
545 (error "Suspend cancelled"))))) | 556 (error "Suspend canceled"))))) |
546 @result{} (lambda nil | 557 @result{} (lambda nil |
547 (or (y-or-n-p "Really suspend? ") | 558 (or (y-or-n-p "Really suspend? ") |
548 (error "Suspend cancelled"))) | 559 (error "Suspend canceled"))) |
549 @end group | 560 @end group |
550 @group | 561 @group |
551 (add-hook 'suspend-resume-hook | 562 (add-hook 'suspend-resume-hook |
552 (function (lambda () (message "Resumed!")))) | 563 (function (lambda () (message "Resumed!")))) |
553 @result{} (lambda nil (message "Resumed!")) | 564 @result{} (lambda nil (message "Resumed!")) |
692 @end defvar | 703 @end defvar |
693 | 704 |
694 @deffn Command getenv var | 705 @deffn Command getenv var |
695 @cindex environment variable access | 706 @cindex environment variable access |
696 This function returns the value of the environment variable @var{var}, | 707 This function returns the value of the environment variable @var{var}, |
697 as a string. Within Emacs, the environment variable values are kept in | 708 as a string. @var{var} should be a string. If @var{var} is undefined |
698 the Lisp variable @code{process-environment}. | 709 in the environment, @code{getenv} returns @code{nil}. If returns |
710 @samp{""} if @var{var} is set but null. Within Emacs, the environment | |
711 variable values are kept in the Lisp variable @code{process-environment}. | |
699 | 712 |
700 @example | 713 @example |
701 @group | 714 @group |
702 (getenv "USER") | 715 (getenv "USER") |
703 @result{} "lewis" | 716 @result{} "lewis" |
715 @end group | 728 @end group |
716 @end example | 729 @end example |
717 @end deffn | 730 @end deffn |
718 | 731 |
719 @c Emacs 19 feature | 732 @c Emacs 19 feature |
720 @deffn Command setenv variable value | 733 @deffn Command setenv variable &optional value |
721 This command sets the value of the environment variable named | 734 This command sets the value of the environment variable named |
722 @var{variable} to @var{value}. Both arguments should be strings. This | 735 @var{variable} to @var{value}. @var{variable} should be a string. |
723 function works by modifying @code{process-environment}; binding that | 736 Internally, Emacs Lisp can handle any string. However, normally |
724 variable with @code{let} is also reasonable practice. | 737 @var{variable} should be a valid shell identifier, that is, a sequence |
738 of letters, digits and underscores, starting with a letter or | |
739 underscore. Otherwise, errors may occur if subprocesses of Emacs try | |
740 to access the value of @var{variable}. If @var{value} is omitted or | |
741 @code{nil}, @code{setenv} removes @var{variable} from the environment. | |
742 Otherwise, @var{value} should be a string. | |
743 | |
744 @code{setenv} works by modifying @code{process-environment}; binding | |
745 that variable with @code{let} is also reasonable practice. | |
746 | |
747 @code{setenv} returns the new value of @var{variable}, or @code{nil} | |
748 if it removed @var{variable} from the environment. | |
725 @end deffn | 749 @end deffn |
726 | 750 |
727 @defvar process-environment | 751 @defvar process-environment |
728 This variable is a list of strings, each describing one environment | 752 This variable is a list of strings, each describing one environment |
729 variable. The functions @code{getenv} and @code{setenv} work by means | 753 variable. The functions @code{getenv} and @code{setenv} work by means |
799 If it is impossible to obtain the load average, this function signals | 823 If it is impossible to obtain the load average, this function signals |
800 an error. On some platforms, access to load averages requires | 824 an error. On some platforms, access to load averages requires |
801 installing Emacs as setuid or setgid so that it can read kernel | 825 installing Emacs as setuid or setgid so that it can read kernel |
802 information, and that usually isn't advisable. | 826 information, and that usually isn't advisable. |
803 | 827 |
828 If the 1-minute load average is available, but the 5- or 15-minute | |
829 averages are not, this function returns a shortened list containing | |
830 the available averages. | |
831 | |
804 @example | 832 @example |
805 @group | 833 @group |
806 (load-average) | 834 (load-average) |
807 @result{} (169 48 36) | 835 @result{} (169 48 36) |
808 @end group | 836 @end group |
818 @end group | 846 @end group |
819 @end example | 847 @end example |
820 @end defun | 848 @end defun |
821 | 849 |
822 @defun emacs-pid | 850 @defun emacs-pid |
823 This function returns the process @acronym{ID} of the Emacs process. | 851 This function returns the process @acronym{ID} of the Emacs process, |
852 as an integer. | |
824 @end defun | 853 @end defun |
825 | 854 |
826 @defvar tty-erase-char | 855 @defvar tty-erase-char |
827 This variable holds the erase character that was selected | 856 This variable holds the erase character that was selected |
828 in the system's terminal driver, before Emacs was started. | 857 in the system's terminal driver, before Emacs was started. |
858 The value is @code{nil} if Emacs is running under a window system. | |
829 @end defvar | 859 @end defvar |
830 | 860 |
831 @defun setprv privilege-name &optional setp getprv | 861 @defun setprv privilege-name &optional setp getprv |
832 This function sets or resets a VMS privilege. (It does not exist on | 862 This function sets or resets a VMS privilege. (It does not exist on |
833 other systems.) The first argument is the privilege name, as a string. | 863 other systems.) The first argument is the privilege name, as a string. |
834 The second argument, @var{setp}, is @code{t} or @code{nil}, indicating | 864 The second argument, @var{setp}, is @code{t} or @code{nil}, indicating |
835 whether the privilege is to be turned on or off. Its default is | 865 whether the privilege is to be turned on or off. Its default is |
836 @code{nil}. The function returns @code{t} if successful, @code{nil} | 866 @code{nil}. The function returns @code{t} if successful, @code{nil} |
837 otherwise. | 867 otherwise. |
838 | 868 |
839 If the third argument, @var{getprv}, is non-@code{nil}, @code{setprv} | 869 If the third argument, @var{getprv}, is non-@code{nil}, @code{setprv} |
840 does not change the privilege, but returns @code{t} or @code{nil} | 870 does not change the privilege, but returns @code{t} or @code{nil} |
841 indicating whether the privilege is currently enabled. | 871 indicating whether the privilege is currently enabled. |
842 @end defun | 872 @end defun |
843 | 873 |
844 @node User Identification | 874 @node User Identification |
845 @section User Identification | 875 @section User Identification |
846 | 876 |
847 @defvar init-file-user | 877 @defvar init-file-user |
848 This variable says which user's init files should be used by Emacs---or | 878 This variable says which user's init files should be used by |
849 @code{nil} if none. The value reflects command-line options such as | 879 Emacs---or @code{nil} if none. @code{""} stands for the user who |
880 originally logged in. The value reflects command-line options such as | |
850 @samp{-q} or @samp{-u @var{user}}. | 881 @samp{-q} or @samp{-u @var{user}}. |
851 | 882 |
852 Lisp packages that load files of customizations, or any other sort of | 883 Lisp packages that load files of customizations, or any other sort of |
853 user profile, should obey this variable in deciding where to find it. | 884 user profile, should obey this variable in deciding where to find it. |
854 They should load the profile of the user name found in this variable. | 885 They should load the profile of the user name found in this variable. |
871 is set, that value is used. Otherwise, if the environment variable | 902 is set, that value is used. Otherwise, if the environment variable |
872 @code{USER} is set, that value is used. Otherwise, the value is based | 903 @code{USER} is set, that value is used. Otherwise, the value is based |
873 on the effective @acronym{UID}, not the real @acronym{UID}. | 904 on the effective @acronym{UID}, not the real @acronym{UID}. |
874 | 905 |
875 If you specify @var{uid}, the value is the user name that corresponds | 906 If you specify @var{uid}, the value is the user name that corresponds |
876 to @var{uid} (which should be an integer). | 907 to @var{uid} (which should be an integer), or @code{nil} if there is |
908 no such user. | |
877 | 909 |
878 @example | 910 @example |
879 @group | 911 @group |
880 (user-login-name) | 912 (user-login-name) |
881 @result{} "lewis" | 913 @result{} "lewis" |
902 @end example | 934 @end example |
903 | 935 |
904 If the Emacs job's user-id does not correspond to any known user (and | 936 If the Emacs job's user-id does not correspond to any known user (and |
905 provided @code{NAME} is not set), the value is @code{"unknown"}. | 937 provided @code{NAME} is not set), the value is @code{"unknown"}. |
906 | 938 |
907 If @var{uid} is non-@code{nil}, then it should be an integer (a user-id) | 939 If @var{uid} is non-@code{nil}, then it should be a number (a user-id) |
908 or a string (a login name). Then @code{user-full-name} returns the full | 940 or a string (a login name). Then @code{user-full-name} returns the full |
909 name corresponding to that user-id or login name. If you specify a | 941 name corresponding to that user-id or login name. If you specify a |
910 user-id or login name that isn't defined, it returns @code{nil}. | 942 user-id or login name that isn't defined, it returns @code{nil}. |
911 @end defun | 943 @end defun |
912 | 944 |
954 @c Emacs 19 feature | 986 @c Emacs 19 feature |
955 The argument @var{time-value}, if given, specifies a time to format | 987 The argument @var{time-value}, if given, specifies a time to format |
956 instead of the current time. The argument should be a list whose first | 988 instead of the current time. The argument should be a list whose first |
957 two elements are integers. Thus, you can use times obtained from | 989 two elements are integers. Thus, you can use times obtained from |
958 @code{current-time} (see below) and from @code{file-attributes} | 990 @code{current-time} (see below) and from @code{file-attributes} |
959 (@pxref{File Attributes}). | 991 (@pxref{Definition of file-attributes}). @var{time-value} can also be |
992 a cons of two integers, but this is considered obsolete. | |
960 | 993 |
961 @example | 994 @example |
962 @group | 995 @group |
963 (current-time-string) | 996 (current-time-string) |
964 @result{} "Wed Oct 14 22:21:05 1987" | 997 @result{} "Wed Oct 14 22:21:05 1987" |
969 @c Emacs 19 feature | 1002 @c Emacs 19 feature |
970 @defun current-time | 1003 @defun current-time |
971 This function returns the system's time value as a list of three | 1004 This function returns the system's time value as a list of three |
972 integers: @code{(@var{high} @var{low} @var{microsec})}. The integers | 1005 integers: @code{(@var{high} @var{low} @var{microsec})}. The integers |
973 @var{high} and @var{low} combine to give the number of seconds since | 1006 @var{high} and @var{low} combine to give the number of seconds since |
974 0:00 January 1, 1970 (local time), which is | 1007 0:00 January 1, 1970 UTC (Coordinated Universal Time), which is |
975 @ifnottex | 1008 @ifnottex |
976 @var{high} * 2**16 + @var{low}. | 1009 @var{high} * 2**16 + @var{low}. |
977 @end ifnottex | 1010 @end ifnottex |
978 @tex | 1011 @tex |
979 $high*2^{16}+low$. | 1012 $high*2^{16}+low$. |
982 The third element, @var{microsec}, gives the microseconds since the | 1015 The third element, @var{microsec}, gives the microseconds since the |
983 start of the current second (or 0 for systems that return time with | 1016 start of the current second (or 0 for systems that return time with |
984 the resolution of only one second). | 1017 the resolution of only one second). |
985 | 1018 |
986 The first two elements can be compared with file time values such as you | 1019 The first two elements can be compared with file time values such as you |
987 get with the function @code{file-attributes}. @xref{File Attributes}. | 1020 get with the function @code{file-attributes}. |
1021 @xref{Definition of file-attributes}. | |
988 @end defun | 1022 @end defun |
989 | 1023 |
990 @c Emacs 19 feature | 1024 @c Emacs 19 feature |
991 @defun current-time-zone &optional time-value | 1025 @defun current-time-zone &optional time-value |
992 This function returns a list describing the time zone that the user is | 1026 This function returns a list describing the time zone that the user is |
999 zone. Both elements change when daylight savings time begins or ends; | 1033 zone. Both elements change when daylight savings time begins or ends; |
1000 if the user has specified a time zone that does not use a seasonal time | 1034 if the user has specified a time zone that does not use a seasonal time |
1001 adjustment, then the value is constant through time. | 1035 adjustment, then the value is constant through time. |
1002 | 1036 |
1003 If the operating system doesn't supply all the information necessary to | 1037 If the operating system doesn't supply all the information necessary to |
1004 compute the value, both elements of the list are @code{nil}. | 1038 compute the value, the unknown elements of the list are @code{nil}. |
1005 | 1039 |
1006 The argument @var{time-value}, if given, specifies a time to analyze | 1040 The argument @var{time-value}, if given, specifies a time to analyze |
1007 instead of the current time. The argument should be a cons cell | 1041 instead of the current time. The argument should have the same form |
1008 containing two integers, or a list whose first two elements are | 1042 as for @code{current-time-string} (see above). Thus, you can use |
1009 integers. Thus, you can use times obtained from @code{current-time} | 1043 times obtained from @code{current-time} (see above) and from |
1010 (see above) and from @code{file-attributes} (@pxref{File Attributes}). | 1044 @code{file-attributes}. @xref{Definition of file-attributes}. |
1011 @end defun | 1045 @end defun |
1012 | 1046 |
1013 @defun set-time-zone-rule tz | 1047 @defun set-time-zone-rule tz |
1014 This function specifies the local time zone according to @var{tz}. If | 1048 This function specifies the local time zone according to @var{tz}. If |
1015 @var{tz} is @code{nil}, that means to use an implementation-defined | 1049 @var{tz} is @code{nil}, that means to use an implementation-defined |
1016 default time zone. If @var{tz} is @code{t}, that means to use | 1050 default time zone. If @var{tz} is @code{t}, that means to use |
1017 Universal Time. | 1051 Universal Time. Otherwise, @var{tz} should be a string specifying a |
1052 time zone rule. | |
1018 @end defun | 1053 @end defun |
1019 | 1054 |
1020 @defun float-time &optional time-value | 1055 @defun float-time &optional time-value |
1021 This function returns the current time as a floating-point number of | 1056 This function returns the current time as a floating-point number of |
1022 seconds since the epoch. The argument @var{time-value}, if given, | 1057 seconds since the epoch. The argument @var{time-value}, if given, |
1023 specifies a time to convert instead of the current time. The argument | 1058 specifies a time to convert instead of the current time. The argument |
1024 should have the same form as for @code{current-time-string} (see | 1059 should have the same form as for @code{current-time-string} (see |
1025 above), and it also accepts the output of @code{current-time} and | 1060 above). Thus, it accepts the output of @code{current-time} and |
1026 @code{file-attributes}. | 1061 @code{file-attributes}. |
1027 | 1062 |
1028 @emph{Warning}: Since the result is floating point, it may not be | 1063 @emph{Warning}: Since the result is floating point, it may not be |
1029 exact. Do not use this function if precise time stamps are required. | 1064 exact. Do not use this function if precise time stamps are required. |
1030 @end defun | 1065 @end defun |
1034 | 1069 |
1035 These functions convert time values (lists of two or three integers) | 1070 These functions convert time values (lists of two or three integers) |
1036 to strings or to calendrical information. There is also a function to | 1071 to strings or to calendrical information. There is also a function to |
1037 convert calendrical information to a time value. You can get time | 1072 convert calendrical information to a time value. You can get time |
1038 values from the functions @code{current-time} (@pxref{Time of Day}) and | 1073 values from the functions @code{current-time} (@pxref{Time of Day}) and |
1039 @code{file-attributes} (@pxref{File Attributes}). | 1074 @code{file-attributes} (@pxref{Definition of file-attributes}). |
1040 | 1075 |
1041 Many operating systems are limited to time values that contain 32 bits | 1076 Many operating systems are limited to time values that contain 32 bits |
1042 of information; these systems typically handle only the times from | 1077 of information; these systems typically handle only the times from |
1043 1901-12-13 20:45:52 UTC through 2038-01-19 03:14:07 UTC. However, some | 1078 1901-12-13 20:45:52 UTC through 2038-01-19 03:14:07 UTC. However, some |
1044 operating systems have larger time values, and can represent times far | 1079 operating systems have larger time values, and can represent times far |
1187 Here is what the elements mean: | 1222 Here is what the elements mean: |
1188 | 1223 |
1189 @table @var | 1224 @table @var |
1190 @item seconds | 1225 @item seconds |
1191 The number of seconds past the minute, as an integer between 0 and 59. | 1226 The number of seconds past the minute, as an integer between 0 and 59. |
1227 On some operating systems, this is 60 for leap seconds. | |
1192 @item minutes | 1228 @item minutes |
1193 The number of minutes past the hour, as an integer between 0 and 59. | 1229 The number of minutes past the hour, as an integer between 0 and 59. |
1194 @item hour | 1230 @item hour |
1195 The hour of the day, as an integer between 0 and 23. | 1231 The hour of the day, as an integer between 0 and 23. |
1196 @item day | 1232 @item day |
1223 yourself before you call @code{encode-time}. | 1259 yourself before you call @code{encode-time}. |
1224 | 1260 |
1225 The optional argument @var{zone} defaults to the current time zone and | 1261 The optional argument @var{zone} defaults to the current time zone and |
1226 its daylight savings time rules. If specified, it can be either a list | 1262 its daylight savings time rules. If specified, it can be either a list |
1227 (as you would get from @code{current-time-zone}), a string as in the | 1263 (as you would get from @code{current-time-zone}), a string as in the |
1228 @code{TZ} environment variable, or an integer (as you would get from | 1264 @code{TZ} environment variable, @code{t} for Universal Time, or an |
1229 @code{decode-time}). The specified zone is used without any further | 1265 integer (as you would get from @code{decode-time}). The specified |
1230 alteration for daylight savings time. | 1266 zone is used without any further alteration for daylight savings time. |
1231 | 1267 |
1232 If you pass more than seven arguments to @code{encode-time}, the first | 1268 If you pass more than seven arguments to @code{encode-time}, the first |
1233 six are used as @var{seconds} through @var{year}, the last argument is | 1269 six are used as @var{seconds} through @var{year}, the last argument is |
1234 used as @var{zone}, and the arguments in between are ignored. This | 1270 used as @var{zone}, and the arguments in between are ignored. This |
1235 feature makes it possible to use the elements of a list returned by | 1271 feature makes it possible to use the elements of a list returned by |
1307 things in an inconsistent state. This is normally unproblematical | 1343 things in an inconsistent state. This is normally unproblematical |
1308 because most timer functions don't do a lot of work. Indeed, for a | 1344 because most timer functions don't do a lot of work. Indeed, for a |
1309 timer to call a function that takes substantial time to run is likely | 1345 timer to call a function that takes substantial time to run is likely |
1310 to be annoying. | 1346 to be annoying. |
1311 | 1347 |
1312 @defun run-at-time time repeat function &rest args | 1348 @deffn Command run-at-time time repeat function &rest args |
1313 This function arranges to call @var{function} with arguments @var{args} | 1349 This sets up a timer that calls the function @var{function} with |
1314 at time @var{time}. The argument @var{function} is a function to call | 1350 arguments @var{args} at time @var{time}. If @var{repeat} is a number |
1315 later, and @var{args} are the arguments to give it when it is called. | 1351 (integer or floating point), the timer also runs every @var{repeat} |
1316 The time @var{time} is specified as a string. | 1352 seconds after that. If @var{repeat} is @code{nil}, the timer runs |
1353 only once. | |
1354 | |
1355 @var{time} may specify an absolute or a relative time. | |
1317 | 1356 |
1318 Absolute times may be specified in a wide variety of formats; this | 1357 Absolute times may be specified in a wide variety of formats; this |
1319 function tries to accept all the commonly used date formats. Valid | 1358 function tries to accept all the commonly used date formats. The most |
1320 formats include these two, | 1359 convenient formats are strings. Valid such formats include these two, |
1321 | 1360 |
1322 @example | 1361 @example |
1323 @var{year}-@var{month}-@var{day} @var{hour}:@var{min}:@var{sec} @var{timezone} | 1362 @var{year}-@var{month}-@var{day} @var{hour}:@var{min}:@var{sec} @var{timezone} |
1324 | 1363 |
1325 @var{hour}:@var{min}:@var{sec} @var{timezone} @var{month}/@var{day}/@var{year} | 1364 @var{hour}:@var{min}:@var{sec} @var{timezone} @var{month}/@var{day}/@var{year} |
1328 @noindent | 1367 @noindent |
1329 where in both examples all fields are numbers; the format that | 1368 where in both examples all fields are numbers; the format that |
1330 @code{current-time-string} returns is also allowed, and many others | 1369 @code{current-time-string} returns is also allowed, and many others |
1331 as well. | 1370 as well. |
1332 | 1371 |
1333 To specify a relative time, use numbers followed by units. | 1372 To specify a relative time as a string, use numbers followed by units. |
1334 For example: | 1373 For example: |
1335 | 1374 |
1336 @table @samp | 1375 @table @samp |
1337 @item 1 min | 1376 @item 1 min |
1338 denotes 1 minute from now. | 1377 denotes 1 minute from now. |
1343 @end table | 1382 @end table |
1344 | 1383 |
1345 For relative time values, Emacs considers a month to be exactly thirty | 1384 For relative time values, Emacs considers a month to be exactly thirty |
1346 days, and a year to be exactly 365.25 days. | 1385 days, and a year to be exactly 365.25 days. |
1347 | 1386 |
1348 If @var{time} is a number (integer or floating point), that specifies a | 1387 Not all convenient formats are strings. If @var{time} is a number |
1349 relative time measured in seconds. | 1388 (integer or floating point), that specifies a relative time measured |
1350 | 1389 in seconds. |
1351 The argument @var{repeat} specifies how often to repeat the call. If | |
1352 @var{repeat} is @code{nil}, there are no repetitions; @var{function} is | |
1353 called just once, at @var{time}. If @var{repeat} is a number, it | |
1354 specifies a repetition period measured in seconds. | |
1355 | 1390 |
1356 In most cases, @var{repeat} has no effect on when @emph{first} call | 1391 In most cases, @var{repeat} has no effect on when @emph{first} call |
1357 takes place---@var{time} alone specifies that. There is one exception: | 1392 takes place---@var{time} alone specifies that. There is one exception: |
1358 if @var{time} is @code{t}, then the timer runs whenever the time is a | 1393 if @var{time} is @code{t}, then the timer runs whenever the time is a |
1359 multiple of @var{repeat} seconds after the epoch. This is useful for | 1394 multiple of @var{repeat} seconds after the epoch. This is useful for |
1360 functions like @code{display-time}. | 1395 functions like @code{display-time}. |
1361 | 1396 |
1362 The function @code{run-at-time} returns a timer value that identifies | 1397 The function @code{run-at-time} returns a timer value that identifies |
1363 the particular scheduled future action. You can use this value to call | 1398 the particular scheduled future action. You can use this value to call |
1364 @code{cancel-timer} (see below). | 1399 @code{cancel-timer} (see below). |
1365 @end defun | 1400 @end deffn |
1366 | 1401 |
1367 @defmac with-timeout (seconds timeout-forms@dots{}) body@dots{} | 1402 @defmac with-timeout (seconds timeout-forms@dots{}) body@dots{} |
1368 Execute @var{body}, but give up after @var{seconds} seconds. If | 1403 Execute @var{body}, but give up after @var{seconds} seconds. If |
1369 @var{body} finishes before the time is up, @code{with-timeout} returns | 1404 @var{body} finishes before the time is up, @code{with-timeout} returns |
1370 the value of the last form in @var{body}. If, however, the execution of | 1405 the value of the last form in @var{body}. If, however, the execution of |
1386 | 1421 |
1387 The function @code{y-or-n-p-with-timeout} provides a simple way to use | 1422 The function @code{y-or-n-p-with-timeout} provides a simple way to use |
1388 a timer to avoid waiting too long for an answer. @xref{Yes-or-No | 1423 a timer to avoid waiting too long for an answer. @xref{Yes-or-No |
1389 Queries}. | 1424 Queries}. |
1390 | 1425 |
1391 @defun run-with-idle-timer secs repeat function &rest args | 1426 @deffn Command run-with-idle-timer secs repeat function &rest args |
1392 Set up a timer which runs when Emacs has been idle for @var{secs} | 1427 Set up a timer which runs when Emacs has been idle for @var{secs} |
1393 seconds. The value of @var{secs} may be an integer or a floating point | 1428 seconds. The value of @var{secs} may be an integer or a floating point |
1394 number. | 1429 number. |
1395 | 1430 |
1396 If @var{repeat} is @code{nil}, the timer runs just once, the first time | 1431 If @var{repeat} is @code{nil}, the timer runs just once, the first time |
1398 non-@code{nil}, which means to run the timer @emph{each time} Emacs | 1433 non-@code{nil}, which means to run the timer @emph{each time} Emacs |
1399 remains idle for @var{secs} seconds. | 1434 remains idle for @var{secs} seconds. |
1400 | 1435 |
1401 The function @code{run-with-idle-timer} returns a timer value which you | 1436 The function @code{run-with-idle-timer} returns a timer value which you |
1402 can use in calling @code{cancel-timer} (see below). | 1437 can use in calling @code{cancel-timer} (see below). |
1403 @end defun | 1438 @end deffn |
1404 | 1439 |
1405 @cindex idleness | 1440 @cindex idleness |
1406 Emacs becomes ``idle'' when it starts waiting for user input, and it | 1441 Emacs becomes ``idle'' when it starts waiting for user input, and it |
1407 remains idle until the user provides some input. If a timer is set for | 1442 remains idle until the user provides some input. If a timer is set for |
1408 five seconds of idleness, it runs approximately five seconds after Emacs | 1443 five seconds of idleness, it runs approximately five seconds after Emacs |
1424 set up to repeat will subsequently run another time, one by one. | 1459 set up to repeat will subsequently run another time, one by one. |
1425 | 1460 |
1426 @defun cancel-timer timer | 1461 @defun cancel-timer timer |
1427 Cancel the requested action for @var{timer}, which should be a value | 1462 Cancel the requested action for @var{timer}, which should be a value |
1428 previously returned by @code{run-at-time} or @code{run-with-idle-timer}. | 1463 previously returned by @code{run-at-time} or @code{run-with-idle-timer}. |
1429 This cancels the effect of that call to @code{run-at-time}; the arrival | 1464 This cancels the effect of that call to one of these functions; the |
1430 of the specified time will not cause anything special to happen. | 1465 arrival of the specified time will not cause anything special to happen. |
1431 @end defun | 1466 @end defun |
1432 | 1467 |
1433 @node Terminal Input | 1468 @node Terminal Input |
1434 @section Terminal Input | 1469 @section Terminal Input |
1435 @cindex terminal input | 1470 @cindex terminal input |
1448 @node Input Modes | 1483 @node Input Modes |
1449 @subsection Input Modes | 1484 @subsection Input Modes |
1450 @cindex input modes | 1485 @cindex input modes |
1451 @cindex terminal input modes | 1486 @cindex terminal input modes |
1452 | 1487 |
1453 @defun set-input-mode interrupt flow meta quit-char | 1488 @defun set-input-mode interrupt flow meta &optional quit-char |
1454 This function sets the mode for reading keyboard input. If | 1489 This function sets the mode for reading keyboard input. If |
1455 @var{interrupt} is non-null, then Emacs uses input interrupts. If it is | 1490 @var{interrupt} is non-null, then Emacs uses input interrupts. If it is |
1456 @code{nil}, then it uses @sc{cbreak} mode. The default setting is | 1491 @code{nil}, then it uses @sc{cbreak} mode. The default setting is |
1457 system-dependent. Some systems always use @sc{cbreak} mode regardless | 1492 system-dependent. Some systems always use @sc{cbreak} mode regardless |
1458 of what is specified. | 1493 of what is specified. |
1521 @code{function-key-map} and then with @code{key-translation-map}. | 1556 @code{function-key-map} and then with @code{key-translation-map}. |
1522 | 1557 |
1523 @c Emacs 19 feature | 1558 @c Emacs 19 feature |
1524 @defvar extra-keyboard-modifiers | 1559 @defvar extra-keyboard-modifiers |
1525 This variable lets Lisp programs ``press'' the modifier keys on the | 1560 This variable lets Lisp programs ``press'' the modifier keys on the |
1526 keyboard. The value is a bit mask: | 1561 keyboard. The value is a character. Only the modifiers of the |
1527 | 1562 character matter. Each time the user types a keyboard key, it is |
1528 @table @asis | 1563 altered as if those modifier keys were held down. For instance, if |
1529 @item 1 | 1564 you bind @code{extra-keyboard-modifiers} to @code{?\C-\M-a}, then all |
1530 The @key{SHIFT} key. | 1565 keyboard input characters typed during the scope of the binding will |
1531 @item 2 | 1566 have the control and meta modifiers applied to them. The character |
1532 The @key{LOCK} key. | 1567 @code{?\C-@@}, equivalent to the integer 0, does not count as a control |
1533 @item 4 | 1568 character for this purpose, but as a character with no modifiers. |
1534 The @key{CTL} key. | 1569 Thus, setting @code{extra-keyboard-modifiers} to zero cancels any |
1535 @item 8 | 1570 modification. |
1536 The @key{META} key. | |
1537 @end table | |
1538 | |
1539 Each time the user types a keyboard key, it is altered as if the | |
1540 modifier keys specified in the bit mask were held down. | |
1541 | 1571 |
1542 When using a window system, the program can ``press'' any of the | 1572 When using a window system, the program can ``press'' any of the |
1543 modifier keys in this way. Otherwise, only the @key{CTL} and @key{META} | 1573 modifier keys in this way. Otherwise, only the @key{CTL} and @key{META} |
1544 keys can be virtually pressed. | 1574 keys can be virtually pressed. |
1575 | |
1576 Note that this variable applies only to events that really come from | |
1577 the keyboard, and has no effect on mouse events or any other events. | |
1545 @end defvar | 1578 @end defvar |
1546 | 1579 |
1547 @defvar keyboard-translate-table | 1580 @defvar keyboard-translate-table |
1548 This variable is the translate table for keyboard characters. It lets | 1581 This variable is the translate table for keyboard characters. It lets |
1549 you reshuffle the keys on the keyboard without changing any command | 1582 you reshuffle the keys on the keyboard without changing any command |
1550 bindings. Its value is normally a char-table, or else @code{nil}. | 1583 bindings. Its value is normally a char-table, or else @code{nil}. |
1584 (It can also be a string or vector, but this is considered obsolete.) | |
1551 | 1585 |
1552 If @code{keyboard-translate-table} is a char-table | 1586 If @code{keyboard-translate-table} is a char-table |
1553 (@pxref{Char-Tables}), then each character read from the keyboard is | 1587 (@pxref{Char-Tables}), then each character read from the keyboard is |
1554 looked up in this char-table. If the value found there is | 1588 looked up in this char-table. If the value found there is |
1555 non-@code{nil}, then it is used instead of the actual input character. | 1589 non-@code{nil}, then it is used instead of the actual input character. |
1585 | 1619 |
1586 Note that this translation is the first thing that happens to a | 1620 Note that this translation is the first thing that happens to a |
1587 character after it is read from the terminal. Record-keeping features | 1621 character after it is read from the terminal. Record-keeping features |
1588 such as @code{recent-keys} and dribble files record the characters after | 1622 such as @code{recent-keys} and dribble files record the characters after |
1589 translation. | 1623 translation. |
1624 | |
1625 Note also that this translation is done before the characters are | |
1626 supplied to input methods (@pxref{Input Methods}). Use | |
1627 @code{translation-table-for-input} (@pxref{Translation of Characters}), | |
1628 if you want to translate characters after input methods operate. | |
1590 @end defvar | 1629 @end defvar |
1591 | 1630 |
1592 @defun keyboard-translate from to | 1631 @defun keyboard-translate from to |
1593 This function modifies @code{keyboard-translate-table} to translate | 1632 This function modifies @code{keyboard-translate-table} to translate |
1594 character code @var{from} into character code @var{to}. It creates | 1633 character code @var{from} into character code @var{to}. It creates |
1697 @end group | 1736 @end group |
1698 @end example | 1737 @end example |
1699 | 1738 |
1700 Finally, if you have enabled keyboard character set decoding using | 1739 Finally, if you have enabled keyboard character set decoding using |
1701 @code{set-keyboard-coding-system}, decoding is done after the | 1740 @code{set-keyboard-coding-system}, decoding is done after the |
1702 translations listed above. @xref{Specifying Coding Systems}. In future | 1741 translations listed above. @xref{Terminal I/O Encoding}. In future |
1703 Emacs versions, character set decoding may be done before the other | 1742 Emacs versions, character set decoding may be done before the other |
1704 translations. | 1743 translations. |
1705 | 1744 |
1706 @node Recording Input | 1745 @node Recording Input |
1707 @subsection Recording Input | 1746 @subsection Recording Input |
1802 Termcap entries or to undesirable settings of terminal options more | 1841 Termcap entries or to undesirable settings of terminal options more |
1803 often than to actual Emacs bugs. Once you are certain which characters | 1842 often than to actual Emacs bugs. Once you are certain which characters |
1804 were actually output, you can determine reliably whether they correspond | 1843 were actually output, you can determine reliably whether they correspond |
1805 to the Termcap specifications in use. | 1844 to the Termcap specifications in use. |
1806 | 1845 |
1807 See also @code{open-dribble-file} in @ref{Terminal Input}. | 1846 You close the termscript file by calling this function with an |
1847 argument of @code{nil}. | |
1848 | |
1849 See also @code{open-dribble-file} in @ref{Recording Input}. | |
1808 | 1850 |
1809 @example | 1851 @example |
1810 @group | 1852 @group |
1811 (open-termscript "../junk/termscript") | 1853 (open-termscript "../junk/termscript") |
1812 @result{} nil | 1854 @result{} nil |
1967 As window systems and PC terminal emulators replace character-only | 2009 As window systems and PC terminal emulators replace character-only |
1968 terminals, the flow control problem is gradually disappearing. For the | 2010 terminals, the flow control problem is gradually disappearing. For the |
1969 mean time, Emacs provides a convenient way of enabling flow control if | 2011 mean time, Emacs provides a convenient way of enabling flow control if |
1970 you want it: call the function @code{enable-flow-control}. | 2012 you want it: call the function @code{enable-flow-control}. |
1971 | 2013 |
1972 @deffn Command enable-flow-control | 2014 @deffn Command enable-flow-control &optional arg |
1973 This function enables use of @kbd{C-s} and @kbd{C-q} for output flow | 2015 When @var{arg} is a positive integer, this function enables use of |
1974 control, and provides the characters @kbd{C-\} and @kbd{C-^} as aliases | 2016 @kbd{C-s} and @kbd{C-q} for output flow control, and provides the |
1975 for them using @code{keyboard-translate-table} (@pxref{Translating Input}). | 2017 characters @kbd{C-\} and @kbd{C-^} as aliases for them using |
2018 @code{keyboard-translate-table} (@pxref{Translating Input}). | |
2019 | |
2020 When @var{arg} is a negative integer or zero, it disables these | |
2021 features. When @var{arg} is @code{nil} or omitted, it toggles. | |
2022 Interactively, @var{arg} is the prefix argument. If non-@code{nil}, | |
2023 its numeric value is used. | |
1976 @end deffn | 2024 @end deffn |
1977 | 2025 |
1978 You can use the function @code{enable-flow-control-on} in your | 2026 You can use the function @code{enable-flow-control-on} in your |
1979 init file to enable flow control automatically on certain | 2027 init file to enable flow control automatically on certain |
1980 terminal types. | 2028 terminal types. |
1992 | 2040 |
1993 @enumerate | 2041 @enumerate |
1994 @item | 2042 @item |
1995 @cindex @sc{cbreak} | 2043 @cindex @sc{cbreak} |
1996 It sets @sc{cbreak} mode for terminal input, and tells the operating | 2044 It sets @sc{cbreak} mode for terminal input, and tells the operating |
1997 system to handle flow control, with @code{(set-input-mode nil t)}. | 2045 system to handle flow control. This is done using @code{set-input-mode}. |
1998 | 2046 |
1999 @item | 2047 @item |
2000 It sets up @code{keyboard-translate-table} to translate @kbd{C-\} and | 2048 It sets up @code{keyboard-translate-table} to translate @kbd{C-\} and |
2001 @kbd{C-^} into @kbd{C-s} and @kbd{C-q}. Except at its very | 2049 @kbd{C-^} into @kbd{C-s} and @kbd{C-q}. Except at its very |
2002 lowest level, Emacs never knows that the characters typed were anything | 2050 lowest level, Emacs never knows that the characters typed were anything |
2059 @defvar emacs-save-session-functions | 2107 @defvar emacs-save-session-functions |
2060 @tindex emacs-save-session-functions | 2108 @tindex emacs-save-session-functions |
2061 Emacs supports saving state by using a hook called | 2109 Emacs supports saving state by using a hook called |
2062 @code{emacs-save-session-functions}. Each function in this hook is | 2110 @code{emacs-save-session-functions}. Each function in this hook is |
2063 called when the session manager tells Emacs that the window system is | 2111 called when the session manager tells Emacs that the window system is |
2064 shutting down. The functions are called with the current buffer set | 2112 shutting down. The functions are called with no arguments and with the |
2065 to a temporary buffer. Each function can use @code{insert} to add | 2113 current buffer set to a temporary buffer. Each function can use |
2066 Lisp code to this buffer. At the end, Emacs saves the buffer in a | 2114 @code{insert} to add Lisp code to this buffer. At the end, Emacs |
2067 file that another Emacs will later load in order to restart the saved session. | 2115 saves the buffer in a file that a subsequent Emacs invocation will |
2116 load in order to restart the saved session. | |
2068 | 2117 |
2069 If a function in @code{emacs-save-session-functions} returns | 2118 If a function in @code{emacs-save-session-functions} returns |
2070 non-@code{nil}, Emacs tells the session manager to cancel the | 2119 non-@code{nil}, Emacs tells the session manager to cancel the |
2071 shutdown. | 2120 shutdown. |
2072 @end defvar | 2121 @end defvar |