[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Masatake YAMATO
Subject: exchange-point-and-register
Date: Thu, 24 Apr 2003 02:21:22 +0900 (JST)

Sometimes I want to go back to the last point just after jumping to a
position where a register specifies. So I wrote a function attached to
this mail. Is this good for official emacs source tree?

I added
+(provide 'register)

for my listreg.el. listreg.el is extended version of
list-register function. 

Masatake YAMATO

Index: lisp/register.el
RCS file: /cvsroot/emacs/emacs/lisp/register.el,v
retrieving revision 1.44
diff -u -r1.44 register.el
--- lisp/register.el    4 Feb 2003 12:00:00 -0000       1.44
+++ lisp/register.el    23 Apr 2003 17:13:59 -0000
@@ -122,6 +122,28 @@
       (error "Register doesn't contain a buffer position or configuration")))))
+(defun exchange-point-and-register (register &optional delete)
+  "Do `jump-to-register' and store the last point or window/frame 
configuration to REGISTER."
+  (interactive "cExchange with register: \nP")
+  (let ((val (get-register register)))
+    (cond
+     ((and (consp val) (frame-configuration-p (car val)))
+      (frame-configuration-to-register register)
+      (set-frame-configuration (car val) (not delete))
+      (goto-char (cadr val)))
+     ((and (consp val) (window-configuration-p (car val)))
+      (window-configuration-to-register register)
+      (set-window-configuration (car val))
+      (goto-char (cadr val)))
+     ((markerp val)
+      (or (marker-buffer val)
+         (error "That register's buffer no longer exists"))
+      (point-to-register register)
+      (switch-to-buffer (marker-buffer val))
+      (goto-char val))
+     (t
+      (error "Register doesn't contain a buffer position or configuration")))))
 (defun register-swap-out ()
   "Turn markers into file-query references when a buffer is killed."
   (and buffer-file-name
@@ -313,4 +335,5 @@
                    (delete-extract-rectangle start end)
                  (extract-rectangle start end))))
+(provide 'register)
 ;;; register.el ends here

reply via email to

[Prev in Thread] Current Thread [Next in Thread]