GNU bug report logs - #79979
timeout-throttle initial return value

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Juri Linkov <juri@HIDDEN>; Done: Juri Linkov <juri@HIDDEN>; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
bug marked as fixed in version 31.0.50, send any further explanations to 79979 <at> debbugs.gnu.org and Juri Linkov <juri@HIDDEN> Request was from Juri Linkov <juri@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 79979 <at> debbugs.gnu.org:


Received: (at 79979) by debbugs.gnu.org; 10 Dec 2025 17:40:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Dec 10 12:40:09 2025
Received: from localhost ([127.0.0.1]:35661 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vTOAb-00018O-F1
	for submit <at> debbugs.gnu.org; Wed, 10 Dec 2025 12:40:09 -0500
Received: from mout-p-202.mailbox.org ([80.241.56.172]:60976)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <juri@HIDDEN>)
 id 1vTOAX-000145-DN; Wed, 10 Dec 2025 12:40:05 -0500
Received: from smtp102.mailbox.org (smtp102.mailbox.org
 [IPv6:2001:67c:2050:b231:465::102])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4dRNJs43P1z9sqV;
 Wed, 10 Dec 2025 18:39:57 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; 
 t=1765388397;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 in-reply-to:in-reply-to:references:references;
 bh=m85amXgBXJRqisvoU3CGa5Pq933MRrMi7DZ0hPBYRfc=;
 b=AlUzP4iuF3JZmuYATXgFVnI1Lj4HU+d+99dUdoONc5bYyHez1HlZeT5JpagccYu6SQSbaW
 wjvvn7UJf6THrKBfBUVLYKbOQHf6XOoaiZhFoRlRykf5srJEcoqbbWR2UCiygsS1vNQ8xe
 kN4q2KPGaVRfN3RgREXw+vRyCpgUWwTTIbs9LOa5EZNiLsmGXcoayLvjfOETBd4WbxGl75
 89RwoPRiUw9yKyCltk2VxNZ60JdRCOgq9jSDD3T1zViv8vXo8wWRH2xIzVBrarGgEyWN33
 szwIZa2F7wNVbQtnEB4e/zUdS4ju9fKde6PVym/cDUzAGNQvCUytabdHHUGA+A==
Authentication-Results: outgoing_mbo_mout; dkim=none;
 spf=pass (outgoing_mbo_mout: domain of juri@HIDDEN designates
 2001:67c:2050:b231:465::102 as permitted sender)
 smtp.mailfrom=juri@HIDDEN
From: Juri Linkov <juri@HIDDEN>
To: Karthik Chikmagalur <karthikchikmagalur@HIDDEN>
Subject: Re: bug#79979: timeout-throttle initial return value
In-Reply-To: <875xaeg3xs.fsf@HIDDEN>
Organization: LINKOV.NET
References: <87qzt2n867.fsf@HIDDEN> <875xaeg3xs.fsf@HIDDEN>
Date: Wed, 10 Dec 2025 19:38:19 +0200
Message-ID: <874ipyi6es.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Rspamd-Queue-Id: 4dRNJs43P1z9sqV
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 79979
Cc: 79979 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

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.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#79979; Package emacs. Full text available.

Message received at 79979 <at> debbugs.gnu.org:


Received: (at 79979) by debbugs.gnu.org; 10 Dec 2025 08:02:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Dec 10 03:02:35 2025
Received: from localhost ([127.0.0.1]:58673 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vTF9e-0000Hu-8m
	for submit <at> debbugs.gnu.org; Wed, 10 Dec 2025 03:02:34 -0500
Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:57793)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <karthikchikmagalur@HIDDEN>)
 id 1vTF9c-0000HP-8F
 for 79979 <at> debbugs.gnu.org; Wed, 10 Dec 2025 03:02:32 -0500
Received: by mail-pj1-x1031.google.com with SMTP id
 98e67ed59e1d1-340ba29d518so4306413a91.3
 for <79979 <at> debbugs.gnu.org>; Wed, 10 Dec 2025 00:02:32 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1765353746; x=1765958546; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:references:in-reply-to:subject:to:from
 :from:to:cc:subject:date:message-id:reply-to;
 bh=PhvE/uBeVuro7Z8mLxo/FhExLoLE5wKh47V1/oOEeoY=;
 b=PPUwIkITtKAnrS9IShgLzl8+0OHwSEiganEVq2FwBEQzAJ3O450gqgZljaSj9EWCDp
 emrDKAj/HNea8/mMTCQEVdqfDn8UGAG9uOl+Gd9E9TpdN9vz6tWIE7OkKDeUMVUvHPbn
 EYekAF19pJqEopXohSIrgHdCJgCWoWrQ+tRh1ul7UEzSPNMRpQra60kUz8TWyBeLyj2T
 wurhLF81GFAkSx8QE9aYdriEkrJv3i/ezCAo7HxKG7fxdga1WBsoHL7XmP6lY5s2ldS8
 9fjzUkdq9RfhmfrTiEiwbZ+qEz33TdwMOVyPTzFo5YX4OJJ9jCXL3q2EOh0Awfye65F5
 tZyw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1765353746; x=1765958546;
 h=mime-version:message-id:date:references:in-reply-to:subject:to:from
 :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=PhvE/uBeVuro7Z8mLxo/FhExLoLE5wKh47V1/oOEeoY=;
 b=QHJU7DEWRJaEmuo+O6/+KM/twzIAGveKbXziM7ISdo3y5SD5bFI24cQHeSsGvRfunT
 ErnbPoMuPF0lHUtJ2UNd8As+9QvGFnapvc0tJCtdB4ZnhKTKyi9Ext0SdH4eB42jEe9t
 kd2ZxIsHHrfkE017iFY8R6qqCoyk+y0nZYa7sR4dG2qWJyInjgunzcB8/yla3uueTDAH
 86WwJepw+H5h52a0mjfNtxK+DxtheW7oaEAtLq21bXSUn+a7/thtEPE+8Bn6W//EshyU
 1AOgRa0U/fQSg5zwBJ+T3zdtZhNE5RQMINeT8b2FRBk0KPB+KL/48ciGmwMXgIWpP70j
 B+YQ==
X-Forwarded-Encrypted: i=1;
 AJvYcCUkDaAJTJl1pOVXEuGjM/5eQOEvnzSlmeNjHdUgK6Ns0VDkViKgrYw2tIRsfO9nMXLsSSMXrw==@debbugs.gnu.org
X-Gm-Message-State: AOJu0YxlYecOXompV96B7BtqekSITa1qGPd2AlN0iXuaF6bHuGW88i/B
 9RCaENWeNNOLA7kPFb0LxukvZVVmhv5FcXzB18+ri7p4ai60JgeOicgD
X-Gm-Gg: ASbGncvicsAnmpGAW2ajMG2p745JDowoVDehU8+9ma+LJcSZqmII4x3K2xIaAsr/AJT
 J4g6rLGDL6nbSeenoHnjfwgN3bZGWO00iTKSSQDmzxiReBi9LLDgGTpzCqeput+4hF5cz392vBH
 RRnbAL8DYbC9o1u3gY53aJZd5OX+F24LDYQlEV3X0t7U6D/AAfzjZby88cdHkMqBrGWOyZHU0Ro
 25qiROUara4agGQOLH899/ZNh3Gnxlc9ZEVh3y+Q7LmLSehvVpzIESy+Tbd2VoYzoKp/ZpaBDVn
 Yr7JlvXBysQRmeEsOLnTXuTrlIWJh+KgY9nR5V40MIrINa4Es30iZnC2i2ylo4BSQuV7WlKMVQM
 hkXbvswjgglCRqi8yiSf24vrmg6xzMY2lXrGScr3hyuD1Htpiqf086lgvkxQ6k+jTnq2jtft1h2
 P4NrDHotapaWS1vxWL0LJdLg==
X-Google-Smtp-Source: AGHT+IGBJ5shbqOgtfMomuH3C/xBh9iquq8CXuFS5kjYqE5rfjgE8ODFt6tadq2B5Yz9UIvvwujslA==
X-Received: by 2002:a05:7022:ef09:b0:119:e56b:98a4 with SMTP id
 a92af1059eb24-11f2967c808mr1360543c88.11.1765353745969; 
 Wed, 10 Dec 2025 00:02:25 -0800 (PST)
Received: from localhost ([2601:646:8201:80b0:383e:877a:38ba:ff0e])
 by smtp.gmail.com with ESMTPSA id
 a92af1059eb24-11f283d4754sm5166265c88.12.2025.12.10.00.02.25
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 10 Dec 2025 00:02:25 -0800 (PST)
From: Karthik Chikmagalur <karthikchikmagalur@HIDDEN>
To: Juri Linkov <juri@HIDDEN>, 79979 <at> debbugs.gnu.org
Subject: Re: bug#79979: timeout-throttle initial return value
In-Reply-To: <87qzt2n867.fsf@HIDDEN>
References: <87qzt2n867.fsf@HIDDEN>
Date: Wed, 10 Dec 2025 00:02:23 -0800
Message-ID: <875xaeg3xs.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79979
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> 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@HIDDEN:
bug#79979; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 10 Dec 2025 07:17:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Dec 10 02:17:10 2025
Received: from localhost ([127.0.0.1]:58301 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vTERi-0005vo-Be
	for submit <at> debbugs.gnu.org; Wed, 10 Dec 2025 02:17:10 -0500
Received: from lists.gnu.org ([2001:470:142::17]:45260)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1vTERd-0005uw-3K
 for submit <at> debbugs.gnu.org; Wed, 10 Dec 2025 02:17:07 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <juri@HIDDEN>) id 1vTERN-0001to-KP
 for bug-gnu-emacs@HIDDEN; Wed, 10 Dec 2025 02:16:50 -0500
Received: from mout-p-202.mailbox.org ([2001:67c:2050:0:465::202])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256)
 (Exim 4.90_1) (envelope-from <juri@HIDDEN>) id 1vTERL-0008RP-LE
 for bug-gnu-emacs@HIDDEN; Wed, 10 Dec 2025 02:16:49 -0500
Received: from smtp2.mailbox.org (smtp2.mailbox.org
 [IPv6:2001:67c:2050:b231:465::2])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4dR6TX0NFQz9t5g
 for <bug-gnu-emacs@HIDDEN>; Wed, 10 Dec 2025 08:16:32 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; 
 t=1765350992;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type;
 bh=qJ9C9Zz053Qm4y5xTyES/tgUTCwKuuHve9SINHgUU8s=;
 b=xcaPyeIyVZWcJIcCYjI9tt4clJmphCbj/yKlVzZlYgzWw6a3lZbN5OFzXvbhchgbZ2UtW3
 BRRnInJ+bbu8UVk8jA06e7T6AhRqfgab15Ez1RZ8cull6o2MwZX5zCtMLrHFhVSBsaFqIv
 wM1ImiUFQHl2o1MW+8Ohheai7Ri5PYUeLE8ZEb6muOfITwRaFEQnLlyxK5aEbezqAhuUmZ
 mBgnekGowYeTNYlH2PSwHEqvBsbG9KtuIkbFh8Cf1RSOca41cKJ7t6y1S7glHV72AAEsEF
 qIOIXLQxRl2oHImPdCy5ptK47Qjfx4F3Q7Jzm3MWRJu0I+YjvMF6ViXHJClJiQ==
Authentication-Results: outgoing_mbo_mout; dkim=none;
 spf=pass (outgoing_mbo_mout: domain of juri@HIDDEN designates
 2001:67c:2050:b231:465::2 as permitted sender) smtp.mailfrom=juri@HIDDEN
From: Juri Linkov <juri@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: timeout-throttle initial return value
Organization: LINKOV.NET
X-Debbugs-Cc: Karthik Chikmagalur <karthikchikmagalur@HIDDEN>
Date: Wed, 10 Dec 2025 09:16:04 +0200
Message-ID: <87qzt2n867.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Rspamd-Queue-Id: 4dR6TX0NFQz9t5g
Received-SPF: pass client-ip=2001:67c:2050:0:465::202;
 envelope-from=juri@HIDDEN; helo=mout-p-202.mailbox.org
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

--=-=-=
Content-Type: text/plain

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:


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=timeout-throttle-result.patch

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.

--=-=-=--




Acknowledgement sent to Juri Linkov <juri@HIDDEN>:
New bug report received and forwarded. Copy sent to karthikchikmagalur@HIDDEN, bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to karthikchikmagalur@HIDDEN, bug-gnu-emacs@HIDDEN:
bug#79979; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 10 Dec 2025 17:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.