diff options
| author | Richard M. Stallman | 1996-07-23 15:40:25 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-07-23 15:40:25 +0000 |
| commit | 0c1241267e595c397a812bc0afa93d7209768f94 (patch) | |
| tree | 49e60ba8673de3b7008b5f6f9653b636447d30e6 | |
| parent | 5e8ae792b15ee318e5493803e3c8c5980e53aa70 (diff) | |
| download | emacs-0c1241267e595c397a812bc0afa93d7209768f94.tar.gz emacs-0c1241267e595c397a812bc0afa93d7209768f94.zip | |
Lots of timer feature updates.
encode-time takes additional arguments and ignores them.
Change linux to gnu/linux for system-type.
More information about key translation features.
| -rw-r--r-- | lispref/os.texi | 133 |
1 files changed, 112 insertions, 21 deletions
diff --git a/lispref/os.texi b/lispref/os.texi index f941b3bfb05..e231a0937ad 100644 --- a/lispref/os.texi +++ b/lispref/os.texi | |||
| @@ -566,7 +566,10 @@ Berkeley BSD. | |||
| 566 | Data General DGUX operating system. | 566 | Data General DGUX operating system. |
| 567 | 567 | ||
| 568 | @item gnu | 568 | @item gnu |
| 569 | A GNU system using the GNU HURD and Mach. | 569 | A GNU system (using the GNU kernel, which consists of the HURD and Mach). |
| 570 | |||
| 571 | @item gnu/linux | ||
| 572 | A variant GNU system using the Linux kernel. | ||
| 570 | 573 | ||
| 571 | @item hpux | 574 | @item hpux |
| 572 | Hewlett-Packard HPUX operating system. | 575 | Hewlett-Packard HPUX operating system. |
| @@ -574,9 +577,6 @@ Hewlett-Packard HPUX operating system. | |||
| 574 | @item irix | 577 | @item irix |
| 575 | Silicon Graphics Irix system. | 578 | Silicon Graphics Irix system. |
| 576 | 579 | ||
| 577 | @item linux | ||
| 578 | A GNU system using the Linux kernel. | ||
| 579 | |||
| 580 | @item ms-dos | 580 | @item ms-dos |
| 581 | Microsoft MS-DOS ``operating system.'' | 581 | Microsoft MS-DOS ``operating system.'' |
| 582 | 582 | ||
| @@ -1023,7 +1023,7 @@ Note that Common Lisp has different meanings for @var{dow} and | |||
| 1023 | @var{zone}. | 1023 | @var{zone}. |
| 1024 | @end defun | 1024 | @end defun |
| 1025 | 1025 | ||
| 1026 | @defun encode-time seconds minutes hour day month year &optional zone | 1026 | @defun encode-time seconds minutes hour day month year &optional @dots{}zone |
| 1027 | This function is the inverse of @code{decode-time}. It converts seven | 1027 | This function is the inverse of @code{decode-time}. It converts seven |
| 1028 | items of calendrical data into a time value. For the meanings of the | 1028 | items of calendrical data into a time value. For the meanings of the |
| 1029 | arguments, see the table above under @code{decode-time}. | 1029 | arguments, see the table above under @code{decode-time}. |
| @@ -1037,12 +1037,31 @@ its daylight savings time rules. If specified, it can be either a list | |||
| 1037 | (as you would get from @code{current-time-zone}) or an integer (as you | 1037 | (as you would get from @code{current-time-zone}) or an integer (as you |
| 1038 | would get from @code{decode-time}). The specified zone is used without | 1038 | would get from @code{decode-time}). The specified zone is used without |
| 1039 | any further alteration for daylight savings time. | 1039 | any further alteration for daylight savings time. |
| 1040 | |||
| 1041 | If you pass more than seven arguments to @code{encode-time}, the first | ||
| 1042 | six are used as @var{seconds} through @var{year}, the last argument is | ||
| 1043 | used as @var{zone}, and the arguments in between are ignored. This | ||
| 1044 | feature makes it possible to use the elements of a list returned by | ||
| 1045 | @code{decode-time} as the arguments to @code{encode-time}, like this: | ||
| 1046 | |||
| 1047 | @example | ||
| 1048 | (apply 'encode-time (decode-time @dots{})) | ||
| 1049 | @end example | ||
| 1040 | @end defun | 1050 | @end defun |
| 1041 | 1051 | ||
| 1042 | @node Timers | 1052 | @node Timers |
| 1043 | @section Timers for Delayed Execution | 1053 | @section Timers for Delayed Execution |
| 1054 | @cindex timer | ||
| 1044 | 1055 | ||
| 1045 | You can set up a timer to call a function at a specified future time. | 1056 | You can set up a @dfn{timer} to call a function at a specified future time or |
| 1057 | after a certain length of idleness. | ||
| 1058 | |||
| 1059 | Emacs cannot run a timer at any arbitrary point in a Lisp program; it | ||
| 1060 | can run them only when Emacs could accept output from a subprocess: | ||
| 1061 | namely, while waiting or inside certain primitive functions such as | ||
| 1062 | @code{sit-for} or @code{read-char} which @emph{can} wait. Therefore, a | ||
| 1063 | timer's execution may be delayed if Emacs is busy. However, the time of | ||
| 1064 | execution is very precise if Emacs is idle. | ||
| 1046 | 1065 | ||
| 1047 | @defun run-at-time time repeat function &rest args | 1066 | @defun run-at-time time repeat function &rest args |
| 1048 | This function arranges to call @var{function} with arguments @var{args} | 1067 | This function arranges to call @var{function} with arguments @var{args} |
| @@ -1050,7 +1069,7 @@ at time @var{time}. The argument @var{function} is a function to call | |||
| 1050 | later, and @var{args} are the arguments to give it when it is called. | 1069 | later, and @var{args} are the arguments to give it when it is called. |
| 1051 | The time @var{time} is specified as a string. | 1070 | The time @var{time} is specified as a string. |
| 1052 | 1071 | ||
| 1053 | Absolute times may be specified in a wide variety of formats; The form | 1072 | Absolute times may be specified in a variety of formats; The form |
| 1054 | @samp{@var{hour}:@var{min}:@var{sec} @var{timezone} | 1073 | @samp{@var{hour}:@var{min}:@var{sec} @var{timezone} |
| 1055 | @var{month}/@var{day}/@var{year}}, where all fields are numbers, works; | 1074 | @var{month}/@var{day}/@var{year}}, where all fields are numbers, works; |
| 1056 | the format that @code{current-time-string} returns is also allowed. | 1075 | the format that @code{current-time-string} returns is also allowed. |
| @@ -1067,26 +1086,85 @@ denotes 65 seconds from now. | |||
| 1067 | denotes exactly 103 months, 123 days, and 10862 seconds from now. | 1086 | denotes exactly 103 months, 123 days, and 10862 seconds from now. |
| 1068 | @end table | 1087 | @end table |
| 1069 | 1088 | ||
| 1070 | If @var{time} is an integer, that specifies a relative time measured in | 1089 | If @var{time} is a number (integer or floating point), that specifies a |
| 1071 | seconds. | 1090 | relative time measured in seconds. |
| 1072 | 1091 | ||
| 1073 | The argument @var{repeat} specifies how often to repeat the call. If | 1092 | The argument @var{repeat} specifies how often to repeat the call. If |
| 1074 | @var{repeat} is @code{nil}, there are no repetitions; @var{function} is | 1093 | @var{repeat} is @code{nil}, there are no repetitions; @var{function} is |
| 1075 | called just once, at @var{time}. If @var{repeat} is an integer, it | 1094 | called just once, at @var{time}. If @var{repeat} is a number, it |
| 1076 | specifies a repetition period measured in seconds. In any case, @var{repeat} | 1095 | specifies a repetition period measured in seconds. In any case, |
| 1077 | has no effect on when @emph{first} call takes place---@var{time} specifies | 1096 | @var{repeat} has no effect on when @emph{first} call takes |
| 1078 | that. | 1097 | place---@var{time} alone specifies that. |
| 1079 | 1098 | ||
| 1080 | The function @code{run-at-time} returns a timer value that identifies | 1099 | The function @code{run-at-time} returns a timer value that identifies |
| 1081 | the particular scheduled future action. You can use this value to call | 1100 | the particular scheduled future action. You can use this value to call |
| 1082 | @code{cancel-timer}. | 1101 | @code{cancel-timer} (see below). |
| 1102 | @end defun | ||
| 1103 | |||
| 1104 | @defmac with-timeout (seconds timeout-forms@dots{}) body@dots{} | ||
| 1105 | Execute @var{body}, but give up after @var{seconds} seconds. If | ||
| 1106 | @var{body} finishes before the time is up, @code{with-timeout} returns | ||
| 1107 | the value of the last form in @var{body}. If, however, the execution of | ||
| 1108 | @var{body} is cut short by the timeout, then @code{with-timeout} | ||
| 1109 | executes all the @var{timeout-forms} and returns the value of the last | ||
| 1110 | of them. | ||
| 1111 | |||
| 1112 | This macro works by set a timer to run after @var{seconds} seconds. If | ||
| 1113 | @var{body} finishes before that time, it cancels the timer. If the | ||
| 1114 | timer actually runs, it terminates execution of @var{body}, then | ||
| 1115 | executes @var{timeout-forms}. | ||
| 1116 | |||
| 1117 | Since timers can run within a Lisp program only when the program calls a | ||
| 1118 | primitive that can wait, @code{with-timeout} cannot stop executing | ||
| 1119 | @var{body} while it is in the midst of a computation---only when it | ||
| 1120 | calls one of those primitives. So use @code{with-timeout} only with a | ||
| 1121 | @var{body} that waits for input, not one that does a long computation. | ||
| 1122 | @end defmac | ||
| 1123 | |||
| 1124 | The function @code{y-or-n-p-with-timeout} provides a simple way to use | ||
| 1125 | a timer to avoid waiting too long for an answer. @xref{Yes-or-No | ||
| 1126 | Queries}. | ||
| 1127 | |||
| 1128 | @defun run-with-idle-timer secs repeat function &rest args | ||
| 1129 | Set up a timer which runs when Emacs has been idle for @var{secs} | ||
| 1130 | seconds. The value of @var{secs} may be an integer or a floating point | ||
| 1131 | number. | ||
| 1132 | |||
| 1133 | If @var{repeat} is @code{nil}, the timer runs just once, the first time | ||
| 1134 | Emacs remains idle for a long enough time. More often @var{repeat} is | ||
| 1135 | non-@code{nil}, which means to run the timer @emph{each time} Emacs | ||
| 1136 | remains idle for @var{secs} seconds. | ||
| 1137 | |||
| 1138 | The function @code{run-with-idle-timer} returns a timer value which you | ||
| 1139 | can use in calling @code{cancel-timer} (see below). | ||
| 1083 | @end defun | 1140 | @end defun |
| 1084 | 1141 | ||
| 1142 | @cindex idleness | ||
| 1143 | Emacs becomes ``idle'' when it starts waiting for user input, and it | ||
| 1144 | remains idle until the user provides some input. If a timer is set for | ||
| 1145 | five seconds of idleness, it runs approximately five seconds after Emacs | ||
| 1146 | first became idle. Even if its @var{repeat} is true, this timer will | ||
| 1147 | not run again as long as Emacs remains idle, because the duration of | ||
| 1148 | idleness will continue to increase and will not go down to five seconds | ||
| 1149 | again. | ||
| 1150 | |||
| 1151 | Emacs can do various things while idle: garbage collect, autosave or | ||
| 1152 | handle data from a subprocess. But these interludes during idleness | ||
| 1153 | have little effect on idle timers. An idle timer set for 600 seconds | ||
| 1154 | will run when ten minutes have elapsed since the last user command was | ||
| 1155 | finished, even if subprocess output has been accepted thousands of times | ||
| 1156 | within those ten minutes, even if there have been garbage collections | ||
| 1157 | and autosaves. | ||
| 1158 | |||
| 1159 | When the user supplies input, Emacs becomes non-idle while executing the | ||
| 1160 | input. Then it becomes idle again, and all the idle timers that are | ||
| 1161 | set up to repeat will subsequently run another time, one by one. | ||
| 1162 | |||
| 1085 | @defun cancel-timer timer | 1163 | @defun cancel-timer timer |
| 1086 | Cancel the requested action for @var{timer}, which should be a value | 1164 | Cancel the requested action for @var{timer}, which should be a value |
| 1087 | previously returned by @code{run-at-time}. This cancels the effect of | 1165 | previously returned by @code{run-at-time} or @code{run-with-idle-timer}. |
| 1088 | that call to @code{run-at-time}; the arrival of the specified time will | 1166 | This cancels the effect of that call to @code{run-at-time}; the arrival |
| 1089 | not cause anything special to happen. | 1167 | of the specified time will not cause anything special to happen. |
| 1090 | @end defun | 1168 | @end defun |
| 1091 | 1169 | ||
| 1092 | @node Terminal Input | 1170 | @node Terminal Input |
| @@ -1169,8 +1247,14 @@ is the character Emacs currently uses for quitting, usually @kbd{C-g}. | |||
| 1169 | @subsection Translating Input Events | 1247 | @subsection Translating Input Events |
| 1170 | @cindex translating input events | 1248 | @cindex translating input events |
| 1171 | 1249 | ||
| 1172 | This section describes features for translating input events into other | 1250 | This section describes features for translating input events into |
| 1173 | input events before they become part of key sequences. | 1251 | other input events before they become part of key sequences. These |
| 1252 | features apply to each event in the order they are described here: each | ||
| 1253 | event is first modified according to @code{extra-keyboard-modifiers}, | ||
| 1254 | then translated through @code{keyboard-translate-table} (if applicable). | ||
| 1255 | If it is being read as part of a key sequence, it is then added to the | ||
| 1256 | sequece being read; then subsequences containing it are checked first | ||
| 1257 | with @code{function-key-map} and then with @code{key-translation-map}. | ||
| 1174 | 1258 | ||
| 1175 | @c Emacs 19 feature | 1259 | @c Emacs 19 feature |
| 1176 | @defvar extra-keyboard-modifiers | 1260 | @defvar extra-keyboard-modifiers |
| @@ -1250,11 +1334,15 @@ character code @var{from} into character code @var{to}. It creates | |||
| 1250 | or enlarges the translate table if necessary. | 1334 | or enlarges the translate table if necessary. |
| 1251 | @end defun | 1335 | @end defun |
| 1252 | 1336 | ||
| 1337 | The remaining translation features translate subsequences of key | ||
| 1338 | sequences being read. They are implemented in @code{read-key-sequence} | ||
| 1339 | and have no effect on @code{read-char}. | ||
| 1340 | |||
| 1253 | @defvar function-key-map | 1341 | @defvar function-key-map |
| 1254 | This variable holds a keymap that describes the character sequences | 1342 | This variable holds a keymap that describes the character sequences |
| 1255 | sent by function keys on an ordinary character terminal. This keymap | 1343 | sent by function keys on an ordinary character terminal. This keymap |
| 1256 | uses the same data structure as other keymaps, but is used differently: it | 1344 | uses the same data structure as other keymaps, but is used differently: it |
| 1257 | specifies translations to make while reading events. | 1345 | specifies translations to make while reading event sequences. |
| 1258 | 1346 | ||
| 1259 | If @code{function-key-map} ``binds'' a key sequence @var{k} to a vector | 1347 | If @code{function-key-map} ``binds'' a key sequence @var{k} to a vector |
| 1260 | @var{v}, then when @var{k} appears as a subsequence @emph{anywhere} in a | 1348 | @var{v}, then when @var{k} appears as a subsequence @emph{anywhere} in a |
| @@ -1299,7 +1387,10 @@ finished; it receives the results of translation by | |||
| 1299 | @code{function-key-map}. | 1387 | @code{function-key-map}. |
| 1300 | 1388 | ||
| 1301 | @item | 1389 | @item |
| 1302 | @code{key-translation-map} overrides actual key bindings. | 1390 | @code{key-translation-map} overrides actual key bindings. For example, |
| 1391 | if @kbd{C-x f} has a binding in @code{key-translation-map}, that | ||
| 1392 | translation takes effect even though @kbd{C-x f} also has a key binding | ||
| 1393 | in the global map. | ||
| 1303 | @end itemize | 1394 | @end itemize |
| 1304 | 1395 | ||
| 1305 | The intent of @code{key-translation-map} is for users to map one | 1396 | The intent of @code{key-translation-map} is for users to map one |