Chisheng Huang cph@chi-square-works.com writes:
I've been thinking that it might be better to bind the "extended" trace command with a prefix arg so that the previous "non-extended" behaviour becomes the default for C-c C-t. This allows all CLs that implement the simpler form of trace to work without problems and only when invoked with C-u C-c C-t will the trace command do something different.
Regards,
António Leitão.
I like this idea a lot. With the extended trace command, it is not convenient to trace all methods of a generic function if I do not have a (DEFGENERIC ...) defined. To do that, I have to either type (TRACE ...) into a REPL or do C-c C-t on all (defmethod ...). Or maybe I'm missing something?
Note that if you trace just a function name (assuming it is generic) you are not tracing all the methods. At most, you are tracing the generic function. In an optimized Lisp, this might not be what you want.
Tracing the defgeneric and all its methods is different (or attempts to be different) from tracing just the function name.
To do what you want, (which I'm assuming it's a normal trace in the normal function case and a normal trace plus all-methods trace in the generic function case), slime would have to ask the Lisp process about the type of function it is tracing and, upon encountering generic functions, it could ask the user if he wants to trace all the methods. It is doable and, IMHO, it is the correct thing to do, but it is not what the trace command is doing right now. Maybe we should change it.
Please make the new extended trace command coexist with the original one.
I'll do that. Here's a new version that also removes one small error. C-c C-t invokes the simpler trace, C-u C-c C-t invokes the contextual trace.
Please (someone with cvs access), replace:
(defun slime-toggle-trace-fdefinition () "Toggle trace." (interactive) (let ((spec (complete-name-context-at-point))) (cond ((symbolp spec) ;;trivial case (slime-toggle-trace-function spec)) (t (ecase (first spec) ((setf) (slime-toggle-trace-function spec)) ((:defun :defmacro) (slime-toggle-trace-function (second spec))) (:defgeneric (slime-toggle-trace-defgeneric (second spec))) (:defmethod (slime-toggle-trace-defmethod spec)) (:call (slime-toggle-trace-maybe-wherein (third spec) (second spec))) ((:labels :flet) (slime-toggle-trace-within spec)))))))
with:
(defun slime-toggle-trace-fdefinition (&optional using-context-p) "Toggle trace." (interactive "P") (let ((spec (if using-context-p (complete-name-context-at-point) (symbol-at-point)))) (cond ((null spec) (error "No symbol to trace")) ((symbolp spec) (slime-toggle-trace-function spec)) (t (ecase (first spec) ((setf) (slime-toggle-trace-function spec)) ((:defun :defmacro) (slime-toggle-trace-function (second spec))) (:defgeneric (slime-toggle-trace-defgeneric (second spec))) (:defmethod (slime-toggle-trace-defmethod spec)) (:call (slime-toggle-trace-maybe-wherein (third spec) (second spec))) ((:labels :flet) (slime-toggle-trace-within spec)))))))
Best regards,
António Leitão.