Next: , Previous: Refresh Screen, Up: Display

38.2 Forcing Redisplay

Emacs normally tries to redisplay the screen whenever it waits for input. With the following function, you can request an immediate attempt to redisplay, in the middle of Lisp code, without actually waiting for input.

— Function: redisplay &optional force

This function tries immediately to redisplay. The optional argument force, if non-nil, forces the redisplay to be performed, instead of being preempted, even if input is pending and the variable redisplay-dont-pause is nil (see below). If redisplay-dont-pause is non-nil (the default), this function redisplays in any case, i.e., force does nothing.

The function returns t if it actually tried to redisplay, and nil otherwise. A value of t does not mean that redisplay proceeded to completion; it could have been preempted by newly arriving input.

— Variable: redisplay-dont-pause

If this variable is nil, arriving input events preempt redisplay; Emacs avoids starting a redisplay, and stops any redisplay that is in progress, until the input has been processed. In particular, (redisplay) returns nil without actually redisplaying, if there is pending input.

The default value is t, which means that pending input does not preempt redisplay.

— Variable: redisplay-preemption-period

If redisplay-dont-pause is nil, this variable specifies how many seconds Emacs waits between checks for new input during redisplay; if input arrives during this interval, redisplay stops and the input is processed. The default value is 0.1; if the value is nil, Emacs does not check for input during redisplay.

This variable has no effect when redisplay-dont-pause is non-nil (the default).

Although redisplay tries immediately to redisplay, it does not change how Emacs decides which parts of its frame(s) to redisplay. By contrast, the following function adds certain windows to the pending redisplay work (as if their contents had completely changed), but does not immediately try to perform redisplay.

— Function: force-window-update &optional object

This function forces some or all windows to be updated the next time Emacs does a redisplay. If object is a window, that window is to be updated. If object is a buffer or buffer name, all windows displaying that buffer are to be updated. If object is nil (or omitted), all windows are to be updated.

This function does not do a redisplay immediately; Emacs does that as it waits for input, or when the function redisplay is called.