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.

132 lines
4.5 KiB

  1. ;; Copyright (C) 2010, 2014, 2016, 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. ;; Common Ruby constants and regular expressions.
  8. (require 'load-relative)
  9. (require-relative-list '("../common/regexp" "../common/loc" "../common/track")
  10. "realgud-")
  11. (declare-function realgud-goto-line-for-pt 'realgud-track)
  12. (declare-function make-realgud-loc-pat 'realgud-regexp)
  13. (defconst realgud-rails-backtrace-loc-pat
  14. (make-realgud-loc-pat
  15. :regexp "^\\([^:]+\\):\\([0-9]+\\)\\(?:[:]in `.*'\\)?"
  16. :file-group 1
  17. :line-group 2)
  18. "A realgud-loc-pat struct that describes a Rails backtrace (or
  19. traceback) line." )
  20. (defconst realgud-rspec-backtrace-loc-pat
  21. (make-realgud-loc-pat
  22. :regexp "^[ ]*# \\([^:]+\\):\\([0-9]+\\)\\(?:[:]in `.*'\\)?"
  23. :file-group 1
  24. :line-group 2)
  25. "A realgud-loc-pat struct that describes an rspec backtrace (or
  26. traceback) line." )
  27. ;; Regular expression that describes a Ruby YARV 1.9 syntax error line.
  28. ;; SyntaxError: /tmp/columnize.rb:270: syntax error, unexpected $end, ...
  29. (defconst realgud-ruby-YARV-syntax-error-pat
  30. (make-realgud-loc-pat
  31. :regexp "^SyntaxError: \\([^:]+\\):\\([0-9]+\\): syntax error"
  32. :file-group 1
  33. :line-group 2)
  34. "A realgud-loc-pat struct that describes a Ruby YARV syntax error message")
  35. (defconst realgud-ruby-backtrace-loc-pat
  36. (make-realgud-loc-pat
  37. :regexp "^[ \t]+from \\([^:]+\\):\\([0-9]+\\)\\(?: in `.*'\\)?"
  38. :file-group 1
  39. :line-group 2)
  40. "A realgud-loc-pat struct that describes a Ruby backtrace (or
  41. traceback) line." )
  42. (defconst realgud-rubinius-backtrace-loc-pat
  43. (make-realgud-loc-pat
  44. :regexp "^\\(?:\\[0;3[1-4]m\\)?[ \t]+.* at \\([^:]+\\):\\([0-9]+\\)"
  45. :file-group 1
  46. :line-group 2)
  47. "A realgud-loc-pat struct that describes a Rubinius backtrace (or
  48. traceback) line." )
  49. (defconst realgud-rubinius-Xagent-backtrace-loc-pat
  50. (make-realgud-loc-pat
  51. :regexp "^\\(?:\\[0;3[1-4]m\\)?0x[a-f0-9]\\{8\\}: .* in \\([^:]+\\):\\([0-9]+\\) ([+][0-9]+)"
  52. :file-group 1
  53. :line-group 2)
  54. "A realgud-loc-pat struct that describes a Rubinius Xagent backtrace (or
  55. traceback) line." )
  56. (defconst realgud-ruby-dollar-bang-loc-pat
  57. (make-realgud-loc-pat
  58. :regexp "^[ \t]*[[]?\\(.+\\):\\([0-9]+\\):in `.*'"
  59. :file-group 1
  60. :line-group 2)
  61. "A realgud-loc-pat that struct that describes a Ruby $! string."
  62. )
  63. ;; FIXME: there is probably a less redundant way to do the following
  64. ;; FNS.
  65. (defun realgud:rails-goto-backtrace-line (pt)
  66. "Display the location mentioned by the Rails backtrace line
  67. described by PT."
  68. (interactive "d")
  69. (realgud-goto-line-for-pt pt "rails-backtrace"))
  70. ;; FIXME: there is probably a less redundant way to do the following
  71. ;; FNS.
  72. (defun realgud:rspec-goto-backtrace-line (pt)
  73. "Display the location mentioned by the Rails backtrace line
  74. described by PT."
  75. (interactive "d")
  76. (realgud-goto-line-for-pt pt "rspec-backtrace"))
  77. (defun realgud:rubinius-goto-Xagent-backtrace-line (pt)
  78. "Display the location mentioned by the Rubinius Xagent- backtrace line
  79. described by PT."
  80. (interactive "d")
  81. (realgud-goto-line-for-pt pt "rubinius-backtrace-Xagent"))
  82. (defun realgud:ruby-goto-backtrace-line (pt)
  83. "Display the location mentioned by the Ruby backtrace line
  84. described by PT."
  85. (interactive "d")
  86. (realgud-goto-line-for-pt pt "lang-backtrace"))
  87. (defun realgud:ruby-goto-dollar-bang-line (pt)
  88. "Display the location mentioned by the Ruby backtrace line
  89. described by PT."
  90. (interactive "d")
  91. (realgud-goto-line-for-pt pt "dollar-bang-backtrace"))
  92. (defun realgud:ruby-populate-command-keys (&optional map)
  93. "Bind the debugger function key layout used by many debuggers.
  94. \\{realgud-example-map-standard}"
  95. (define-key map (kbd "C-c !l") 'realgud:goto-lang-backtrace-line)
  96. (define-key map (kbd "C-c !!") 'realgud:ruby-goto-dollar-bang-line)
  97. (define-key map (kbd "C-c !b") 'realgud:goto-debugger-backtrace-line)
  98. (define-key map (kbd "C-c !r") 'realgud:rails-goto-backtrace-line)
  99. (define-key map (kbd "C-c !s") 'realgud:rspec-goto-backtrace-line)
  100. )
  101. ;; Some things common to all trepan debuggers (Rubinius and Ruby 1.9.2)
  102. (defconst realgud:trepan-frame-start-regexp
  103. "\\(?:^\\|\n\\)\\(-->\\| \\)")
  104. (defconst realgud:trepan-frame-num-regexp
  105. "#\\([0-9]+\\)")
  106. (defconst realgud:trepan-frame-line-regexp
  107. "[ \t\n]+at line \\([0-9]+\\)\\(?:\n\\|$\\)")
  108. (provide-me "realgud-lang-")