Klimi's new dotfiles with stow.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

68 wiersze
3.0 KiB

4 lat temu
  1. (eval-and-compile
  2. (require 'slime))
  3. (define-slime-contrib slime-fancy-trace
  4. "Enhanced version of slime-trace capable of tracing local functions,
  5. methods, setf functions, and other entities supported by specific
  6. swank:swank-toggle-trace backends. Invoke via C-u C-t."
  7. (:authors "Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de>"
  8. "Tobias C. Rittweiler <tcr@freebits.de>")
  9. (:license "GPL")
  10. (:slime-dependencies slime-parse))
  11. (defun slime-trace-query (spec)
  12. "Ask the user which function to trace; SPEC is the default.
  13. The result is a string."
  14. (cond ((null spec)
  15. (slime-read-from-minibuffer "(Un)trace: "))
  16. ((stringp spec)
  17. (slime-read-from-minibuffer "(Un)trace: " spec))
  18. ((symbolp spec) ; `slime-extract-context' can return symbols.
  19. (slime-read-from-minibuffer "(Un)trace: " (prin1-to-string spec)))
  20. (t
  21. (slime-dcase spec
  22. ((setf n)
  23. (slime-read-from-minibuffer "(Un)trace: " (prin1-to-string spec)))
  24. ((:defun n)
  25. (slime-read-from-minibuffer "(Un)trace: " (prin1-to-string n)))
  26. ((:defgeneric n)
  27. (let* ((name (prin1-to-string n))
  28. (answer (slime-read-from-minibuffer "(Un)trace: " name)))
  29. (cond ((and (string= name answer)
  30. (y-or-n-p (concat "(Un)trace also all "
  31. "methods implementing "
  32. name "? ")))
  33. (prin1-to-string `(:defgeneric ,n)))
  34. (t
  35. answer))))
  36. ((:defmethod &rest _)
  37. (slime-read-from-minibuffer "(Un)trace: " (prin1-to-string spec)))
  38. ((:call caller callee)
  39. (let* ((callerstr (prin1-to-string caller))
  40. (calleestr (prin1-to-string callee))
  41. (answer (slime-read-from-minibuffer "(Un)trace: "
  42. calleestr)))
  43. (cond ((and (string= calleestr answer)
  44. (y-or-n-p (concat "(Un)trace only when " calleestr
  45. " is called by " callerstr "? ")))
  46. (prin1-to-string `(:call ,caller ,callee)))
  47. (t
  48. answer))))
  49. (((:labels :flet) &rest _)
  50. (slime-read-from-minibuffer "(Un)trace local function: "
  51. (prin1-to-string spec)))
  52. (t (error "Don't know how to trace the spec %S" spec))))))
  53. (defun slime-toggle-fancy-trace (&optional using-context-p)
  54. "Toggle trace."
  55. (interactive "P")
  56. (let* ((spec (if using-context-p
  57. (slime-extract-context)
  58. (slime-symbol-at-point)))
  59. (spec (slime-trace-query spec)))
  60. (message "%s" (slime-eval `(swank:swank-toggle-trace ,spec)))))
  61. ;; override slime-toggle-trace-fdefinition
  62. (define-key slime-prefix-map "\C-t" 'slime-toggle-fancy-trace)
  63. (provide 'slime-fancy-trace)