diff options
| -rw-r--r-- | lisp/subr.el | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 3bdef5988ce..84129908fc7 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -1862,6 +1862,19 @@ is allowed once again." | |||
| 1862 | ,@body) | 1862 | ,@body) |
| 1863 | (quit (setq quit-flag t) nil))) | 1863 | (quit (setq quit-flag t) nil))) |
| 1864 | 1864 | ||
| 1865 | (defmacro while-no-input (&rest body) | ||
| 1866 | "Execute BODY only as long as there's no pending input. | ||
| 1867 | If input arrives, that ends the execution of BODY, | ||
| 1868 | and `while-no-input' returns nil. If BODY finishes, | ||
| 1869 | `while-no-input' returns whatever value BODY produced." | ||
| 1870 | (declare (debug t) (indent 0)) | ||
| 1871 | (let ((catch-sym (make-symbol "input"))) | ||
| 1872 | `(with-local-quit | ||
| 1873 | (catch ',catch-sym | ||
| 1874 | (let ((throw-on-input ',catch-sym)) | ||
| 1875 | (when (sit-for 0 0 t) | ||
| 1876 | ,@body)))))) | ||
| 1877 | |||
| 1865 | (defmacro combine-after-change-calls (&rest body) | 1878 | (defmacro combine-after-change-calls (&rest body) |
| 1866 | "Execute BODY, but don't call the after-change functions till the end. | 1879 | "Execute BODY, but don't call the after-change functions till the end. |
| 1867 | If BODY makes changes in the buffer, they are recorded | 1880 | If BODY makes changes in the buffer, they are recorded |