[slime-cvs] CVS slime/contrib
CVS User sboukarev
sboukarev at common-lisp.net
Mon Apr 5 14:48:55 UTC 2010
Update of /project/slime/cvsroot/slime/contrib
In directory cl-net:/tmp/cvs-serv17211/contrib
Modified Files:
ChangeLog slime-autodoc.el swank-arglists.lisp
Log Message:
* slime-autodoc.el (slime-autodoc-full): New command,
displays multiline arglists. Bound to C-c C-d a.
(slime-make-autodoc-rpc-form): Don't send
:print-lines to autodoc, always use the actual width for
:print-right-margin, remove newlines on formatting when needed.
(slime-autodoc): Add optional parameter multilinep defaulted to
slime-autodoc-use-multiline-p, pass it to slime-format-autodoc.
* swank-arglists.lisp (autodoc, decoded-arglist-to-string): remove
print-lines parameter, it's not used anymore.
* slime.el (slime-doc-bindings): Move slime-apropos to C-c C-d A,
C-c C-d a will be bound to slime-autodoc-full.
--- /project/slime/cvsroot/slime/contrib/ChangeLog 2010/04/05 10:53:02 1.365
+++ /project/slime/cvsroot/slime/contrib/ChangeLog 2010/04/05 14:48:55 1.366
@@ -1,5 +1,18 @@
2010-04-05 Stas Boukarev <stassats at gmail.com>
+ * slime-autodoc.el (slime-autodoc-full): New command,
+ displays multiline arglists. Bound to C-c C-d a.
+ (slime-make-autodoc-rpc-form): Don't send
+ :print-lines to autodoc, always use the actual width for
+ :print-right-margin, remove newlines on formatting when needed.
+ (slime-autodoc): Add optional parameter multilinep defaulted to
+ slime-autodoc-use-multiline-p, pass it to slime-format-autodoc.
+
+ * swank-arglists.lisp (autodoc, decoded-arglist-to-string): remove
+ print-lines parameter, it's not used anymore.
+
+2010-04-05 Stas Boukarev <stassats at gmail.com>
+
* slime-sprof.el (slime-sprof-browser): Use slime-with-popup-buffer for
buffer creation.
--- /project/slime/cvsroot/slime/contrib/slime-autodoc.el 2010/04/03 14:03:53 1.40
+++ /project/slime/cvsroot/slime/contrib/slime-autodoc.el 2010/04/05 14:48:55 1.41
@@ -64,11 +64,9 @@
(buffer-form (slime-parse-form-upto-point levels)))
(when buffer-form
(values buffer-form
- (multiple-value-bind (width height)
- (slime-autodoc-message-dimensions)
- `(swank:autodoc ',buffer-form
- :print-right-margin ,width
- :print-lines ,height))))))
+ `(swank:autodoc ',buffer-form
+ :print-right-margin
+ ,(window-width (minibuffer-window)))))))
(defun slime-autodoc-global-at-point ()
"Return the global variable name at point, if any."
@@ -88,23 +86,6 @@
(and (< (length name) 80) ; avoid overflows in regexp matcher
(string-match slime-global-variable-name-regexp name)))
-(defvar slime-autodoc-dimensions-function nil)
-
-(defun slime-autodoc-message-dimensions ()
- "Return the available width and height for pretty printing autodoc
-messages."
- (cond
- (slime-autodoc-dimensions-function
- (funcall slime-autodoc-dimensions-function))
- (slime-autodoc-use-multiline-p
- ;; Use the full width of the minibuffer;
- ;; minibuffer will grow vertically if necessary
- (values (window-width (minibuffer-window))
- nil))
- (t
- ;; Try to fit everything in one line; we cut off when displaying
- (values 1000 1))))
-
;;;; Autodoc cache
@@ -125,11 +106,11 @@
;;;; Formatting autodoc
-(defun slime-format-autodoc (doc)
- (setq doc (slime-fontify-string doc))
- (unless slime-autodoc-use-multiline-p
- (setq doc (slime-oneliner doc)))
- doc)
+(defun slime-format-autodoc (doc multilinep)
+ (let ((doc (slime-fontify-string doc)))
+ (if multilinep
+ doc
+ (slime-oneliner (replace-regexp-in-string "[ \n\t]+" " " doc)))))
(defun slime-fontify-string (string)
"Fontify STRING as `font-lock-mode' does in Lisp mode."
@@ -154,8 +135,8 @@
;;;; slime-autodoc-mode
-
-(defun slime-autodoc ()
+(defun* slime-autodoc (&optional (multilinep slime-autodoc-use-multiline-p)
+ cache-multiline)
"Returns the cached arglist information as string, or nil.
If it's not in the cache, the cache will be updated asynchronously."
(interactive)
@@ -165,27 +146,49 @@
;; data.
(save-match-data
(unless (slime-inside-string-or-comment-p)
- (multiple-value-bind (cache-key retrieve-form)
+ (multiple-value-bind (cache-key retrieve-form)
(slime-make-autodoc-rpc-form)
- (let ((cached))
- (cond
+ (let* (cached
+ (multiline-cached (slime-autodoc-cache-multine (car cache-key)
+ cache-multiline))
+ (multilinep (or multilinep multiline-cached)))
+ (cond
((not cache-key) nil)
- ((setq cached (slime-get-cached-autodoc cache-key)) cached)
+ ((setq cached (slime-get-cached-autodoc cache-key))
+ (slime-format-autodoc cached multilinep))
(t
;; If nothing is in the cache, we first decline (by
;; returning nil), and fetch the arglist information
;; asynchronously.
(slime-eval-async retrieve-form
- (lexical-let ((cache-key cache-key))
+ (lexical-let ((cache-key cache-key)
+ (multilinep multilinep))
(lambda (doc)
- (unless (eq doc :not-available)
- (setq doc (slime-format-autodoc doc))
+ (unless (eq doc :not-available)
+ (slime-store-into-autodoc-cache cache-key doc)
;; Now that we've got our information,
;; get it to the user ASAP.
- (eldoc-message doc)
- (slime-store-into-autodoc-cache cache-key doc)))))
+ (eldoc-message
+ (slime-format-autodoc doc multilinep))))))
nil))))))))
+(defvar slime-autodoc-cache-car nil)
+
+(defun slime-autodoc-cache-multine (cache-key cache-new-p)
+ (cond (cache-new-p
+ (setq slime-autodoc-cache-car
+ cache-key))
+ ((not (equal cache-key
+ slime-autodoc-cache-car))
+ (setq slime-autodoc-cache-car nil)))
+ (equal cache-key
+ slime-autodoc-cache-car))
+
+(defun slime-autodoc-full ()
+ "Like slime-autodoc, but with slime-autodoc-use-multiline-p enabled"
+ (interactive)
+ (eldoc-message (slime-autodoc t t)))
+
(make-variable-buffer-local (defvar slime-autodoc-mode nil))
(defun slime-autodoc-mode (&optional arg)
@@ -211,7 +214,8 @@
(not (active-minibuffer-window))
;; Display arglist only when inferior Lisp will be able
;; to cope with the request.
- (slime-background-activities-enabled-p))))
+ (slime-background-activities-enabled-p)))
+ (slime-bind-keys slime-doc-map t '((?a slime-autodoc-full))))
ad-return-value)
--- /project/slime/cvsroot/slime/contrib/swank-arglists.lisp 2010/04/03 17:00:04 1.64
+++ /project/slime/cvsroot/slime/contrib/swank-arglists.lisp 2010/04/05 14:48:55 1.65
@@ -386,11 +386,10 @@
(defun decoded-arglist-to-string (decoded-arglist
&key operator highlight
- print-right-margin print-lines)
+ print-right-margin)
(with-output-to-string (*standard-output*)
(with-arglist-io-syntax
- (let ((*print-right-margin* print-right-margin)
- (*print-lines* print-lines))
+ (let ((*print-right-margin* print-right-margin))
(print-decoded-arglist decoded-arglist
:operator operator
:highlight highlight)))))
@@ -1102,32 +1101,30 @@
;;; %CURSOR-MARKER%)). Only the forms up to point should be
;;; considered.
-(defslimefun autodoc (raw-form &key print-right-margin print-lines)
+(defslimefun autodoc (raw-form &key print-right-margin)
"Return a string representing the arglist for the deepest subform in
RAW-FORM that does have an arglist. The highlighted parameter is
wrapped in ===> X <===."
(handler-bind ((serious-condition
#'(lambda (c)
(unless (debug-on-swank-error)
- (let ((*print-right-margin* print-right-margin)
- (*print-lines* print-lines))
+ (let ((*print-right-margin* print-right-margin))
(return-from autodoc
(format nil "Arglist Error: \"~A\"" c)))))))
- (with-buffer-syntax ()
- (multiple-value-bind (form arglist obj-at-cursor form-path)
- (find-subform-with-arglist (parse-raw-form raw-form))
- (cond ((interesting-variable-p obj-at-cursor)
- (print-variable-to-string obj-at-cursor))
- (t
- (with-available-arglist (arglist) arglist
- (decoded-arglist-to-string
- arglist
- :print-right-margin print-right-margin
- :print-lines print-lines
- :operator (car form)
- :highlight (form-path-to-arglist-path form-path
- form
- arglist)))))))))
+ (with-buffer-syntax ()
+ (multiple-value-bind (form arglist obj-at-cursor form-path)
+ (find-subform-with-arglist (parse-raw-form raw-form))
+ (cond ((interesting-variable-p obj-at-cursor)
+ (print-variable-to-string obj-at-cursor))
+ (t
+ (with-available-arglist (arglist) arglist
+ (decoded-arglist-to-string
+ arglist
+ :print-right-margin print-right-margin
+ :operator (car form)
+ :highlight (form-path-to-arglist-path form-path
+ form
+ arglist)))))))))
(defun print-variable-to-string (symbol)
"Return a short description of VARIABLE-NAME, or NIL."
More information about the slime-cvs
mailing list