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.

113 lines
4.1 KiB

  1. ;; Copyright (C) 2015-2016 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. ;; Used to parse programming-language backtrace-like tracks
  14. ;; output. In contrast to track-mode, there doesn't have to be a
  15. ;; process shell arround Compare with backtrace-mode.el which
  16. ;; handles backtraces inside the debugger
  17. (require 'shell)
  18. (require 'load-relative)
  19. (require-relative-list
  20. '("core" "helper" "track" "loc" "lochist" "file"
  21. "fringe" "window" "regexp" "menu"
  22. "send" "shortkey") "realgud-")
  23. (declare-function realgud:debugger-name-transform 'realgud-helper)
  24. (declare-function realgud-populate-debugger-menu 'realgud-menu)
  25. (declare-function realgud:track-set-debugger 'realgud-track)
  26. (defvar realgud-backtrack-mode-map
  27. (let ((map (make-sparse-keymap)))
  28. (define-key map [frames-menu]
  29. (list 'menu-item "Specific Frames" 'realgud:frames-menu))
  30. (define-key map [M-right] 'realgud-track-hist-newest)
  31. (define-key map [M-down] 'realgud-track-hist-newer)
  32. (define-key map [M-up] 'realgud-track-hist-older)
  33. (define-key map [M-print] 'realgud-track-hist-older)
  34. (define-key map [M-S-down] 'realgud-track-hist-newest)
  35. (define-key map [M-S-up] 'realgud-track-hist-oldest)
  36. (realgud-populate-debugger-menu map)
  37. map)
  38. "Keymap used in `realgud-backtrack-minor-mode'.")
  39. ;; FIXME figure out if I can put this in something like a header file.
  40. ;; FIXME: combine with realgud:track-set-debugger's completing read
  41. (defun realgud-backtrack-set-debugger (debugger-name)
  42. "Set debugger name This info is returned or nil if we can't find a
  43. debugger with that information"
  44. (interactive
  45. (list (completing-read "Debugger name: " realgud-pat-hash)))
  46. (let ((regexp-hash (gethash debugger-name realgud-pat-hash)))
  47. (if regexp-hash
  48. (let* ((base-variable-name
  49. (or (gethash debugger-name realgud:variable-basename-hash)
  50. debugger-name))
  51. (specific-track-mode (intern (concat base-variable-name "-backtrack-mode")))
  52. )
  53. (if (and (not (eval specific-track-mode))
  54. (functionp specific-track-mode))
  55. (funcall specific-track-mode 't))
  56. )
  57. (progn
  58. (message "I Don't have %s listed as a debugger." debugger-name)
  59. nil)
  60. )))
  61. (define-minor-mode realgud-backtrack-mode
  62. "Minor mode for backtracking parsing."
  63. :init-value nil
  64. :global nil
  65. :group 'realgud
  66. :lighter
  67. (:eval (progn
  68. (concat " "
  69. (if (realgud-cmdbuf-info-set?)
  70. (realgud-sget 'cmdbuf-info 'debugger-name)
  71. "dbgr??"))))
  72. :keymap realgud-backtrack-mode-map
  73. ;; Setup/teardown
  74. )
  75. (defmacro realgud-backtrack-mode-vars (name)
  76. `(progn
  77. (defvar ,(intern (concat name "-backtrack-mode")) nil
  78. ,(format "Non-nil if using %s-backtrack-mode as a minor mode of some other mode.
  79. Use the command `%s-track-mode' to toggle or set this variable." name name))
  80. (defvar ,(intern (concat name "-backtrack-mode-map")) (make-sparse-keymap)
  81. ,(format "Keymap used in `%s-backtrack-mode'." name))
  82. ))
  83. ;; FIXME: The below could be a macro? I have a hard time getting
  84. ;; macros right.
  85. (defun realgud-backtrack-mode-body(name)
  86. "Used in by custom debuggers: pydbgr, trepan, gdb, etc. NAME is
  87. the name of the debugger which is used to preface variables."
  88. (realgud:track-set-debugger name)
  89. (funcall (intern (concat "realgud-define-" name "-commands")))
  90. (if (intern (concat name "-backtrack-mode"))
  91. (progn
  92. (realgud-backtrack-mode 't)
  93. (run-mode-hooks (intern (concat name "-backtrack-mode-hook"))))
  94. (progn
  95. (realgud-backtrack-mode nil)
  96. )))
  97. (provide-me "realgud-")