branch: externals/realgud commit d026e8b210eb8fc1f20b742612d3979953480917 Author: rocky <ro...@gnu.org> Commit: rocky <ro...@gnu.org>
Start macro for delayed- and expand to cover pdb --- realgud/common/run.el | 17 ++++++++++++++++- realgud/debugger/pdb/pdb.el | 27 ++++++++++++++++++++++++++- realgud/debugger/trepan2/trepan2.el | 8 ++++---- realgud/debugger/trepan3k/trepan3k.el | 7 ++++--- 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/realgud/common/run.el b/realgud/common/run.el index f78bd35..b34a3f0 100644 --- a/realgud/common/run.el +++ b/realgud/common/run.el @@ -1,4 +1,4 @@ -;; Copyright (C) 2015-2016 Free Software Foundation, Inc +;; Copyright (C) 2015-2017 Free Software Foundation, Inc ;; Author: Rocky Bernstein <ro...@gnu.org> @@ -198,6 +198,21 @@ Otherwise nil is returned. ) ) +;; For name = trepan2 we produce: +;; +;; (defalias 'trepan2 'realgud:trepan2) +;; (defvar realgud:trepan2-delayed-minibuffer-history nil +;; "minibuffer history list for the command `realgud:trepan2-delayed'.") + +(defmacro realgud-deferred-invoke-setup (name) + `(progn + (defalias + ',(intern (concat name "-delayed")) + ',(intern (concat "realgud:" name "-delayed"))) + (defvar ,(intern (concat "realgud:" name "-delayed-minibuffer-history")) nil + ,(format "minibuffer history for the command `%s-delayed'" name)) + )) + (provide-me "realgud:") ;; Local Variables: diff --git a/realgud/debugger/pdb/pdb.el b/realgud/debugger/pdb/pdb.el index 8ddd380..386f412 100644 --- a/realgud/debugger/pdb/pdb.el +++ b/realgud/debugger/pdb/pdb.el @@ -1,4 +1,4 @@ -;; Copyright (C) 2015-2016 Free Software Foundation, Inc +;; Copyright (C) 2015-2017 Free Software Foundation, Inc ;; Author: Rocky Bernstein <ro...@gnu.org> @@ -105,4 +105,29 @@ fringe and marginal icons. (defalias 'pdb 'realgud:pdb) +;;;###autoload +(defun realgud:pdb-delayed () + "This is like `pdb', but assumes inside the program to be debugged, you +have a call to the debugger somewhere, e.g. 'from trepan.api import debug; debug()'. +Therefore we invoke python rather than the debugger initially. + +" + (interactive) + (let* ((initial-debugger python-shell-interpreter) + (actual-debugger "pdb") + (cmd-str (trepan2-query-cmdline initial-debugger)) + (cmd-args (split-string-and-unquote cmd-str)) + ;; XXX: python gets registered as the interpreter rather than + ;; a debugger, and the debugger position (nth 1) is missing: + ;; the script-args takes its place. + (parsed-args (trepan2-parse-cmd-args cmd-args)) + (script-args (nth 1 parsed-args)) + (script-name (car script-args)) + (parsed-cmd-args + (cl-remove-if 'nil (realgud:flatten parsed-args)))) + (realgud:run-process actual-debugger script-name parsed-cmd-args + 'realgud:trepan2-minibuffer-history))) + +(realgud-deferred-invoke-setup "pdb") + (provide-me "realgud-") diff --git a/realgud/debugger/trepan2/trepan2.el b/realgud/debugger/trepan2/trepan2.el index 73415cd..a444be5 100644 --- a/realgud/debugger/trepan2/trepan2.el +++ b/realgud/debugger/trepan2/trepan2.el @@ -9,6 +9,7 @@ ;; Main interface to trepan2 via Emacs +(require 'python) ; for python-shell-interpreter (require 'load-relative) (require-relative-list '("../../common/helper") "realgud-") (require-relative-list '("../../common/run") "realgud:") @@ -69,16 +70,15 @@ fringe and marginal icons. opt-cmd-line no-reset) ) -(defalias 'trepan2 'realgud:trepan2) - ;;;###autoload (defun realgud:trepan2-delayed () "This is like `trepan2', but assumes inside the program to be debugged, you have a call to the debugger somewhere, e.g. 'from trepan.api import debug; debug()'. Therefore we invoke python rather than the debugger initially. + " (interactive) - (let* ((initial-debugger "python") + (let* ((initial-debugger python-shell-interpreter) (actual-debugger "trepan2") (cmd-str (trepan2-query-cmdline initial-debugger)) (cmd-args (split-string-and-unquote cmd-str)) @@ -93,6 +93,6 @@ Therefore we invoke python rather than the debugger initially. (realgud:run-process actual-debugger script-name parsed-cmd-args 'realgud:trepan2-minibuffer-history))) -(defalias 'trepan2-delayed 'realgud:trepan2-delayed) +(realgud-deferred-invoke-setup "trepan2") (provide-me "realgud-") diff --git a/realgud/debugger/trepan3k/trepan3k.el b/realgud/debugger/trepan3k/trepan3k.el index 6d861f3..88bee00 100644 --- a/realgud/debugger/trepan3k/trepan3k.el +++ b/realgud/debugger/trepan3k/trepan3k.el @@ -7,6 +7,7 @@ ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. +(require 'python) ; for python-shell-interpreter (require 'load-relative) (require-relative-list '("../../common/helper") "realgud-") (require-relative-list '("../../common/run") "realgud:") @@ -76,7 +77,7 @@ have a call to the debugger somewhere, e.g. 'from trepan.api import debug; debug Therefore we invoke python rather than the debugger initially. " (interactive) - (let* ((initial-debugger "python") + (let* ((initial-debugger python-shell-interpreter) (actual-debugger "trepan3k") (cmd-str (trepan2-query-cmdline initial-debugger)) (cmd-args (split-string-and-unquote cmd-str)) @@ -89,8 +90,8 @@ Therefore we invoke python rather than the debugger initially. (parsed-cmd-args (cl-remove-if 'nil (realgud:flatten parsed-args)))) (realgud:run-process actual-debugger script-name parsed-cmd-args - 'realgud:trepan3k-minibuffer-history))) + 'realgud:trepan3k-deferred-minibuffer-history))) -(defalias 'trepan3k-delayed 'realgud:trepan3k-delayed) +(realgud-deferred-invoke-setup "trepan3k") (provide-me "realgud-")