branch: externals/timeout
commit 639e0f8f2686e6ae0b302723f3a16f3cb57bcca8
Author: Karthik Chikmagalur <karthikchikmaga...@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmaga...@gmail.com>

    timeout: Update default result when debouncing (#6)
    
    * timeout.el (timeout--debounce-advice, timeout-debounce): Update
    the DEFAULT return value of debounced function when the function
    runs.  This brings the behavior in line with that of
    timeout-throttle.
---
 timeout.el | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/timeout.el b/timeout.el
index 2e51c2bc75..4715a5d436 100644
--- a/timeout.el
+++ b/timeout.el
@@ -93,10 +93,11 @@ This is intended for use as function advice."
                  (lambda (buf)
                    (cancel-timer debounce-timer)
                    (setq debounce-timer nil)
-                   (if (buffer-live-p buf)
-                       (with-current-buffer buf
-                         (apply orig-fn args))
-                     (apply orig-fn args)))
+                   (setq default
+                         (if (buffer-live-p buf)
+                             (with-current-buffer buf
+                               (apply orig-fn args))
+                           (apply orig-fn args))))
                  (current-buffer))))))))
 
 ;;;###autoload
@@ -199,10 +200,11 @@ value of the function when called."
                      (lambda (buf)
                        (cancel-timer debounce-timer)
                        (setq debounce-timer nil)
-                       (if (buffer-live-p buf)
-                           (with-current-buffer buf
-                             (apply func args))
-                         (apply func args)))
+                       (setq default
+                             (if (buffer-live-p buf)
+                                 (with-current-buffer buf
+                                   (apply func args))
+                               (apply func args))))
                      (current-buffer))))))
       ;; NON-INTERACTIVE version
       (lambda (&rest args)
@@ -219,10 +221,11 @@ value of the function when called."
                    (lambda (buf)
                      (cancel-timer debounce-timer)
                      (setq debounce-timer nil)
-                     (if (buffer-live-p buf)
-                         (with-current-buffer buf
-                           (apply func args))
-                       (apply func args)))
+                     (setq default
+                           (if (buffer-live-p buf)
+                               (with-current-buffer buf
+                                 (apply func args))
+                             (apply func args))))
                    (current-buffer)))))))))
 
 (provide 'timeout)

Reply via email to