diff options
| author | Chong Yidong | 2012-03-18 23:02:12 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-03-18 23:02:12 +0800 |
| commit | d15aac68209502b0a4e748a3a24e4b1c6a4bc54a (patch) | |
| tree | 3d1b8ebb4dc2ae5c9781787018af29398b87a06a /doc | |
| parent | 4c5779ab90f6be7862604d700f4b1dee17ba10c4 (diff) | |
| download | emacs-d15aac68209502b0a4e748a3a24e4b1c6a4bc54a.tar.gz emacs-d15aac68209502b0a4e748a3a24e4b1c6a4bc54a.zip | |
Copyedits for Internals and OS chapters of Lisp manual.
* doc/lispref/internals.texi (Building Emacs, Garbage Collection): Copyedits.
(Writing Emacs Primitives): Re-organize discussion of functions
with variable Lisp arguments are handled. Delete an obsolete
remark, previously tagged as FIXME.
* doc/lispref/os.texi (Idle Timers): Minor clarification.
(Idle Timers): Link to Time of Day for description of time list.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/ChangeLog | 10 | ||||
| -rw-r--r-- | doc/lispref/internals.texi | 180 | ||||
| -rw-r--r-- | doc/lispref/os.texi | 50 |
3 files changed, 104 insertions, 136 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 6c512a33978..af0cb306245 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2012-03-18 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * internals.texi (Building Emacs, Garbage Collection): Copyedits. | ||
| 4 | (Writing Emacs Primitives): Re-organize discussion of functions | ||
| 5 | with variable Lisp arguments are handled. Delete an obsolete | ||
| 6 | remark, previously tagged as FIXME. | ||
| 7 | |||
| 8 | * os.texi (Idle Timers): Minor clarification. | ||
| 9 | (Idle Timers): Link to Time of Day for description of time list. | ||
| 10 | |||
| 1 | 2012-03-18 Glenn Morris <rgm@gnu.org> | 11 | 2012-03-18 Glenn Morris <rgm@gnu.org> |
| 2 | 12 | ||
| 3 | * os.texi (System Interface): Flow control was removed. | 13 | * os.texi (System Interface): Flow control was removed. |
diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi index 55b18edf2ec..edf892e751a 100644 --- a/doc/lispref/internals.texi +++ b/doc/lispref/internals.texi | |||
| @@ -28,42 +28,39 @@ internal aspects of GNU Emacs that may be of interest to C programmers. | |||
| 28 | This section explains the steps involved in building the Emacs | 28 | This section explains the steps involved in building the Emacs |
| 29 | executable. You don't have to know this material to build and install | 29 | executable. You don't have to know this material to build and install |
| 30 | Emacs, since the makefiles do all these things automatically. This | 30 | Emacs, since the makefiles do all these things automatically. This |
| 31 | information is pertinent to Emacs maintenance. | 31 | information is pertinent to Emacs developers. |
| 32 | 32 | ||
| 33 | Compilation of the C source files in the @file{src} directory | 33 | Compilation of the C source files in the @file{src} directory |
| 34 | produces an executable file called @file{temacs}, also called a | 34 | produces an executable file called @file{temacs}, also called a |
| 35 | @dfn{bare impure Emacs}. It contains the Emacs Lisp interpreter and I/O | 35 | @dfn{bare impure Emacs}. It contains the Emacs Lisp interpreter and |
| 36 | routines, but not the editing commands. | 36 | I/O routines, but not the editing commands. |
| 37 | 37 | ||
| 38 | @cindex @file{loadup.el} | 38 | @cindex @file{loadup.el} |
| 39 | The command @w{@samp{temacs -l loadup}} uses @file{temacs} to create | 39 | The command @w{@command{temacs -l loadup}} would run @file{temacs} |
| 40 | the real runnable Emacs executable. These arguments direct | 40 | and direct it to load @file{loadup.el}. The @code{loadup} library |
| 41 | @file{temacs} to evaluate the Lisp files specified in the file | 41 | loads additional Lisp libraries, which set up the normal Emacs editing |
| 42 | @file{loadup.el}. These files set up the normal Emacs editing | 42 | environment. After this step, the Emacs executable is no longer |
| 43 | environment, resulting in an Emacs that is still impure but no longer | 43 | @dfn{bare}. |
| 44 | bare. | ||
| 45 | 44 | ||
| 46 | @cindex dumping Emacs | 45 | @cindex dumping Emacs |
| 47 | It takes some time to load the standard Lisp files. Luckily, | 46 | Because it takes some time to load the standard Lisp files, the |
| 48 | you don't have to do this each time you run Emacs; @file{temacs} can | 47 | @file{temacs} executable usually isn't run directly by users. |
| 49 | dump out an executable program called @file{emacs} that has these files | 48 | Instead, as one of the last steps of building Emacs, the command |
| 50 | preloaded. @file{emacs} starts more quickly because it does not need to | 49 | @samp{temacs -batch -l loadup dump} is run. The special @samp{dump} |
| 51 | load the files. This is the Emacs executable that is normally | 50 | argument causes @command{temacs} to dump out an executable program, |
| 52 | installed. | 51 | called @file{emacs}, which has all the standard Lisp files preloaded. |
| 53 | 52 | (The @samp{-batch} argument prevents @file{temacs} from trying to | |
| 53 | initialize any of its data on the terminal, so that the tables of | ||
| 54 | terminal information are empty in the dumped Emacs.) | ||
| 55 | |||
| 56 | @cindex preloaded Lisp files | ||
| 54 | @vindex preloaded-file-list | 57 | @vindex preloaded-file-list |
| 55 | @cindex dumped Lisp files | 58 | The dumped @file{emacs} executable (also called a @dfn{pure} Emacs) |
| 56 | To create @file{emacs}, use the command @samp{temacs -batch -l loadup | 59 | is the one which is installed. The variable |
| 57 | dump}. The purpose of @samp{-batch} here is to prevent @file{temacs} | 60 | @code{preloaded-file-list} stores a list of the Lisp files preloaded |
| 58 | from trying to initialize any of its data on the terminal; this ensures | 61 | into the dumped Emacs. If you port Emacs to a new operating system, |
| 59 | that the tables of terminal information are empty in the dumped Emacs. | 62 | and are not able to implement dumping, then Emacs must load |
| 60 | The argument @samp{dump} tells @file{loadup.el} to dump a new executable | 63 | @file{loadup.el} each time it starts. |
| 61 | named @file{emacs}. The variable @code{preloaded-file-list} stores a | ||
| 62 | list of the Lisp files that were dumped with the @file{emacs} executable. | ||
| 63 | |||
| 64 | If you port Emacs to a new operating system, and are not able to | ||
| 65 | implement dumping, then Emacs must load @file{loadup.el} each time it | ||
| 66 | starts. | ||
| 67 | 64 | ||
| 68 | @cindex @file{site-load.el} | 65 | @cindex @file{site-load.el} |
| 69 | You can specify additional files to preload by writing a library named | 66 | You can specify additional files to preload by writing a library named |
| @@ -163,7 +160,7 @@ all the new data created during an Emacs session are kept | |||
| 163 | in the preloaded standard Lisp files---data that should never change | 160 | in the preloaded standard Lisp files---data that should never change |
| 164 | during actual use of Emacs. | 161 | during actual use of Emacs. |
| 165 | 162 | ||
| 166 | Pure storage is allocated only while @file{temacs} is loading the | 163 | Pure storage is allocated only while @command{temacs} is loading the |
| 167 | standard preloaded Lisp libraries. In the file @file{emacs}, it is | 164 | standard preloaded Lisp libraries. In the file @file{emacs}, it is |
| 168 | marked as read-only (on operating systems that permit this), so that | 165 | marked as read-only (on operating systems that permit this), so that |
| 169 | the memory space can be shared by all the Emacs jobs running on the | 166 | the memory space can be shared by all the Emacs jobs running on the |
| @@ -214,31 +211,27 @@ You should not change this flag in a running Emacs. | |||
| 214 | 211 | ||
| 215 | @node Garbage Collection | 212 | @node Garbage Collection |
| 216 | @section Garbage Collection | 213 | @section Garbage Collection |
| 217 | @cindex garbage collection | ||
| 218 | 214 | ||
| 219 | @cindex memory allocation | 215 | @cindex memory allocation |
| 220 | When a program creates a list or the user defines a new function (such | 216 | When a program creates a list or the user defines a new function |
| 221 | as by loading a library), that data is placed in normal storage. If | 217 | (such as by loading a library), that data is placed in normal storage. |
| 222 | normal storage runs low, then Emacs asks the operating system to | 218 | If normal storage runs low, then Emacs asks the operating system to |
| 223 | allocate more memory in blocks of 1k bytes. Each block is used for one | 219 | allocate more memory. Different types of Lisp objects, such as |
| 224 | type of Lisp object, so symbols, cons cells, markers, etc., are | 220 | symbols, cons cells, markers, etc., are segregated in distinct blocks |
| 225 | segregated in distinct blocks in memory. (Vectors, long strings, | 221 | in memory. (Vectors, long strings, buffers and certain other editing |
| 226 | buffers and certain other editing types, which are fairly large, are | 222 | types, which are fairly large, are allocated in individual blocks, one |
| 227 | allocated in individual blocks, one per object, while small strings are | 223 | per object, while small strings are packed into blocks of 8k bytes.) |
| 228 | packed into blocks of 8k bytes.) | ||
| 229 | |||
| 230 | It is quite common to use some storage for a while, then release it by | ||
| 231 | (for example) killing a buffer or deleting the last pointer to an | ||
| 232 | object. Emacs provides a @dfn{garbage collector} to reclaim this | ||
| 233 | abandoned storage. (This name is traditional, but ``garbage recycler'' | ||
| 234 | might be a more intuitive metaphor for this facility.) | ||
| 235 | 224 | ||
| 236 | The garbage collector operates by finding and marking all Lisp objects | 225 | @cindex garbage collection |
| 237 | that are still accessible to Lisp programs. To begin with, it assumes | 226 | It is quite common to use some storage for a while, then release it |
| 238 | all the symbols, their values and associated function definitions, and | 227 | by (for example) killing a buffer or deleting the last pointer to an |
| 239 | any data presently on the stack, are accessible. Any objects that can | 228 | object. Emacs provides a @dfn{garbage collector} to reclaim this |
| 240 | be reached indirectly through other accessible objects are also | 229 | abandoned storage. The garbage collector operates by finding and |
| 241 | accessible. | 230 | marking all Lisp objects that are still accessible to Lisp programs. |
| 231 | To begin with, it assumes all the symbols, their values and associated | ||
| 232 | function definitions, and any data presently on the stack, are | ||
| 233 | accessible. Any objects that can be reached indirectly through other | ||
| 234 | accessible objects are also accessible. | ||
| 242 | 235 | ||
| 243 | When marking is finished, all objects still unmarked are garbage. No | 236 | When marking is finished, all objects still unmarked are garbage. No |
| 244 | matter what the Lisp program or the user does, it is impossible to refer | 237 | matter what the Lisp program or the user does, it is impossible to refer |
| @@ -336,11 +329,9 @@ The total size of all strings, in characters. | |||
| 336 | The total number of elements of existing vectors. | 329 | The total number of elements of existing vectors. |
| 337 | 330 | ||
| 338 | @item used-floats | 331 | @item used-floats |
| 339 | @c Emacs 19 feature | ||
| 340 | The number of floats in use. | 332 | The number of floats in use. |
| 341 | 333 | ||
| 342 | @item free-floats | 334 | @item free-floats |
| 343 | @c Emacs 19 feature | ||
| 344 | The number of floats for which space has been obtained from the | 335 | The number of floats for which space has been obtained from the |
| 345 | operating system, but that are not currently being used. | 336 | operating system, but that are not currently being used. |
| 346 | 337 | ||
| @@ -417,7 +408,6 @@ memory used by Lisp data, broken down by data type. By contrast, the | |||
| 417 | function @code{memory-limit} provides information on the total amount of | 408 | function @code{memory-limit} provides information on the total amount of |
| 418 | memory Emacs is currently using. | 409 | memory Emacs is currently using. |
| 419 | 410 | ||
| 420 | @c Emacs 19 feature | ||
| 421 | @defun memory-limit | 411 | @defun memory-limit |
| 422 | This function returns the address of the last byte Emacs has allocated, | 412 | This function returns the address of the last byte Emacs has allocated, |
| 423 | divided by 1024. We divide the value by 1024 to make sure it fits in a | 413 | divided by 1024. We divide the value by 1024 to make sure it fits in a |
| @@ -428,7 +418,7 @@ memory usage. | |||
| 428 | @end defun | 418 | @end defun |
| 429 | 419 | ||
| 430 | @defvar memory-full | 420 | @defvar memory-full |
| 431 | This variable is @code{t} if Emacs is close to out of memory for Lisp | 421 | This variable is @code{t} if Emacs is nearly out of memory for Lisp |
| 432 | objects, and @code{nil} otherwise. | 422 | objects, and @code{nil} otherwise. |
| 433 | @end defvar | 423 | @end defvar |
| 434 | 424 | ||
| @@ -519,8 +509,9 @@ appearance.) | |||
| 519 | @smallexample | 509 | @smallexample |
| 520 | @group | 510 | @group |
| 521 | DEFUN ("or", For, Sor, 0, UNEVALLED, 0, | 511 | DEFUN ("or", For, Sor, 0, UNEVALLED, 0, |
| 522 | doc: /* Eval args until one of them yields non-nil, then return that | 512 | doc: /* Eval args until one of them yields non-nil, then return |
| 523 | value. The remaining args are not evalled at all. | 513 | that value. |
| 514 | The remaining args are not evalled at all. | ||
| 524 | If all args return nil, return nil. | 515 | If all args return nil, return nil. |
| 525 | @end group | 516 | @end group |
| 526 | @group | 517 | @group |
| @@ -566,14 +557,11 @@ This is the name of the Lisp symbol to define as the function name; in | |||
| 566 | the example above, it is @code{or}. | 557 | the example above, it is @code{or}. |
| 567 | 558 | ||
| 568 | @item fname | 559 | @item fname |
| 569 | This is the C function name for this function. This is | 560 | This is the C function name for this function. This is the name that |
| 570 | the name that is used in C code for calling the function. The name is, | 561 | is used in C code for calling the function. The name is, by |
| 571 | by convention, @samp{F} prepended to the Lisp name, with all dashes | 562 | convention, @samp{F} prepended to the Lisp name, with all dashes |
| 572 | (@samp{-}) in the Lisp name changed to underscores. Thus, to call this | 563 | (@samp{-}) in the Lisp name changed to underscores. Thus, to call |
| 573 | function from C code, call @code{For}. Remember that the arguments must | 564 | this function from C code, call @code{For}. |
| 574 | be of type @code{Lisp_Object}; various macros and functions for creating | ||
| 575 | values of type @code{Lisp_Object} are declared in the file | ||
| 576 | @file{lisp.h}. | ||
| 577 | 565 | ||
| 578 | @item sname | 566 | @item sname |
| 579 | This is a C variable name to use for a structure that holds the data for | 567 | This is a C variable name to use for a structure that holds the data for |
| @@ -627,38 +615,35 @@ too. | |||
| 627 | @end table | 615 | @end table |
| 628 | 616 | ||
| 629 | After the call to the @code{DEFUN} macro, you must write the | 617 | After the call to the @code{DEFUN} macro, you must write the |
| 630 | argument list that every C function must have, including the types for | 618 | argument list for the C function, including the types for the |
| 631 | the arguments. For a function with a fixed maximum number of | 619 | arguments. If the primitive accepts a fixed maximum number of Lisp |
| 632 | arguments, declare a C argument for each Lisp argument, and give them | 620 | arguments, there must be one C argument for each Lisp argument, and |
| 633 | all type @code{Lisp_Object}. When a Lisp function has no upper limit | 621 | each argument must be of type @code{Lisp_Object}. (Various macros and |
| 634 | on the number of arguments, its implementation in C actually receives | 622 | functions for creating values of type @code{Lisp_Object} are declared |
| 635 | exactly two arguments: the first is the number of Lisp arguments, and | 623 | in the file @file{lisp.h}.) If the primitive has no upper limit on |
| 636 | the second is the address of a block containing their values. They | 624 | the number of Lisp arguments, it must have exactly two C arguments: |
| 637 | have types @code{int} and @w{@code{Lisp_Object *}}. | 625 | the first is the number of Lisp arguments, and the second is the |
| 626 | address of a block containing their values. These have types | ||
| 627 | @code{int} and @w{@code{Lisp_Object *}} respectively. | ||
| 638 | 628 | ||
| 639 | @cindex @code{GCPRO} and @code{UNGCPRO} | 629 | @cindex @code{GCPRO} and @code{UNGCPRO} |
| 640 | @cindex protect C variables from garbage collection | 630 | @cindex protect C variables from garbage collection |
| 641 | Within the function @code{For} itself, note the use of the macros | 631 | Within the function @code{For} itself, note the use of the macros |
| 642 | @code{GCPRO1} and @code{UNGCPRO}. @code{GCPRO1} is used to | 632 | @code{GCPRO1} and @code{UNGCPRO}. These macros are defined for the |
| 643 | ``protect'' a variable from garbage collection---to inform the garbage | 633 | sake of the few platforms which do not use Emacs' default |
| 644 | collector that it must look in that variable and regard its contents | 634 | stack-marking garbage collector. The @code{GCPRO1} macro ``protects'' |
| 645 | as an accessible object. GC protection is necessary whenever you call | 635 | a variable from garbage collection, explicitly informing the garbage |
| 646 | @code{eval_sub} (or @code{Feval}) either directly or indirectly. | 636 | collector that that variable and all its contents must be as |
| 647 | At such a time, any Lisp object that this function may refer to again | 637 | accessible. GC protection is necessary in any function which can |
| 648 | must be protected somehow. | 638 | perform Lisp evaluation by calling @code{eval_sub} or @code{Feval} as |
| 639 | a subroutine, either directly or indirectly. | ||
| 649 | 640 | ||
| 650 | It suffices to ensure that at least one pointer to each object is | 641 | It suffices to ensure that at least one pointer to each object is |
| 651 | GC-protected; that way, the object cannot be recycled, so all pointers | 642 | GC-protected. Thus, a particular local variable can do without |
| 652 | to it remain valid. Thus, a particular local variable can do without | ||
| 653 | protection if it is certain that the object it points to will be | 643 | protection if it is certain that the object it points to will be |
| 654 | preserved by some other pointer (such as another local variable that | 644 | preserved by some other pointer (such as another local variable that |
| 655 | has a @code{GCPRO}). | 645 | has a @code{GCPRO}). Otherwise, the local variable needs a |
| 656 | @ignore | 646 | @code{GCPRO}. |
| 657 | @footnote{Formerly, strings were a special exception; in older Emacs | ||
| 658 | versions, every local variable that might point to a string needed a | ||
| 659 | @code{GCPRO}.}. | ||
| 660 | @end ignore | ||
| 661 | Otherwise, the local variable needs a @code{GCPRO}. | ||
| 662 | 647 | ||
| 663 | The macro @code{GCPRO1} protects just one local variable. If you | 648 | The macro @code{GCPRO1} protects just one local variable. If you |
| 664 | want to protect two variables, use @code{GCPRO2} instead; repeating | 649 | want to protect two variables, use @code{GCPRO2} instead; repeating |
| @@ -667,34 +652,17 @@ want to protect two variables, use @code{GCPRO2} instead; repeating | |||
| 667 | implicitly use local variables such as @code{gcpro1}; you must declare | 652 | implicitly use local variables such as @code{gcpro1}; you must declare |
| 668 | these explicitly, with type @code{struct gcpro}. Thus, if you use | 653 | these explicitly, with type @code{struct gcpro}. Thus, if you use |
| 669 | @code{GCPRO2}, you must declare @code{gcpro1} and @code{gcpro2}. | 654 | @code{GCPRO2}, you must declare @code{gcpro1} and @code{gcpro2}. |
| 670 | Alas, we can't explain all the tricky details here. | ||
| 671 | 655 | ||
| 672 | @code{UNGCPRO} cancels the protection of the variables that are | 656 | @code{UNGCPRO} cancels the protection of the variables that are |
| 673 | protected in the current function. It is necessary to do this | 657 | protected in the current function. It is necessary to do this |
| 674 | explicitly. | 658 | explicitly. |
| 675 | 659 | ||
| 676 | Built-in functions that take a variable number of arguments actually | ||
| 677 | accept two arguments at the C level: the number of Lisp arguments, and | ||
| 678 | a @code{Lisp_Object *} pointer to a C vector containing those Lisp | ||
| 679 | arguments. This C vector may be part of a Lisp vector, but it need | ||
| 680 | not be. The responsibility for using @code{GCPRO} to protect the Lisp | ||
| 681 | arguments from GC if necessary rests with the caller in this case, | ||
| 682 | since the caller allocated or found the storage for them. | ||
| 683 | |||
| 684 | You must not use C initializers for static or global variables unless | 660 | You must not use C initializers for static or global variables unless |
| 685 | the variables are never written once Emacs is dumped. These variables | 661 | the variables are never written once Emacs is dumped. These variables |
| 686 | with initializers are allocated in an area of memory that becomes | 662 | with initializers are allocated in an area of memory that becomes |
| 687 | read-only (on certain operating systems) as a result of dumping Emacs. | 663 | read-only (on certain operating systems) as a result of dumping Emacs. |
| 688 | @xref{Pure Storage}. | 664 | @xref{Pure Storage}. |
| 689 | 665 | ||
| 690 | @c FIXME is this still true? I don't think so... | ||
| 691 | Do not use static variables within functions---place all static | ||
| 692 | variables at top level in the file. This is necessary because Emacs on | ||
| 693 | some operating systems defines the keyword @code{static} as a null | ||
| 694 | macro. (This definition is used because those systems put all variables | ||
| 695 | declared static in a place that becomes read-only after dumping, whether | ||
| 696 | they have initializers or not.) | ||
| 697 | |||
| 698 | @cindex @code{defsubr}, Lisp symbol for a primitive | 666 | @cindex @code{defsubr}, Lisp symbol for a primitive |
| 699 | Defining the C function is not enough to make a Lisp primitive | 667 | Defining the C function is not enough to make a Lisp primitive |
| 700 | available; you must also create the Lisp symbol for the primitive and | 668 | available; you must also create the Lisp symbol for the primitive and |
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index ee1aa88a2dd..1021787a0f4 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi | |||
| @@ -1760,9 +1760,9 @@ certain length of time. Aside from how to set them up, idle timers | |||
| 1760 | work just like ordinary timers. | 1760 | work just like ordinary timers. |
| 1761 | 1761 | ||
| 1762 | @deffn Command run-with-idle-timer secs repeat function &rest args | 1762 | @deffn Command run-with-idle-timer secs repeat function &rest args |
| 1763 | Set up a timer which runs when Emacs has been idle for @var{secs} | 1763 | Set up a timer which runs the next time Emacs is idle for @var{secs} |
| 1764 | seconds. The value of @var{secs} may be an integer or a floating point | 1764 | seconds. The value of @var{secs} may be an integer or a floating |
| 1765 | number; a value of the type returned by @code{current-idle-time} | 1765 | point number; a value of the type returned by @code{current-idle-time} |
| 1766 | is also allowed. | 1766 | is also allowed. |
| 1767 | 1767 | ||
| 1768 | If @var{repeat} is @code{nil}, the timer runs just once, the first time | 1768 | If @var{repeat} is @code{nil}, the timer runs just once, the first time |
| @@ -1775,13 +1775,13 @@ can use in calling @code{cancel-timer} (@pxref{Timers}). | |||
| 1775 | @end deffn | 1775 | @end deffn |
| 1776 | 1776 | ||
| 1777 | @cindex idleness | 1777 | @cindex idleness |
| 1778 | Emacs becomes ``idle'' when it starts waiting for user input, and it | 1778 | Emacs becomes @dfn{idle} when it starts waiting for user input, and |
| 1779 | remains idle until the user provides some input. If a timer is set for | 1779 | it remains idle until the user provides some input. If a timer is set |
| 1780 | five seconds of idleness, it runs approximately five seconds after Emacs | 1780 | for five seconds of idleness, it runs approximately five seconds after |
| 1781 | first becomes idle. Even if @var{repeat} is non-@code{nil}, this timer | 1781 | Emacs first becomes idle. Even if @var{repeat} is non-@code{nil}, |
| 1782 | will not run again as long as Emacs remains idle, because the duration | 1782 | this timer will not run again as long as Emacs remains idle, because |
| 1783 | of idleness will continue to increase and will not go down to five | 1783 | the duration of idleness will continue to increase and will not go |
| 1784 | seconds again. | 1784 | down to five seconds again. |
| 1785 | 1785 | ||
| 1786 | Emacs can do various things while idle: garbage collect, autosave or | 1786 | Emacs can do various things while idle: garbage collect, autosave or |
| 1787 | handle data from a subprocess. But these interludes during idleness do | 1787 | handle data from a subprocess. But these interludes during idleness do |
| @@ -1795,22 +1795,12 @@ minutes, and even if there have been garbage collections and autosaves. | |||
| 1795 | input. Then it becomes idle again, and all the idle timers that are | 1795 | input. Then it becomes idle again, and all the idle timers that are |
| 1796 | set up to repeat will subsequently run another time, one by one. | 1796 | set up to repeat will subsequently run another time, one by one. |
| 1797 | 1797 | ||
| 1798 | @c Emacs 19 feature | ||
| 1799 | @defun current-idle-time | 1798 | @defun current-idle-time |
| 1800 | If Emacs is idle, this function returns the length of time Emacs has | 1799 | If Emacs is idle, this function returns the length of time Emacs has |
| 1801 | been idle, as a list of three integers: @code{(@var{high} @var{low} | 1800 | been idle, as a list of three integers: @code{(@var{sec-high} |
| 1802 | @var{microsec})}. The integers @var{high} and @var{low} combine to | 1801 | @var{sec-low} @var{microsec})}, where @var{high} and @var{low} are the |
| 1803 | give the number of seconds of idleness, which is | 1802 | high and low bits for the number of seconds and @var{microsec} is the |
| 1804 | @ifnottex | 1803 | additional number of microseconds (@pxref{Time of Day}). |
| 1805 | @var{high} * 2**16 + @var{low}. | ||
| 1806 | @end ifnottex | ||
| 1807 | @tex | ||
| 1808 | $high*2^{16}+low$. | ||
| 1809 | @end tex | ||
| 1810 | |||
| 1811 | The third element, @var{microsec}, gives the microseconds since the | ||
| 1812 | start of the current second (or 0 for systems that return time with | ||
| 1813 | the resolution of only one second). | ||
| 1814 | 1804 | ||
| 1815 | When Emacs is not idle, @code{current-idle-time} returns @code{nil}. | 1805 | When Emacs is not idle, @code{current-idle-time} returns @code{nil}. |
| 1816 | This is a convenient way to test whether Emacs is idle. | 1806 | This is a convenient way to test whether Emacs is idle. |
| @@ -1843,9 +1833,9 @@ Here's an example: | |||
| 1843 | @end smallexample | 1833 | @end smallexample |
| 1844 | @end defun | 1834 | @end defun |
| 1845 | 1835 | ||
| 1846 | Some idle timer functions in user Lisp packages have a loop that | 1836 | Do not write an idle timer function containing a loop which does a |
| 1847 | does a certain amount of processing each time around, and exits when | 1837 | certain amount of processing each time around, and exits when |
| 1848 | @code{(input-pending-p)} is non-@code{nil}. That approach seems very | 1838 | @code{(input-pending-p)} is non-@code{nil}. This approach seems very |
| 1849 | natural but has two problems: | 1839 | natural but has two problems: |
| 1850 | 1840 | ||
| 1851 | @itemize | 1841 | @itemize |
| @@ -1858,9 +1848,9 @@ It blocks out any idle timers that ought to run during that time. | |||
| 1858 | @end itemize | 1848 | @end itemize |
| 1859 | 1849 | ||
| 1860 | @noindent | 1850 | @noindent |
| 1861 | To avoid these problems, don't use that technique. Instead, write | 1851 | The correct approach is for the idle timer to reschedule itself after |
| 1862 | such idle timers to reschedule themselves after a brief pause, using | 1852 | a brief pause, using the method in the @code{timer-function} example |
| 1863 | the method in the @code{timer-function} example above. | 1853 | above. |
| 1864 | 1854 | ||
| 1865 | @node Terminal Input | 1855 | @node Terminal Input |
| 1866 | @section Terminal Input | 1856 | @section Terminal Input |