emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master d5ac667: Turn gdb-wait-for-pending into a plain function


From: Mattias Engdegård
Subject: master d5ac667: Turn gdb-wait-for-pending into a plain function
Date: Wed, 18 Nov 2020 07:53:59 -0500 (EST)

branch: master
commit d5ac6679df4925ef51cc0f299af2a84f27faafe7
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Turn gdb-wait-for-pending into a plain function
    
    This avoids unnecessary body duplication in expansion and macro
    recursion (causing macro-expansions at runtime), making it clearer
    what is going on.
    
    * lisp/progmodes/gdb-mi.el (gdb-wait-for-pending): Make it a function,
    remove lambda quoting,  η-reduce and simplify.
    (gdb-thread-exited, gdb-thread-selected): Adapt callers.
---
 lisp/progmodes/gdb-mi.el | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 0023e1f..9030056 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -373,19 +373,17 @@ were not yet received."
   (dolist (handler gdb-handler-list)
     (setf (gdb-handler-pending-trigger handler) nil)))
 
-(defmacro gdb-wait-for-pending (&rest body)
-  "Wait for all pending GDB commands to finish and evaluate BODY.
+(defun gdb-wait-for-pending (func)
+  "Wait for all pending GDB commands to finish and call FUNC.
 
 This function checks every 0.5 seconds if there are any pending
 triggers in `gdb-handler-list'."
-  `(run-with-timer
-    0.5 nil
-    '(lambda ()
-       (if (not (cl-find-if (lambda (handler)
-                               (gdb-handler-pending-trigger handler))
-                             gdb-handler-list))
-          (progn ,@body)
-        (gdb-wait-for-pending ,@body)))))
+  (run-with-timer
+   0.5 nil
+   (lambda ()
+     (if (cl-some #'gdb-handler-pending-trigger gdb-handler-list)
+        (gdb-wait-for-pending func)
+       (funcall func)))))
 
 ;; Publish-subscribe
 
@@ -2524,7 +2522,7 @@ Unset `gdb-thread-number' if current thread exited and 
update threads list."
     ;; disallow us to properly call -thread-info without --thread option.
     ;; Thus we need to use gdb-wait-for-pending.
     (gdb-wait-for-pending
-     (gdb-emit-signal gdb-buf-publisher 'update-threads))))
+     (lambda () (gdb-emit-signal gdb-buf-publisher 'update-threads)))))
 
 (defun gdb-thread-selected (_token output-field)
   "Handler for =thread-selected MI output record.
@@ -2538,11 +2536,10 @@ Sets `gdb-thread-number' to new id."
     ;; as usually. Things happen too fast and second call (from
     ;; gdb-thread-selected handler) gets cut off by our beloved
     ;; pending triggers.
-    ;; Solution is `gdb-wait-for-pending' macro: it guarantees that its
-    ;; body will get executed when `gdb-handler-list' if free of
+    ;; Solution is `gdb-wait-for-pending': it guarantees that its
+    ;; argument will get called when `gdb-handler-list' if free of
     ;; pending triggers.
-    (gdb-wait-for-pending
-     (gdb-update))))
+    (gdb-wait-for-pending #'gdb-update)))
 
 (defun gdb-running (_token output-field)
   (let* ((thread-id



reply via email to

[Prev in Thread] Current Thread [Next in Thread]