[slime-devel] [PATCH] add eldoc support

Sean O'Rourke sorourke at cs.ucsd.edu
Sun Nov 2 02:46:34 UTC 2003


This patch lets SLIME support Eldoc (i.e. flashing argument lists in
the minibuffer).  Inspired by semantic/cedet, which does this for
many languages.

/s

--- slime.el.~1.61.~	Wed Oct 29 17:18:24 2003
+++ slime.el	Sat Nov  1 18:06:03 2003
@@ -1771,20 +1771,40 @@
 	     (slime-function-called-at-point/line))
     (slime-arglist (symbol-name (slime-function-called-at-point/line)))))
 
-(defun slime-arglist (symbol-name)
+(defvar slime-arglist-cache (make-hash-table :test 'equal)
+  "Cache for Slime arglist info (useful with Eldoc).")
+
+(defun slime-arglist (symbol-name &optional show)
   "Show the argument list for the nearest function call, if any."
   (interactive (list (slime-read-symbol "Arglist of: ")))
-  (slime-eval-async 
-   `(swank:arglist-string ,symbol-name)
-   (slime-buffer-package)
-   (lexical-let ((symbol-name symbol-name))
-     (lambda (arglist)
-       (message "%s" (slime-format-arglist symbol-name arglist))))))
+  (unless show
+    (setq show #'message))
+  (let ((val (gethash symbol-name slime-arglist-cache)))
+    (if val
+        (funcall show "%s" val)
+        (slime-eval-async 
+         `(swank:arglist-string ,symbol-name)
+         (slime-buffer-package)
+         (lexical-let ((symbol-name symbol-name))
+           (lambda (arglist)
+             (funcall show "%s"
+                      (setf (gethash symbol-name slime-arglist-cache)
+                            (slime-format-arglist symbol-name arglist)))))))))
 
 (defun slime-get-arglist (symbol-name)
   "Return the argument list for SYMBOL-NAME."
-  (slime-format-arglist symbol-name
-                        (slime-eval `(swank:arglist-string ,symbol-name))))
+  (or (gethash symbol-name slime-arglist-cache)
+      (setf (gethash symbol-name slime-arglist-cache)
+            (slime-format-arglist symbol-name
+                 (slime-eval `(swank:arglist-string ,symbol-name))))))
+
+(defadvice eldoc-print-current-symbol-info (around slime activate)
+  "Enable Eldoc argument list feedback with SLIME/SWANK."
+  (if (eq major-mode 'lisp-mode)
+      (let ((sym (slime-function-called-at-point/line)))
+	(when sym
+	  (slime-arglist (symbol-name sym) #'eldoc-message)))
+      ad-do-it))
 
 (defun slime-format-arglist (symbol-name arglist)
   (format "(%s %s)" symbol-name (substring arglist 1 -1)))





More information about the slime-devel mailing list