annotate lisp/kmacro.el @ 47137:cecbc6fb52f0

(x_specified_cursor_type): Removed. (x_set_cursor_type): Use set_frame_cursor_types.
author Kim F. Storm <storm@cua.dk>
date Fri, 30 Aug 2002 12:01:27 +0000
parents cbc107c19e30
children 5a8754f590f4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
1 ;;; kmacro.el --- enhanced keyboard macros
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
2
46085
33538dc6ac79 Fixed copyright and keywords.
Kim F. Storm <storm@cua.dk>
parents: 46083
diff changeset
3 ;; Copyright (C) 2002 Free Software Foundation, Inc.
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
4
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
5 ;; Author: Kim F. Storm <storm@cua.dk>
46085
33538dc6ac79 Fixed copyright and keywords.
Kim F. Storm <storm@cua.dk>
parents: 46083
diff changeset
6 ;; Keywords: keyboard convenience
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
7
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
9
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
13 ;; any later version.
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
14
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
18 ;; GNU General Public License for more details.
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
19
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
24
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
25 ;;; Commentary:
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
26
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
27 ;; The kmacro package is an alternative user interface to emacs'
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
28 ;; keyboard macro functionality. This functionality is normally bound
46099
d441fc235798 Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46085
diff changeset
29 ;; to C-x (, C-x ), and C-x e, but these bindings are too hard to
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
30 ;; type to be really useful for doing small repeated tasks.
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
31
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
32 ;; With kmacro, two function keys are dedicated to keyboard macros,
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
33 ;; by default F3 and F4. Personally, I prefer F1 and F2, but those
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
34 ;; keys already have default bindings.
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
35 ;;
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
36 ;; To start defining a keyboard macro, use F3. To end the macro,
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
37 ;; use F4, and to call the macro also use F4. This makes it very
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
38 ;; easy to repeat a macro immediately after defining it.
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
39 ;;
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
40 ;; You can call the macro repeatedly by pressing F4 multiple times, or
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
41 ;; you can give a numeric prefix argument specifying the number of
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
42 ;; times to repeat the macro. Macro execution automatically
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
43 ;; terminates when point reaches the end of the buffer or if an error
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
44 ;; is signalled by ringing the bell.
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
45
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
46 ;; When you define a macro with F3/F4, it is automatically added to
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
47 ;; the head of the "keyboard macro ring", and F4 actually executes the
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
48 ;; first element of the macro ring.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
49 ;;
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
50 ;; Note: an empty macro is never added to the macro ring.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
51 ;;
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
52 ;; You can execute the second element on the macro ring with C-u F4 or
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
53 ;; C-x C-k C-l, you can use C-x C-k C-p and C-x C-k C-n to cycle
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
54 ;; through the macro ring, and you can swap the first and second
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
55 ;; elements with C-x C-k C-t. To delete the first element in the
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
56 ;; macro ring, use C-x C-k C-d.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
57 ;;
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
58 ;;
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
59 ;; You can also use C-x C-k C-s to start a macro, and C-x C-k C-k to
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
60 ;; end it; then use C-k to execute it immediately, or C-x C-k C-k to
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
61 ;; execute it later.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
62 ;;
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
63 ;; In general, immediately after using C-x C-k followed by one of C-k,
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
64 ;; C-l, C-p, or C-n, you can further cycle the macro ring using C-p or
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
65 ;; C-n, execute the first or second macro using C-k or C-l, delete
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
66 ;; the head macro with C-d, or edit the current macro with C-e without
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
67 ;; repeating the C-x C-k prefix.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
68
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
69 ;; If you enter F3 while defining the macro, the numeric value of
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
70 ;; `kmacro-counter' is inserted using the `kmacro-counter-format', and
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
71 ;; `kmacro-counter' is incremented by 1 (or the numeric prefix value
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
72 ;; of F3).
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
73 ;;
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
74 ;; The initial value of `kmacro-counter' is 0, or the numeric prefix
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
75 ;; value given to F3 when starting the macro.
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
76 ;;
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
77 ;; Now, each time you call the macro using F4, the current
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
78 ;; value of `kmacro-counter' is inserted and incremented, making it
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
79 ;; easy to insert incremental numbers in the buffer.
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
80 ;;
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
81 ;; Example:
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
82 ;;
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
83 ;; The following sequence: M-5 F3 x M-2 F3 y F4 F4 F4 F4
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
84 ;; inserts the following string: x5yx7yx9yx11y
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
85
46099
d441fc235798 Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46085
diff changeset
86 ;; A macro can also be called using a mouse click, default S-mouse-3.
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
87 ;; This calls the macro at the point where you click the mouse.
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
88
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
89 ;; You can edit the last macro using C-x C-k C-e.
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
90
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
91 ;; You can append to the last macro using C-u F3.
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
92
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
93 ;; You can set the macro counter using C-x C-k C-c, add to it using C-x C-k C-a,
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
94 ;; and you can set the macro counter format with C-x C-k C-f.
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
95
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
96 ;; The following key bindings are performed:
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
97 ;;
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
98 ;; Normal While defining macro
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
99 ;; --------------------------- ------------------------------
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
100 ;; f3 Define macro Insert current counter value
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
101 ;; Prefix arg specifies initial and increase counter by prefix
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
102 ;; counter value (default 0) (default increment: 1)
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
103 ;;
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
104 ;; C-u f3 APPENDs to last macro
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
105 ;;
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
106 ;; f4 Call last macro End macro
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
107 ;; Prefix arg specifies number
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
108 ;; of times to execute macro.
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
109 ;;
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
110 ;; C-u f4 Swap last and head of macro ring.
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
111 ;;
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
112 ;; S-mouse-3 Set point at click and End macro and execute macro at
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
113 ;; execute last macro. click.
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
114
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
115 ;;; Code:
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
116
46099
d441fc235798 Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46085
diff changeset
117 ;; Customization:
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
118
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
119 (defgroup kmacro nil
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
120 "Simplified keyboard macro user interface."
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
121 :group 'keyboard
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
122 :group 'convenience
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
123 :link '(emacs-commentary-link :tag "Commentary" "kmacro.el")
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
124 :link '(emacs-library-link :tag "Lisp File" "kmacro.el"))
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
125
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
126 (defcustom kmacro-call-mouse-event 'S-mouse-3
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
127 "The mouse event used by kmacro to call a macro.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
128 Set to nil if no mouse binding is desired."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
129 :type 'symbol
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
130 :group 'kmacro)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
131
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
132 (defcustom kmacro-ring-max 8
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
133 "Maximum number of keyboard macros to save in macro ring."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
134 :type 'integer
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
135 :group 'kmacro)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
136
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
137
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
138 (defcustom kmacro-execute-before-append t
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
139 "Controls whether appending to a macro starts by executing the macro.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
140 If non-nil, using a single \\[universal-argument] prefix executes the macro
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
141 before appending, while more than one \\[universal-argument] prefix does not
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
142 execute the macro.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
143 Otherwise, a single \\[universal-argument] prefix does not execute the
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
144 macro, while more than one \\[universal-argument] prefix causes the
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
145 macro to be executed before appending to it."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
146 :type 'boolean
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
147 :group 'kmacro)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
148
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
149
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
150 (defcustom kmacro-repeat-no-prefix t
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
151 "Allow repeating certain macro commands without entering the C-x C-k prefix."
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
152 :type 'boolean
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
153 :group 'kmacro)
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
154
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
155 (defcustom kmacro-call-repeat-key t
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
156 "Allow repeating macro call using last key or a specific key."
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
157 :type '(choice (const :tag "Disabled" nil)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
158 (const :tag "Last key" t)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
159 (character :tag "Character" :value ?e)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
160 (symbol :tag "Key symbol" :value RET))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
161 :group 'kmacro)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
162
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
163 (defcustom kmacro-call-repeat-with-arg nil
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
164 "Repeat macro call with original arg when non-nil; repeat once if nil."
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
165 :type 'boolean
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
166 :group 'kmacro)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
167
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
168
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
169 ;; Keymap
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
170
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
171 (defvar kmacro-keymap
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
172 (let ((map (make-sparse-keymap)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
173 (define-key map "\C-s" 'kmacro-start-macro)
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
174 (define-key map "\C-k" 'kmacro-end-or-call-macro-repeat)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
175 (define-key map "\C-e" 'kmacro-edit-macro-repeat)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
176 (define-key map "\r" 'kmacro-edit-macro)
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
177 (define-key map "l" 'kmacro-edit-lossage)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
178 (define-key map "\C-i" 'kmacro-insert-counter)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
179 (define-key map "\C-a" 'kmacro-add-counter)
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
180 (define-key map "\C-v" 'kmacro-view-macro-repeat)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
181 (define-key map "\C-l" 'kmacro-call-ring-2nd-repeat)
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
182 (define-key map "\C-r" 'kmacro-view-ring-2nd)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
183 (define-key map "\C-n" 'kmacro-cycle-ring-next)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
184 (define-key map "\C-p" 'kmacro-cycle-ring-previous)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
185 (define-key map "\C-f" 'kmacro-set-format)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
186 (define-key map "\C-c" 'kmacro-set-counter)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
187 (define-key map "\C-t" 'kmacro-swap-ring)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
188 (define-key map "\C-b" 'kmacro-bind-to-key)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
189 (define-key map "\C-d" 'kmacro-delete-ring-head)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
190 ;; Compatibility bindings
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
191 (define-key map "q" 'kbd-macro-query)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
192 (define-key map "n" 'name-last-kbd-macro)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
193 (define-key map "e" 'edit-kbd-macro)
46972
88b4ed0b18c9 Bind C-x C-k r to apply-macro-to-region-lines.
Kim F. Storm <storm@cua.dk>
parents: 46961
diff changeset
194 (define-key map "r" 'apply-macro-to-region-lines)
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
195 map)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
196 "Keymap for keyboard macro commands.")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
197 (defalias 'kmacro-keymap kmacro-keymap)
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
198
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
199 ;;; Provide some binding for startup:
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
200 ;;;###autoload (global-set-key "\C-x(" 'kmacro-start-macro)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
201 ;;;###autoload (global-set-key "\C-x)" 'kmacro-end-macro)
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
202 ;;;###autoload (global-set-key "\C-xe" 'kmacro-end-or-call-macro)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
203 ;;;###autoload (global-set-key [f3] 'kmacro-start-macro-or-insert-counter)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
204 ;;;###autoload (global-set-key [f4] 'kmacro-end-or-call-macro)
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
205 ;;;###autoload (global-set-key "\C-x\C-k" 'kmacro-keymap)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
206 ;;;###autoload (autoload 'kmacro-keymap "kmacro" "Keymap for keyboard macro commands." t 'keymap)
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
207
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
208 (if kmacro-call-mouse-event
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
209 (global-set-key (vector kmacro-call-mouse-event) 'kmacro-end-call-mouse))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
210
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
211
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
212
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
213 ;;; Keyboard macro counter
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
214
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
215 (defvar kmacro-counter 0
46099
d441fc235798 Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46085
diff changeset
216 "*Current keyboard macro counter.")
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
217
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
218 (defvar kmacro-counter-format "%d"
46099
d441fc235798 Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46085
diff changeset
219 "*Current keyboard macro counter format.")
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
220
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
221 (defvar kmacro-counter-format-start kmacro-counter-format
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
222 "Macro format at start of macro execution.")
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
223
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
224 (defvar kmacro-counter-value-start kmacro-counter
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
225 "Macro counter at start of macro execution.")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
226
46099
d441fc235798 Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46085
diff changeset
227 (defvar kmacro-last-counter 0 "Last counter inserted by key macro.")
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
228
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
229
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
230 (defun kmacro-insert-counter (arg)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
231 "Insert macro counter and increment with ARG or 1 if missing.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
232 With \\[universal-argument], insert previous kmacro-counter (but do not modify counter)."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
233 (interactive "P")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
234 (if (and arg (listp arg))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
235 (insert (format kmacro-counter-format kmacro-last-counter))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
236 (insert (format kmacro-counter-format kmacro-counter))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
237 (kmacro-add-counter (prefix-numeric-value arg))))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
238
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
239
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
240 (defun kmacro-set-format (format)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
241 "Set macro counter FORMAT."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
242 (interactive "sMacro Counter Format (printf format): ")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
243 (setq kmacro-counter-format
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
244 (if (equal format "") "%d" format))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
245 ;; redefine initial macro counter if we are not executing a macro.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
246 (if (not (or defining-kbd-macro executing-kbd-macro))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
247 (setq kmacro-counter-format-start kmacro-counter-format)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
248
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
249
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
250 (defun kmacro-display-counter (&optional value)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
251 "Display current counter value."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
252 (unless value (setq value kmacro-counter))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
253 (message "New macro counter value: %s (%d)" (format kmacro-counter-format value) value))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
254
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
255
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
256 (defun kmacro-set-counter (arg)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
257 "Set kmacro-counter to ARG or prompt if missing.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
258 With \\[universal-argument], reset counter to its value prior to this iteration of the macro."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
259 (interactive "NMacro counter value: ")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
260 (setq kmacro-last-counter kmacro-counter
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
261 kmacro-counter (if (and current-prefix-arg (listp current-prefix-arg))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
262 kmacro-counter-value-start
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
263 arg))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
264 (unless executing-kbd-macro
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
265 (kmacro-display-counter)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
266
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
267
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
268 (defun kmacro-add-counter (arg)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
269 "Add numeric prefix arg (prompt if missing) to macro counter.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
270 With \\[universal-argument], restore previous counter value."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
271 (interactive "NAdd to macro counter: ")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
272 (let ((last kmacro-last-counter))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
273 (setq kmacro-last-counter kmacro-counter
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
274 kmacro-counter (if (and current-prefix-arg (listp current-prefix-arg))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
275 last
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
276 kmacro-counter (+ kmacro-counter arg))))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
277 (unless executing-kbd-macro
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
278 (kmacro-display-counter)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
279
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
280
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
281 (defun kmacro-loop-setup-function ()
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
282 "Function called prior to each iteration of macro."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
283 ;; Restore macro counter format to initial format, so it is ok to change
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
284 ;; counter format in the macro without restoring it.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
285 (setq kmacro-counter-format kmacro-counter-format-start)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
286 ;; Save initial counter value so we can restore it with C-u kmacro-set-counter.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
287 (setq kmacro-counter-value-start kmacro-counter)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
288 ;; Return non-nil to continue execution.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
289 t)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
290
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
291
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
292 ;;; Keyboard macro ring
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
293
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
294 (defvar kmacro-ring nil
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
295 "The keyboard macro ring.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
296 Each element is a list (MACRO COUNTER FORMAT). Actually, the head of
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
297 the macro ring (when defining or executing) is not stored in the ring;
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
298 instead it is available in the variables `last-kbd-macro', `kmacro-counter',
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
299 and `kmacro-counter-format'.")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
300
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
301
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
302 (defun kmacro-ring-head ()
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
303 "Return pseudo head element in macro ring."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
304 (and last-kbd-macro
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
305 (list last-kbd-macro kmacro-counter kmacro-counter-format-start)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
306
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
307
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
308 (defun kmacro-push-ring (&optional elt)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
309 "Push ELT or current macro onto `kmacro-ring'."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
310 (when (setq elt (or elt (kmacro-ring-head)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
311 (let ((len (length kmacro-ring)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
312 (setq kmacro-ring (cons elt kmacro-ring))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
313 (if (>= len kmacro-ring-max)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
314 (setcdr (nthcdr len kmacro-ring) nil)))))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
315
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
316
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
317 (defun kmacro-split-ring-element (elt)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
318 (setq last-kbd-macro (car elt)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
319 kmacro-counter (nth 1 elt)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
320 kmacro-counter-format-start (nth 2 elt)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
321
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
322
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
323 (defun kmacro-pop-ring1 (&optional raw)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
324 "Pop head element off macro ring (no check).
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
325 Non-nil arg RAW means just return raw first element."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
326 (prog1 (car kmacro-ring)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
327 (unless raw
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
328 (kmacro-split-ring-element (car kmacro-ring)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
329 (setq kmacro-ring (cdr kmacro-ring))))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
330
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
331
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
332 (defun kmacro-pop-ring (&optional raw)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
333 "Pop head element off macro ring.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
334 Non-nil arg RAW means just return raw first element."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
335 (unless (kmacro-ring-empty-p)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
336 (kmacro-pop-ring1 raw)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
337
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
338
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
339 (defun kmacro-ring-length ()
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
340 "Return length of macro ring, including pseudo head."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
341 (+ (if last-kbd-macro 1 0) (length kmacro-ring)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
342
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
343
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
344 (defun kmacro-ring-empty-p (&optional none)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
345 "Tell user and return t if `last-kbd-macro' is nil or `kmacro-ring' is empty.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
346 Check only `last-kbd-macro' if optional arg NONE is non-nil."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
347 (while (and (null last-kbd-macro) kmacro-ring)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
348 (kmacro-pop-ring1))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
349 (cond
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
350 ((null last-kbd-macro)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
351 (message "No keyboard macro defined.")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
352 t)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
353 ((and (null none) (null kmacro-ring))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
354 (message "Only one keyboard macro defined.")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
355 t)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
356 (t nil)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
357
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
358
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
359 (defun kmacro-display (macro &optional trunc descr empty )
46099
d441fc235798 Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46085
diff changeset
360 "Display a keyboard MACRO."
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
361 (if macro
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
362 (let* ((x 60)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
363 (m (format-kbd-macro macro))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
364 (l (length m))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
365 (z (and nil trunc (> l x))))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
366 (message (format "%s: %s%s" (or descr "Macro")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
367 (if z (substring m 0 (1- x)) m) (if z "..." ""))))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
368 (message (or empty "No keyboard macros defined"))))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
369
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
370
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
371 (defun kmacro-repeat-on-last-key (keys)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
372 "Process kmacro commands keys immidiately after cycling the ring."
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
373 (setq keys (vconcat keys))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
374 (let ((n (1- (length keys)))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
375 cmd done repeat)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
376 (while (and last-kbd-macro
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
377 (not done)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
378 (aset keys n (read-event))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
379 (setq cmd (key-binding keys t))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
380 (setq repeat (get cmd 'kmacro-repeat)))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
381 (clear-this-command-keys t)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
382 (cond
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
383 ((eq repeat 'ring)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
384 (if kmacro-ring
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
385 (let ((kmacro-repeat-no-prefix nil))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
386 (funcall cmd nil))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
387 (kmacro-display last-kbd-macro t)))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
388 ((eq repeat 'head)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
389 (let ((kmacro-repeat-no-prefix nil))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
390 (funcall cmd nil)))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
391 ((eq repeat 'stop)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
392 (funcall cmd nil)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
393 (setq done t)))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
394 (setq last-input-event nil)))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
395 (when last-input-event
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
396 (clear-this-command-keys t)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
397 (setq unread-command-events (list last-input-event))))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
398
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
399
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
400 (defun kmacro-get-repeat-prefix ()
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
401 (let (keys)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
402 (and kmacro-repeat-no-prefix
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
403 (setq keys (this-single-command-keys))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
404 (> (length keys) 1)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
405 keys)))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
406
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
407
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
408 (defun kmacro-call-ring-2nd (arg)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
409 "Execute second keyboard macro at in macro ring."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
410 (interactive "P")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
411 (unless (kmacro-ring-empty-p)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
412 ;; should use counter format specific to the macro on the ring!
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
413 (let ((kmacro-counter (nth 1 (car kmacro-ring)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
414 (kmacro-counter-format-start (nth 2 (car kmacro-ring))))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
415 (execute-kbd-macro (car (car kmacro-ring)) arg #'kmacro-loop-setup-function)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
416 (setcar (cdr (car kmacro-ring)) kmacro-counter))))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
417
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
418
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
419 (defun kmacro-call-ring-2nd-repeat (arg)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
420 "Like `kmacro-call-ring-2nd', but allow repeat without repeating prefix."
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
421 (interactive "P")
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
422 (let ((keys (kmacro-get-repeat-prefix)))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
423 (kmacro-call-ring-2nd arg)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
424 (if (and kmacro-ring keys)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
425 (kmacro-repeat-on-last-key keys))))
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
426
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
427 (put 'kmacro-call-ring-2nd-repeat 'kmacro-repeat 'head)
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
428
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
429
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
430 (defun kmacro-view-ring-2nd ()
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
431 "Display the current head of the keyboard macro ring."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
432 (interactive)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
433 (unless (kmacro-ring-empty-p)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
434 (kmacro-display (car (car kmacro-ring)) "2nd macro")))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
435
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
436
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
437
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
438 (defun kmacro-cycle-ring-next (&optional arg)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
439 "Move to next keyboard macro in keyboard macro ring.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
440 Displays the selected macro in the echo area."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
441 (interactive)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
442 (unless (kmacro-ring-empty-p)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
443 (kmacro-push-ring)
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
444 (let* ((keys (kmacro-get-repeat-prefix))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
445 (len (length kmacro-ring))
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
446 (tail (nthcdr (- len 2) kmacro-ring))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
447 (elt (car (cdr tail))))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
448 (setcdr tail nil)
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
449 (kmacro-split-ring-element elt)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
450 (kmacro-display last-kbd-macro t)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
451 (if keys
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
452 (kmacro-repeat-on-last-key keys)))))
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
453
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
454 (put 'kmacro-cycle-ring-next 'kmacro-repeat 'ring)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
455
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
456
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
457 (defun kmacro-cycle-ring-previous (&optional arg)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
458 "Move to previous keyboard macro in keyboard macro ring.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
459 Displays the selected macro in the echo area."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
460 (interactive)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
461 (unless (kmacro-ring-empty-p)
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
462 (let ((keys (kmacro-get-repeat-prefix))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
463 (cur (kmacro-ring-head)))
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
464 (kmacro-pop-ring1)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
465 (if kmacro-ring
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
466 (nconc kmacro-ring (list cur))
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
467 (setq kmacro-ring (list cur)))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
468 (kmacro-display last-kbd-macro t)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
469 (if keys
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
470 (kmacro-repeat-on-last-key keys)))))
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
471
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
472 (put 'kmacro-cycle-ring-previous 'kmacro-repeat 'ring)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
473
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
474
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
475 (defun kmacro-swap-ring ()
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
476 "Swap first two elements on keyboard macro ring."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
477 (interactive)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
478 (unless (kmacro-ring-empty-p)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
479 (let ((cur (kmacro-ring-head)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
480 (kmacro-pop-ring1)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
481 (kmacro-push-ring cur))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
482 (kmacro-display last-kbd-macro t)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
483
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
484
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
485 (defun kmacro-delete-ring-head (&optional arg)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
486 "Delete current macro from keyboard macro ring."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
487 (interactive)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
488 (unless (kmacro-ring-empty-p t)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
489 (if (null kmacro-ring)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
490 (setq last-kbd-macro nil)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
491 (kmacro-pop-ring))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
492 (kmacro-display last-kbd-macro t nil "Keyboard macro ring is now empty.")))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
493
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
494 (put 'kmacro-delete-ring-head 'kmacro-repeat 'head)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
495
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
496 ;;; Traditional bindings:
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
497
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
498
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
499 ;;;###autoload
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
500 (defun kmacro-start-macro (arg)
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
501 "Record subsequent keyboard input, defining a keyboard macro.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
502 The commands are recorded even as they are executed.
47051
11f467f2a131 (kmacro-start-macro): Doc fix.
Andreas Schwab <schwab@suse.de>
parents: 46972
diff changeset
503 Use \\[kmacro-end-macro] to finish recording and make the macro available.
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
504 Use \\[call-last-kbd-macro] to execute the macro.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
505 Use \\[name-last-kbd-macro] to give it a permanent name.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
506 Non-nil arg (prefix arg) means append to last macro defined;
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
507
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
508 With \\[universal-argument] prefix, append to last keyboard macro
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
509 defined. Depending on `kmacro-execute-before-append', this may begin
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
510 by re-executing the last macro as if you typed it again.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
511
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
512 Otherwise, it sets `kmacro-counter' to ARG or 0 if missing before
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
513 defining the macro.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
514
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
515 Use \\[kmacro-insert-counter] to insert (and increment) the macro counter.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
516 The counter value can be set or modified via \\[kmacro-set-counter] and \\[kmacro-add-counter].
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
517 The format of the counter can be modified via \\[kmacro-set-format]."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
518 (interactive "P")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
519 (if (or defining-kbd-macro executing-kbd-macro)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
520 (message "Already defining keyboard macro.")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
521 (let ((append (and arg (listp arg))))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
522 (unless append
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
523 (if last-kbd-macro
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
524 (let ((len (length kmacro-ring)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
525 (setq kmacro-ring
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
526 (cons
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
527 (list last-kbd-macro kmacro-counter kmacro-counter-format-start)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
528 kmacro-ring))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
529 (if (>= len kmacro-ring-max)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
530 (setcdr (nthcdr len kmacro-ring) nil))))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
531 (setq kmacro-counter (if arg (prefix-numeric-value arg) 0)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
532 kmacro-counter-value-start kmacro-counter
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
533 kmacro-last-counter kmacro-counter
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
534 kmacro-counter-format-start kmacro-counter-format))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
535
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
536 (start-kbd-macro append
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
537 (and append
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
538 (if kmacro-execute-before-append
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
539 (> (car arg) 4)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
540 (= (car arg) 4)))))))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
541
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
542
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
543 ;;;###autoload
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
544 (defun kmacro-end-macro (arg)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
545 "Finish defining a keyboard macro.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
546 The definition was started by \\[kmacro-start-macro].
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
547 The macro is now available for use via \\[kmacro-call-macro],
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
548 or it can be given a name with \\[name-last-kbd-macro] and then invoked
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
549 under that name.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
550
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
551 With numeric arg, repeat macro now that many times,
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
552 counting the definition just completed as the first repetition.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
553 An argument of zero means repeat until error."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
554 (interactive "P")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
555 (end-kbd-macro arg #'kmacro-loop-setup-function)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
556 (when (and last-kbd-macro (= (length last-kbd-macro) 0))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
557 (message "Ignore empty macro")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
558 (kmacro-pop-ring)))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
559
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
560
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
561 ;;;###autoload
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
562 (defun kmacro-call-macro (arg &optional no-repeat end-macro)
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
563 "Call the last keyboard macro that you defined with \\[kmacro-start-macro].
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
564 A prefix argument serves as a repeat count. Zero means repeat until error.
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
565
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
566 When you call the macro, you can call the macro again by repeating
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
567 just the last key in the key sequence that you used to call this
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
568 command. See `kmacro-call-repeat-key' and `kmacro-call-repeat-with-arg'
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
569 for details on how to adjust or disable this behaviour.
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
570
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
571 To make a macro permanent so you can call it even after defining
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
572 others, use M-x name-last-kbd-macro."
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
573 (interactive "p")
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
574 (let ((repeat-key (and (null no-repeat)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
575 (> (length (this-single-command-keys)) 1)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
576 last-input-event))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
577 repeat-key-str)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
578 (if end-macro
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
579 (kmacro-end-macro arg)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
580 (call-last-kbd-macro arg #'kmacro-loop-setup-function))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
581 (when (and (or (null arg) (> arg 0))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
582 (setq repeat-key
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
583 (if (eq kmacro-call-repeat-key t) repeat-key kmacro-call-repeat-key)))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
584 (require 'edmacro)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
585 (setq repeat-key-str (edmacro-format-keys (vector repeat-key) nil))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
586 (while repeat-key
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
587 (message "Repeat macro %swith `%s'..."
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
588 (if (and kmacro-call-repeat-with-arg
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
589 arg (> arg 1))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
590 (format "%d times " arg) "")
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
591 repeat-key-str)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
592 (if (equal repeat-key (read-event))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
593 (progn
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
594 (clear-this-command-keys t)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
595 (call-last-kbd-macro (and kmacro-call-repeat-with-arg arg) #'kmacro-loop-setup-function)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
596 (setq last-input-event nil))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
597 (setq repeat-key nil)))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
598 (when last-input-event
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
599 (clear-this-command-keys t)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
600 (setq unread-command-events (list last-input-event))))))
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
601
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
602
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
603 ;;; Combined function key bindings:
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
604
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
605 ;;;###autoload
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
606 (defun kmacro-start-macro-or-insert-counter (arg)
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
607 "Record subsequent keyboard input, defining a keyboard macro.
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
608 The commands are recorded even as they are executed.
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
609
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
610 Sets the `kmacro-counter' to ARG (or 0 if no prefix arg) before defining the
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
611 macro.
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
612
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
613 With \\[universal-argument], appends to current keyboard macro (keeping
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
614 the current value of `kmacro-counter').
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
615
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
616 When defining/executing macro, inserts macro counter and increments
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
617 the counter with ARG or 1 if missing. With \\[universal-argument],
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
618 inserts previous kmacro-counter (but do not modify counter).
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
619
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
620 The macro counter can be modified via \\[kmacro-set-counter] and \\[kmacro-add-counter].
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
621 The format of the counter can be modified via \\[kmacro-set-format]."
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
622 (interactive "P")
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
623 (if (or defining-kbd-macro executing-kbd-macro)
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
624 (kmacro-insert-counter arg)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
625 (kmacro-start-macro arg)))
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
626
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
627
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
628 ;;;###autoload
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
629 (defun kmacro-end-or-call-macro (arg &optional no-repeat)
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
630 "End kbd macro if currently being defined; else call last kbd macro.
46099
d441fc235798 Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46085
diff changeset
631 With numeric prefix ARG, repeat macro that many times.
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
632 With \\[universal-argument], call second macro in macro ring."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
633 (interactive "P")
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
634 (cond
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
635 (defining-kbd-macro
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
636 (if kmacro-call-repeat-key
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
637 (kmacro-call-macro arg no-repeat t)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
638 (kmacro-end-macro arg)))
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
639 ((and arg (listp arg))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
640 (kmacro-call-ring-2nd 1))
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
641 (t
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
642 (kmacro-call-macro arg no-repeat))))
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
643
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
644
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
645 (defun kmacro-end-or-call-macro-repeat (arg)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
646 "As `kmacro-end-or-call-macro' but allows repeat without repeating prefix."
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
647 (interactive "P")
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
648 (let ((keys (kmacro-get-repeat-prefix)))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
649 (kmacro-end-or-call-macro arg t)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
650 (if keys
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
651 (kmacro-repeat-on-last-key keys))))
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
652
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
653 (put 'kmacro-end-or-call-macro-repeat 'kmacro-repeat 'head)
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
654
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
655
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
656 ;;;###autoload
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
657 (defun kmacro-end-call-mouse (event)
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
658 "Move point to the position clicked with the mouse and call last kbd macro.
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
659 If kbd macro currently being defined end it before activating it."
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
660 (interactive "e")
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
661 (when defining-kbd-macro
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
662 (end-kbd-macro))
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
663 (mouse-set-point event)
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
664 (kmacro-call-macro nil t))
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
665
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
666
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
667 ;;; Misc. commands
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
668
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
669 (defun kmacro-bind-to-key (arg)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
670 "When not defining or executing a macro, offer to bind last macro to a key."
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
671 (interactive "p")
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
672 (if (or defining-kbd-macro executing-kbd-macro)
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
673 (if defining-kbd-macro
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
674 (message "Cannot save macro while defining it."))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
675 (unless last-kbd-macro
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
676 (error "No keyboard macro defined"))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
677 (let ((key-seq (read-key-sequence "Bind last macro to key: ")))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
678 (unless (equal key-seq "")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
679 (define-key global-map key-seq last-kbd-macro)))))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
680
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
681
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
682 (defun kmacro-view-macro (&optional arg)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
683 "Display the last keyboard macro."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
684 (interactive)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
685 (kmacro-display last-kbd-macro))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
686
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
687
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
688 (defun kmacro-view-macro-repeat (&optional arg)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
689 "Like `kmacro-view-macro', but allow repeat without repeating prefix."
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
690 (interactive)
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
691 (let ((keys (kmacro-get-repeat-prefix)))
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
692 (kmacro-view-macro arg)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
693 (if (and last-kbd-macro keys)
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
694 (kmacro-repeat-on-last-key keys))))
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
695
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
696 (put 'kmacro-view-macro-repeat 'kmacro-repeat 'head)
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
697
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
698
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
699 (defun kmacro-edit-macro-repeat (&optional arg)
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
700 "Edit last keyboard macro."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
701 (interactive "P")
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
702 (edit-kbd-macro "\r" arg))
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
703
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
704 (put 'kmacro-edit-macro-repeat 'kmacro-repeat 'stop)
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
705
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
706
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
707 (defun kmacro-edit-macro (&optional arg)
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
708 "As edit last keyboard macro, but without kmacro-repeat property."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
709 (interactive "P")
47094
cbc107c19e30 Changed default bindings from F7/F8 to F3/F4.
Kim F. Storm <storm@cua.dk>
parents: 47051
diff changeset
710 (edit-kbd-macro "\r" arg))
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
711
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
712
46961
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
713 (defun kmacro-edit-lossage ()
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
714 "Edit most recent 100 keystrokes as a keyboard macro."
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
715 (interactive)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
716 (kmacro-push-ring)
7e8358ec31ba Major rework based on discussions with RMS.
Kim F. Storm <storm@cua.dk>
parents: 46099
diff changeset
717 (edit-kbd-macro "\C-hl"))
46083
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
718
bd954daa704a New file.
Kim F. Storm <storm@cua.dk>
parents:
diff changeset
719
46099
d441fc235798 Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46085
diff changeset
720 (provide 'kmacro)
d441fc235798 Passed it through checkdoc. Moved `provide' to the end, where it belongs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46085
diff changeset
721 ;;; kmacro.el ends here