Personal emacs config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.7 KiB

  1. ;; Copyright (C) 2010-2014, 2016-2017 Free Software Foundation, Inc
  2. ;; Author: Rocky Bernstein <rocky@gnu.org>
  3. ;; This program is free software; you can redistribute it and/or modify
  4. ;; it under the terms of the GNU General Public License as published by
  5. ;; the Free Software Foundation, either version 3 of the License, or
  6. ;; (at your option) any later version.
  7. (require 'python) ; for python-shell-interpreter
  8. (require 'load-relative)
  9. (require-relative-list '("../../common/helper") "realgud-")
  10. (require-relative-list '("../../common/run") "realgud:")
  11. (require-relative-list '("core" "track-mode") "realgud:trepan3k-")
  12. ;; This is needed, or at least the docstring part of it is needed to
  13. ;; get the customization menu to work in Emacs 25.
  14. (defgroup realgud:trepan3k nil
  15. "The realgud interface to the Python debugger, trepan3k"
  16. :group 'realgud
  17. :group 'python
  18. :version "25.1")
  19. (declare-function trepan3k-query-cmdline 'realgud:trepan3k-core)
  20. (declare-function trepan3k-parse-cmd-args 'realgud:trepan3k-core)
  21. (declare-function realgud:run-debugger 'realgud:run)
  22. (declare-function realgud:run-process 'realgud:core)
  23. (declare-function realgud:flatten 'realgud-utils)
  24. ;; -------------------------------------------------------------------
  25. ;; User-definable variables
  26. ;;
  27. (defcustom realgud:trepan3k-command-name
  28. ;;"trepan3k --emacs 3"
  29. "trepan3k"
  30. "File name for executing the Python debugger and command options.
  31. This should be an executable on your path, or an absolute file name."
  32. :type 'string
  33. :group 'realgud:trepan3k)
  34. (declare-function trepan3k-track-mode (bool))
  35. ;; -------------------------------------------------------------------
  36. ;; The end.
  37. ;;
  38. ;;;###autoload
  39. (defun realgud:trepan3k (&optional opt-cmd-line no-reset)
  40. "Invoke the trepan3k Python debugger and start the Emacs user interface.
  41. String OPT-CMD-LINE is treated like a shell string; arguments are
  42. tokenized by `split-string-and-unquote'. The tokenized string is
  43. parsed by `trepan3k-parse-cmd-args' and path elements found by that
  44. are expanded using `realgud:expand-file-name-if-exists'.
  45. Normally, command buffers are reused when the same debugger is
  46. reinvoked inside a command buffer with a similar command. If we
  47. discover that the buffer has prior command-buffer information and
  48. NO-RESET is nil, then that information which may point into other
  49. buffers and source buffers which may contain marks and fringe or
  50. marginal icons is reset. See `loc-changes-clear-buffer' to clear
  51. fringe and marginal icons.
  52. "
  53. (interactive)
  54. (realgud:run-debugger "trepan3k"
  55. 'trepan3k-query-cmdline
  56. 'trepan3k-parse-cmd-args
  57. 'realgud:trepan3k-minibuffer-history
  58. opt-cmd-line no-reset)
  59. )
  60. ;;;###autoload
  61. (defalias 'trepan3k 'realgud:trepan3k)
  62. ;;;###autoload
  63. (defun realgud:trepan3k-delayed ()
  64. "This is like `trepan3k', but assumes inside the program to be debugged, you
  65. have a call to the debugger somewhere, e.g. 'from trepan.api import debug; debug()'.
  66. Therefore we invoke python rather than the debugger initially.
  67. "
  68. (interactive)
  69. (let* ((initial-debugger python-shell-interpreter)
  70. (actual-debugger "trepan3k")
  71. (cmd-str (trepan3k-query-cmdline initial-debugger))
  72. (cmd-args (split-string-and-unquote cmd-str))
  73. ;; XXX: python gets registered as the interpreter rather than
  74. ;; a debugger, and the debugger position (nth 1) is missing:
  75. ;; the script-args takes its place.
  76. (parsed-args (trepan3k-parse-cmd-args cmd-args))
  77. (script-args (nth 1 parsed-args))
  78. (script-name (car script-args))
  79. (parsed-cmd-args
  80. (cl-remove-if 'nil (realgud:flatten parsed-args))))
  81. (realgud:run-process actual-debugger script-name parsed-cmd-args
  82. 'realgud:trepan3k-deferred-minibuffer-history)))
  83. (realgud-deferred-invoke-setup "trepan3k")
  84. (provide-me "realgud-")