GNU bug report logs -
#79979
timeout-throttle initial return value
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Wed, 10 Dec 2025 07:18:02 UTC
Severity: normal
Fixed in version 31.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 79979 in the body.
You can then email your comments to 79979 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
karthikchikmagalur <at> gmail.com, bug-gnu-emacs <at> gnu.org:
bug#79979; Package
emacs.
(Wed, 10 Dec 2025 07:18:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to
karthikchikmagalur <at> gmail.com, bug-gnu-emacs <at> gnu.org.
(Wed, 10 Dec 2025 07:18:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
This recipe demonstrates that unexpectedly 'timeout-throttle'
returns nil on the first call, contrary to its specification:
(require 'timeout)
(setq func (timeout-throttled-func (lambda () 1) 10))
(funcall func) => nil
(funcall func) => 1
This is because 'prog1' in 'timeout-throttled-func' causes it
to return nil on the first call. Here is the fix:
[timeout-throttle-result.patch (text/x-diff, inline)]
diff --git a/lisp/emacs-lisp/timeout.el b/lisp/emacs-lisp/timeout.el
index 2b90650f02a..cf8a81a4f44 100644
--- a/lisp/emacs-lisp/timeout.el
+++ b/lisp/emacs-lisp/timeout.el
@@ -82,7 +82,7 @@ timeout--throttle-advice
(result))
(lambda (orig-fn &rest args)
"Throttle calls to this function."
- (prog1 result
+ (progn
(unless (and throttle-timer (timerp throttle-timer))
(setq result (apply orig-fn args))
(setq throttle-timer
@@ -90,7 +90,8 @@ timeout--throttle-advice
(timeout--eval-value timeout-value) nil
(lambda ()
(cancel-timer throttle-timer)
- (setq throttle-timer nil)))))))))
+ (setq throttle-timer nil)))))
+ result))))
(defun timeout--debounce-advice (&optional delay default)
"Return a function that debounces its argument function.
@@ -182,7 +183,7 @@ timeout-throttled-func
"\n\nThrottle calls to this function"))
(interactive (advice-eval-interactive-spec
(cadr (interactive-form func))))
- (prog1 result
+ (progn
(unless (and throttle-timer (timerp throttle-timer))
(setq result (apply func args))
(setq throttle-timer
@@ -190,14 +191,15 @@ timeout-throttled-func
(timeout--eval-value throttle-value) nil
(lambda ()
(cancel-timer throttle-timer)
- (setq throttle-timer nil)))))))
+ (setq throttle-timer nil)))))
+ result))
;; NON-INTERACTIVE version
(lambda (&rest args)
(:documentation
(concat
(documentation func)
"\n\nThrottle calls to this function"))
- (prog1 result
+ (progn
(unless (and throttle-timer (timerp throttle-timer))
(setq result (apply func args))
(setq throttle-timer
@@ -205,7 +207,8 @@ timeout-throttled-func
(timeout--eval-value throttle-value) nil
(lambda ()
(cancel-timer throttle-timer)
- (setq throttle-timer nil))))))))))
+ (setq throttle-timer nil)))))
+ result)))))
(defun timeout-debounced-func (func &optional delay default)
"Return a debounced version of function FUNC.
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79979; Package
emacs.
(Wed, 10 Dec 2025 08:03:03 GMT)
Full text and
rfc822 format available.
Message #8 received at 79979 <at> debbugs.gnu.org (full text, mbox):
> This is because 'prog1' in 'timeout-throttled-func' causes it
> to return nil on the first call. Here is the fix:
Thank you Juri. I have tested and applied the fix upstream, at
https://github.com/karthink/timeout.
Karthik
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79979; Package
emacs.
(Wed, 10 Dec 2025 17:41:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 79979 <at> debbugs.gnu.org (full text, mbox):
close 79979 31.0.50
thanks
>> This is because 'prog1' in 'timeout-throttled-func' causes it
>> to return nil on the first call. Here is the fix:
>
> Thank you Juri. I have tested and applied the fix upstream, at
> https://github.com/karthink/timeout.
Thanks for confirming. So now pushed to the Emacs repo as well.
BTW, I also added ###autoload to 4 entry points of the package.
bug marked as fixed in version 31.0.50, send any further explanations to
79979 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net>
Request was from
Juri Linkov <juri <at> linkov.net>
to
control <at> debbugs.gnu.org.
(Wed, 10 Dec 2025 17:41:03 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79979; Package
emacs.
(Wed, 10 Dec 2025 20:24:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 79979 <at> debbugs.gnu.org (full text, mbox):
> BTW, I also added ###autoload to 4 entry points of the package.
Not autoloading these functions was intentional. One of the Elisp
linters included with Emacs, perhaps package-lint, complains that only
interactive commands should be autoloaded. So I assumed that this was
the official practice.
Karthik
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79979; Package
emacs.
(Thu, 11 Dec 2025 07:07:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 79979 <at> debbugs.gnu.org (full text, mbox):
>> BTW, I also added ###autoload to 4 entry points of the package.
>
> Not autoloading these functions was intentional. One of the Elisp
> linters included with Emacs, perhaps package-lint, complains that only
> interactive commands should be autoloaded. So I assumed that this was
> the official practice.
'package-lint--check-autoloads-on-private-functions' warns only
about autoloaded internal functions with "--" in their names.
While even package-lint.el has many non-interactive functions autoloaded.
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79979; Package
emacs.
(Thu, 11 Dec 2025 07:12:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 79979 <at> debbugs.gnu.org (full text, mbox):
>> Not autoloading these functions was intentional. One of the Elisp
>> linters included with Emacs, perhaps package-lint, complains that only
>> interactive commands should be autoloaded. So I assumed that this was
>> the official practice.
>
> 'package-lint--check-autoloads-on-private-functions' warns only
> about autoloaded internal functions with "--" in their names.
> While even package-lint.el has many non-interactive functions autoloaded.
Ah, that makes sense, thanks. I knew that Emacs autoloads a bunch of
noninteractive functions, like in the seq library.
Karthik
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79979; Package
emacs.
(Thu, 11 Dec 2025 07:50:01 GMT)
Full text and
rfc822 format available.
Message #25 received at 79979 <at> debbugs.gnu.org (full text, mbox):
> Cc: 79979 <at> debbugs.gnu.org
> From: Karthik Chikmagalur <karthikchikmagalur <at> gmail.com>
> Date: Wed, 10 Dec 2025 12:23:13 -0800
>
> > BTW, I also added ###autoload to 4 entry points of the package.
>
> Not autoloading these functions was intentional. One of the Elisp
> linters included with Emacs, perhaps package-lint, complains that only
> interactive commands should be autoloaded. So I assumed that this was
> the official practice.
No, there's no official practice in place which says that only
interactive commands should be autoloaded. If you look at our
sources, you will find that our practice is very far from that, and
for good reasons.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org.
(Thu, 08 Jan 2026 12:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified today.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.