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.

145 lines
5.6 KiB

  1. ;; Copyright (C) 2010-2019 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. ;; This program is distributed in the hope that it will be useful,
  8. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. ;; GNU General Public License for more details.
  11. ;; You should have received a copy of the GNU General Public License
  12. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ;; trepan3k: Python 3.2 and beyond
  14. (eval-when-compile (require 'cl-lib)) ;For setf.
  15. (require 'load-relative)
  16. (require-relative-list '("../../common/regexp"
  17. "../../common/loc"
  18. "../../common/init")
  19. "realgud-")
  20. (require-relative-list '("../../lang/python") "realgud-lang-")
  21. (defvar realgud-pat-hash)
  22. (declare-function make-realgud-loc-pat 'realgud-regexp)
  23. (defvar realgud:trepan3k-pat-hash (make-hash-table :test 'equal)
  24. "Hash key is the what kind of pattern we want to match:
  25. backtrace, prompt, etc. The values of a hash entry is a
  26. realgud-loc-pat struct")
  27. (declare-function make-realgud-loc 'realgud-loc)
  28. ;; realgud-loc-pat that describes a trepan3k location generally shown
  29. ;; before a command prompt.
  30. ;;
  31. ;; For example:
  32. ;; (/usr/bin/zonetab2pot.py:15 @3): <module>
  33. ;; (/usr/bin/zonetab2pot.py:15 remapped <string>): <module>
  34. ;; or MS Windows:
  35. ;; (c:\\mydirectory\\gcd.py:10): <module>
  36. (setf (gethash "loc" realgud:trepan3k-pat-hash)
  37. realgud:python-trepan-loc-pat)
  38. ;; An initial list of regexps that don't generally have files
  39. ;; associated with them and therefore we should not try to find file
  40. ;; associations for them. This list is used to seed a field of the
  41. ;; same name in the cmd-info structure inside a command buffer. A user
  42. ;; may add additional files to the command-buffer's re-ignore-list.
  43. (setf (gethash "ignore-re-file-list" realgud:trepan3k-pat-hash)
  44. (list realgud-python-ignore-file-re))
  45. ;; realgud-loc-pat that describes a trepan3k prompt.
  46. ;; Note: the prompt in nested debugging
  47. ;; For example:
  48. ;; (trepan3)
  49. ;; ((trepan3k))
  50. (setf (gethash "prompt" realgud:trepan3k-pat-hash)
  51. (make-realgud-loc-pat
  52. :regexp "^(+trepan3k+) "
  53. ))
  54. ;; realgud-loc-pat that describes a trepan3k backtrace line.
  55. ;; For example:
  56. ;; ->0 get_distribution(dist='trepan==0.3.9')
  57. ;; called from file '/python2.7/dist-packages/pkg_res.py' at line 341
  58. ;; ##1 load_entry_point(dist='tr=0.3.9', group='console_scripts', name='tr')
  59. ;; called from file '/python2.7/dist-packages/pkg_res.py' at line 351
  60. ;; ##2 <module> exec()
  61. (setf (gethash "debugger-backtrace" realgud:trepan3k-pat-hash)
  62. realgud:python-trepan-backtrace-pat)
  63. ;; realgud-loc-pat that describes a line a Python "info break" line.
  64. ;; For example:
  65. ;; 1 breakpoint keep y at /usr/local/bin/trepan3k:7
  66. (setf (gethash "debugger-breakpoint" realgud:trepan3k-pat-hash)
  67. realgud-python-breakpoint-pat)
  68. ;; realgud-loc-pat that describes a Python backtrace line.
  69. (setf (gethash "lang-backtrace" realgud:trepan3k-pat-hash)
  70. realgud-python-backtrace-loc-pat)
  71. ;; realgud-loc-pat that describes location in a pytest error
  72. (setf (gethash "pytest-error" realgud:trepan3k-pat-hash)
  73. realgud-pytest-error-loc-pat)
  74. ;; realgud-loc-pat that describes location in a flake8 message
  75. (setf (gethash "flake8-msg" realgud:trepan3k-pat-hash)
  76. realgud-flake8-msg-loc-pat)
  77. ;; realgud-loc-pat that describes a "breakpoint set" line
  78. (setf (gethash "brkpt-set" realgud:trepan3k-pat-hash)
  79. realgud:python-trepan-brkpt-set-pat)
  80. ;; realgud-loc-pat that describes a "delete breakpoint" line
  81. (setf (gethash "brkpt-del" realgud:trepan3k-pat-hash)
  82. realgud:python-trepan-brkpt-del-pat)
  83. ;; realgud-loc-pat that describes a debugger "disable" (breakpoint) response.
  84. ;; For example:
  85. ;; Breakpoint 4 disabled.
  86. (setf (gethash "brkpt-disable" realgud:trepan3k-pat-hash)
  87. realgud:python-trepan-brkpt-disable-pat)
  88. ;; realgud-loc-pat that describes a debugger "enable" (breakpoint) response.
  89. ;; For example:
  90. ;; Breakpoint 4 enabled.
  91. (setf (gethash "brkpt-enable" realgud:trepan3k-pat-hash)
  92. realgud:python-trepan-brkpt-enable-pat)
  93. ;; realgud-loc-pat for a termination message.
  94. (setf (gethash "termination" realgud:trepan3k-pat-hash)
  95. "^trepan3k: That's all, folks...\n")
  96. (setf (gethash "font-lock-keywords" realgud:trepan3k-pat-hash)
  97. realgud:python-debugger-font-lock-keywords)
  98. (setf (gethash "font-lock-breakpoint-keywords" realgud:trepan3k-pat-hash)
  99. realgud:python-debugger-font-lock-breakpoint-keywords)
  100. (setf (gethash "trepan3k" realgud-pat-hash) realgud:trepan3k-pat-hash)
  101. (defvar realgud:trepan3k-command-hash (make-hash-table :test 'equal)
  102. "Hash key is command name like 'shell' and the value is
  103. the trepan3k command to use, like 'python'")
  104. (setf (gethash "eval" realgud:trepan3k-command-hash) "eval %s")
  105. (setf (gethash "info-breakpoints" realgud:trepan3k-command-hash) "info break")
  106. (setf (gethash "pprint" realgud:trepan3k-command-hash) "pp %s")
  107. (setf (gethash "shell" realgud:trepan3k-command-hash) "python")
  108. (setf (gethash "until" realgud:trepan3k-command-hash) "continue %l")
  109. ;; If your version of trepan3k doesn't support "quit!",
  110. ;; get a more recent version of trepan3k
  111. (setf (gethash "quit" realgud:trepan3k-command-hash) "quit!")
  112. (setf (gethash "trepan3k" realgud-command-hash) realgud:trepan3k-command-hash)
  113. (provide-me "realgud:trepan3k-")