[slime-devel] patch for editing method definitions from inspector

Earl J. Wagner earljwagner at alum.mit.edu
Tue Aug 1 22:37:11 UTC 2006


This fixes a problem in the inspector where I'd hit M-. on the method  
name, then have to choose the method even though the method  
specializers were right there.

Also, the previous patch is for keyword symbol completion. I'm not  
sure if my first (incorrect) patch was posted to the list or blocked.  
It it arrives, ignore it.

-Earl



Index: slime.el
===================================================================
RCS file: /project/slime/cvsroot/slime/slime.el,v
retrieving revision 1.635
diff -u -r1.635 slime.el
--- slime.el	24 Jul 2006 14:01:03 -0000	1.635
+++ slime.el	1 Aug 2006 22:22:03 -0000
@@ -6319,12 +6319,15 @@
                               (:type list))
    dspec location)
+
(defun slime-edit-definition (name &optional where)
    "Lookup the definition of the name at point.
If there's no name at point, or a prefix argument is given, then the
function name is prompted."
    (interactive (list (slime-read-symbol-name "Name: ")))
-  (let ((definitions (slime-eval `(swank:find-definitions-for- 
emacs ,name))))
+  (let* ((method-context (slime-extract-method-context name))
+         (full-name (if method-context (format "%s" method-context)  
name))
+         (definitions (slime-eval `(swank:find-definitions-for- 
emacs ,full-name))))
      (cond
       ((null definitions)
        (if slime-edit-definition-fallback-function
@@ -6801,15 +6804,7 @@
             ;;a setf-definition, but which?
             (backward-up-list 1)
             (slime-parse-context `(setf ,name)))
-          ((slime-in-expression-p '(defmethod *))
-           (unless (looking-at "\\s ")
-             (forward-sexp 1)) ; skip over the methodname
-           (let (qualifiers arglist)
-             (loop for e = (read (current-buffer))
-                   until (listp e) do (push e qualifiers)
-                   finally (setq arglist e))
-             `(:defmethod ,name , at qualifiers
-                          ,(slime-arglist-specializers arglist))))
+          ((slime-in-expression-p '(defmethod *)) (slime-extract- 
method-context name))
            ((and (symbolp name)
                  (slime-in-expression-p `(,name)))
             ;; looks like a regular call
@@ -6829,6 +6824,22 @@
            (t
             name))))
+(defun slime-extract-method-context (name)
+  (save-excursion
+    (let ((method-p (when (slime-in-expression-p '(method *)) 'method))
+          (defmethod-p (when (slime-in-expression-p '(defmethod *))  
'defmethod)))
+      (when (or method-p defmethod-p)
+        (unless (looking-at "\\s ")
+          (forward-sexp 1))             ; skip over the methodname
+        (let (qualifiers arglist)
+          (loop for e = (read (current-buffer))
+                until (listp e) do (push e qualifiers)
+                finally (setq arglist e))
+          (if method-p
+              `(method ,name , at qualifiers ,arglist)
+            `(:defmethod ,name , at qualifiers
+                         ,(slime-arglist-specializers arglist))))))))
+
(defun slime-in-expression-p (pattern)
    "A helper function to determine the current context.
The pattern can have the form:





More information about the slime-devel mailing list