aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1997-12-04 06:14:04 +0000
committerKarl Heuer1997-12-04 06:14:04 +0000
commit070c25062342b2b299e644463fb6d95b9421694e (patch)
tree2f8911d85c85fba303cd6ee5b97d20c4d1686ec0
parentbdb45de9fc75fb0cbcc6b1a1e123557ffdedb106 (diff)
downloademacs-070c25062342b2b299e644463fb6d95b9421694e.tar.gz
emacs-070c25062342b2b299e644463fb6d95b9421694e.zip
(frame-configuration-to-register)
(window-configuration-to-register): Use a marker to save point. (point-to-register): Include point when saving a frame config. (number-to-register): New command (was commented out). (increment-register): New command (view-register): Handle frame configs and window configs included in a list with a pointer. (view-register, insert-register): Use numberp, not integerp.
-rw-r--r--lisp/register.el78
1 files changed, 41 insertions, 37 deletions
diff --git a/lisp/register.el b/lisp/register.el
index 54a64ef52d8..69f33ca4b24 100644
--- a/lisp/register.el
+++ b/lisp/register.el
@@ -33,12 +33,15 @@
33 33
34(defvar register-alist nil 34(defvar register-alist nil
35 "Alist of elements (NAME . CONTENTS), one for each Emacs register. 35 "Alist of elements (NAME . CONTENTS), one for each Emacs register.
36NAME is a character (a number). CONTENTS is a string, number, 36NAME is a character (a number). CONTENTS is a string, number, marker or list.
37frame configuration, mark or list.
38A list of strings represents a rectangle. 37A list of strings represents a rectangle.
39A list of the form (file . NAME) represents the file named NAME. 38A list of the form (file . NAME) represents the file named NAME.
40A list of the form (file-query NAME POSITION) represents position POSITION 39A list of the form (file-query NAME POSITION) represents position POSITION
41 in the file named NAME, but query before visiting it.") 40 in the file named NAME, but query before visiting it.
41A list of the form (WINDOW-CONFIGURATION POSITION)
42 represents a saved window configuration plus a saved value of point.
43A list of the form (FRAME-CONFIGURATION POSITION)
44 represents a saved frame configuration plus a saved value of point.")
42 45
43(defun get-register (reg) 46(defun get-register (reg)
44 "Return contents of Emacs register named REG, or nil if none." 47 "Return contents of Emacs register named REG, or nil if none."
@@ -61,7 +64,8 @@ Use \\[jump-to-register] to go to that location or restore that configuration.
61Argument is a character, naming the register." 64Argument is a character, naming the register."
62 (interactive "cPoint to register: \nP") 65 (interactive "cPoint to register: \nP")
63 (set-register register 66 (set-register register
64 (if arg (current-frame-configuration) (point-marker)))) 67 (if arg (list (current-frame-configuration) (point-marker))
68 (point-marker))))
65 69
66(defun window-configuration-to-register (register &optional arg) 70(defun window-configuration-to-register (register &optional arg)
67 "Store the window configuration of the selected frame in register REGISTER. 71 "Store the window configuration of the selected frame in register REGISTER.
@@ -70,7 +74,7 @@ Argument is a character, naming the register."
70 (interactive "cWindow configuration to register: \nP") 74 (interactive "cWindow configuration to register: \nP")
71 ;; current-window-configuration does not include the value 75 ;; current-window-configuration does not include the value
72 ;; of point in the current buffer, so record that separately. 76 ;; of point in the current buffer, so record that separately.
73 (set-register register (list (current-window-configuration) (point)))) 77 (set-register register (list (current-window-configuration) (point-marker))))
74 78
75(defun frame-configuration-to-register (register &optional arg) 79(defun frame-configuration-to-register (register &optional arg)
76 "Store the window configuration of all frames in register REGISTER. 80 "Store the window configuration of all frames in register REGISTER.
@@ -79,7 +83,7 @@ Argument is a character, naming the register."
79 (interactive "cFrame configuration to register: \nP") 83 (interactive "cFrame configuration to register: \nP")
80 ;; current-frame-configuration does not include the value 84 ;; current-frame-configuration does not include the value
81 ;; of point in the current buffer, so record that separately. 85 ;; of point in the current buffer, so record that separately.
82 (set-register register (list (current-frame-configuration) (point)))) 86 (set-register register (list (current-frame-configuration) (point-marker))))
83 87
84(defalias 'register-to-point 'jump-to-register) 88(defalias 'register-to-point 'jump-to-register)
85(defun jump-to-register (register &optional delete) 89(defun jump-to-register (register &optional delete)
@@ -132,33 +136,33 @@ delete any existing frames that the frame configuration doesn't mention.
132 136
133(add-hook 'kill-buffer-hook 'register-swap-out) 137(add-hook 'kill-buffer-hook 'register-swap-out)
134 138
135;(defun number-to-register (arg char) 139(defun number-to-register (arg char)
136; "Store a number in a register. 140 "Store a number in a register.
137;Two args, NUMBER and REGISTER (a character, naming the register). 141Two args, NUMBER and REGISTER (a character, naming the register).
138;If NUMBER is nil, digits in the buffer following point are read 142If NUMBER is nil, digits in the buffer following point are read
139;to get the number to store. 143to get the number to store.
140;Interactively, NUMBER is the prefix arg (none means nil)." 144Interactively, NUMBER is the prefix arg (none means nil)."
141; (interactive "P\ncNumber to register: ") 145 (interactive "P\ncNumber to register: ")
142; (set-register char 146 (set-register char
143; (if arg 147 (if arg
144; (prefix-numeric-value arg) 148 (prefix-numeric-value arg)
145; (if (looking-at "[0-9][0-9]*") 149 (if (looking-at "[0-9][0-9]*")
146; (save-excursion 150 (save-excursion
147; (save-restriction 151 (save-restriction
148; (narrow-to-region (point) 152 (narrow-to-region (point)
149; (progn (skip-chars-forward "0-9") 153 (progn (skip-chars-forward "0-9")
150; (point))) 154 (point)))
151; (goto-char (point-min)) 155 (goto-char (point-min))
152; (read (current-buffer)))) 156 (read (current-buffer))))
153; 0)))) 157 0))))
154 158
155;(defun increment-register (arg char) 159(defun increment-register (arg char)
156; "Add NUMBER to the contents of register REGISTER. 160 "Add NUMBER to the contents of register REGISTER.
157;Interactively, NUMBER is the prefix arg (none means nil)." 161Interactively, NUMBER is the prefix arg (none means nil)."
158; (interactive "p\ncNumber to register: ") 162 (interactive "p\ncIncrement register: ")
159; (or (integerp (get-register char)) 163 (or (numberp (get-register char))
160; (error "Register does not contain a number")) 164 (error "Register does not contain a number"))
161; (set-register char (+ arg (get-register char)))) 165 (set-register char (+ arg (get-register char))))
162 166
163(defun view-register (register) 167(defun view-register (register)
164 "Display what is contained in register named REGISTER. 168 "Display what is contained in register named REGISTER.
@@ -172,7 +176,7 @@ The Lisp value REGISTER is a character."
172 (princ (single-key-description register)) 176 (princ (single-key-description register))
173 (princ " contains ") 177 (princ " contains ")
174 (cond 178 (cond
175 ((integerp val) 179 ((numberp val)
176 (princ val)) 180 (princ val))
177 181
178 ((markerp val) 182 ((markerp val)
@@ -184,10 +188,10 @@ The Lisp value REGISTER is a character."
184 (princ ", position ") 188 (princ ", position ")
185 (princ (marker-position val))))) 189 (princ (marker-position val)))))
186 190
187 ((window-configuration-p val) 191 ((and (consp val) (window-configuration-p (car val)))
188 (princ "a window configuration.")) 192 (princ "a window configuration."))
189 193
190 ((frame-configuration-p val) 194 ((and (consp val) (frame-configuration-p (car val)))
191 (princ "a frame configuration.")) 195 (princ "a frame configuration."))
192 196
193 ((and (consp val) (eq (car val) 'file)) 197 ((and (consp val) (eq (car val) 'file))
@@ -223,7 +227,7 @@ Interactively, second arg is non-nil if prefix arg is supplied."
223 (insert-rectangle val)) 227 (insert-rectangle val))
224 ((stringp val) 228 ((stringp val)
225 (insert val)) 229 (insert val))
226 ((integerp val) 230 ((numberp val)
227 (princ val (current-buffer))) 231 (princ val (current-buffer)))
228 ((and (markerp val) (marker-position val)) 232 ((and (markerp val) (marker-position val))
229 (princ (marker-position val) (current-buffer))) 233 (princ (marker-position val) (current-buffer)))