[slime-cvs] CVS slime

CVS User nsiivola nsiivola at common-lisp.net
Thu Jun 9 16:35:09 UTC 2011


Update of /project/slime/cvsroot/slime
In directory common-lisp.net:/tmp/cvs-serv17070

Modified Files:
	ChangeLog slime.el swank.lisp 
Log Message:
slime-indentation: per-package indentation from swank

  SWANK sends indentation information for macro-lambda lists
  to the Emacs side.

  Prior to this, however, this was a lossy N->1 mapping, where different
  symbols with the same name from multiple packages were conflated.

  Now an indentation update also includes a list of packages where the symbol
  in question is accessible.

  If slime-indentation is not being used, this information is dropped by Emacs.

  If, however, slime-indentation is used, the package information is stored in
  common-lisp-system-indentation hash-table, which is used as a fallback when
  indentation from other sources is not available for the symbol in question.

  Package used for looking up the indentation spec is either picked up from
  the package qualifier in the source, or guessed from the buffer.


--- /project/slime/cvsroot/slime/ChangeLog	2011/05/27 07:45:44	1.2195
+++ /project/slime/cvsroot/slime/ChangeLog	2011/06/09 16:35:09	1.2196
@@ -1,3 +1,19 @@
+2011-06-09  Nikodemus Siivola  <nikodemus at random-state.net>
+
+	Support for per-package derived indentation, when
+	slime-indentation is used.
+
+	* swank.lisp (update-indentation/delta-for-emacs): Tell Emacs
+	which packages the symbol is available in. Unless
+	slime-indentation is used, this information is just dropped on the
+	floor.
+
+	* slime.el (slime-update-system-indentation): New function. Use
+	this to inform indentation about derived specs when
+	`common-lisp-system-indentation' is bound.
+	(slime-handle-indentation-update): Adjust to support per-package
+	derived indentation specs when slime-indentation is available.
+
 2011-05-27  Helmut Eller  <heller at common-lisp.net>
 
 	Fix "wrong number of args" problem with slime-inspector-quit.
--- /project/slime/cvsroot/slime/slime.el	2011/05/27 07:45:44	1.1370
+++ /project/slime/cvsroot/slime/slime.el	2011/06/09 16:35:09	1.1371
@@ -6932,6 +6932,21 @@
         (t
          spec)))
 
+(defun slime-update-system-indentation (symbol indent packages)
+  (let ((list (gethash symbol common-lisp-system-indentation)))
+    (if (not list)
+        (puthash symbol (list (cons indent packages))
+                 common-lisp-system-indentation)
+      (or (dolist (spec list)
+            (when (equal (car spec) indent)
+              (dolist (p packages)
+                (unless (member p (cdr spec))
+                  (push p (cdr spec))))
+              (return t)))
+          (puthash symbol (cons (cons indent packages)
+                                list)
+                   common-lisp-system-indentation)))))
+
 (defun slime-handle-indentation-update (alist)
   "Update Lisp indent information.
 
@@ -6940,13 +6955,17 @@
 is setup, unless the user already set one explicitly."
   (dolist (info alist)
     (let ((symbol (intern (car info)))
-          (indent (slime-intern-indentation-spec (cdr info))))
-      ;; Does the symbol have an indentation value that we set?
-      (when (equal (get symbol 'common-lisp-indent-function)
-                   (get symbol 'slime-indent))
-        (put symbol 'common-lisp-indent-function indent)
-        (put symbol 'slime-indent indent))
-      (run-hook-with-args 'slime-indentation-update-hooks symbol indent))))
+          (indent (slime-intern-indentation-spec (second info)))
+          (packages (third info)))
+      (if (boundp 'common-lisp-system-indentation)
+          ;; A table provided by slime-cl-indent.el.
+          (slime-update-system-indentation symbol indent packages)
+        ;; Does the symbol have an indentation value that we set?
+        (when (equal (get symbol 'common-lisp-indent-function)
+                     (get symbol 'slime-indent))
+          (put symbol 'common-lisp-indent-function indent)
+          (put symbol 'slime-indent indent)))
+      (run-hook-with-args 'slime-indentation-update-hooks symbol indent packages))))
 
 
 ;;;; Contrib modules
--- /project/slime/cvsroot/slime/swank.lisp	2011/05/23 22:51:46	1.743
+++ /project/slime/cvsroot/slime/swank.lisp	2011/06/09 16:35:09	1.744
@@ -3893,16 +3893,20 @@
         (send-to-emacs (list :indentation-update delta))))))
 
 (defun update-indentation/delta-for-emacs (cache &optional force)
-  "Update the cache and return the changes in a (SYMBOL . INDENT) list.
+  "Update the cache and return the changes in a (SYMBOL INDENT PACKAGES) list.
 If FORCE is true then check all symbols, otherwise only check symbols
 belonging to the buffer package."
   (let ((alist '()))
-      (flet ((consider (symbol)
+    (flet ((consider (symbol)
              (let ((indent (symbol-indentation symbol)))
                (when indent
                  (unless (equal (gethash symbol cache) indent)
                    (setf (gethash symbol cache) indent)
-                   (push (cons (string-downcase symbol) indent) alist))))))
+                   (let ((pkgs (loop for p in (list-all-packages)
+                                     when (eq symbol (find-symbol (string symbol) p))
+                                     collect (package-name p)))
+                         (name (string-downcase symbol)))
+                     (push (list name indent pkgs) alist)))))))
       (if force
           (do-all-symbols (symbol)
             (consider symbol))





More information about the slime-cvs mailing list