diff options
author | Mattias Engdegård <mattiase@acm.org> | 2020-11-18 10:55:41 +0100 |
---|---|---|
committer | Mattias Engdegård <mattiase@acm.org> | 2020-11-18 13:51:55 +0100 |
commit | d5ac6679df4925ef51cc0f299af2a84f27faafe7 (patch) | |
tree | 6ce8bf916dd74bd87c95eaf012e88e816e9e7d54 /lisp/progmodes/gdb-mi.el | |
parent | 88d5b1d3253728bd314de36544996aa15345bd29 (diff) | |
download | emacs-d5ac6679df4925ef51cc0f299af2a84f27faafe7.tar.gz emacs-d5ac6679df4925ef51cc0f299af2a84f27faafe7.tar.bz2 emacs-d5ac6679df4925ef51cc0f299af2a84f27faafe7.zip |
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.
Diffstat (limited to 'lisp/progmodes/gdb-mi.el')
-rw-r--r-- | lisp/progmodes/gdb-mi.el | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 0023e1fb5d0..903005610d7 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 |