Mercurial > emacs
annotate lisp/register.el @ 19483:51345fa7e08b
(sgml-mode-common): Set paragraph-start like paragraph-separate.
Do match a line which is just a <...> construct after whitespac.e
Set adaptive-fill-regexp to match whitespace only.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 23 Aug 1997 06:12:46 +0000 |
parents | e69577ede89e |
children | 2365fc61875d |
rev | line source |
---|---|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
243
diff
changeset
|
1 ;;; register.el --- register commands for Emacs. |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
243
diff
changeset
|
2 |
7300 | 3 ;; Copyright (C) 1985, 1993, 1994 Free Software Foundation, Inc. |
845 | 4 |
789
71d052f72ac1
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
5 ;; Maintainer: FSF |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
6 ;; Keywords: internal |
789
71d052f72ac1
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
7 |
47 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
789
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
47 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
14169 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
47 | 24 |
2315
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2203
diff
changeset
|
25 ;;; Commentary: |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2203
diff
changeset
|
26 |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2203
diff
changeset
|
27 ;; This package of functions emulates and somewhat extends the venerable |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2203
diff
changeset
|
28 ;; TECO's `register' feature, which permits you to save various useful |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2203
diff
changeset
|
29 ;; pieces of buffer state to named variables. The entry points are |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2203
diff
changeset
|
30 ;; documented in the Emacs user's manual. |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2203
diff
changeset
|
31 |
789
71d052f72ac1
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
32 ;;; Code: |
47 | 33 |
34 (defvar register-alist nil | |
35 "Alist of elements (NAME . CONTENTS), one for each Emacs register. | |
36 NAME is a character (a number). CONTENTS is a string, number, | |
779 | 37 frame configuration, mark or list. |
2699
83fee0378e0e
(jump-to-register): Allow file name "in" a register.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
38 A list of strings represents a rectangle. |
16279
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
39 A list of the form (file . NAME) represents the file named NAME. |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
40 A list of the form (file-query NAME POSITION) represents position POSITION |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
41 in the file named NAME, but query before visiting it.") |
47 | 42 |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
43 (defun get-register (reg) |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
44 "Return contents of Emacs register named REG, or nil if none." |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
45 (cdr (assq reg register-alist))) |
47 | 46 |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
47 (defun set-register (register value) |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
48 "Set contents of Emacs register named REGISTER to VALUE. Returns VALUE. |
2699
83fee0378e0e
(jump-to-register): Allow file name "in" a register.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
49 See the documentation of the variable `register-alist' for possible VALUE." |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
50 (let ((aelt (assq register register-alist))) |
47 | 51 (if aelt |
52 (setcdr aelt value) | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
53 (setq aelt (cons register value)) |
47 | 54 (setq register-alist (cons aelt register-alist))) |
55 value)) | |
56 | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
57 (defun point-to-register (register &optional arg) |
141 | 58 "Store current location of point in register REGISTER. |
779 | 59 With prefix argument, store current frame configuration. |
141 | 60 Use \\[jump-to-register] to go to that location or restore that configuration. |
47 | 61 Argument is a character, naming the register." |
141 | 62 (interactive "cPoint to register: \nP") |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
63 (set-register register |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
64 (if arg (current-frame-configuration) (point-marker)))) |
47 | 65 |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
66 (defun window-configuration-to-register (register &optional arg) |
820
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
67 "Store the window configuration of the selected frame in register REGISTER. |
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
68 Use \\[jump-to-register] to restore the configuration. |
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
69 Argument is a character, naming the register." |
4669
e212db4385f9
({window,frame}-configuration-to-register): Fix prompt string in
Roland McGrath <roland@gnu.org>
parents:
3656
diff
changeset
|
70 (interactive "cWindow configuration to register: \nP") |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
71 (set-register register (current-window-configuration))) |
820
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
72 |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
73 (defun frame-configuration-to-register (register &optional arg) |
820
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
74 "Store the window configuration of all frames in register REGISTER. |
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
75 Use \\[jump-to-register] to restore the configuration. |
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
76 Argument is a character, naming the register." |
4669
e212db4385f9
({window,frame}-configuration-to-register): Fix prompt string in
Roland McGrath <roland@gnu.org>
parents:
3656
diff
changeset
|
77 (interactive "cFrame configuration to register: \nP") |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
78 (set-register register (current-frame-configuration))) |
820
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
79 |
2571
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2315
diff
changeset
|
80 (defalias 'register-to-point 'jump-to-register) |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
81 (defun jump-to-register (register &optional delete) |
47 | 82 "Move point to location stored in a register. |
2699
83fee0378e0e
(jump-to-register): Allow file name "in" a register.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
83 If the register contains a file name, find that file. |
83fee0378e0e
(jump-to-register): Allow file name "in" a register.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
84 \(To put a file name in a register, you must use `set-register'.) |
820
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
85 If the register contains a window configuration (one frame) or a frame |
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
86 configuration (all frames), restore that frame or all frames accordingly. |
4671
3c5e001c9d60
(jump-to-register): Take new optional arg NODELETE (prefix arg); pass
Roland McGrath <roland@gnu.org>
parents:
4669
diff
changeset
|
87 First argument is a character, naming the register. |
4931
ad035a2d8e26
(jump-to-register): Rename prefix arg to DELETE and invert its sense.
Richard M. Stallman <rms@gnu.org>
parents:
4671
diff
changeset
|
88 Optional second arg non-nil (interactively, prefix argument) says to |
ad035a2d8e26
(jump-to-register): Rename prefix arg to DELETE and invert its sense.
Richard M. Stallman <rms@gnu.org>
parents:
4671
diff
changeset
|
89 delete any existing frames that the frame configuration doesn't mention. |
4932
5986d619b4ca
(jump-to-register): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
4931
diff
changeset
|
90 \(Otherwise, these frames are iconified.)" |
4671
3c5e001c9d60
(jump-to-register): Take new optional arg NODELETE (prefix arg); pass
Roland McGrath <roland@gnu.org>
parents:
4669
diff
changeset
|
91 (interactive "cJump to register: \nP") |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
92 (let ((val (get-register register))) |
2202
081afcef5e85
Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents:
1955
diff
changeset
|
93 (cond |
3039
7520bbbe9100
(jump-to-register): Don't fail if frame-configuration-p is unbound.
Richard M. Stallman <rms@gnu.org>
parents:
2699
diff
changeset
|
94 ((and (fboundp 'frame-configuration-p) |
7520bbbe9100
(jump-to-register): Don't fail if frame-configuration-p is unbound.
Richard M. Stallman <rms@gnu.org>
parents:
2699
diff
changeset
|
95 (frame-configuration-p val)) |
4931
ad035a2d8e26
(jump-to-register): Rename prefix arg to DELETE and invert its sense.
Richard M. Stallman <rms@gnu.org>
parents:
4671
diff
changeset
|
96 (set-frame-configuration val (not delete))) |
2202
081afcef5e85
Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents:
1955
diff
changeset
|
97 ((window-configuration-p val) |
081afcef5e85
Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents:
1955
diff
changeset
|
98 (set-window-configuration val)) |
081afcef5e85
Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents:
1955
diff
changeset
|
99 ((markerp val) |
6462
e58207907f53
(jump-to-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
6336
diff
changeset
|
100 (or (marker-buffer val) |
e58207907f53
(jump-to-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
6336
diff
changeset
|
101 (error "That register's buffer no longer exists")) |
2202
081afcef5e85
Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents:
1955
diff
changeset
|
102 (switch-to-buffer (marker-buffer val)) |
081afcef5e85
Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents:
1955
diff
changeset
|
103 (goto-char val)) |
2699
83fee0378e0e
(jump-to-register): Allow file name "in" a register.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
104 ((and (consp val) (eq (car val) 'file)) |
83fee0378e0e
(jump-to-register): Allow file name "in" a register.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
105 (find-file (cdr val))) |
16279
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
106 ((and (consp val) (eq (car val) 'file-query)) |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
107 (or (find-buffer-visiting (nth 1 val)) |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
108 (y-or-n-p (format "Visit file %s again? " (nth 1 val))) |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
109 (error "Register access aborted")) |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
110 (find-file (nth 1 val)) |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
111 (goto-char (nth 2 val))) |
2202
081afcef5e85
Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents:
1955
diff
changeset
|
112 (t |
081afcef5e85
Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents:
1955
diff
changeset
|
113 (error "Register doesn't contain a buffer position or configuration"))))) |
47 | 114 |
16279
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
115 ;; Turn markers into file-query references when a buffer is killed. |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
116 (defun register-swap-out () |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
117 (and buffer-file-name |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
118 (let ((tail register-alist)) |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
119 (while tail |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
120 (and (markerp (cdr (car tail))) |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
121 (eq (marker-buffer (cdr (car tail))) (current-buffer)) |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
122 (setcdr (car tail) |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
123 (list 'file-query |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
124 buffer-file-name |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
125 (marker-position (cdr (car tail)))))) |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
126 (setq tail (cdr tail)))))) |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
127 |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
128 (add-hook 'kill-buffer-hook 'register-swap-out) |
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
129 |
47 | 130 ;(defun number-to-register (arg char) |
131 ; "Store a number in a register. | |
132 ;Two args, NUMBER and REGISTER (a character, naming the register). | |
133 ;If NUMBER is nil, digits in the buffer following point are read | |
134 ;to get the number to store. | |
135 ;Interactively, NUMBER is the prefix arg (none means nil)." | |
136 ; (interactive "P\ncNumber to register: ") | |
137 ; (set-register char | |
138 ; (if arg | |
139 ; (prefix-numeric-value arg) | |
140 ; (if (looking-at "[0-9][0-9]*") | |
141 ; (save-excursion | |
142 ; (save-restriction | |
143 ; (narrow-to-region (point) | |
144 ; (progn (skip-chars-forward "0-9") | |
145 ; (point))) | |
146 ; (goto-char (point-min)) | |
147 ; (read (current-buffer)))) | |
148 ; 0)))) | |
149 | |
150 ;(defun increment-register (arg char) | |
151 ; "Add NUMBER to the contents of register REGISTER. | |
152 ;Interactively, NUMBER is the prefix arg (none means nil)." | |
153 ; (interactive "p\ncNumber to register: ") | |
154 ; (or (integerp (get-register char)) | |
155 ; (error "Register does not contain a number")) | |
156 ; (set-register char (+ arg (get-register char)))) | |
157 | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
158 (defun view-register (register) |
47 | 159 "Display what is contained in register named REGISTER. |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
160 The Lisp value REGISTER is a character." |
47 | 161 (interactive "cView register: ") |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
162 (let ((val (get-register register))) |
47 | 163 (if (null val) |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
164 (message "Register %s is empty" (single-key-description register)) |
47 | 165 (with-output-to-temp-buffer "*Output*" |
166 (princ "Register ") | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
167 (princ (single-key-description register)) |
47 | 168 (princ " contains ") |
2203
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
169 (cond |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
170 ((integerp val) |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
171 (princ val)) |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
172 |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
173 ((markerp val) |
6336
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
174 (let ((buf (marker-buffer val))) |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
175 (if (null buf) |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
176 (princ "a marker in no buffer") |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
177 (princ "a buffer position:\nbuffer ") |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
178 (princ (buffer-name buf)) |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
179 (princ ", position ") |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
180 (princ (marker-position val))))) |
2203
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
181 |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
182 ((window-configuration-p val) |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
183 (princ "a window configuration.")) |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
184 |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
185 ((frame-configuration-p val) |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
186 (princ "a frame configuration.")) |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
187 |
3656
c57aec7e822b
(view-register): Handle file name values.
Richard M. Stallman <rms@gnu.org>
parents:
3039
diff
changeset
|
188 ((and (consp val) (eq (car val) 'file)) |
c57aec7e822b
(view-register): Handle file name values.
Richard M. Stallman <rms@gnu.org>
parents:
3039
diff
changeset
|
189 (princ "the file ") |
c57aec7e822b
(view-register): Handle file name values.
Richard M. Stallman <rms@gnu.org>
parents:
3039
diff
changeset
|
190 (prin1 (cdr val)) |
c57aec7e822b
(view-register): Handle file name values.
Richard M. Stallman <rms@gnu.org>
parents:
3039
diff
changeset
|
191 (princ ".")) |
c57aec7e822b
(view-register): Handle file name values.
Richard M. Stallman <rms@gnu.org>
parents:
3039
diff
changeset
|
192 |
2203
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
193 ((consp val) |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
194 (princ "the rectangle:\n") |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
195 (while val |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
196 (princ (car val)) |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
197 (terpri) |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
198 (setq val (cdr val)))) |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
199 |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
200 ((stringp val) |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
201 (princ "the text:\n") |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
202 (princ val)) |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
203 |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
204 (t |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
205 (princ "Garbage:\n") |
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
206 (prin1 val))))))) |
47 | 207 |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
208 (defun insert-register (register &optional arg) |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
209 "Insert contents of register REGISTER. (REGISTER is a character.) |
47 | 210 Normally puts point before and mark after the inserted text. |
211 If optional second arg is non-nil, puts mark before and point after. | |
212 Interactively, second arg is non-nil if prefix arg is supplied." | |
8812
36f7b14b38e3
(insert-register): Add `*' interactive spec.
Karl Heuer <kwzh@gnu.org>
parents:
7300
diff
changeset
|
213 (interactive "*cInsert register: \nP") |
47 | 214 (push-mark) |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
215 (let ((val (get-register register))) |
6336
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
216 (cond |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
217 ((consp val) |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
218 (insert-rectangle val)) |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
219 ((stringp val) |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
220 (insert val)) |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
221 ((integerp val) |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
222 (princ val (current-buffer))) |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
223 ((and (markerp val) (marker-position val)) |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
224 (princ (marker-position val) (current-buffer))) |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
225 (t |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
226 (error "Register does not contain text")))) |
47 | 227 (if (not arg) (exchange-point-and-mark))) |
228 | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
229 (defun copy-to-register (register start end &optional delete-flag) |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
230 "Copy region into register REGISTER. With prefix arg, delete as well. |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
231 Called from program, takes four args: REGISTER, START, END and DELETE-FLAG. |
47 | 232 START and END are buffer positions indicating what to copy." |
233 (interactive "cCopy to register: \nr\nP") | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
234 (set-register register (buffer-substring start end)) |
47 | 235 (if delete-flag (delete-region start end))) |
236 | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
237 (defun append-to-register (register start end &optional delete-flag) |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
238 "Append region to text in register REGISTER. |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
239 With prefix arg, delete as well. |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
240 Called from program, takes four args: REGISTER, START, END and DELETE-FLAG. |
47 | 241 START and END are buffer positions indicating what to append." |
242 (interactive "cAppend to register: \nr\nP") | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
243 (or (stringp (get-register register)) |
47 | 244 (error "Register does not contain text")) |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
245 (set-register register (concat (get-register register) |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
246 (buffer-substring start end))) |
47 | 247 (if delete-flag (delete-region start end))) |
248 | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
249 (defun prepend-to-register (register start end &optional delete-flag) |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
250 "Prepend region to text in register REGISTER. |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
251 With prefix arg, delete as well. |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
252 Called from program, takes four args: REGISTER, START, END and DELETE-FLAG. |
47 | 253 START and END are buffer positions indicating what to prepend." |
254 (interactive "cPrepend to register: \nr\nP") | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
255 (or (stringp (get-register register)) |
47 | 256 (error "Register does not contain text")) |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
257 (set-register register (concat (buffer-substring start end) |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
258 (get-register register))) |
47 | 259 (if delete-flag (delete-region start end))) |
260 | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
261 (defun copy-rectangle-to-register (register start end &optional delete-flag) |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
262 "Copy rectangular region into register REGISTER. |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
263 With prefix arg, delete as well. |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
264 Called from program, takes four args: REGISTER, START, END and DELETE-FLAG. |
47 | 265 START and END are buffer positions giving two corners of rectangle." |
266 (interactive "cCopy rectangle to register: \nr\nP") | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
267 (set-register register |
47 | 268 (if delete-flag |
269 (delete-extract-rectangle start end) | |
270 (extract-rectangle start end)))) | |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
243
diff
changeset
|
271 |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
243
diff
changeset
|
272 ;;; register.el ends here |