/[slime]/slime/swank.lisp
ViewVC logotype

Diff of /slime/swank.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.442 by alendvai, Sun Dec 24 13:40:05 2006 UTC revision 1.443 by alendvai, Sun Dec 24 13:44:11 2006 UTC
# Line 40  Line 40 
40             #:*default-worker-thread-bindings*             #:*default-worker-thread-bindings*
41             #:*macroexpand-printer-bindings*             #:*macroexpand-printer-bindings*
42             #:*record-repl-results*             #:*record-repl-results*
43               #:*inspector-dwim-lookup-hooks*
44             ;; These are re-exported directly from the backend:             ;; These are re-exported directly from the backend:
45             #:buffer-first-change             #:buffer-first-change
46             #:frame-source-location-for-emacs             #:frame-source-location-for-emacs
# Line 4835  See `methods-by-applicability'.") Line 4836  See `methods-by-applicability'.")
4836             (not (third form))             (not (third form))
4837             (eq (first form) 'setf))))             (eq (first form) 'setf))))
4838    
4839    (defvar *inspector-dwim-lookup-hooks* '(default-dwim-inspector-lookup-hook)
4840      "A list of funcallables with one argument. It can be used to register user hooks that look up various things when inspecting in dwim mode.")
4841    
4842    (defun default-dwim-inspector-lookup-hook (form)
4843      (let ((result '()))
4844        (when (and (symbolp form)
4845                   (boundp form))
4846          (push (symbol-value form) result))
4847        (when (and (valid-function-name-p form)
4848                   (fboundp form))
4849          (push (fdefinition form) result))
4850        (when (and (symbolp form)
4851                   (find-class form nil))
4852          (push (find-class form) result))
4853        (when (and (consp form)
4854                   (valid-function-name-p (first form))
4855                   (fboundp (first form)))
4856          (push (eval form) result))
4857        (values result (not (null result)))))
4858    
4859  (defslimefun init-inspector (string &key (reset t) (eval t) (dwim-mode nil))  (defslimefun init-inspector (string &key (reset t) (eval t) (dwim-mode nil))
4860    (with-buffer-syntax ()    (with-buffer-syntax ()
4861      (when reset      (when reset
4862        (reset-inspector))        (reset-inspector))
4863      (let* ((form (read-from-string string))      (let* ((form (read-from-string string))
4864             (value (cond (dwim-mode             (value (cond
4865                           ;; TODO: here we _may_ want to present the                      (dwim-mode
4866                           ;; multiple possibilities when available                       (let ((things (loop for hook :in *inspector-dwim-lookup-hooks*
4867                           ;; instead of this hardcoded order.                                           for (result foundp) = (multiple-value-list
4868                           (cond ((and (symbolp form)                                                                   (funcall hook form))
4869                                       (boundp form))                                           when foundp
4870                                  (symbol-value form))                                           append (if (consp result)
4871                                 ((and (valid-function-name-p form)                                                      result
4872                                       (fboundp form))                                                      (list result)))))
4873                                  (fdefinition form))                         (if (rest things)
4874                                 ((and (symbolp form)                             things
4875                                       (find-class form nil))                             (first things))))
4876                                  (find-class form))                      (eval (eval form))
4877                                 ((atom form)                      (t form))))
                                 form)  
                                (t (if (and (valid-function-name-p (first form))  
                                            (fboundp (first form)))  
                                       (eval form)  
                                       form))))  
                         (eval (eval form))  
                         (t form))))  
4878        (when (and dwim-mode        (when (and dwim-mode
4879                   form)                   form
4880                     value)
4881          ;; push the form to the inspector stack, so you can go back to it          ;; push the form to the inspector stack, so you can go back to it
4882          ;; with slime-inspector-pop if dwim missed the intention          ;; with slime-inspector-pop if dwim missed the intention
4883          (push form *inspector-stack*))          (push form *inspector-stack*))
4884        (inspect-object value))))        (inspect-object (if dwim-mode
4885                              (or value form)
4886                              value)))))
4887    
4888  (defun print-part-to-string (value)  (defun print-part-to-string (value)
4889    (let ((string (to-string value))    (let ((string (to-string value))
4890          (pos (position value *inspector-history*)))          (pos (position value *inspector-history*)))

Legend:
Removed from v.1.442  
changed lines
  Added in v.1.443

  ViewVC Help
Powered by ViewVC 1.1.5