Mercurial > emacs
annotate lisp/register.el @ 110654:d631a67d1138
configure.in: Don't enable ImageMagick unless HAVE_X11.
author | Romain Francoise <romain@orebokech.com> |
---|---|
date | Wed, 29 Sep 2010 20:52:34 +0200 |
parents | 280c8ae2476d |
children | 417b1e4d63cd |
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 |
74442 | 3 ;; Copyright (C) 1985, 1993, 1994, 2001, 2002, 2003, 2004, |
106815 | 4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
845 | 5 |
789
71d052f72ac1
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
6 ;; Maintainer: FSF |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
7 ;; Keywords: internal |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
8 ;; Package: emacs |
789
71d052f72ac1
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
9 |
47 | 10 ;; This file is part of GNU Emacs. |
11 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
47 | 13 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; (at your option) any later version. |
47 | 16 |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
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 |
106034
4ff5c9cf147f
* register.el (jump-to-register, insert-register): Handle Semantic
Chong Yidong <cyd@stupidchicken.com>
parents:
105128
diff
changeset
|
32 (declare-function semantic-insert-foreign-tag "semantic/tag" (foreign-tag)) |
4ff5c9cf147f
* register.el (jump-to-register, insert-register): Handle Semantic
Chong Yidong <cyd@stupidchicken.com>
parents:
105128
diff
changeset
|
33 (declare-function semantic-tag-buffer "semantic/tag" (tag)) |
4ff5c9cf147f
* register.el (jump-to-register, insert-register): Handle Semantic
Chong Yidong <cyd@stupidchicken.com>
parents:
105128
diff
changeset
|
34 (declare-function semantic-tag-start "semantic/tag" (tag)) |
4ff5c9cf147f
* register.el (jump-to-register, insert-register): Handle Semantic
Chong Yidong <cyd@stupidchicken.com>
parents:
105128
diff
changeset
|
35 |
96441
40356b7a4808
Bind global keys to ctl-x-r-map in autoload cookies.
Juri Linkov <juri@jurta.org>
parents:
94678
diff
changeset
|
36 ;;; Global key bindings |
40356b7a4808
Bind global keys to ctl-x-r-map in autoload cookies.
Juri Linkov <juri@jurta.org>
parents:
94678
diff
changeset
|
37 |
105128
c4c3db18d05c
(ctl-x-r-map): Define the keys here instead of using autoload.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103249
diff
changeset
|
38 (define-key ctl-x-r-map "\C-@" 'point-to-register) |
c4c3db18d05c
(ctl-x-r-map): Define the keys here instead of using autoload.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103249
diff
changeset
|
39 (define-key ctl-x-r-map [?\C-\ ] 'point-to-register) |
c4c3db18d05c
(ctl-x-r-map): Define the keys here instead of using autoload.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103249
diff
changeset
|
40 (define-key ctl-x-r-map " " 'point-to-register) |
c4c3db18d05c
(ctl-x-r-map): Define the keys here instead of using autoload.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103249
diff
changeset
|
41 (define-key ctl-x-r-map "j" 'jump-to-register) |
c4c3db18d05c
(ctl-x-r-map): Define the keys here instead of using autoload.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103249
diff
changeset
|
42 (define-key ctl-x-r-map "s" 'copy-to-register) |
c4c3db18d05c
(ctl-x-r-map): Define the keys here instead of using autoload.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103249
diff
changeset
|
43 (define-key ctl-x-r-map "x" 'copy-to-register) |
c4c3db18d05c
(ctl-x-r-map): Define the keys here instead of using autoload.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103249
diff
changeset
|
44 (define-key ctl-x-r-map "i" 'insert-register) |
c4c3db18d05c
(ctl-x-r-map): Define the keys here instead of using autoload.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103249
diff
changeset
|
45 (define-key ctl-x-r-map "g" 'insert-register) |
c4c3db18d05c
(ctl-x-r-map): Define the keys here instead of using autoload.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103249
diff
changeset
|
46 (define-key ctl-x-r-map "r" 'copy-rectangle-to-register) |
c4c3db18d05c
(ctl-x-r-map): Define the keys here instead of using autoload.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103249
diff
changeset
|
47 (define-key ctl-x-r-map "n" 'number-to-register) |
c4c3db18d05c
(ctl-x-r-map): Define the keys here instead of using autoload.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103249
diff
changeset
|
48 (define-key ctl-x-r-map "+" 'increment-register) |
c4c3db18d05c
(ctl-x-r-map): Define the keys here instead of using autoload.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103249
diff
changeset
|
49 (define-key ctl-x-r-map "w" 'window-configuration-to-register) |
c4c3db18d05c
(ctl-x-r-map): Define the keys here instead of using autoload.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103249
diff
changeset
|
50 (define-key ctl-x-r-map "f" 'frame-configuration-to-register) |
96441
40356b7a4808
Bind global keys to ctl-x-r-map in autoload cookies.
Juri Linkov <juri@jurta.org>
parents:
94678
diff
changeset
|
51 |
789
71d052f72ac1
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
779
diff
changeset
|
52 ;;; Code: |
47 | 53 |
54 (defvar register-alist nil | |
55 "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
|
56 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
|
57 A list of strings represents a rectangle. |
103249
019c8b2b5898
* register.el (register-alist): Doc fix (Bug#3311).
Chong Yidong <cyd@stupidchicken.com>
parents:
102508
diff
changeset
|
58 A list of the form (file . FILE-NAME) represents the file named FILE-NAME. |
019c8b2b5898
* register.el (register-alist): Doc fix (Bug#3311).
Chong Yidong <cyd@stupidchicken.com>
parents:
102508
diff
changeset
|
59 A list of the form (file-query FILE-NAME POSITION) represents |
019c8b2b5898
* register.el (register-alist): Doc fix (Bug#3311).
Chong Yidong <cyd@stupidchicken.com>
parents:
102508
diff
changeset
|
60 position POSITION in the file named FILE-NAME, but query before |
019c8b2b5898
* register.el (register-alist): Doc fix (Bug#3311).
Chong Yidong <cyd@stupidchicken.com>
parents:
102508
diff
changeset
|
61 visiting it. |
20417
01d602ca5dcf
(frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents:
20324
diff
changeset
|
62 A list of the form (WINDOW-CONFIGURATION POSITION) |
01d602ca5dcf
(frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents:
20324
diff
changeset
|
63 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
|
64 A list of the form (FRAME-CONFIGURATION POSITION) |
01d602ca5dcf
(frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents:
20324
diff
changeset
|
65 represents a saved frame configuration plus a saved value of point.") |
47 | 66 |
102508
13b4ea6830b5
* register.el (get-register): Rename arg REG to REGISTER for
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
67 (defun get-register (register) |
13b4ea6830b5
* register.el (get-register): Rename arg REG to REGISTER for
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
68 "Return contents of Emacs register named REGISTER, or nil if none." |
13b4ea6830b5
* register.el (get-register): Rename arg REG to REGISTER for
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
69 (cdr (assq register register-alist))) |
47 | 70 |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
71 (defun set-register (register value) |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
72 "Set contents of Emacs register named REGISTER to VALUE. Returns VALUE. |
102508
13b4ea6830b5
* register.el (get-register): Rename arg REG to REGISTER for
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
73 See the documentation of the variable `register-alist' for possible VALUEs." |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
74 (let ((aelt (assq register register-alist))) |
47 | 75 (if aelt |
76 (setcdr aelt value) | |
47646
0e418919d79e
(set-register): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44677
diff
changeset
|
77 (push (cons register value) register-alist)) |
47 | 78 value)) |
79 | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
80 (defun point-to-register (register &optional arg) |
141 | 81 "Store current location of point in register REGISTER. |
779 | 82 With prefix argument, store current frame configuration. |
141 | 83 Use \\[jump-to-register] to go to that location or restore that configuration. |
47 | 84 Argument is a character, naming the register." |
141 | 85 (interactive "cPoint to register: \nP") |
47646
0e418919d79e
(set-register): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44677
diff
changeset
|
86 ;; Turn the marker into a file-ref if the buffer is killed. |
0e418919d79e
(set-register): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44677
diff
changeset
|
87 (add-hook 'kill-buffer-hook 'register-swap-out nil t) |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
88 (set-register register |
20417
01d602ca5dcf
(frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents:
20324
diff
changeset
|
89 (if arg (list (current-frame-configuration) (point-marker)) |
01d602ca5dcf
(frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents:
20324
diff
changeset
|
90 (point-marker)))) |
47 | 91 |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
92 (defun window-configuration-to-register (register &optional arg) |
820
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
93 "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
|
94 Use \\[jump-to-register] to restore the configuration. |
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
95 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
|
96 (interactive "cWindow configuration to register: \nP") |
20324
2365fc61875d
(window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents:
16279
diff
changeset
|
97 ;; current-window-configuration does not include the value |
2365fc61875d
(window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents:
16279
diff
changeset
|
98 ;; 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
|
99 (set-register register (list (current-window-configuration) (point-marker)))) |
820
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
100 |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
101 (defun frame-configuration-to-register (register &optional arg) |
820
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
102 "Store the window configuration of all frames in register REGISTER. |
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
103 Use \\[jump-to-register] to restore the configuration. |
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
104 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
|
105 (interactive "cFrame configuration to register: \nP") |
20324
2365fc61875d
(window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents:
16279
diff
changeset
|
106 ;; current-frame-configuration does not include the value |
2365fc61875d
(window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents:
16279
diff
changeset
|
107 ;; 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
|
108 (set-register register (list (current-frame-configuration) (point-marker)))) |
820
cd6b1e1da3fc
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
814
diff
changeset
|
109 |
2571
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2315
diff
changeset
|
110 (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
|
111 (defun jump-to-register (register &optional delete) |
47 | 112 "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
|
113 If the register contains a file name, find that file. |
102508
13b4ea6830b5
* register.el (get-register): Rename arg REG to REGISTER for
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
114 \(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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 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
|
120 \(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
|
121 (interactive "cJump to register: \nP") |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
122 (let ((val (get-register register))) |
2202
081afcef5e85
Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents:
1955
diff
changeset
|
123 (cond |
20324
2365fc61875d
(window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents:
16279
diff
changeset
|
124 ((and (consp val) (frame-configuration-p (car val))) |
2365fc61875d
(window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents:
16279
diff
changeset
|
125 (set-frame-configuration (car val) (not delete)) |
2365fc61875d
(window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents:
16279
diff
changeset
|
126 (goto-char (cadr val))) |
2365fc61875d
(window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents:
16279
diff
changeset
|
127 ((and (consp val) (window-configuration-p (car val))) |
2365fc61875d
(window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents:
16279
diff
changeset
|
128 (set-window-configuration (car val)) |
2365fc61875d
(window-configuration-to-register):
Karl Heuer <kwzh@gnu.org>
parents:
16279
diff
changeset
|
129 (goto-char (cadr val))) |
2202
081afcef5e85
Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents:
1955
diff
changeset
|
130 ((markerp val) |
6462
e58207907f53
(jump-to-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
6336
diff
changeset
|
131 (or (marker-buffer val) |
e58207907f53
(jump-to-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
6336
diff
changeset
|
132 (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
|
133 (switch-to-buffer (marker-buffer val)) |
081afcef5e85
Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents:
1955
diff
changeset
|
134 (goto-char val)) |
2699
83fee0378e0e
(jump-to-register): Allow file name "in" a register.
Richard M. Stallman <rms@gnu.org>
parents:
2571
diff
changeset
|
135 ((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
|
136 (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
|
137 ((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
|
138 (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
|
139 (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
|
140 (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
|
141 (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
|
142 (goto-char (nth 2 val))) |
106034
4ff5c9cf147f
* register.el (jump-to-register, insert-register): Handle Semantic
Chong Yidong <cyd@stupidchicken.com>
parents:
105128
diff
changeset
|
143 ((and (fboundp 'semantic-foreign-tag-p) |
4ff5c9cf147f
* register.el (jump-to-register, insert-register): Handle Semantic
Chong Yidong <cyd@stupidchicken.com>
parents:
105128
diff
changeset
|
144 semantic-mode |
4ff5c9cf147f
* register.el (jump-to-register, insert-register): Handle Semantic
Chong Yidong <cyd@stupidchicken.com>
parents:
105128
diff
changeset
|
145 (semantic-foreign-tag-p val)) |
4ff5c9cf147f
* register.el (jump-to-register, insert-register): Handle Semantic
Chong Yidong <cyd@stupidchicken.com>
parents:
105128
diff
changeset
|
146 (switch-to-buffer (semantic-tag-buffer val)) |
4ff5c9cf147f
* register.el (jump-to-register, insert-register): Handle Semantic
Chong Yidong <cyd@stupidchicken.com>
parents:
105128
diff
changeset
|
147 (goto-char (semantic-tag-start val))) |
2202
081afcef5e85
Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents:
1955
diff
changeset
|
148 (t |
081afcef5e85
Make frame configurations start with a distinctive symbol.
Jim Blandy <jimb@redhat.com>
parents:
1955
diff
changeset
|
149 (error "Register doesn't contain a buffer position or configuration"))))) |
47 | 150 |
16279
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
151 (defun register-swap-out () |
47646
0e418919d79e
(set-register): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44677
diff
changeset
|
152 "Turn markers into file-query references when a buffer is killed." |
16279
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
153 (and buffer-file-name |
47646
0e418919d79e
(set-register): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44677
diff
changeset
|
154 (dolist (elem register-alist) |
0e418919d79e
(set-register): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44677
diff
changeset
|
155 (and (markerp (cdr elem)) |
0e418919d79e
(set-register): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44677
diff
changeset
|
156 (eq (marker-buffer (cdr elem)) (current-buffer)) |
0e418919d79e
(set-register): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44677
diff
changeset
|
157 (setcdr elem |
0e418919d79e
(set-register): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44677
diff
changeset
|
158 (list 'file-query |
0e418919d79e
(set-register): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44677
diff
changeset
|
159 buffer-file-name |
0e418919d79e
(set-register): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44677
diff
changeset
|
160 (marker-position (cdr elem)))))))) |
16279
e69577ede89e
New kind of register value is a file name and position.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
161 |
20675
483ae4df691a
(number-to-register, increment-register): Args
Karl Heuer <kwzh@gnu.org>
parents:
20511
diff
changeset
|
162 (defun number-to-register (number register) |
20417
01d602ca5dcf
(frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents:
20324
diff
changeset
|
163 "Store a number in a register. |
01d602ca5dcf
(frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents:
20324
diff
changeset
|
164 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
|
165 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
|
166 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
|
167 Interactively, NUMBER is the prefix arg (none means nil)." |
01d602ca5dcf
(frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents:
20324
diff
changeset
|
168 (interactive "P\ncNumber to register: ") |
48451
c623c9adbefe
(describe-register-1): Don't assign to val the value returned by
Juanma Barranquero <lekktu@gmail.com>
parents:
47646
diff
changeset
|
169 (set-register register |
20675
483ae4df691a
(number-to-register, increment-register): Args
Karl Heuer <kwzh@gnu.org>
parents:
20511
diff
changeset
|
170 (if number |
483ae4df691a
(number-to-register, increment-register): Args
Karl Heuer <kwzh@gnu.org>
parents:
20511
diff
changeset
|
171 (prefix-numeric-value number) |
20430
1b4c829e2f42
(number-to-register): Move point as a side effect.
Karl Heuer <kwzh@gnu.org>
parents:
20417
diff
changeset
|
172 (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
|
173 (progn |
1b4c829e2f42
(number-to-register): Move point as a side effect.
Karl Heuer <kwzh@gnu.org>
parents:
20417
diff
changeset
|
174 (goto-char (match-end 0)) |
51057
afc4352d55f3
(number-to-register): Use `string-to-number' instead
John Paul Wallington <jpw@pobox.com>
parents:
49597
diff
changeset
|
175 (string-to-number (match-string 0))) |
20417
01d602ca5dcf
(frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents:
20324
diff
changeset
|
176 0)))) |
47 | 177 |
20675
483ae4df691a
(number-to-register, increment-register): Args
Karl Heuer <kwzh@gnu.org>
parents:
20511
diff
changeset
|
178 (defun increment-register (number register) |
20417
01d602ca5dcf
(frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents:
20324
diff
changeset
|
179 "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
|
180 Interactively, NUMBER is the prefix arg." |
20417
01d602ca5dcf
(frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents:
20324
diff
changeset
|
181 (interactive "p\ncIncrement register: ") |
20675
483ae4df691a
(number-to-register, increment-register): Args
Karl Heuer <kwzh@gnu.org>
parents:
20511
diff
changeset
|
182 (or (numberp (get-register register)) |
20417
01d602ca5dcf
(frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents:
20324
diff
changeset
|
183 (error "Register does not contain a number")) |
20675
483ae4df691a
(number-to-register, increment-register): Args
Karl Heuer <kwzh@gnu.org>
parents:
20511
diff
changeset
|
184 (set-register register (+ number (get-register register)))) |
47 | 185 |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
186 (defun view-register (register) |
47 | 187 "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
|
188 The Lisp value REGISTER is a character." |
47 | 189 (interactive "cView register: ") |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
190 (let ((val (get-register register))) |
47 | 191 (if (null val) |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
192 (message "Register %s is empty" (single-key-description register)) |
47 | 193 (with-output-to-temp-buffer "*Output*" |
43170
a2f11ee215ea
(list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents:
38412
diff
changeset
|
194 (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
|
195 |
43170
a2f11ee215ea
(list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents:
38412
diff
changeset
|
196 (defun list-registers () |
a2f11ee215ea
(list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents:
38412
diff
changeset
|
197 "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
|
198 (interactive) |
a2f11ee215ea
(list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents:
38412
diff
changeset
|
199 (let ((list (copy-sequence register-alist))) |
a2f11ee215ea
(list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents:
38412
diff
changeset
|
200 (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
|
201 (with-output-to-temp-buffer "*Output*" |
a2f11ee215ea
(list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents:
38412
diff
changeset
|
202 (dolist (elt list) |
a2f11ee215ea
(list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents:
38412
diff
changeset
|
203 (when (get-register (car elt)) |
a2f11ee215ea
(list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents:
38412
diff
changeset
|
204 (describe-register-1 (car elt)) |
a2f11ee215ea
(list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents:
38412
diff
changeset
|
205 (terpri)))))) |
a2f11ee215ea
(list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents:
38412
diff
changeset
|
206 |
a2f11ee215ea
(list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents:
38412
diff
changeset
|
207 (defun describe-register-1 (register &optional verbose) |
a2f11ee215ea
(list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents:
38412
diff
changeset
|
208 (princ "Register ") |
a2f11ee215ea
(list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents:
38412
diff
changeset
|
209 (princ (single-key-description register)) |
a2f11ee215ea
(list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents:
38412
diff
changeset
|
210 (princ " contains ") |
43291
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
211 (let ((val (get-register register))) |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
212 (cond |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
213 ((numberp val) |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
214 (princ val)) |
2203
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
215 |
43291
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
216 ((markerp val) |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
217 (let ((buf (marker-buffer val))) |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
218 (if (null buf) |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
219 (princ "a marker in no buffer") |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
220 (princ "a buffer position:\n buffer ") |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
221 (princ (buffer-name buf)) |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
222 (princ ", position ") |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
223 (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
|
224 |
43291
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
225 ((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
|
226 (princ "a window configuration.")) |
43170
a2f11ee215ea
(list-registers): New command.
Richard M. Stallman <rms@gnu.org>
parents:
38412
diff
changeset
|
227 |
43291
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
228 ((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
|
229 (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
|
230 |
43291
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
231 ((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
|
232 (princ "the file ") |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
233 (prin1 (cdr val)) |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
234 (princ ".")) |
3656
c57aec7e822b
(view-register): Handle file name values.
Richard M. Stallman <rms@gnu.org>
parents:
3039
diff
changeset
|
235 |
43291
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
236 ((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
|
237 (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
|
238 (prin1 (car (cdr val))) |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
239 (princ ",\n position ") |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
240 (princ (car (cdr (cdr val)))) |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
241 (princ ".")) |
20511
9a051580fa02
(view-register): Show register type file-query.
Richard M. Stallman <rms@gnu.org>
parents:
20430
diff
changeset
|
242 |
43291
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
243 ((consp val) |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
244 (if verbose |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
245 (progn |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
246 (princ "the rectangle:\n") |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
247 (while val |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
248 (princ " ") |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
249 (princ (car val)) |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
250 (terpri) |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
251 (setq val (cdr val)))) |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
252 (princ "a rectangle starting with ") |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
253 (princ (car val)))) |
2203
12e9bc8a4a7f
* register.el (view-register): Neglect not to avoid failing to
Jim Blandy <jimb@redhat.com>
parents:
2202
diff
changeset
|
254 |
43291
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
255 ((stringp val) |
60281
90ca0ff28286
(describe-register-1): Explicitly handle yank-excluded-properties = t.
Richard M. Stallman <rms@gnu.org>
parents:
54406
diff
changeset
|
256 (if (eq yank-excluded-properties t) |
90ca0ff28286
(describe-register-1): Explicitly handle yank-excluded-properties = t.
Richard M. Stallman <rms@gnu.org>
parents:
54406
diff
changeset
|
257 (set-text-properties 0 (length val) nil val) |
90ca0ff28286
(describe-register-1): Explicitly handle yank-excluded-properties = t.
Richard M. Stallman <rms@gnu.org>
parents:
54406
diff
changeset
|
258 (remove-list-of-text-properties 0 (length val) |
90ca0ff28286
(describe-register-1): Explicitly handle yank-excluded-properties = t.
Richard M. Stallman <rms@gnu.org>
parents:
54406
diff
changeset
|
259 yank-excluded-properties val)) |
43291
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
260 (if verbose |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
261 (progn |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
262 (princ "the text:\n") |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
263 (princ val)) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48715
diff
changeset
|
264 (cond |
48715
1e0c7ad65f05
(describe-register-1): Use window-width
Richard M. Stallman <rms@gnu.org>
parents:
48451
diff
changeset
|
265 ;; Extract first N characters starting with first non-whitespace. |
1e0c7ad65f05
(describe-register-1): Use window-width
Richard M. Stallman <rms@gnu.org>
parents:
48451
diff
changeset
|
266 ((string-match (format "[^ \t\n].\\{,%d\\}" |
1e0c7ad65f05
(describe-register-1): Use window-width
Richard M. Stallman <rms@gnu.org>
parents:
48451
diff
changeset
|
267 ;; Deduct 6 for the spaces inserted below. |
1e0c7ad65f05
(describe-register-1): Use window-width
Richard M. Stallman <rms@gnu.org>
parents:
48451
diff
changeset
|
268 (min 20 (max 0 (- (window-width) 6)))) |
1e0c7ad65f05
(describe-register-1): Use window-width
Richard M. Stallman <rms@gnu.org>
parents:
48451
diff
changeset
|
269 val) |
1e0c7ad65f05
(describe-register-1): Use window-width
Richard M. Stallman <rms@gnu.org>
parents:
48451
diff
changeset
|
270 (princ "text starting with\n ") |
1e0c7ad65f05
(describe-register-1): Use window-width
Richard M. Stallman <rms@gnu.org>
parents:
48451
diff
changeset
|
271 (princ (match-string 0 val))) |
1e0c7ad65f05
(describe-register-1): Use window-width
Richard M. Stallman <rms@gnu.org>
parents:
48451
diff
changeset
|
272 ((string-match "^[ \t\n]+$" val) |
1e0c7ad65f05
(describe-register-1): Use window-width
Richard M. Stallman <rms@gnu.org>
parents:
48451
diff
changeset
|
273 (princ "whitespace")) |
1e0c7ad65f05
(describe-register-1): Use window-width
Richard M. Stallman <rms@gnu.org>
parents:
48451
diff
changeset
|
274 (t |
1e0c7ad65f05
(describe-register-1): Use window-width
Richard M. Stallman <rms@gnu.org>
parents:
48451
diff
changeset
|
275 (princ "the empty string"))))) |
43291
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
276 (t |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
277 (princ "Garbage:\n") |
d6866cd43406
(describe-register-1): Access register contents here.
Richard M. Stallman <rms@gnu.org>
parents:
43170
diff
changeset
|
278 (if verbose (prin1 val)))))) |
47 | 279 |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
280 (defun insert-register (register &optional arg) |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
281 "Insert contents of register REGISTER. (REGISTER is a character.) |
47 | 282 Normally puts point before and mark after the inserted text. |
283 If optional second arg is non-nil, puts mark before and point after. | |
284 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
|
285 (interactive "*cInsert register: \nP") |
47 | 286 (push-mark) |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
287 (let ((val (get-register register))) |
6336
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
288 (cond |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
289 ((consp val) |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
290 (insert-rectangle val)) |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
291 ((stringp val) |
44677
b8ccc58cc821
(insert-register): Use insert-for-yank.
Richard M. Stallman <rms@gnu.org>
parents:
43291
diff
changeset
|
292 (insert-for-yank val)) |
20417
01d602ca5dcf
(frame-configuration-to-register)
Karl Heuer <kwzh@gnu.org>
parents:
20324
diff
changeset
|
293 ((numberp val) |
6336
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
294 (princ val (current-buffer))) |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
295 ((and (markerp val) (marker-position val)) |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
296 (princ (marker-position val) (current-buffer))) |
106034
4ff5c9cf147f
* register.el (jump-to-register, insert-register): Handle Semantic
Chong Yidong <cyd@stupidchicken.com>
parents:
105128
diff
changeset
|
297 ((and (fboundp 'semantic-foreign-tag-p) |
4ff5c9cf147f
* register.el (jump-to-register, insert-register): Handle Semantic
Chong Yidong <cyd@stupidchicken.com>
parents:
105128
diff
changeset
|
298 semantic-mode |
4ff5c9cf147f
* register.el (jump-to-register, insert-register): Handle Semantic
Chong Yidong <cyd@stupidchicken.com>
parents:
105128
diff
changeset
|
299 (semantic-foreign-tag-p val)) |
4ff5c9cf147f
* register.el (jump-to-register, insert-register): Handle Semantic
Chong Yidong <cyd@stupidchicken.com>
parents:
105128
diff
changeset
|
300 (semantic-insert-foreign-tag val)) |
6336
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
301 (t |
d7f922a411f9
(view-register, insert-register): Handle dead marker.
Karl Heuer <kwzh@gnu.org>
parents:
4932
diff
changeset
|
302 (error "Register does not contain text")))) |
47 | 303 (if (not arg) (exchange-point-and-mark))) |
304 | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
305 (defun copy-to-register (register start end &optional delete-flag) |
102508
13b4ea6830b5
* register.el (get-register): Rename arg REG to REGISTER for
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
306 "Copy region into register REGISTER. |
13b4ea6830b5
* register.el (get-register): Rename arg REG to REGISTER for
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
307 With prefix arg, delete as well. |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
308 Called from program, takes four args: REGISTER, START, END and DELETE-FLAG. |
47 | 309 START and END are buffer positions indicating what to copy." |
310 (interactive "cCopy to register: \nr\nP") | |
61112
c0f29f51c65c
(copy-to-register, append-to-register, prepend-to-register):
Richard M. Stallman <rms@gnu.org>
parents:
60281
diff
changeset
|
311 (set-register register (filter-buffer-substring start end)) |
47 | 312 (if delete-flag (delete-region start end))) |
313 | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
314 (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
|
315 "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
|
316 With prefix arg, delete as well. |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
317 Called from program, takes four args: REGISTER, START, END and DELETE-FLAG. |
47 | 318 START and END are buffer positions indicating what to append." |
319 (interactive "cAppend to register: \nr\nP") | |
85914
b51c8db87a41
(append-to-register, prepend-to-register):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78236
diff
changeset
|
320 (let ((reg (get-register register)) |
b51c8db87a41
(append-to-register, prepend-to-register):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78236
diff
changeset
|
321 (text (filter-buffer-substring start end))) |
b51c8db87a41
(append-to-register, prepend-to-register):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78236
diff
changeset
|
322 (set-register |
b51c8db87a41
(append-to-register, prepend-to-register):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78236
diff
changeset
|
323 register (cond ((not reg) text) |
b51c8db87a41
(append-to-register, prepend-to-register):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78236
diff
changeset
|
324 ((stringp reg) (concat reg text)) |
b51c8db87a41
(append-to-register, prepend-to-register):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78236
diff
changeset
|
325 (t (error "Register does not contain text"))))) |
47 | 326 (if delete-flag (delete-region start end))) |
327 | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
328 (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
|
329 "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
|
330 With prefix arg, delete as well. |
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
331 Called from program, takes four args: REGISTER, START, END and DELETE-FLAG. |
47 | 332 START and END are buffer positions indicating what to prepend." |
333 (interactive "cPrepend to register: \nr\nP") | |
85914
b51c8db87a41
(append-to-register, prepend-to-register):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78236
diff
changeset
|
334 (let ((reg (get-register register)) |
b51c8db87a41
(append-to-register, prepend-to-register):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78236
diff
changeset
|
335 (text (filter-buffer-substring start end))) |
b51c8db87a41
(append-to-register, prepend-to-register):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78236
diff
changeset
|
336 (set-register |
b51c8db87a41
(append-to-register, prepend-to-register):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78236
diff
changeset
|
337 register (cond ((not reg) text) |
b51c8db87a41
(append-to-register, prepend-to-register):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78236
diff
changeset
|
338 ((stringp reg) (concat text reg)) |
b51c8db87a41
(append-to-register, prepend-to-register):
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
78236
diff
changeset
|
339 (t (error "Register does not contain text"))))) |
47 | 340 (if delete-flag (delete-region start end))) |
341 | |
13009
a418156c25ea
Rename all register-name args to `register'.
Richard M. Stallman <rms@gnu.org>
parents:
8812
diff
changeset
|
342 (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
|
343 "Copy rectangular region into register REGISTER. |
102508
13b4ea6830b5
* register.el (get-register): Rename arg REG to REGISTER for
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
344 With prefix arg, delete as well. |
13b4ea6830b5
* register.el (get-register): Rename arg REG to REGISTER for
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
345 To insert this register in the buffer, use \\[insert-register]. |
53410
ce3a88ca37ee
(copy-rectangle-to-register): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
346 |
ce3a88ca37ee
(copy-rectangle-to-register): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
347 Called from a program, takes four args: REGISTER, START, END and DELETE-FLAG. |
47 | 348 START and END are buffer positions giving two corners of rectangle." |
349 (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
|
350 (set-register register |
47 | 351 (if delete-flag |
352 (delete-extract-rectangle start end) | |
353 (extract-rectangle start end)))) | |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
243
diff
changeset
|
354 |
54406
1647b704e48e
Provide `register' feature.
Masatake YAMATO <jet@gyve.org>
parents:
53410
diff
changeset
|
355 (provide 'register) |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
356 ;; arch-tag: ce14dd68-8265-475f-9341-5d4ec5a53035 |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
243
diff
changeset
|
357 ;;; register.el ends here |