[slime-cvs] CVS slime
nsiivola
nsiivola at common-lisp.net
Tue Dec 12 15:40:23 UTC 2006
Update of /project/slime/cvsroot/slime
In directory clnet:/tmp/cvs-serv6807
Modified Files:
ChangeLog slime.el swank-backend.lisp swank.lisp
Log Message:
Implement INSPECT-IN-EMACS, tweak inspection of integers.
--- /project/slime/cvsroot/slime/ChangeLog 2006/12/08 13:32:45 1.1018
+++ /project/slime/cvsroot/slime/ChangeLog 2006/12/12 15:40:19 1.1019
@@ -1,3 +1,20 @@
+2006-12-12 Nikodemus Siivola <nikodemus at random-state.net>
+
+ * swank.lisp (inspect-for-emacs integer): Pad the hex formatted
+ value to eight digits, "Code-char:" instead of "Corresponding
+ character:", "Integer-length:" instead of "Length:",
+ "Universal-time:" instead of "As time".
+ (inspect-object): Use TYPE-FOR-EMACS instead of TYPE-OF.
+ (inspect-in-emacs): New function, analogous to ED-IN-EMACS.
+
+ * swank-backend.lisp (type-for-emacs): New generic function,
+ defaults to TYPE-OF for non-integers, and returns FIXNUM or BIGNUM
+ for integers.
+
+ * slime.el (destructure-case): Indicate in the error message that
+ it was the Elisp destructure-case that failed to avoid confusion.
+ (slime-check-eval-in-emacs-enabled): More verbose error message.
+
2006-12-07 Marco Baringer <mb at bese.it>
* swank.lisp (init-inspector): Added eval parameter. If NIL we
--- /project/slime/cvsroot/slime/slime.el 2006/12/11 12:55:55 1.704
+++ /project/slime/cvsroot/slime/slime.el 2006/12/12 15:40:19 1.705
@@ -1122,7 +1122,7 @@
patterns)
,@(if (eq (caar (last patterns)) t)
'()
- `((t (error "destructure-case failed: %S" ,tmp))))))))
+ `((t (error "Elisp destructure-case failed: %S" ,tmp))))))))
(put 'destructure-case 'lisp-indent-function 1)
@@ -2687,14 +2687,16 @@
((:open-dedicated-output-stream port)
(slime-open-stream-to-lisp port))
((:eval-no-wait fun args)
- (slime-check-eval-in-emacs-enabled)
(apply (intern fun) args))
((:eval thread tag form-string)
+ (slime-check-eval-in-emacs-enabled)
(slime-eval-for-lisp thread tag form-string))
((:emacs-return thread tag value)
(slime-send `(:emacs-return ,thread ,tag ,value)))
((:ed what)
(slime-ed what))
+ ((:inspect what)
+ (slime-open-inspector what))
((:background-message message)
(slime-background-message "%s" message))
((:debug-condition thread message)
@@ -6921,7 +6923,7 @@
(defun slime-check-eval-in-emacs-enabled ()
"Raise an error if `slime-enable-evaluate-in-emacs' isn't true."
(unless slime-enable-evaluate-in-emacs
- (error "eval-in-emacs not enabled")))
+ (error "slime-eval-in-emacs disabled for security. Set slime-enable-evaluate-in-emacs true to enable it.")))
;;;; `ED'
--- /project/slime/cvsroot/slime/swank-backend.lisp 2006/12/11 12:51:59 1.111
+++ /project/slime/cvsroot/slime/swank-backend.lisp 2006/12/12 15:40:23 1.112
@@ -38,6 +38,7 @@
#:fancy-inspection
#:label-value-line
#:label-value-line*
+ #:type-for-emacs
))
(defpackage :swank-mop
@@ -880,6 +881,20 @@
` (append ,@(loop for (label value) in label-values
collect `(label-value-line ,label ,value))))
+(defgeneric type-for-emacs (object)
+ (:documentation
+ "Return a type specifier suitable for display in the Emacs inspector.")
+ (:method (object)
+ (type-of object))
+ (:method ((object integer))
+ ;; Some lisps report integer types as (MOD ...), which while nice
+ ;; in a sense doesn't answer the often more immediate question of
+ ;; fixnumness.
+ (if (typep object 'fixnum)
+ 'fixnum
+ 'bignum)))
+
+
(definterface describe-primitive-type (object)
"Return a string describing the primitive type of object."
(declare (ignore object))
--- /project/slime/cvsroot/slime/swank.lisp 2006/12/11 14:12:14 1.425
+++ /project/slime/cvsroot/slime/swank.lisp 2006/12/12 15:40:23 1.426
@@ -18,6 +18,7 @@
#:start-server
#:create-server
#:ed-in-emacs
+ #:inspect-in-emacs
#:print-indentation-lossage
#:swank-debugger-hook
#:run-after-init-hook
@@ -730,7 +731,7 @@
(send (find-thread thread-id) `(take-input ,tag ,value)))
(((:write-string :presentation-start :presentation-end
:new-package :new-features :ed :%apply :indentation-update
- :eval-no-wait :background-message)
+ :eval-no-wait :background-message :inspect)
&rest _)
(declare (ignore _))
(encode-message event socket-io))))
@@ -872,7 +873,7 @@
(((:write-string :new-package :new-features :debug-condition
:presentation-start :presentation-end
:indentation-update :ed :%apply :eval-no-wait
- :background-message)
+ :background-message :inspect)
&rest _)
(declare (ignore _))
(send event)))))
@@ -2666,6 +2667,19 @@
(send-oob-to-emacs `(:ed ,target))))
(t nil)))))
+(defslimefun inspect-in-emacs (what)
+ "Inspect WHAT in Emacs."
+ (flet ((send-it ()
+ (with-buffer-syntax ()
+ (reset-inspector)
+ (send-oob-to-emacs `(:inspect ,(inspect-object what))))))
+ (cond
+ (*emacs-connection*
+ (send-it))
+ ((default-connection)
+ (with-connection ((default-connection))
+ (send-it))))))
+
(defslimefun value-for-editing (form)
"Return a readable value of FORM for editing in Emacs.
FORM is expected, but not required, to be SETF'able."
@@ -4668,16 +4682,15 @@
(defmethod inspect-for-emacs ((i integer) inspector)
(declare (ignore inspector))
(values "A number."
- (append
- `(,(format nil "Value: ~D = #x~X = #o~O = #b~,,' ,8:B = ~E"
+ (append
+ `(,(format nil "Value: ~D = #x~8,'0X = #o~O = #b~,,' ,8:B = ~E"
i i i i i)
(:newline))
- (if (< -1 i char-code-limit)
- (label-value-line "Corresponding character" (code-char i)))
- (label-value-line "Length" (integer-length i))
+ (when (< -1 i char-code-limit)
+ (label-value-line "Code-char" (code-char i)))
+ (label-value-line "Integer-length" (integer-length i))
(ignore-errors
- (list "As time: "
- (format-iso8601-time i t))))))
+ (label-value-line "Universal-time" (format-iso8601-time i t))))))
(defmethod inspect-for-emacs ((c complex) inspector)
(declare (ignore inspector))
@@ -4814,7 +4827,7 @@
(multiple-value-bind (title content)
(inspect-for-emacs object inspector)
(list :title title
- :type (to-string (type-of object))
+ :type (to-string (type-for-emacs object))
:content (inspector-content-for-emacs content)
:id (assign-index object *inspectee-parts*)))))
More information about the slime-cvs
mailing list