Index: slime.el
===================================================================
RCS file: /project/slime/cvsroot/slime/slime.el,v
retrieving revision 1.78
diff -p -u -w -r1.78 slime.el
--- slime.el	4 Nov 2003 22:29:03 -0000	1.78
+++ slime.el	5 Nov 2003 00:25:54 -0000
@@ -1973,20 +1973,90 @@ more than one space."
 	     (slime-function-called-at-point/line))
     (slime-arglist (symbol-name (slime-function-called-at-point/line)))))
 
-(defun slime-arglist (symbol-name)
+(defvar slime-cache-type 'last
+  "* The type of caching to do for function arglists.  Possible
+values are:
+    - nil -- none
+    - last -- cache only the most recently-looked-at function.
+      This avoids stale arglists.
+    - all -- cache all looked-at functions.  This will make eldoc
+      faster, but may cause stale arglists. ")
+
+(defvar slime-arglist-cache nil ; (make-hash-table :test 'equal)
+  )
+(defvar slime-last-arglist nil)
+
+(defun slime-try-get-arglist (symbol-name)
+  (case slime-cache-type
+    (all (cdr (assoc symbol-name slime-arglist-cache))
+;;          (gethash (concat (slime-buffer-package) "::" symbol-name)
+;;                   slime-arglist-cache)
+         )
+    (last (and slime-last-arglist
+	       (equal symbol-name (car slime-last-arglist))
+	       (cdr slime-last-arglist)))
+    (t nil)))
+
+(defun slime-update-arglist (symbol-name value)
+  (setq value
+	(or (and value
+		 (not (string= value "(-- <Unknown-Function>)"))
+		 (slime-format-arglist symbol-name value))
+	    ""))
+  (case slime-cache-type
+    (all
+     (let ((x (assoc symbol-name slime-arglist-cache)))
+       (if x (setf (cdr x) value)
+           (push (cons symbol-name value) slime-arglist-cache))
+       value)
+;;      (setf (gethash (concat (slime-buffer-package) "::" symbol-name)
+;;                         slime-arglist-cache) value)
+     )
+    (last (setq slime-last-arglist (cons symbol-name value))
+	  value)
+    (t value)))
+
+(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: ")))
+  (unless show
+    (setq show #'message))
+  (let ((val (slime-try-get-arglist symbol-name)))
+    (if val
+        (funcall show "%s" val)
   (slime-eval-async 
    `(swank:arglist-string ,symbol-name)
    (slime-buffer-package)
-   (lexical-let ((symbol-name symbol-name))
+         (lexical-let ((symbol-name symbol-name)
+                       (show show))
      (lambda (arglist)
-       (message "%s" (slime-format-arglist symbol-name arglist))))))
+	     (funcall show "%s" (slime-update-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 (slime-try-get-arglist symbol-name)
+      (slime-update-arglist symbol-name
+			    (slime-eval `(swank:arglist-string ,symbol-name)))))
+
+(if (boundp 'eldoc-print-current-symbol-info-function)
+    ;; Newer emacsen have a hook here.
+    (progn
+      (defvar-mode-local lisp-mode eldoc-print-current-symbol-info-function
+        'slime-print-current-symbol-info)
+      (defvar-mode-local inferior-lisp-mode
+          eldoc-print-current-symbol-info-function
+        'slime-print-current-symbol-info))
+    ;; Older ones have to be advised.
+    (defadvice eldoc-print-current-symbol-info (around slime-eldoc activate)
+      (if (member major-mode '(lisp-mode inferior-lisp-mode))
+          (message (slime-print-current-symbol-info))
+          ad-do-it)))
+
+(defun slime-print-current-symbol-info ()
+  "Enable Eldoc argument list feedback with SLIME/SWANK."
+  (let ((sym (slime-function-called-at-point/line)))
+    (when sym
+      (slime-get-arglist (symbol-name sym)))))
 
 (defun slime-format-arglist (symbol-name arglist)
   (format "(%s %s)" symbol-name (substring arglist 1 -1)))
@@ -2330,6 +2400,17 @@ First make the variable unbound, then ev
   (when (not symbol-name)
     (error "No symbol given"))
   (slime-eval-describe `(swank:describe-symbol ,symbol-name)))
+
+(defun slime-documentation (symbol-name)
+"Display function- or symbol-documentation for SYMBOL-NAME or, if
+none exists, display the description, like
+``slime-describe-symbol''."
+  (interactive (list (slime-read-symbol-name "Documentation for symbol: ")))
+  (when (not symbol-name)
+    (error "No symbol given"))
+  (slime-eval-describe
+   `(cl:or (swank:documentation-symbol ,symbol-name)
+	   (swank:describe-symbol ,symbol-name))))
 
 (defun slime-apropos (string &optional only-external-p package)
   (interactive
Index: swank.lisp
===================================================================
RCS file: /project/slime/cvsroot/slime/swank.lisp,v
retrieving revision 1.55
diff -p -u -w -r1.55 swank.lisp
--- swank.lisp	4 Nov 2003 22:33:31 -0000	1.55
+++ swank.lisp	5 Nov 2003 00:25:54 -0000
@@ -157,6 +157,11 @@ buffer are best read in this package.  S
   (let ((*package* *buffer-package*))
     (read-from-string string)))
 
+(defun symbol-from-string (string)
+  "Read string in the *BUFFER-PACKAGE*"
+  (let ((*package* *buffer-package*))
+    (find-symbol (string-upcase string))))
+
 (defun to-string (string)
   "Write string in the *BUFFER-PACKAGE*."
   (let ((*package* *buffer-package*))
@@ -351,10 +356,21 @@ The time is measured in microseconds."
   (print-output-to-string (lambda () (describe object))))
 
 (defslimefun describe-symbol (symbol-name)
-  (print-description-to-string (from-string symbol-name)))
+  (print-description-to-string (symbol-from-string symbol-name)))
 
 (defslimefun describe-function (symbol-name)
-  (print-description-to-string (symbol-function (from-string symbol-name))))
+  (print-description-to-string
+   (symbol-function (symbol-from-string symbol-name))))
+
+(defslimefun documentation-symbol (symbol-name)
+  (let ((*package* *buffer-package*))
+    (let ((vdoc (documentation (symbol-from-string symbol-name) 'variable))
+          (fdoc (documentation (symbol-from-string symbol-name) 'function)))
+      (and (or vdoc fdoc)
+           (concatenate 'string
+                        fdoc
+                        (and vdoc fdoc '(#\Newline #\Newline))
+                        vdoc)))))
 
 ;;; Macroexpansion
 
@@ -438,7 +454,7 @@ Return three values:
             (if pos (subseq string 0 pos) nil))
           (search "::" string)))
 
-(defun find-symbol-designator (string default-package)
+(defun find-symbol-designator (string &optional (default-package *buffer-package*))
   "Return the symbol corresponding to the symbol designator STRING.
 If string is not package qualified use DEFAULT-PACKAGE for the
 resolution.  Return nil if no such symbol exists."
