diff options
author | Richard M. Stallman <rms@gnu.org> | 1996-09-22 05:09:27 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1996-09-22 05:09:27 +0000 |
commit | 5ad47ed797dc056232125e35d160797fc3a018ee (patch) | |
tree | 2b8535b52de5eddb2b5629fc39527dad9adaaac4 | |
parent | 18d5cd63bc0d662e0cd5b9052e161e727095d3a6 (diff) | |
download | emacs-5ad47ed797dc056232125e35d160797fc3a018ee.tar.gz |
New kind of register value is a file name and position.
(jump-to-register): Handle file-query.
(register-swap-out): New function. Add it to kill-buffer-hook.
(register-alist): Doc fix.
-rw-r--r-- | lisp/register.el | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lisp/register.el b/lisp/register.el index 54851f0bbe1..32cd981bdca 100644 --- a/lisp/register.el +++ b/lisp/register.el @@ -36,7 +36,9 @@ 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." @@ -101,9 +103,30 @@ delete any existing frames that the frame configuration doesn't mention. (goto-char val)) ((and (consp val) (eq (car val) 'file)) (find-file (cdr val))) + ((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))) (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 () + (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) + ;(defun number-to-register (arg char) ; "Store a number in a register. ;Two args, NUMBER and REGISTER (a character, naming the register). |