[slime-cvs] CVS slime

CVS User heller heller at common-lisp.net
Sun Nov 23 22:11:36 UTC 2008


Update of /project/slime/cvsroot/slime
In directory cl-net:/tmp/cvs-serv10236

Modified Files:
	ChangeLog slime.el 
Log Message:
`q' in temp buffers should only delete the window if it was newly
created for the buffer.

* slime.el (slime-display-popup-buffer): New function.  Recognize
if the window didn't exist before.  Save the created window and
the selected window in buffer local variables.
(slime-make-popup-buffer): Renamed from slime-popup-buffer.
(slime-popup-buffer-quit): Delete the created window (if needed)
and restore the old selected window.  Don't touch other windows.

(slime-edit-value-callback): Calling lisp-mode deletes all local
variables.  We need to that inside with-popup-buffer.

--- /project/slime/cvsroot/slime/ChangeLog	2008/11/22 22:36:40	1.1586
+++ /project/slime/cvsroot/slime/ChangeLog	2008/11/23 22:11:36	1.1587
@@ -1,3 +1,18 @@
+2008-11-23  Helmut Eller  <heller at common-lisp.net>
+
+	`q' in temp buffers should only delete the window if it was newly
+	created for the buffer.
+
+	* slime.el (slime-display-popup-buffer): New function.  Recognize
+	if the window didn't exist before.  Save the created window and
+	the selected window in buffer local variables.
+	(slime-make-popup-buffer): Renamed from slime-popup-buffer.
+	(slime-popup-buffer-quit): Delete the created window (if needed)
+	and restore the old selected window.  Don't touch other windows.
+
+	(slime-edit-value-callback): Calling lisp-mode deletes all local
+	variables.  We need to that inside with-popup-buffer.
+
 2008-11-22  Helmut Eller  <heller at common-lisp.net>
 
 	* slime.el (slime-update-all-modelines): Only walk through
--- /project/slime/cvsroot/slime/slime.el	2008/11/22 22:36:40	1.1064
+++ /project/slime/cvsroot/slime/slime.el	2008/11/23 22:11:36	1.1065
@@ -1021,26 +1021,24 @@
                        ,(if (eq connection t) '(slime-connection) connection)
                        ;; Defer the decision for NILness until runtime.
                        (or ,emacs-snapshot (slime-current-emacs-snapshot))))
-          (standard-output (slime-popup-buffer ,name vars%)))
+          (standard-output (slime-make-popup-buffer ,name vars%)))
      (with-current-buffer standard-output
        (prog1 (progn , at body)
          (assert (eq (current-buffer) standard-output))
          (setq buffer-read-only t)
-         (slime-init-popup-buffer vars%)))))
+         (slime-init-popup-buffer vars%)
+         (slime-display-popup-buffer)))))
 
 (put 'slime-with-popup-buffer 'lisp-indent-function 1)
 
-(defun slime-popup-buffer (name buffer-vars)
+(defun slime-make-popup-buffer (name buffer-vars)
   "Return a temporary buffer called NAME.
-The buffer also uses the minor-mode `slime-popup-buffer-mode'.
-Pressing `q' in the buffer will restore the window configuration
-to the way it is when the buffer was created, i.e. when this
-function was called."
+The buffer also uses the minor-mode `slime-popup-buffer-mode'."
   (when (and (get-buffer name) (kill-buffer (get-buffer name))))
   (with-current-buffer (get-buffer-create name)
     (set-syntax-table lisp-mode-syntax-table)
-    (prog1 (pop-to-buffer (current-buffer))
-      (slime-init-popup-buffer buffer-vars))))
+    (slime-init-popup-buffer buffer-vars)
+    (current-buffer)))
 
 (defun slime-init-popup-buffer (buffer-vars)
   (slime-popup-buffer-mode 1)
@@ -1051,6 +1049,19 @@
                         slime-popup-buffer-saved-emacs-snapshot)
     buffer-vars))
 
+(defun slime-display-popup-buffer ()
+  "Display the current buffer.
+Save the selected-window in a buffer-local variable, so that we
+can restore it later."
+  (let ((selected-window (selected-window))
+        (windows))
+    (walk-windows (lambda (w) (push w windows)) nil t)
+    (prog1 (pop-to-buffer (current-buffer))
+      (set (make-local-variable 'slime-popup-buffer-restore-info)
+           (list (unless (memq (selected-window) windows)
+                   (selected-window))
+                 selected-window)))))
+
 (define-minor-mode slime-popup-buffer-mode 
   "Mode for displaying read only stuff"
   nil
@@ -1078,8 +1089,13 @@
     ;;(when (slime-popup-buffer-snapshot-unchanged-p)
     ;;  (slime-popup-buffer-restore-snapshot))
     (setq slime-popup-buffer-saved-emacs-snapshot nil) ; buffer-local var!
-    (delete-windows-on buffer (selected-frame))
-    (bury-buffer buffer) 
+    (destructuring-bind (created-window selected-window) 
+        slime-popup-buffer-restore-info
+      (bury-buffer)
+      (when (eq created-window (selected-window))
+        (delete-window created-window))
+      (when (window-live-p selected-window)
+        (select-window selected-window)))
     (when kill-buffer-p
       (kill-buffer buffer))))
 
@@ -5599,16 +5615,17 @@
   '(("\C-c\C-c" . slime-edit-value-commit)))
 
 (defun slime-edit-value-callback (form-string current-value package)
-  (let ((name (generate-new-buffer-name (format "*Edit %s*" form-string))))
-    (with-current-buffer (slime-with-popup-buffer (name package t)
-                           (current-buffer))
-      (lisp-mode)
-      (slime-mode 1)
-      (slime-popup-buffer-mode -1)       ; don't want binding of 'q'
-      (slime-edit-value-mode 1)
-      (setq buffer-read-only nil)
-      (setq slime-edit-form-string form-string)
-      (insert current-value))))
+  (let* ((name (generate-new-buffer-name (format "*Edit %s*" form-string)))
+         (buffer (slime-with-popup-buffer (name package t)
+                  (lisp-mode)
+                  (slime-mode 1)
+                  (slime-popup-buffer-mode -1) ; don't want binding of 'q'
+                  (slime-edit-value-mode 1)
+                  (setq slime-edit-form-string form-string)
+                  (insert current-value)
+                  (current-buffer))))
+    (with-current-buffer buffer
+      (setq buffer-read-only nil))))
 
 (defun slime-edit-value-commit ()
   "Commit the edited value to the Lisp image.





More information about the slime-cvs mailing list