[slime-devel] [Patch] Improve slime-edit-definition-other-window and ...-frame

Matthias Koeppe mkoeppe+slime at mail.math.uni-magdeburg.de
Sun Mar 27 15:15:22 UTC 2005


Hi,

I am sending a little patch that improves the commands
slime-edit-definition-other-window and ...-frame.  Would someone like
to merge it into CVS?

Cheers,
Matthias

2005-03-27  Matthias Koeppe  <mkoeppe at mail.math.uni-magdeburg.de>

	* slime.el (slime-keys): Bind slime-edit-definition-other-window
	to `C-x 4 .' and slime-edit-definition-other-frame to `C-x 5 .',
	shadowing the equivalent find-tag... bindings.
	(slime-goto-definition-other-window-aux): New function,
	adapted from the Emacs function find-tag-other-window.
	(slime-goto-definition): In the other-window and other-frame cases,
	make sure point does not move in the originating window, even when
	the definition is found in the same buffer.

--- slime.el.~1.473.~	2005-03-27 16:35:04.000000000 +0200
+++ slime.el	2005-03-27 17:02:06.000000000 +0200
@@ -555,6 +555,8 @@
     ("\C-i" slime-complete-symbol :prefixed t :inferior t)
     ("\M-i" slime-fuzzy-complete-symbol :prefixed t :inferior t)
     ("\M-." slime-edit-definition :inferior t :sldb t)
+    ("\C-x4." slime-edit-definition-other-window :inferior t :sldb t)
+    ("\C-x5." slime-edit-definition-other-frame :inferior t :sldb t)
     ("\M-," slime-pop-find-definition-stack :inferior t :sldb t)
     ("\M-*" slime-pop-find-definition-stack :inferior t :sldb t)
     ("\C-q" slime-close-parens-at-point :prefixed t :inferior t)
@@ -5122,18 +5124,41 @@
           (error "No known definition for: %s" name))
       (slime-goto-definition name definitions where))))
 
+(defun slime-goto-definition-other-window-aux (definition)
+  ;; Taken from the Emacs function `find-tag-other-window':
+  ;; This hair is to deal with the case where the tag is found in the
+  ;; selected window's buffer; without the hair, point is moved in both
+  ;; windows.  To prevent this, we save the selected window's point before
+  ;; doing find-tag-noselect, and restore it after.
+  (let ((window-point (window-point (selected-window))))
+    (slime-goto-source-location (slime-definition.location
+                                 definition))
+    (let ((tagbuf (current-buffer))
+          (tagpoint (point)))
+      (set-window-point (prog1
+                            (selected-window)
+                          (switch-to-buffer-other-window tagbuf)
+                          ;; We have to set this new window's point; it
+                          ;; might already have been displaying a
+                          ;; different portion of tagbuf, in which case
+                          ;; switch-to-buffer-other-window doesn't set
+                          ;; the window's point from the buffer.
+                          (set-window-point (selected-window) tagpoint))
+                        window-point))))
+
 (defun slime-goto-definition (name definitions &optional where)
   (slime-push-definition-stack)
   (cond ((slime-length> definitions 1)
          (slime-show-definitions name definitions))
         (t
-         (slime-goto-source-location (slime-definition.location
-                                      (car definitions)))
          (cond ((equal where 'window)
-                (switch-to-buffer-other-window (current-buffer)))
+                (slime-goto-definition-other-window-aux (car definitions)))
                ((equal where 'frame)
-                (switch-to-buffer-other-frame (current-buffer)))
+                (let ((pop-up-frames t))
+                  (slime-goto-definition-other-window-aux (car definitions))))
                (t
+                (slime-goto-source-location (slime-definition.location
+                                             (car definitions)))
                 (switch-to-buffer (current-buffer)))))))
 
 (defun slime-edit-definition-other-window (name)

-- 
Matthias Koeppe -- http://www.math.uni-magdeburg.de/~mkoeppe



More information about the slime-devel mailing list