unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* exchange-point-and-register
@ 2003-04-23 17:21 Masatake YAMATO
  2003-04-28  4:38 ` exchange-point-and-register Richard Stallman
  0 siblings, 1 reply; 2+ messages in thread
From: Masatake YAMATO @ 2003-04-23 17:21 UTC (permalink / raw)


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 @@
      (t
       (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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: exchange-point-and-register
  2003-04-23 17:21 exchange-point-and-register Masatake YAMATO
@ 2003-04-28  4:38 ` Richard Stallman
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Stallman @ 2003-04-28  4:38 UTC (permalink / raw)
  Cc: emacs-devel

This seems rather limited in usefulness to me.
Why do you particularly want to do this operation?

For instance, why not use two registers?
You could use C-x / a C-x j b, and later C-x /  b C-x j a.
Is there some specific reason why you need to use just one register?

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-04-28  4:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-23 17:21 exchange-point-and-register Masatake YAMATO
2003-04-28  4:38 ` exchange-point-and-register Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).