annotate lisp/register.el @ 12103:5a4f4ce4ebb6

Delete version number. (s-region-bind): Doc fix. (s-region-move): Split into s-region-move and s-region-move-p1. (s-region-move-p2): New function. (s-region-move): Bind this-command. Bind keys to s-region-move-p1 or s-region-move-p2 as appropriate.
author Karl Heuer <kwzh@gnu.org>
date Wed, 07 Jun 1995 18:58:06 +0000
parents 36f7b14b38e3
children a418156c25ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
cc7cd83ccf3f Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 6462
diff changeset
3 ;; Copyright (C) 1985, 1993, 1994 Free Software Foundation, Inc.
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 820
diff changeset
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
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
2315
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2203
diff changeset
24 ;;; Commentary:
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2203
diff changeset
25
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2203
diff changeset
26 ;; 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
27 ;; 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
28 ;; 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
29 ;; documented in the Emacs user's manual.
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2203
diff changeset
30
789
71d052f72ac1 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 779
diff changeset
31 ;;; Code:
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 (defvar register-alist nil
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 "Alist of elements (NAME . CONTENTS), one for each Emacs register.
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 NAME is a character (a number). CONTENTS is a string, number,
779
c2dbf1fe0506 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 658
diff changeset
36 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
37 A list of strings represents a rectangle.
83fee0378e0e (jump-to-register): Allow file name "in" a register.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
38 A list of the form (file . NAME) represents the file named NAME.")
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 (defun get-register (char)
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 "Return contents of Emacs register named CHAR, or nil if none."
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 (cdr (assq char register-alist)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 (defun set-register (char value)
2699
83fee0378e0e (jump-to-register): Allow file name "in" a register.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
45 "Set contents of Emacs register named CHAR to VALUE. Returns VALUE.
83fee0378e0e (jump-to-register): Allow file name "in" a register.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
46 See the documentation of the variable `register-alist' for possible VALUE."
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 (let ((aelt (assq char register-alist)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 (if aelt
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 (setcdr aelt value)
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (setq aelt (cons char value))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 (setq register-alist (cons aelt register-alist)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 value))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53
1955
8ac912d2d369 (point-to-register): Make arg ARG optional.
Richard M. Stallman <rms@gnu.org>
parents: 845
diff changeset
54 (defun point-to-register (char &optional arg)
141
405b4fa6de27 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 72
diff changeset
55 "Store current location of point in register REGISTER.
779
c2dbf1fe0506 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 658
diff changeset
56 With prefix argument, store current frame configuration.
141
405b4fa6de27 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 72
diff changeset
57 Use \\[jump-to-register] to go to that location or restore that configuration.
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 Argument is a character, naming the register."
141
405b4fa6de27 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 72
diff changeset
59 (interactive "cPoint to register: \nP")
779
c2dbf1fe0506 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 658
diff changeset
60 (set-register char (if arg (current-frame-configuration) (point-marker))))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61
1955
8ac912d2d369 (point-to-register): Make arg ARG optional.
Richard M. Stallman <rms@gnu.org>
parents: 845
diff changeset
62 (defun window-configuration-to-register (char &optional arg)
820
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
63 "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
64 Use \\[jump-to-register] to restore the configuration.
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
65 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
66 (interactive "cWindow configuration to register: \nP")
820
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
67 (set-register char (current-window-configuration)))
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
68
1955
8ac912d2d369 (point-to-register): Make arg ARG optional.
Richard M. Stallman <rms@gnu.org>
parents: 845
diff changeset
69 (defun frame-configuration-to-register (char &optional arg)
820
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
70 "Store the window configuration of all frames in register REGISTER.
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
71 Use \\[jump-to-register] to restore the configuration.
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
72 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
73 (interactive "cFrame configuration to register: \nP")
820
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
74 (set-register char (current-frame-configuration)))
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
75
2571
b65cf676a09b All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2315
diff changeset
76 (defalias 'register-to-point 'jump-to-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
77 (defun jump-to-register (char &optional delete)
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 "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
79 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
80 \(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
81 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
82 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
83 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
84 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
85 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
86 \(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
87 (interactive "cJump to register: \nP")
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (let ((val (get-register char)))
2202
081afcef5e85 Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents: 1955
diff changeset
89 (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
90 ((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
91 (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
92 (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
93 ((window-configuration-p val)
081afcef5e85 Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents: 1955
diff changeset
94 (set-window-configuration val))
081afcef5e85 Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents: 1955
diff changeset
95 ((markerp val)
6462
e58207907f53 (jump-to-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 6336
diff changeset
96 (or (marker-buffer val)
e58207907f53 (jump-to-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 6336
diff changeset
97 (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
98 (switch-to-buffer (marker-buffer val))
081afcef5e85 Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents: 1955
diff changeset
99 (goto-char val))
2699
83fee0378e0e (jump-to-register): Allow file name "in" a register.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
100 ((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
101 (find-file (cdr val)))
2202
081afcef5e85 Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents: 1955
diff changeset
102 (t
081afcef5e85 Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents: 1955
diff changeset
103 (error "Register doesn't contain a buffer position or configuration")))))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 ;(defun number-to-register (arg char)
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ; "Store a number in a register.
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;Two args, NUMBER and REGISTER (a character, naming the register).
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ;If NUMBER is nil, digits in the buffer following point are read
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 ;to get the number to store.
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 ;Interactively, NUMBER is the prefix arg (none means nil)."
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 ; (interactive "P\ncNumber to register: ")
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 ; (set-register char
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ; (if arg
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 ; (prefix-numeric-value arg)
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ; (if (looking-at "[0-9][0-9]*")
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 ; (save-excursion
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ; (save-restriction
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ; (narrow-to-region (point)
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 ; (progn (skip-chars-forward "0-9")
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ; (point)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ; (goto-char (point-min))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ; (read (current-buffer))))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ; 0))))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ;(defun increment-register (arg char)
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 ; "Add NUMBER to the contents of register REGISTER.
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 ;Interactively, NUMBER is the prefix arg (none means nil)."
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ; (interactive "p\ncNumber to register: ")
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ; (or (integerp (get-register char))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 ; (error "Register does not contain a number"))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 ; (set-register char (+ arg (get-register char))))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (defun view-register (char)
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 "Display what is contained in register named REGISTER.
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 REGISTER is a character."
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (interactive "cView register: ")
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (let ((val (get-register char)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (if (null val)
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (message "Register %s is empty" (single-key-description char))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (with-output-to-temp-buffer "*Output*"
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (princ "Register ")
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (princ (single-key-description char))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (princ " contains ")
2203
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
144 (cond
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
145 ((integerp val)
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
146 (princ val))
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
147
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
148 ((markerp val)
6336
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
149 (let ((buf (marker-buffer val)))
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
150 (if (null buf)
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
151 (princ "a marker in no buffer")
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
152 (princ "a buffer position:\nbuffer ")
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
153 (princ (buffer-name buf))
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
154 (princ ", position ")
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
155 (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
156
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
157 ((window-configuration-p val)
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
158 (princ "a window configuration."))
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
159
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
160 ((frame-configuration-p val)
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
161 (princ "a frame configuration."))
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
162
3656
c57aec7e822b (view-register): Handle file name values.
Richard M. Stallman <rms@gnu.org>
parents: 3039
diff changeset
163 ((and (consp val) (eq (car val) 'file))
c57aec7e822b (view-register): Handle file name values.
Richard M. Stallman <rms@gnu.org>
parents: 3039
diff changeset
164 (princ "the file ")
c57aec7e822b (view-register): Handle file name values.
Richard M. Stallman <rms@gnu.org>
parents: 3039
diff changeset
165 (prin1 (cdr val))
c57aec7e822b (view-register): Handle file name values.
Richard M. Stallman <rms@gnu.org>
parents: 3039
diff changeset
166 (princ "."))
c57aec7e822b (view-register): Handle file name values.
Richard M. Stallman <rms@gnu.org>
parents: 3039
diff changeset
167
2203
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
168 ((consp val)
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
169 (princ "the rectangle:\n")
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
170 (while val
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
171 (princ (car val))
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
172 (terpri)
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
173 (setq val (cdr val))))
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
174
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
175 ((stringp val)
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
176 (princ "the text:\n")
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
177 (princ val))
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
178
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
179 (t
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
180 (princ "Garbage:\n")
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
181 (prin1 val)))))))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (defun insert-register (char &optional arg)
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 "Insert contents of register REG. REG is a character.
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 Normally puts point before and mark after the inserted text.
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 If optional second arg is non-nil, puts mark before and point after.
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 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
188 (interactive "*cInsert register: \nP")
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (push-mark)
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (let ((val (get-register char)))
6336
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
191 (cond
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
192 ((consp val)
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
193 (insert-rectangle val))
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
194 ((stringp val)
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
195 (insert val))
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
196 ((integerp val)
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
197 (princ val (current-buffer)))
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
198 ((and (markerp val) (marker-position val))
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
199 (princ (marker-position val) (current-buffer)))
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
200 (t
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
201 (error "Register does not contain text"))))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (if (not arg) (exchange-point-and-mark)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (defun copy-to-register (char start end &optional delete-flag)
243
6155e428f077 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 151
diff changeset
205 "Copy region into register REG. With prefix arg, delete as well.
6155e428f077 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 151
diff changeset
206 Called from program, takes four args: REG, START, END and DELETE-FLAG.
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 START and END are buffer positions indicating what to copy."
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (interactive "cCopy to register: \nr\nP")
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (set-register char (buffer-substring start end))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (if delete-flag (delete-region start end)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (defun append-to-register (char start end &optional delete-flag)
243
6155e428f077 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 151
diff changeset
213 "Append region to text in register REG. With prefix arg, delete as well.
6155e428f077 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 151
diff changeset
214 Called from program, takes four args: REG, START, END and DELETE-FLAG.
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 START and END are buffer positions indicating what to append."
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (interactive "cAppend to register: \nr\nP")
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (or (stringp (get-register char))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (error "Register does not contain text"))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (set-register char (concat (get-register char)
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (buffer-substring start end)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (if delete-flag (delete-region start end)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (defun prepend-to-register (char start end &optional delete-flag)
243
6155e428f077 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 151
diff changeset
224 "Prepend region to text in register REG. With prefix arg, delete as well.
6155e428f077 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 151
diff changeset
225 Called from program, takes four args: REG, START, END and DELETE-FLAG.
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 START and END are buffer positions indicating what to prepend."
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (interactive "cPrepend to register: \nr\nP")
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (or (stringp (get-register char))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (error "Register does not contain text"))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (set-register char (concat (buffer-substring start end)
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (get-register char)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (if delete-flag (delete-region start end)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (defun copy-rectangle-to-register (char start end &optional delete-flag)
243
6155e428f077 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 151
diff changeset
235 "Copy rectangular region into register REG. With prefix arg, delete as well.
6155e428f077 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 151
diff changeset
236 Called from program, takes four args: REG, START, END and DELETE-FLAG.
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 START and END are buffer positions giving two corners of rectangle."
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (interactive "cCopy rectangle to register: \nr\nP")
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (set-register char
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 (if delete-flag
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 (delete-extract-rectangle start end)
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 (extract-rectangle start end))))
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 243
diff changeset
243
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 243
diff changeset
244 ;;; register.el ends here