# HG changeset patch # User Stefan Monnier # Date 1033148858 0 # Node ID 0e418919d79e199341066fe5f3d01c96ce4973a6 # Parent d033b85fc797b1113cee8fcaea465ade5a85dca6 (set-register): Use push. (point-to-register): Set kill-buffer-hook in this buffer. (register-swap-out): Use dolist. (kill-buffer-hook): Don't change globally. diff -r d033b85fc797 -r 0e418919d79e lisp/register.el --- a/lisp/register.el Fri Sep 27 17:43:29 2002 +0000 +++ b/lisp/register.el Fri Sep 27 17:47:38 2002 +0000 @@ -53,8 +53,7 @@ (let ((aelt (assq register register-alist))) (if aelt (setcdr aelt value) - (setq aelt (cons register value)) - (setq register-alist (cons aelt register-alist))) + (push (cons register value) register-alist)) value)) (defun point-to-register (register &optional arg) @@ -63,6 +62,8 @@ Use \\[jump-to-register] to go to that location or restore that configuration. Argument is a character, naming the register." (interactive "cPoint to register: \nP") + ;; Turn the marker into a file-ref if the buffer is killed. + (add-hook 'kill-buffer-hook 'register-swap-out nil t) (set-register register (if arg (list (current-frame-configuration) (point-marker)) (point-marker)))) @@ -121,20 +122,16 @@ (t (error "Register doesn't contain a buffer position or configuration"))))) -;; Turn markers into file-query references when a buffer is killed. (defun register-swap-out () + "Turn markers into file-query references when a buffer is killed." (and buffer-file-name - (let ((tail register-alist)) - (while tail - (and (markerp (cdr (car tail))) - (eq (marker-buffer (cdr (car tail))) (current-buffer)) - (setcdr (car tail) - (list 'file-query - buffer-file-name - (marker-position (cdr (car tail)))))) - (setq tail (cdr tail)))))) - -(add-hook 'kill-buffer-hook 'register-swap-out) + (dolist (elem register-alist) + (and (markerp (cdr elem)) + (eq (marker-buffer (cdr elem)) (current-buffer)) + (setcdr elem + (list 'file-query + buffer-file-name + (marker-position (cdr elem)))))))) (defun number-to-register (number register) "Store a number in a register.