Hi,
While I believe this patch very trivial, does really nobody take care of
this? Or, may I commit it by myself?
Since the current behavior is incompatible either GNU Emacs 20.7 and
21.4, I'll have to copy&paste the fixed with-timeout to my elisp
programs.
>>>> In
<e106a472-e2be-4238-841e-0d3b10d3689c(a)well-done.deisui.org>
>>>> Daiki Ueno <ueno(a)unixuser.org> wrote:
The docstring of with-timeout says that
If we give up, we run the TIMEOUT-FORMS and return the value of the
last one.
The call should look like:
(with-timeout (SECONDS TIMEOUT-FORMS...) BODY...)
However, it just throws away the result of TIMEOUT-FORMS
(with-timeout (0.1 t) (sleep-for 10) nil)
=> nil
Here is a patch to fix this.
2006-07-25 Daiki Ueno <ueno(a)unixuser.org>
* timer-funcs.el (with-timeout): Return the result of
TIMEOUT-FORMS if the timeout expires.
xemacs-packages source patch:
Diff command: cvs -q diff -u
Files affected: xemacs-packages/xemacs-base/timer-funcs.el
Index: xemacs-packages/xemacs-base/timer-funcs.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/xemacs-base/timer-funcs.el,v
retrieving revision 1.2
diff -u -r1.2 timer-funcs.el
--- xemacs-packages/xemacs-base/timer-funcs.el 11 Oct 2005 11:21:41 -0000 1.2
+++ xemacs-packages/xemacs-base/timer-funcs.el 25 Jul 2006 08:45:26 -0000
@@ -182,14 +182,14 @@
`(let ((with-timeout-tag (cons nil nil))
with-timeout-value with-timeout-timer)
(unwind-protect
- (when (catch with-timeout-tag
+ (if (catch with-timeout-tag
(progn
(setq with-timeout-timer
(start-itimer "with-timeout" #'with-timeout-handler
,seconds nil nil t with-timeout-tag))
(setq with-timeout-value (progn ,@body))
nil))
- ,@timeout-forms
+ ,@timeout-forms
with-timeout-value)
(delete-itimer with-timeout-timer)))))
--
Daiki Ueno
--
Daiki Ueno