diff options
| author | Richard M. Stallman | 2004-12-13 19:26:42 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2004-12-13 19:26:42 +0000 |
| commit | c2b53d7bd469c048527051fc04c1924bb0cb7c89 (patch) | |
| tree | 2b7811eae19711b39c99322cfaff4beb987664d9 | |
| parent | 42ed718e49546a46536ba8f7de3110a67677b722 (diff) | |
| download | emacs-c2b53d7bd469c048527051fc04c1924bb0cb7c89.tar.gz emacs-c2b53d7bd469c048527051fc04c1924bb0cb7c89.zip | |
(while-no-input): New macro.
| -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 |