NAME is a character (a number). CONTENTS is a string, number,
frame configuration, mark or list.
A list of strings represents a rectangle.
-A list of the form (file . NAME) represents the file named NAME.")
+A list of the form (file . NAME) represents the file named NAME.
+A list of the form (file-query NAME POSITION) represents position POSITION
+ in the file named NAME, but query before visiting it.")
(defun get-register (reg)
"Return contents of Emacs register named REG, or nil if none."
((and (consp val) (eq (car val) 'file))
+ ((and (consp val) (eq (car val) 'file-query))
+ (or (find-buffer-visiting (nth 1 val))
+ (y-or-n-p (format "Visit file %s again? " (nth 1 val)))
+ (error "Register access aborted"))
+ (find-file (nth 1 val))
+ (goto-char (nth 2 val)))
(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 ()
+ (let ((tail register-alist))
+ (and (markerp (cdr (car tail)))
+ (eq (marker-buffer (cdr (car tail))) (current-buffer))
+ (marker-position (cdr (car tail))))))
+ (setq tail (cdr tail))))))
+(add-hook 'kill-buffer-hook 'register-swap-out)
;(defun number-to-register (arg char)
; "Store a number in a register.
;Two args, NUMBER and REGISTER (a character, naming the register).