annotate lisp/register.el @ 45620:1ae71892eb5f

(read_minibuf): Cast `current_column' return value to int.
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Mon, 03 Jun 2002 01:42:52 +0000
parents b8ccc58cc821
children 0e418919d79e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 20675
diff changeset
1 ;;; register.el --- register commands for Emacs
658
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
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13009
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13009
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13009
diff changeset
23 ;; Boston, MA 02111-1307, USA.
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 (defvar register-alist nil
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 "Alist of elements (NAME . CONTENTS), one for each Emacs register.
20417
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
36 NAME is a character (a number). CONTENTS is a string, number, marker 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.
16279
e69577ede89e New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
38 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
39 A list of the form (file-query NAME POSITION) represents position POSITION
20417
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
40 in the file named NAME, but query before visiting it.
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
41 A list of the form (WINDOW-CONFIGURATION POSITION)
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
42 represents a saved window configuration plus a saved value of point.
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
43 A list of the form (FRAME-CONFIGURATION POSITION)
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
44 represents a saved frame configuration plus a saved value of point.")
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
46 (defun get-register (reg)
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
47 "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
48 (cdr (assq reg register-alist)))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
50 (defun set-register (register value)
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
51 "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
52 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
53 (let ((aelt (assq register register-alist)))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 (if aelt
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 (setcdr aelt value)
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
56 (setq aelt (cons register value))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 (setq register-alist (cons aelt register-alist)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 value))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
60 (defun point-to-register (register &optional arg)
141
405b4fa6de27 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 72
diff changeset
61 "Store current location of point in register REGISTER.
779
c2dbf1fe0506 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 658
diff changeset
62 With prefix argument, store current frame configuration.
141
405b4fa6de27 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 72
diff changeset
63 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
64 Argument is a character, naming the register."
141
405b4fa6de27 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 72
diff changeset
65 (interactive "cPoint to register: \nP")
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
66 (set-register register
20417
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
67 (if arg (list (current-frame-configuration) (point-marker))
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
68 (point-marker))))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
70 (defun window-configuration-to-register (register &optional arg)
820
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
71 "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
72 Use \\[jump-to-register] to restore the configuration.
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
73 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
74 (interactive "cWindow configuration to register: \nP")
20324
2365fc61875d (window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents: 16279
diff changeset
75 ;; current-window-configuration does not include the value
2365fc61875d (window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents: 16279
diff changeset
76 ;; of point in the current buffer, so record that separately.
20417
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
77 (set-register register (list (current-window-configuration) (point-marker))))
820
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
78
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
79 (defun frame-configuration-to-register (register &optional arg)
820
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
80 "Store the window configuration of all frames in register REGISTER.
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
81 Use \\[jump-to-register] to restore the configuration.
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
82 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
83 (interactive "cFrame configuration to register: \nP")
20324
2365fc61875d (window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents: 16279
diff changeset
84 ;; current-frame-configuration does not include the value
2365fc61875d (window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents: 16279
diff changeset
85 ;; of point in the current buffer, so record that separately.
20417
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
86 (set-register register (list (current-frame-configuration) (point-marker))))
820
cd6b1e1da3fc *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
87
2571
b65cf676a09b All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2315
diff changeset
88 (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
89 (defun jump-to-register (register &optional delete)
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 "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
91 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
92 \(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
93 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
94 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
95 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
96 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
97 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
98 \(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
99 (interactive "cJump to register: \nP")
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
100 (let ((val (get-register register)))
2202
081afcef5e85 Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents: 1955
diff changeset
101 (cond
20324
2365fc61875d (window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents: 16279
diff changeset
102 ((and (consp val) (frame-configuration-p (car val)))
2365fc61875d (window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents: 16279
diff changeset
103 (set-frame-configuration (car val) (not delete))
2365fc61875d (window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents: 16279
diff changeset
104 (goto-char (cadr val)))
2365fc61875d (window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents: 16279
diff changeset
105 ((and (consp val) (window-configuration-p (car val)))
2365fc61875d (window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents: 16279
diff changeset
106 (set-window-configuration (car val))
2365fc61875d (window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents: 16279
diff changeset
107 (goto-char (cadr val)))
2202
081afcef5e85 Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents: 1955
diff changeset
108 ((markerp val)
6462
e58207907f53 (jump-to-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 6336
diff changeset
109 (or (marker-buffer val)
e58207907f53 (jump-to-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 6336
diff changeset
110 (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
111 (switch-to-buffer (marker-buffer val))
081afcef5e85 Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents: 1955
diff changeset
112 (goto-char val))
2699
83fee0378e0e (jump-to-register): Allow file name "in" a register.
Richard M. Stallman <rms@gnu.org>
parents: 2571
diff changeset
113 ((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
114 (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
115 ((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
116 (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
117 (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
118 (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
119 (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
120 (goto-char (nth 2 val)))
2202
081afcef5e85 Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents: 1955
diff changeset
121 (t
081afcef5e85 Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents: 1955
diff changeset
122 (error "Register doesn't contain a buffer position or configuration")))))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123
16279
e69577ede89e New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
124 ;; 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
125 (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
126 (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
127 (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
128 (while tail
e69577ede89e New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
129 (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
130 (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
131 (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
132 (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
133 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
134 (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
135 (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
136
e69577ede89e New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
137 (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
138
20675
483ae4df691a (number-to-register, increment-register): Args
Karl Heuer <kwzh@gnu.org>
parents: 20511
diff changeset
139 (defun number-to-register (number register)
20417
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
140 "Store a number in a register.
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
141 Two args, NUMBER and REGISTER (a character, naming the register).
20430
1b4c829e2f42 (number-to-register): Move point as a side effect.
Karl Heuer <kwzh@gnu.org>
parents: 20417
diff changeset
142 If NUMBER is nil, a decimal number is read from the buffer starting
1b4c829e2f42 (number-to-register): Move point as a side effect.
Karl Heuer <kwzh@gnu.org>
parents: 20417
diff changeset
143 at point, and point moves to the end of that number.
20417
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
144 Interactively, NUMBER is the prefix arg (none means nil)."
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
145 (interactive "P\ncNumber to register: ")
20675
483ae4df691a (number-to-register, increment-register): Args
Karl Heuer <kwzh@gnu.org>
parents: 20511
diff changeset
146 (set-register register
483ae4df691a (number-to-register, increment-register): Args
Karl Heuer <kwzh@gnu.org>
parents: 20511
diff changeset
147 (if number
483ae4df691a (number-to-register, increment-register): Args
Karl Heuer <kwzh@gnu.org>
parents: 20511
diff changeset
148 (prefix-numeric-value number)
20430
1b4c829e2f42 (number-to-register): Move point as a side effect.
Karl Heuer <kwzh@gnu.org>
parents: 20417
diff changeset
149 (if (looking-at "\\s-*-?[0-9]+")
1b4c829e2f42 (number-to-register): Move point as a side effect.
Karl Heuer <kwzh@gnu.org>
parents: 20417
diff changeset
150 (progn
1b4c829e2f42 (number-to-register): Move point as a side effect.
Karl Heuer <kwzh@gnu.org>
parents: 20417
diff changeset
151 (goto-char (match-end 0))
1b4c829e2f42 (number-to-register): Move point as a side effect.
Karl Heuer <kwzh@gnu.org>
parents: 20417
diff changeset
152 (string-to-int (match-string 0)))
20417
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
153 0))))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154
20675
483ae4df691a (number-to-register, increment-register): Args
Karl Heuer <kwzh@gnu.org>
parents: 20511
diff changeset
155 (defun increment-register (number register)
20417
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
156 "Add NUMBER to the contents of register REGISTER.
20675
483ae4df691a (number-to-register, increment-register): Args
Karl Heuer <kwzh@gnu.org>
parents: 20511
diff changeset
157 Interactively, NUMBER is the prefix arg."
20417
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
158 (interactive "p\ncIncrement register: ")
20675
483ae4df691a (number-to-register, increment-register): Args
Karl Heuer <kwzh@gnu.org>
parents: 20511
diff changeset
159 (or (numberp (get-register register))
20417
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
160 (error "Register does not contain a number"))
20675
483ae4df691a (number-to-register, increment-register): Args
Karl Heuer <kwzh@gnu.org>
parents: 20511
diff changeset
161 (set-register register (+ number (get-register register))))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
163 (defun view-register (register)
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 "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
165 The Lisp value REGISTER is a character."
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 (interactive "cView register: ")
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
167 (let ((val (get-register register)))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (if (null val)
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
169 (message "Register %s is empty" (single-key-description register))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 (with-output-to-temp-buffer "*Output*"
43170
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
171 (describe-register-1 register t)))))
2203
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
172
43170
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
173 (defun list-registers ()
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
174 "Display a list of nonempty registers saying briefly what they contain."
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
175 (interactive)
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
176 (let ((list (copy-sequence register-alist)))
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
177 (setq list (sort list (lambda (a b) (< (car a) (car b)))))
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
178 (with-output-to-temp-buffer "*Output*"
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
179 (dolist (elt list)
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
180 (when (get-register (car elt))
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
181 (describe-register-1 (car elt))
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
182 (terpri))))))
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
183
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
184 (defun describe-register-1 (register &optional verbose)
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
185 (princ "Register ")
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
186 (princ (single-key-description register))
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
187 (princ " contains ")
43291
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
188 (let ((val (get-register register)))
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
189 (cond
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
190 ((numberp val)
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
191 (princ val))
2203
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
192
43291
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
193 ((markerp val)
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
194 (let ((buf (marker-buffer val)))
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
195 (if (null buf)
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
196 (princ "a marker in no buffer")
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
197 (princ "a buffer position:\n buffer ")
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
198 (princ (buffer-name buf))
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
199 (princ ", position ")
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
200 (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
201
43291
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
202 ((and (consp val) (window-configuration-p (car val)))
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
203 (princ "a window configuration."))
43170
a2f11ee215ea (list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents: 38412
diff changeset
204
43291
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
205 ((and (consp val) (frame-configuration-p (car val)))
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
206 (princ "a frame configuration."))
2203
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
207
43291
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
208 ((and (consp val) (eq (car val) 'file))
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
209 (princ "the file ")
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
210 (prin1 (cdr val))
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
211 (princ "."))
3656
c57aec7e822b (view-register): Handle file name values.
Richard M. Stallman <rms@gnu.org>
parents: 3039
diff changeset
212
43291
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
213 ((and (consp val) (eq (car val) 'file-query))
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
214 (princ "a file-query reference:\n file ")
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
215 (prin1 (car (cdr val)))
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
216 (princ ",\n position ")
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
217 (princ (car (cdr (cdr val))))
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
218 (princ "."))
20511
9a051580fa02 (view-register): Show register type file-query.
Richard M. Stallman <rms@gnu.org>
parents: 20430
diff changeset
219
43291
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
220 ((consp val)
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
221 (if verbose
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
222 (progn
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
223 (princ "the rectangle:\n")
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
224 (while val
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
225 (princ " ")
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
226 (princ (car val))
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
227 (terpri)
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
228 (setq val (cdr val))))
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
229 (princ "a rectangle starting with ")
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
230 (princ (car val))))
2203
12e9bc8a4a7f * register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents: 2202
diff changeset
231
43291
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
232 ((stringp val)
44677
b8ccc58cc821 (insert-register): Use insert-for-yank.
Richard M. Stallman <rms@gnu.org>
parents: 43291
diff changeset
233 (setq val
b8ccc58cc821 (insert-register): Use insert-for-yank.
Richard M. Stallman <rms@gnu.org>
parents: 43291
diff changeset
234 (remove-list-of-text-properties 0 (length val)
b8ccc58cc821 (insert-register): Use insert-for-yank.
Richard M. Stallman <rms@gnu.org>
parents: 43291
diff changeset
235 yank-excluded-properties val))
43291
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
236 (if verbose
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
237 (progn
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
238 (princ "the text:\n")
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
239 (princ val))
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
240 (princ "text starting with\n ")
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
241 (string-match "[^ \t\n].\\{,20\\}" val)
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
242 (princ (match-string 0 val))))
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
243 (t
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
244 (princ "Garbage:\n")
d6866cd43406 (describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents: 43170
diff changeset
245 (if verbose (prin1 val))))))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
247 (defun insert-register (register &optional arg)
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
248 "Insert contents of register REGISTER. (REGISTER is a character.)
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 Normally puts point before and mark after the inserted text.
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 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
251 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
252 (interactive "*cInsert register: \nP")
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (push-mark)
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
254 (let ((val (get-register register)))
6336
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
255 (cond
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
256 ((consp val)
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
257 (insert-rectangle val))
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
258 ((stringp val)
44677
b8ccc58cc821 (insert-register): Use insert-for-yank.
Richard M. Stallman <rms@gnu.org>
parents: 43291
diff changeset
259 (insert-for-yank val))
20417
01d602ca5dcf (frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents: 20324
diff changeset
260 ((numberp val)
6336
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
261 (princ val (current-buffer)))
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
262 ((and (markerp val) (marker-position val))
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
263 (princ (marker-position val) (current-buffer)))
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
264 (t
d7f922a411f9 (view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents: 4932
diff changeset
265 (error "Register does not contain text"))))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (if (not arg) (exchange-point-and-mark)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
268 (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
269 "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
270 Called from program, takes four args: REGISTER, START, END and DELETE-FLAG.
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 START and END are buffer positions indicating what to copy."
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (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
273 (set-register register (buffer-substring start end))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (if delete-flag (delete-region start end)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
276 (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
277 "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
278 With prefix arg, delete as well.
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
279 Called from program, takes four args: REGISTER, START, END and DELETE-FLAG.
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 START and END are buffer positions indicating what to append."
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (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
282 (or (stringp (get-register register))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (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
284 (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
285 (buffer-substring start end)))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (if delete-flag (delete-region start end)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
288 (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
289 "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
290 With prefix arg, delete as well.
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
291 Called from program, takes four args: REGISTER, START, END and DELETE-FLAG.
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 START and END are buffer positions indicating what to prepend."
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (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
294 (or (stringp (get-register register))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (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
296 (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
297 (get-register register)))
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (if delete-flag (delete-region start end)))
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299
13009
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
300 (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
301 "Copy rectangular region into register REGISTER.
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
302 With prefix arg, delete as well.
a418156c25ea Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents: 8812
diff changeset
303 Called from program, takes four args: REGISTER, START, END and DELETE-FLAG.
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 START and END are buffer positions giving two corners of rectangle."
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (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
306 (set-register register
47
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 (if delete-flag
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 (delete-extract-rectangle start end)
dfec464ac265 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (extract-rectangle start end))))
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 243
diff changeset
310
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 243
diff changeset
311 ;;; register.el ends here