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.

103 lines
3.7 KiB

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