[slime-cvs] CVS slime
alendvai
alendvai at common-lisp.net
Tue Dec 19 10:29:44 UTC 2006
Update of /project/slime/cvsroot/slime
In directory clnet:/tmp/cvs-serv15780
Modified Files:
slime.el swank.lisp
Log Message:
Added dwim-mode to slime-inspect that tries to be smart unless prefixed
--- /project/slime/cvsroot/slime/slime.el 2006/12/19 10:26:53 1.713
+++ /project/slime/cvsroot/slime/slime.el 2006/12/19 10:29:42 1.714
@@ -9070,20 +9070,24 @@
(defvar slime-saved-window-config)
(defun* slime-inspect (form &key no-reset (eval (not current-prefix-arg)) thread)
- "Eval an expression and inspect the result.
+ "Take an expression and inspect it trying to be smart about what was the intention.
-If called with a prefix argument the value will not be evaluated."
- (interactive (list (slime-read-object (if current-prefix-arg
- "Inspect value: "
- "Inspect value (evaluated): "))))
+If called with a prefix argument the value will be evaluated and inspected
+without any magic in behind the stage."
+ (interactive
+ (list (slime-read-object (if current-prefix-arg
+ "Inspect value (evaluated): "
+ "Inspect value (dwim mode): ")
+ :return-names-unconfirmed (not current-prefix-arg))))
(slime-eval-async `(swank:init-inspector ,form
:reset ,(not no-reset)
- :eval ,eval)
+ :eval ,(not (null current-prefix-arg))
+ :dwim-mode ,(not current-prefix-arg))
(with-lexical-bindings (thread)
(lambda (thing)
(slime-open-inspector thing :thread thread)))))
-(defun slime-read-object (prompt)
+(defun* slime-read-object (prompt &key return-names-unconfirmed)
"Read a Common Lisp expression from the minibuffer, providing
defaults from the s-expression at point. If point is within a
presentation, don't prompt, just return the presentation."
@@ -9091,8 +9095,14 @@
(slime-presentation-around-point (point))
(if presentation
(slime-presentation-expression presentation)
- (slime-read-from-minibuffer prompt
- (slime-sexp-at-point)))))
+ (let ((sexp (slime-sexp-at-point)))
+ (if (and sexp
+ return-names-unconfirmed
+ ;; an string with alphanumeric chars and hyphens only?
+ (and (string-match "\\([\-|0-9|a-z|A-Z]*\\)" sexp)
+ (= (match-end 0) (length sexp))))
+ sexp
+ (slime-read-from-minibuffer prompt sexp))))))
(define-derived-mode slime-inspector-mode fundamental-mode "Slime-Inspector"
(set-syntax-table lisp-mode-syntax-table)
--- /project/slime/cvsroot/slime/swank.lisp 2006/12/19 10:21:32 1.429
+++ /project/slime/cvsroot/slime/swank.lisp 2006/12/19 10:29:44 1.430
@@ -4775,14 +4775,30 @@
*inspectee-actions* (make-array 10 :adjustable t :fill-pointer 0)
*inspector-history* (make-array 10 :adjustable t :fill-pointer 0)))
-(defslimefun init-inspector (string &key (reset t) (eval t))
+(defslimefun init-inspector (string &key (reset t) (eval t) (dwim-mode nil))
(with-buffer-syntax ()
(when reset
(reset-inspector))
(let* ((form (read-from-string string))
- (value (if eval
- (eval form)
- form)))
+ (value (cond (dwim-mode
+ (typecase form
+ (symbol (or (and (fboundp form)
+ (fdefinition form))
+ (and (boundp form)
+ (symbol-value form))
+ (find-class form nil)
+ form))
+ (atom form)
+ (t (if (fboundp (first form))
+ (eval form)
+ form))))
+ (eval (eval form))
+ (t form))))
+ (when (and dwim-mode
+ form)
+ ;; push the form to the inspector stack, so you can go back to it
+ ;; with slime-inspector-pop if dwim missed the intention
+ (push form *inspector-stack*))
(inspect-object value))))
(defun print-part-to-string (value)
More information about the slime-cvs
mailing list