comparison lisp/emacs-lisp/timer.el @ 90200:f9a65d7ebd29

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-68 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 459-473) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 86-87) - Update from CVS
author Miles Bader <miles@gnu.org>
date Thu, 07 Jul 2005 12:43:14 +0000
parents 3ebd9bdb4fe5 18a818a2ee7c
children fbb2bea03df9
comparison
equal deleted inserted replaced
90199:bb71c6cf2009 90200:f9a65d7ebd29
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details. 17 ;; GNU General Public License for more details.
18 18
19 ;; You should have received a copy of the GNU General Public License 19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the 20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02111-1307, USA. 22 ;; Boston, MA 02110-1301, USA.
23 23
24 ;;; Commentary: 24 ;;; Commentary:
25 25
26 ;; This package gives you the capability to run Emacs Lisp commands at 26 ;; This package gives you the capability to run Emacs Lisp commands at
27 ;; specified times in the future, either as one-shots or periodically. 27 ;; specified times in the future, either as one-shots or periodically.
406 406
407 ;;;###autoload 407 ;;;###autoload
408 (defmacro with-timeout (list &rest body) 408 (defmacro with-timeout (list &rest body)
409 "Run BODY, but if it doesn't finish in SECONDS seconds, give up. 409 "Run BODY, but if it doesn't finish in SECONDS seconds, give up.
410 If we give up, we run the TIMEOUT-FORMS and return the value of the last one. 410 If we give up, we run the TIMEOUT-FORMS and return the value of the last one.
411 The call should look like:
412 (with-timeout (SECONDS TIMEOUT-FORMS...) BODY...)
413 The timeout is checked whenever Emacs waits for some kind of external 411 The timeout is checked whenever Emacs waits for some kind of external
414 event \(such as keyboard input, input from subprocesses, or a certain time); 412 event (such as keyboard input, input from subprocesses, or a certain time);
415 if the program loops without waiting in any way, the timeout will not 413 if the program loops without waiting in any way, the timeout will not
416 be detected." 414 be detected.
415 \n(fn (SECONDS TIMEOUT-FORMS...) BODY)"
417 (let ((seconds (car list)) 416 (let ((seconds (car list))
418 (timeout-forms (cdr list))) 417 (timeout-forms (cdr list)))
419 `(let ((with-timeout-tag (cons nil nil)) 418 `(let ((with-timeout-tag (cons nil nil))
420 with-timeout-value with-timeout-timer) 419 with-timeout-value with-timeout-timer)
421 (if (catch with-timeout-tag 420 (if (catch with-timeout-tag