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.

150 lines
5.4 KiB

  1. ;; Copyright (C) 2010-2011, 2016, 2018 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. ;; Ruby 1.8 debugger: ruby-debug (rdebug)
  8. (eval-when-compile (require 'cl-lib)) ;For stef.
  9. (require 'load-relative)
  10. (require-relative-list '("../../common/regexp" "../../common/loc") "realgud-")
  11. (require-relative-list '("../../lang/ruby") "realgud-lang-")
  12. (defvar realgud-pat-hash)
  13. (declare-function make-realgud-loc-pat 'realgud-regexp)
  14. (defvar realgud-rdebug-pat-hash (make-hash-table :test 'equal)
  15. "Hash key is the what kind of pattern we want to match:
  16. backtrace, prompt, etc. The values of a hash entry is a
  17. realgud-loc-pat struct")
  18. ;; Regular expression that describes a rdebug location generally shown
  19. ;; before a command prompt.
  20. ;; For example:
  21. ;; /usr/lib/ruby/1.8/rubygems/custom_require.rb:31 # in Emacs
  22. ;; /usr/bin/irb:12
  23. (setf (gethash "loc" realgud-rdebug-pat-hash)
  24. (make-realgud-loc-pat
  25. :regexp "\\(?:source \\)?\\(\\(?:[a-zA-Z]:\\)?\\(?:.+\\)\\):\\([0-9]+\\).*\\(?:\n\\|$\\)"
  26. :file-group 1
  27. :line-group 2
  28. ))
  29. ;; An initial list of regexps that don't generally have files
  30. ;; associated with them and therefore we should not try to find file
  31. ;; associations for them. This list is used to seed a field of the
  32. ;; same name in the cmd-info structure inside a command buffer. A user
  33. ;; may add additional files to the command-buffer's re-ignore-list.
  34. (setf (gethash "ignore-re-file-list" realgud-rdebug-pat-hash)
  35. '("(eval)"))
  36. ;; Regular expression that describes a rdebug command prompt
  37. ;; For example:
  38. ;; (rdb:1)
  39. (setf (gethash "prompt" realgud-rdebug-pat-hash)
  40. (make-realgud-loc-pat
  41. :regexp "^(rdb:[0-9]+) "
  42. ))
  43. ;; Regular expression that describes a Ruby backtrace line.
  44. (setf (gethash "lang-backtrace" realgud-rdebug-pat-hash)
  45. realgud-ruby-backtrace-loc-pat)
  46. ;; Regular expression that describes a ruby $! backtrace
  47. (setf (gethash "dollar-bang-backtrace" realgud-rdebug-pat-hash)
  48. realgud-ruby-dollar-bang-loc-pat)
  49. ;; Regular expression that describes a rdebug "breakpoint set" line
  50. ;; For example:
  51. ;; Breakpoint 1 file /test/gcd.rb, line 6
  52. ;; -----------^------^^^^^^^^^^^^-------^
  53. (setf (gethash "brkpt-set" realgud-rdebug-pat-hash)
  54. (make-realgud-loc-pat
  55. :regexp "^Breakpoint \\([0-9]+\\) file \\(.+\\), line \\([0-9]+\\)\n"
  56. :num 1
  57. :file-group 2
  58. :line-group 3))
  59. (defconst realgud-rdebug-frame-file-line-regexp
  60. "[ \t\n]+at line \\(.*\\):\\([0-9]+\\)$")
  61. (defconst realgud-rdebug-frame-start-regexp realgud:trepan-frame-start-regexp)
  62. (defconst realgud-rdebug-frame-num-regexp realgud:trepan-frame-num-regexp)
  63. ;; Regular expression that describes a Ruby $! string
  64. (setf (gethash "dollar-bang" realgud-rdebug-pat-hash)
  65. realgud-ruby-dollar-bang-loc-pat)
  66. ;; Regular expression that describes a Ruby $! string
  67. (setf (gethash "rails-backtrace" realgud-rdebug-pat-hash)
  68. realgud-rails-backtrace-loc-pat)
  69. ;; Regular expression that describes a debugger "backtrace" command line.
  70. ;; e.g.
  71. ;; --> #0 at line /usr/bin/irb:12
  72. ;; #1 main.__script__ at /tmp/fact.rb:1
  73. ;; #1 main.__script__ at /tmp/fact.rb:1
  74. ;; #0 IRB.start(ap_path#String) at line /usr/lib/ruby/1.8/irb.rb:52
  75. (setf (gethash "debugger-backtrace" realgud-rdebug-pat-hash)
  76. (make-realgud-loc-pat
  77. :regexp (concat realgud-rdebug-frame-start-regexp " "
  78. realgud-rdebug-frame-num-regexp
  79. "\\(?: \\(?:\\(.+\\)(\\(.*\\))\\)\\)?"
  80. realgud-rdebug-frame-file-line-regexp
  81. )
  82. :num 2
  83. :file-group 5
  84. :line-group 6)
  85. )
  86. (setf (gethash "font-lock-keywords" realgud-rdebug-pat-hash)
  87. '(
  88. ;; Parameters and first type entry. E.g Object.gcd(a#Fixnum, b#Fixnum)
  89. ;; ^-^^^^^^ ^-^^^^^^
  90. ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)#\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\>"
  91. (1 font-lock-variable-name-face)
  92. (2 font-lock-constant-face))
  93. ;; "::Type", which occurs in class name of function and in
  94. ;; parameter list.
  95. ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
  96. (1 font-lock-type-face))
  97. ;; The frame number and first type name, if present.
  98. ;; E.g. --> #0 Object.gcd(a#Fixnum, b#Fixnum)
  99. ;; -----^-^^^^^^.^^^
  100. ("^\\(-->\\)? *#\\([0-9]+\\) *\\(\\([a-zA-Z_][a-zA-Z0-9_]*\\)[.:]\\)?"
  101. (2 realgud-backtrace-number-face)
  102. (4 font-lock-constant-face nil t)) ; t means optional.
  103. ;; File name and line number. E.g. at line /test/gcd.rb:6
  104. ;; -------^^^^^^^^^^^^^-^
  105. ("at line \\(.*\\):\\([0-9]+\\)$"
  106. (1 realgud-file-name-face)
  107. (2 realgud-line-number-face))
  108. ;; Function name.
  109. ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
  110. (1 font-lock-type-face)
  111. (2 font-lock-function-name-face))
  112. ;; (rdebug-frames-match-current-line
  113. ;; (0 rdebug-frames-current-frame-face append))
  114. ))
  115. (setf (gethash "rdebug" realgud-pat-hash) realgud-rdebug-pat-hash)
  116. (defvar realgud-rdebug-command-hash (make-hash-table :test 'equal)
  117. "Hash key is command name like 'quit' and the value is
  118. the trepanx command to use, like 'quit!'")
  119. (setf (gethash "quit" realgud-rdebug-command-hash) "quit!")
  120. (setf (gethash "shell" realgud-rdebug-command-hash) "irb")
  121. (setf (gethash "rdebug" realgud-command-hash) realgud-rdebug-command-hash)
  122. (provide-me "realgud-rdebug-")