annotate src/macros.c @ 47576:b31c8ab7336a

Sync with version 2.0.20. Lengthy ChangeLog follows: 2002-09-22 Kai Gro?ohann <grossjoh@ls6.informatik.uni-dortmund.de> Version 2.0.20 released. 2002-09-20 Kai Gro?ohann <grossjoh@ls6.informatik.uni-dortmund.de> * net/tramp.el (tramp-completion-function-alist): Escape open paren in docstring. (tramp-user-regexp, tramp-host-regexp): Allow empty strings. (tramp-handle-insert-file-contents): Call tramp-message-for-buffer instead of tramp-message. (tramp-open-connection-rsh): Handle empty string as user name. (tramp-open-connection-su): Handle empty string as host name. Handle nil user name. (tramp-handle-file-local-copy, tramp-handle-write-region) (tramp-completion-handle-file-name-all-completions) (tramp-open-connection-telnet, tramp-open-connection-rsh) (tramp-open-connection-su, tramp-post-connection) (tramp-maybe-open-connection, tramp-method-out-of-band-p) (tramp-get-connection-function, tramp-get-remote-sh) (tramp-get-rsh-program, tramp-get-rsh-args) (tramp-get-rcp-program, tramp-get-rcp-args) (tramp-get-rcp-keep-date-arg, tramp-get-su-program) (tramp-get-su-args, tramp-get-telnet-program) (tramp-get-telnet-args): Use `tramp-find-method', perhaps require additional args USER, HOST. (tramp-action-password, tramp-open-connection-telnet) (tramp-open-connection-su, tramp-open-connection-multi) (tramp-method-out-of-band-p): `tramp-method-out-of-band-p' now takes USER and HOST arguments, to be able to use `tramp-find-method'. Update callers. (tramp-find-method): New function. 2002-09-20 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-handle-insert-directory): Handle "--dired" in SWITCHES (by removing it). 2002-09-18 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-file-name-handler): Add `file-remote-p' property. 2002-09-17 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (top-level): Maybe autoload uudecode-decode-region. 2002-09-16 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-bug): Add tramp-methods. 2002-09-16 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-methods): Update docstring: tramp-encoding-command, tramp-decoding-command, tramp-encoding-function and tramp-decoding-function are not parameters anymore. (tramp-uuencode-region): Autoload it. 2002-09-13 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> Version 2.0.19 released. * net/tramp-uu.el: New file, implements uuencode in Lisp. * net/tramp.el (tramp-coding-commands): Use `tramp-uuencode-region' as local encoder for the uuencode based entries. 2002-09-13 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-handle-write-region): Wrong parens. 2002-09-13 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> Version 2.0.18 released. * net/tramp.el (tramp-perl-decode): Perl changes to accomodate older versions of Perl. Now tested with 5.004. Suggestion from Michael Albinus. 2002-09-12 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-find-inline-encoding): Call tramp-call-local-coding-command with nil for INPUT and OUTPUT. (tramp-call-local-coding-command): OUTPUT equals nil means to discard the output. INPUT equals nil means /dev/null. 2002-09-12 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-encoding-shell): Default to environment variable COMSPEC on Windows. (tramp-handle-write-region): More debugging output. (tramp-find-inline-encoding): Ditto. 2002-09-11 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-handle-file-name-all-completions): Define `result1'. (tramp-parse-hosts-group): Discard IPv6 entries. 2002-09-11 Kai Gro?ohann <grossjoh@ls6.informatik.uni-dortmund.de> * net/tramp.el (tramp-post-connection): Only send Perl mime-encode/decode implementations when using inline method. (tramp-handle-file-local-copy) (tramp-handle-write-region, tramp-post-connection) (tramp-coding-commands, tramp-find-inline-encoding): For the inline encodings, distinguish between local and remote commands, instead of between commands and functions. (The local commands can be functions, too.) If the local host is a Windows machine, we can't expect the same commands to work there as on the remote host. (tramp-call-local-coding-command): New function for calling local encoding and decoding commands. (tramp-set-remote-encoding, tramp-get-remote-encoding) (tramp-set-remote-decoding, tramp-get-remote-decoding) (tramp-set-local-encoding, tramp-get-local-encoding) (tramp-set-local-decoding, tramp-get-local-decoding): New functions. (tramp-get-encoding-command, tramp-set-encoding-command) (tramp-get-decoding-command, tramp-set-decoding-command) (tramp-get-encoding-function, tramp-set-encoding-function) (tramp-get-decoding-function, tramp-set-decoding-function): Old functions, removed. 2002-09-10 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-open-connection-setup-interactive-shell): Change command to invoke /bin/sh slightly to make it compatible with the `rc' shell. Suggested by Daniel Pittman. 2002-09-10 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-handle-write-region): Added missing `)'. Hope it's the right place. 2002-09-09 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-open-connection-setup-interactive-shell): Do "exec env PS1='$ ' /bin/sh" instead of just "exec /bin/sh" in order to get a sane shell prompt. If people have ${CWD}, say, in their shell prompt, then the default login shell might display something harmless, but the /bin/sh will display a dollar sign which confused the subsequent prompt recognition. (tramp-multi-action-password): More debugging output. (tramp-encoding-shell): Renamed from tramp-sh-program. More documentation. Default to cmd.exe on Windows NT. (tramp-encoding-command-switch): New variable. Use instead of hard-wired "-c" which is only good for /bin/sh. (tramp-encoding-reads-stdin): New variable. If t, commands are called like "/bin/sh -c COMMAND <INPUT", if nil, they are called like "/bin/sh -c COMMAND INPUT", ie the input file is the last argument. (tramp-multi-sh-program): Always default to tramp-encoding-shell. (tramp-handle-file-local-copy, tramp-handle-write-region): Respect tramp-encoding-shell and friends. (tramp-find-inline-encoding): Use new-style calls for checking if the local commands work. 2002-09-07 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-methods): Remove `tramp-completion-function' entries. They are handled now by `tramp-completion-function-alist'. (tramp-completion-function): Defvar removed. I've never used it. Hmm. (tramp-get-completion-function) (tramp-get-completion-rsh, tramp-get-completion-ssh) (tramp-get-completion-telnet, tramp-get-completion-su): Functions removed as well. Not necessary any longer due to extended customization means. (tramp-completion-function-alist): New defcustom. Holds all FUNCTION FILE pairs used for user and host name completion relevant for METHOD. (tramp-completion-function-alist-rsh) (tramp-completion-function-alist-ssh) (tramp-completion-function-alist-telnet) (tramp-completion-function-alist-su): Defconst for initializing `tramp-completion-function-alist'. Unfortunately, mainly UNIX-like values are known for me until now. Needs to be completed for at least VMS++ like operating systems. (tramp-set-completion-function) (tramp-get-completion-function): New functions for configuration of `tramp-completion-function-alist'. The old definition of `tramp-get-completion-function' has been discarded. (tramp-completion-handle-file-name-all-completions): Change function call for user/host completion according to definition in `tramp-completion-function-alist'. (tramp-parse-passwd): Added exception handling for "root", because `tramp-get-completion-su' (the previous place for this stuff) doesn't exist any longer. 2002-09-07 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-enter-password): Use `tramp-password-end-of-line' to terminate the line. (tramp-bug): Include new variable `tramp-password-end-of-line'. (tramp-password-end-of-line): New variable. People who use plink under Windows might have to issue "\r\n" after the password, but they need to send just "\n" after the other commands. So this variable was introduced to complement `tramp-rsh-end-of-line'. (tramp-wait-for-output, tramp-post-connection): Allow "\r" at end of line of the output delimiter. 2002-09-06 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-handle-file-local-copy, tramp-find-shell) (tramp-open-connection-setup-interactive-shell): Add some comments about Douglas Grey Stephen's suggestions to make Tramp work better with plink under Windows. I'm not sure what to think of them, but now I have a guinea pig to try it out on. Said guinea pig is having other problems, though... Also remove some commented-out code. 2002-09-06 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-get-completion-methods): Algorithm slightly tuned. (tramp-get-completion-user-host): Accept user names as they are if typed until "@". (tramp-completion-mode): Replace `last-input-char' by modern `last-input-event'. Check for `event-modifiers'. 2002-09-06 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (file-expand-wildcards): Corrected check to see if advising is necessary. 2002-09-05 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-postfix-single-method-format) (tramp-postfix-multi-method-format) (tramp-postfix-multi-hop-format) (tramp-postfix-user-format): New format strings. (tramp-postfix-single-method-regexp) (tramp-postfix-multi-method-regexp) (tramp-postfix-multi-hop-regexp) (tramp-postfix-user-regexp) (tramp-make-multi-tramp-file-format) (tramp-make-tramp-file-name): Apply them. (tramp-completion-handle-file-name-all-completions): Fix for invoking ange-ftp in case of "/ftp:xxx" file names. 2002-09-04 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-prefix-format) (tramp-postfix-host-format): New format strings. (tramp-prefix-regexp, tramp-method-regexp) (tramp-postfix-single-method-regexp) (tramp-postfix-multi-method-regexp) (tramp-postfix-multi-hop-regexp) (tramp-user-regexp, tramp-postfix-user-regexp) (tramp-host-regexp, tramp-postfix-host-regexp) (tramp-path-regexp): New atomar regular expressions. If corresponding format strings exist, derived from them. (tramp-file-name-structure) (tramp-multi-file-name-structure) (tramp-multi-file-name-hop-structure) (tramp-make-multi-tramp-file-format) (tramp-completion-mode) (tramp-completion-dissect-file-name) (tramp-parse-rhosts-group) (tramp-parse-shosts-group) (tramp-parse-hosts-group) (tramp-parse-passwd-group): Apply these expressions. (tramp-file-name-structure-unified) (tramp-file-name-structure-separate) (tramp-make-tramp-file-format-unified) (tramp-make-tramp-file-format-separate) (tramp-make-tramp-file-format) (tramp-make-tramp-file-user-nil-format-unified) (tramp-make-tramp-file-user-nil-format-separate) (tramp-make-tramp-file-user-nil-format) (tramp-multi-file-name-structure-unified) (tramp-multi-file-name-structure-separate) (tramp-multi-file-name-hop-structure-unified) (tramp-multi-file-name-hop-structure-separate) (tramp-make-multi-tramp-file-format-unified) (tramp-make-multi-tramp-file-format-separate): Removed. (tramp-make-tramp-file-name): Allow partial tramp file names. Generate tramp file format on-the-fly depending on parameters. Apply atomar format strings resp expressions. (tramp-get-completion-methods) (tramp-get-completion-user-host): Apply `tramp-make-tramp-file-name'. (tramp-parse-hosts-group): Take all host names and IP addresses into account. (tramp-bug): Remove `tramp-make-tramp-file-format'. 2002-09-01 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-methods): Add `tramp-completion-function' for "su" and "sudo". (tramp-get-completion-telnet): Implement it. (tramp-parse-hosts) (tramp-parse-hosts-group) (tramp-get-completion-su) (tramp-parse-passwd) (tramp-parse-passwd-group): New functions. 2002-08-31 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-mode): Check for `last-input-char'. (tramp-completion-file-name-handler-alist): Add handler for `file-exists-p. (tramp-completion-handle-file-exists-p): New function. (tramp-completion-handle-file-name-completion): Simplified. (tramp-completion-dissect-file-name): Regexp's reorganised. (tramp-completion-handle-file-name-all-completions): Call completion-function only if `user' or `host' is given. (tramp-get-completion-user-host): New function. (tramp-get-completion-rsh) (tramp-get-completion-ssh): Apply it. 2002-08-29 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-file-name-handler-alist): Add handler for `expand-file-name'. (tramp-completion-handle-expand-file-name): New function. 2002-08-26 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-mode): New function. (tramp-completion-handle-file-name-directory) (tramp-completion-handle-file-name-all-completions): Apply it. (tramp-methods): Remove double definition of `ssh1-old' and `ssh2-old'. (tramp-point-at-eol): New defalias. (tramp-parse-rhosts-group) (tramp-parse-shosts-group):: Apply it. 2002-08-25 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-get-completion-methods) (tramp-get-completion-rsh) (tramp-get-completion-ssh): Add "[" for Xemacs. (tramp-completion-file-name-regexp-separate): Expression adapted. (tramp-completion-file-name-handler-alist): Add handler for `file-name-directory' and `file-name-nondirectory'. (tramp-completion-handle-file-name-directory) (tramp-completion-handle-file-name-nondirectory) (tramp-completion-run-real-handler): New functions. (tramp-completion-file-name-handler) (tramp-completion-handle-file-name-all-completions): Apply `tramp-completion-run-real-handler'. (tramp-parse-rhosts) (tramp-parse-shosts): Use `with-temp-buffer'. `result? renamed to `res' (otherwise side effects in XEmacs). 2002-08-24 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-file-name-regexp) (tramp-completion-file-name-handler-alist) (tramp-flatten-list) (tramp-completion-dissect-file-name) (tramp-get-completion-rsh) (tramp-parse-rhosts) (tramp-parse-rhosts-group) (tramp-get-completion-ssh): Doc string tuned. (tramp-methods): Doc string and custom type extended for `tramp-completion-function'. (tramp-completion-function): Variable added. Is it really used? Other variables like `tramp-completion-function' aren't used. (tramp-completion-file-name-handler-alist): Add handler for `file-name-completion'. (tramp-completion-handle-file-name-completion): New function. 2002-08-18 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-parse-rhosts) (tramp-parse-rhosts-group) (tramp-parse-shosts) (tramp-parse-shosts-group): New functions. 2002-08-17 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-dissect-file-name) (tramp-completion-dissect-file-name1): New functions. 2002-08-16 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-get-completion-function) (tramp-get-completion-rsh) (tramp-get-completion-ssh) (tramp-get-completion-telnet): New functions. (tramp-methods): Add `tramp-completion-function' for all methods. 2002-08-15 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-get-completion-methods): New function. (tramp-find-default-method): Allow host to be nil (like user). 2002-08-14 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-file-name-regexp-unified) (tramp-completion-file-name-regexp-separate) (tramp-completion-file-name-regexp) (tramp-completion-file-name-handler-alist): New defcustoms. (tramp-completion-file-name-handler): New function. Add `tramp-completion-file-name-handler' to `file-name-handler-alist'. (tramp-run-real-handler): Add `tramp-completion-file-name-handler' to `inhibit-file-name-handlers'. (tramp-completion-handle-file-name-all-completions) (tramp-completion-handle-file-name-completion): New functions. 2002-08-12 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-invoke-ange-ftp): `tramp-disable-ange-ftp' must be called again after activating `ange-ftp'. (tramp-ange-ftp-file-name-p): Check for Xemacs. 2002-08-08 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-do-copy-or-rename-file): Don't pass KEEP-DATE to tramp-invoke-ange-ftp 'rename. (tramp-handle-write-region): Don't pass LOCKNAME and CONFIRM to tramp-invoke-ange-ftp 'write-region. (tramp-handle-set-file-modes): Change order of FILENAME and MODE passing to tramp-invoke-ange-ftp 'set-file-modes. (tramp-flatten-list): New function. Maybe this functionality does exist already elsewhere in the libraries. (tramp-invoke-ange-ftp): Apply `tramp-flatten-list' to parameter list in order to avoid nested lists, f.e. when invoked from `tramp-handle-dired-call-process'. 2002-09-05 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-chunksize): New kluge variable. (tramp-send-region): If tramp-chunksize is non-nil, send region in parts and sleep 0.1 seconds between chunks. 2002-09-03 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-handle-insert-directory): Use `insert-buffer-substring' instead of `insert-buffer', which is not supposed to be used from Lisp. Remember old point in a variable instead of using `mark'. Suggestion from Stefan Monnier. (tramp-unified-filenames): New variable. Use it in default value of other filename variables. (file-expand-wildcards): Don't advise unless "[" and "]" are used in the filename format. 2002-09-01 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-methods): Remove duplicate definition of ssh1-old and ssh2-old.
author Kai Großjohann <kgrossjo@eu.uu.net>
date Sun, 22 Sep 2002 13:23:36 +0000
parents 7e9809c820b0
children 23a1cea22d13
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* Keyboard macros.
35119
97a19f647a12 (Qkbd_macro_termination_hook): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 34361
diff changeset
2 Copyright (C) 1985, 1986, 1993, 2000, 2001 Free Software Foundation, Inc.
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This file is part of GNU Emacs.
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
647
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 any later version.
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14100
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14100
diff changeset
19 Boston, MA 02111-1307, USA. */
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 2961
diff changeset
22 #include <config.h>
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 #include "lisp.h"
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 #include "macros.h"
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 #include "commands.h"
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 #include "buffer.h"
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 #include "window.h"
11341
e0f3fa4e7bf3 Include keyboard.h.
Richard M. Stallman <rms@gnu.org>
parents: 11009
diff changeset
28 #include "keyboard.h"
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29
35119
97a19f647a12 (Qkbd_macro_termination_hook): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 34361
diff changeset
30 Lisp_Object Qexecute_kbd_macro, Qkbd_macro_termination_hook;
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31
15968
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
32 /* Kbd macro currently being executed (a string or vector). */
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
33
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 Lisp_Object Vexecuting_macro;
15968
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
35
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
36 /* Index of next character to fetch from that macro. */
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
37
47307
06c376f5df86 (executing_macro_index): Change type to EMACS_INT.
Kim F. Storm <storm@cua.dk>
parents: 46887
diff changeset
38 EMACS_INT executing_macro_index;
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39
15968
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
40 /* Number of successful iterations so far
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
41 for innermost keyboard macro.
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
42 This is not bound at each level,
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
43 so after an error, it describes the innermost interrupted macro. */
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
44
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
45 int executing_macro_iterations;
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
46
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
47 /* This is the macro that was executing.
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
48 This is not bound at each level,
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
49 so after an error, it describes the innermost interrupted macro.
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
50 We use it only as a kind of flag, so no need to protect it. */
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
51
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
52 Lisp_Object executing_macro;
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
53
23434
1dd05eb0443d (Fexecute_kbd_macro): Set real_this_command.
Richard M. Stallman <rms@gnu.org>
parents: 22968
diff changeset
54 extern Lisp_Object real_this_command;
1dd05eb0443d (Fexecute_kbd_macro): Set real_this_command.
Richard M. Stallman <rms@gnu.org>
parents: 22968
diff changeset
55
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 Lisp_Object Fexecute_kbd_macro ();
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57
46887
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
58 DEFUN ("start-kbd-macro", Fstart_kbd_macro, Sstart_kbd_macro, 1, 2, "P",
41940
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
59 doc: /* Record subsequent keyboard input, defining a keyboard macro.
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
60 The commands are recorded even as they are executed.
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
61 Use \\[end-kbd-macro] to finish recording and make the macro available.
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
62 Use \\[name-last-kbd-macro] to give it a permanent name.
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
63 Non-nil arg (prefix arg) means append to last macro defined;
46887
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
64 this begins by re-executing that macro as if you typed it again.
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
65 If optional second arg, NO-EXEC, is non-nil, do not re-execute last
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
66 macro before appending to it. */)
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
67 (append, no_exec)
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
68 Lisp_Object append, no_exec;
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 {
11009
399469e5eb5b Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents: 10992
diff changeset
70 if (!NILP (current_kboard->defining_kbd_macro))
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 error ("Already defining kbd macro");
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72
11009
399469e5eb5b Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents: 10992
diff changeset
73 if (!current_kboard->kbd_macro_buffer)
10910
b0edc245c9b7 (defining_kbd_macro): Delete; now part of perdisplay. All uses changed.
Karl Heuer <kwzh@gnu.org>
parents: 10856
diff changeset
74 {
11009
399469e5eb5b Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents: 10992
diff changeset
75 current_kboard->kbd_macro_bufsize = 30;
399469e5eb5b Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents: 10992
diff changeset
76 current_kboard->kbd_macro_buffer
14301
621f53083d60 * macros.c (Fstart_kbd_macro): Use xmalloc.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
77 = (Lisp_Object *)xmalloc (30 * sizeof (Lisp_Object));
10910
b0edc245c9b7 (defining_kbd_macro): Delete; now part of perdisplay. All uses changed.
Karl Heuer <kwzh@gnu.org>
parents: 10856
diff changeset
78 }
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 update_mode_lines++;
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 434
diff changeset
80 if (NILP (append))
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 {
14301
621f53083d60 * macros.c (Fstart_kbd_macro): Use xmalloc.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
82 if (current_kboard->kbd_macro_bufsize > 200)
621f53083d60 * macros.c (Fstart_kbd_macro): Use xmalloc.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
83 {
621f53083d60 * macros.c (Fstart_kbd_macro): Use xmalloc.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
84 current_kboard->kbd_macro_bufsize = 30;
621f53083d60 * macros.c (Fstart_kbd_macro): Use xmalloc.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
85 current_kboard->kbd_macro_buffer
15223
be1bc5b3f14e (Fstart_kbd_macro): Add missing xrealloc arg.
Karl Heuer <kwzh@gnu.org>
parents: 14301
diff changeset
86 = (Lisp_Object *)xrealloc (current_kboard->kbd_macro_buffer,
be1bc5b3f14e (Fstart_kbd_macro): Add missing xrealloc arg.
Karl Heuer <kwzh@gnu.org>
parents: 14301
diff changeset
87 30 * sizeof (Lisp_Object));
14301
621f53083d60 * macros.c (Fstart_kbd_macro): Use xmalloc.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
88 }
11009
399469e5eb5b Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents: 10992
diff changeset
89 current_kboard->kbd_macro_ptr = current_kboard->kbd_macro_buffer;
399469e5eb5b Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents: 10992
diff changeset
90 current_kboard->kbd_macro_end = current_kboard->kbd_macro_buffer;
14301
621f53083d60 * macros.c (Fstart_kbd_macro): Use xmalloc.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
91 message ("Defining kbd macro...");
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 }
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 else
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 {
26825
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
95 int i, len;
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
96
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
97 /* Check the type of last-kbd-macro in case Lisp code changed it. */
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
98 if (!STRINGP (current_kboard->Vlast_kbd_macro)
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
99 && !VECTORP (current_kboard->Vlast_kbd_macro))
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
100 current_kboard->Vlast_kbd_macro
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
101 = wrong_type_argument (Qarrayp, current_kboard->Vlast_kbd_macro);
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
102
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
103 len = XINT (Flength (current_kboard->Vlast_kbd_macro));
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
104
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
105 /* Copy last-kbd-macro into the buffer, in case the Lisp code
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
106 has put another macro there. */
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
107 if (current_kboard->kbd_macro_bufsize < len + 30)
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
108 {
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
109 current_kboard->kbd_macro_bufsize = len + 30;
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
110 current_kboard->kbd_macro_buffer
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
111 = (Lisp_Object *)xrealloc (current_kboard->kbd_macro_buffer,
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
112 (len + 30) * sizeof (Lisp_Object));
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
113 }
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
114 for (i = 0; i < len; i++)
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
115 current_kboard->kbd_macro_buffer[i]
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
116 = Faref (current_kboard->Vlast_kbd_macro, make_number (i));
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
117
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
118 current_kboard->kbd_macro_ptr = current_kboard->kbd_macro_buffer + len;
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
119 current_kboard->kbd_macro_end = current_kboard->kbd_macro_ptr;
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
120
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
121 /* Re-execute the macro we are appending to,
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
122 for consistency of behavior. */
46887
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
123 if (NILP (no_exec))
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
124 Fexecute_kbd_macro (current_kboard->Vlast_kbd_macro,
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
125 make_number (1), Qnil);
26825
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
126
66dfce1feb9c (Fstart_kbd_macro): Handle case where last-kbd-macro
Richard M. Stallman <rms@gnu.org>
parents: 24530
diff changeset
127 message ("Appending to kbd macro...");
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 }
11009
399469e5eb5b Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents: 10992
diff changeset
129 current_kboard->defining_kbd_macro = Qt;
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 return Qnil;
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 }
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133
47348
7e9809c820b0 (end_kbd_macro): New function.
Kim F. Storm <storm@cua.dk>
parents: 47307
diff changeset
134 /* Finish defining the current keyboard macro. */
7e9809c820b0 (end_kbd_macro): New function.
Kim F. Storm <storm@cua.dk>
parents: 47307
diff changeset
135
7e9809c820b0 (end_kbd_macro): New function.
Kim F. Storm <storm@cua.dk>
parents: 47307
diff changeset
136 void
7e9809c820b0 (end_kbd_macro): New function.
Kim F. Storm <storm@cua.dk>
parents: 47307
diff changeset
137 end_kbd_macro ()
7e9809c820b0 (end_kbd_macro): New function.
Kim F. Storm <storm@cua.dk>
parents: 47307
diff changeset
138 {
7e9809c820b0 (end_kbd_macro): New function.
Kim F. Storm <storm@cua.dk>
parents: 47307
diff changeset
139 current_kboard->defining_kbd_macro = Qnil;
7e9809c820b0 (end_kbd_macro): New function.
Kim F. Storm <storm@cua.dk>
parents: 47307
diff changeset
140 update_mode_lines++;
7e9809c820b0 (end_kbd_macro): New function.
Kim F. Storm <storm@cua.dk>
parents: 47307
diff changeset
141 current_kboard->Vlast_kbd_macro
7e9809c820b0 (end_kbd_macro): New function.
Kim F. Storm <storm@cua.dk>
parents: 47307
diff changeset
142 = make_event_array ((current_kboard->kbd_macro_end
7e9809c820b0 (end_kbd_macro): New function.
Kim F. Storm <storm@cua.dk>
parents: 47307
diff changeset
143 - current_kboard->kbd_macro_buffer),
7e9809c820b0 (end_kbd_macro): New function.
Kim F. Storm <storm@cua.dk>
parents: 47307
diff changeset
144 current_kboard->kbd_macro_buffer);
7e9809c820b0 (end_kbd_macro): New function.
Kim F. Storm <storm@cua.dk>
parents: 47307
diff changeset
145 }
7e9809c820b0 (end_kbd_macro): New function.
Kim F. Storm <storm@cua.dk>
parents: 47307
diff changeset
146
46887
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
147 DEFUN ("end-kbd-macro", Fend_kbd_macro, Send_kbd_macro, 0, 2, "p",
41940
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
148 doc: /* Finish defining a keyboard macro.
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
149 The definition was started by \\[start-kbd-macro].
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
150 The macro is now available for use via \\[call-last-kbd-macro],
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
151 or it can be given a name with \\[name-last-kbd-macro] and then invoked
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
152 under that name.
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
153
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
154 With numeric arg, repeat macro now that many times,
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
155 counting the definition just completed as the first repetition.
46887
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
156 An argument of zero means repeat until error.
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
157
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
158 In Lisp, optional second arg LOOPFUNC may be a function that is called prior to
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
159 each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */)
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
160 (repeat, loopfunc)
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
161 Lisp_Object repeat, loopfunc;
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 {
11009
399469e5eb5b Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents: 10992
diff changeset
163 if (NILP (current_kboard->defining_kbd_macro))
22915
ef9dd93e3077 (Fexecute_kbd_macro): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents: 20299
diff changeset
164 error ("Not defining kbd macro");
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165
14081
addc50fc3981 (Fend_kbd_macro, Fexecute_kbd_macro): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents: 13773
diff changeset
166 if (NILP (repeat))
addc50fc3981 (Fend_kbd_macro, Fexecute_kbd_macro): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents: 13773
diff changeset
167 XSETFASTINT (repeat, 1);
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 else
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40635
diff changeset
169 CHECK_NUMBER (repeat);
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170
11009
399469e5eb5b Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents: 10992
diff changeset
171 if (!NILP (current_kboard->defining_kbd_macro))
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 {
47348
7e9809c820b0 (end_kbd_macro): New function.
Kim F. Storm <storm@cua.dk>
parents: 47307
diff changeset
173 end_kbd_macro ();
14301
621f53083d60 * macros.c (Fstart_kbd_macro): Use xmalloc.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
174 message ("Keyboard macro defined");
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 }
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176
14081
addc50fc3981 (Fend_kbd_macro, Fexecute_kbd_macro): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents: 13773
diff changeset
177 if (XFASTINT (repeat) == 0)
46887
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
178 Fexecute_kbd_macro (current_kboard->Vlast_kbd_macro, repeat, loopfunc);
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 else
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 {
14081
addc50fc3981 (Fend_kbd_macro, Fexecute_kbd_macro): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents: 13773
diff changeset
181 XSETINT (repeat, XINT (repeat)-1);
addc50fc3981 (Fend_kbd_macro, Fexecute_kbd_macro): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents: 13773
diff changeset
182 if (XINT (repeat) > 0)
46887
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
183 Fexecute_kbd_macro (current_kboard->Vlast_kbd_macro, repeat, loopfunc);
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 }
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 return Qnil;
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 }
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 /* Store character c into kbd macro being defined */
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189
20299
608c1a9aefc8 (store_kbd_macro_char): Define as returning nothing.
Andreas Schwab <schwab@suse.de>
parents: 16562
diff changeset
190 void
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 store_kbd_macro_char (c)
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 Lisp_Object c;
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 {
39135
73d05c66ef70 (store_kbd_macro_char): Fix computation of kbd_macro_end.
Gerd Moellmann <gerd@gnu.org>
parents: 37926
diff changeset
194 struct kboard *kb = current_kboard;
73d05c66ef70 (store_kbd_macro_char): Fix computation of kbd_macro_end.
Gerd Moellmann <gerd@gnu.org>
parents: 37926
diff changeset
195
73d05c66ef70 (store_kbd_macro_char): Fix computation of kbd_macro_end.
Gerd Moellmann <gerd@gnu.org>
parents: 37926
diff changeset
196 if (!NILP (kb->defining_kbd_macro))
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 {
39135
73d05c66ef70 (store_kbd_macro_char): Fix computation of kbd_macro_end.
Gerd Moellmann <gerd@gnu.org>
parents: 37926
diff changeset
198 if (kb->kbd_macro_ptr - kb->kbd_macro_buffer == kb->kbd_macro_bufsize)
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 {
39135
73d05c66ef70 (store_kbd_macro_char): Fix computation of kbd_macro_end.
Gerd Moellmann <gerd@gnu.org>
parents: 37926
diff changeset
200 int ptr_offset, end_offset, nbytes;
73d05c66ef70 (store_kbd_macro_char): Fix computation of kbd_macro_end.
Gerd Moellmann <gerd@gnu.org>
parents: 37926
diff changeset
201
73d05c66ef70 (store_kbd_macro_char): Fix computation of kbd_macro_end.
Gerd Moellmann <gerd@gnu.org>
parents: 37926
diff changeset
202 ptr_offset = kb->kbd_macro_ptr - kb->kbd_macro_buffer;
73d05c66ef70 (store_kbd_macro_char): Fix computation of kbd_macro_end.
Gerd Moellmann <gerd@gnu.org>
parents: 37926
diff changeset
203 end_offset = kb->kbd_macro_end - kb->kbd_macro_buffer;
73d05c66ef70 (store_kbd_macro_char): Fix computation of kbd_macro_end.
Gerd Moellmann <gerd@gnu.org>
parents: 37926
diff changeset
204 kb->kbd_macro_bufsize *= 2;
73d05c66ef70 (store_kbd_macro_char): Fix computation of kbd_macro_end.
Gerd Moellmann <gerd@gnu.org>
parents: 37926
diff changeset
205 nbytes = kb->kbd_macro_bufsize * sizeof *kb->kbd_macro_buffer;
73d05c66ef70 (store_kbd_macro_char): Fix computation of kbd_macro_end.
Gerd Moellmann <gerd@gnu.org>
parents: 37926
diff changeset
206 kb->kbd_macro_buffer
73d05c66ef70 (store_kbd_macro_char): Fix computation of kbd_macro_end.
Gerd Moellmann <gerd@gnu.org>
parents: 37926
diff changeset
207 = (Lisp_Object *) xrealloc (kb->kbd_macro_buffer, nbytes);
73d05c66ef70 (store_kbd_macro_char): Fix computation of kbd_macro_end.
Gerd Moellmann <gerd@gnu.org>
parents: 37926
diff changeset
208 kb->kbd_macro_ptr = kb->kbd_macro_buffer + ptr_offset;
73d05c66ef70 (store_kbd_macro_char): Fix computation of kbd_macro_end.
Gerd Moellmann <gerd@gnu.org>
parents: 37926
diff changeset
209 kb->kbd_macro_end = kb->kbd_macro_buffer + end_offset;
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 }
34361
385981407528 (store_kbd_macro_char): Change the way buffers are
Gerd Moellmann <gerd@gnu.org>
parents: 31829
diff changeset
211
39135
73d05c66ef70 (store_kbd_macro_char): Fix computation of kbd_macro_end.
Gerd Moellmann <gerd@gnu.org>
parents: 37926
diff changeset
212 *kb->kbd_macro_ptr++ = c;
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 }
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 }
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 /* Declare that all chars stored so far in the kbd macro being defined
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 really belong to it. This is done in between editor commands. */
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218
20299
608c1a9aefc8 (store_kbd_macro_char): Define as returning nothing.
Andreas Schwab <schwab@suse.de>
parents: 16562
diff changeset
219 void
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 finalize_kbd_macro_chars ()
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 {
11009
399469e5eb5b Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents: 10992
diff changeset
222 current_kboard->kbd_macro_end = current_kboard->kbd_macro_ptr;
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 }
12845
9ee2045cda62 (Fcancel_kbd_macro_events): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12119
diff changeset
224
9ee2045cda62 (Fcancel_kbd_macro_events): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12119
diff changeset
225 DEFUN ("cancel-kbd-macro-events", Fcancel_kbd_macro_events,
9ee2045cda62 (Fcancel_kbd_macro_events): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12119
diff changeset
226 Scancel_kbd_macro_events, 0, 0, 0,
41940
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
227 doc: /* Cancel the events added to a keyboard macro for this command. */)
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
228 ()
12845
9ee2045cda62 (Fcancel_kbd_macro_events): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12119
diff changeset
229 {
9ee2045cda62 (Fcancel_kbd_macro_events): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12119
diff changeset
230 current_kboard->kbd_macro_ptr = current_kboard->kbd_macro_end;
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 26825
diff changeset
231 return Qnil;
12845
9ee2045cda62 (Fcancel_kbd_macro_events): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12119
diff changeset
232 }
13773
7d50ac085b12 (Fstore_kbd_macro_event): New function.
Karl Heuer <kwzh@gnu.org>
parents: 12845
diff changeset
233
7d50ac085b12 (Fstore_kbd_macro_event): New function.
Karl Heuer <kwzh@gnu.org>
parents: 12845
diff changeset
234 DEFUN ("store-kbd-macro-event", Fstore_kbd_macro_event,
7d50ac085b12 (Fstore_kbd_macro_event): New function.
Karl Heuer <kwzh@gnu.org>
parents: 12845
diff changeset
235 Sstore_kbd_macro_event, 1, 1, 0,
41940
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
236 doc: /* Store EVENT into the keyboard macro being defined. */)
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
237 (event)
13773
7d50ac085b12 (Fstore_kbd_macro_event): New function.
Karl Heuer <kwzh@gnu.org>
parents: 12845
diff changeset
238 Lisp_Object event;
7d50ac085b12 (Fstore_kbd_macro_event): New function.
Karl Heuer <kwzh@gnu.org>
parents: 12845
diff changeset
239 {
7d50ac085b12 (Fstore_kbd_macro_event): New function.
Karl Heuer <kwzh@gnu.org>
parents: 12845
diff changeset
240 store_kbd_macro_char (event);
7d50ac085b12 (Fstore_kbd_macro_event): New function.
Karl Heuer <kwzh@gnu.org>
parents: 12845
diff changeset
241 return Qnil;
7d50ac085b12 (Fstore_kbd_macro_event): New function.
Karl Heuer <kwzh@gnu.org>
parents: 12845
diff changeset
242 }
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 DEFUN ("call-last-kbd-macro", Fcall_last_kbd_macro, Scall_last_kbd_macro,
46887
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
245 0, 2, "p",
41940
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
246 doc: /* Call the last keyboard macro that you defined with \\[start-kbd-macro].
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
247
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
248 A prefix argument serves as a repeat count. Zero means repeat until error.
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
249
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
250 To make a macro permanent so you can call it even after
46887
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
251 defining others, use \\[name-last-kbd-macro].
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
252
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
253 In Lisp, optional second arg LOOPFUNC may be a function that is called prior to
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
254 each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */)
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
255 (prefix, loopfunc)
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
256 Lisp_Object prefix, loopfunc;
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 {
16562
4999fc12564e (Fcall_last_kbd_macro): Set this_command from last_command
Richard M. Stallman <rms@gnu.org>
parents: 15976
diff changeset
258 /* Don't interfere with recognition of the previous command
4999fc12564e (Fcall_last_kbd_macro): Set this_command from last_command
Richard M. Stallman <rms@gnu.org>
parents: 15976
diff changeset
259 from before this macro started. */
22968
edcf24874ef5 (Fcall_last_kbd_macro): this_command renamed to Vthis_command.
Richard M. Stallman <rms@gnu.org>
parents: 22915
diff changeset
260 Vthis_command = current_kboard->Vlast_command;
24530
14cc75ebfd7b (Fexecute_kbd_macro): Save real_this_command.
Karl Heuer <kwzh@gnu.org>
parents: 24482
diff changeset
261 /* C-x z after the macro should repeat the macro. */
14cc75ebfd7b (Fexecute_kbd_macro): Save real_this_command.
Karl Heuer <kwzh@gnu.org>
parents: 24482
diff changeset
262 real_this_command = current_kboard->Vlast_kbd_macro;
16562
4999fc12564e (Fcall_last_kbd_macro): Set this_command from last_command
Richard M. Stallman <rms@gnu.org>
parents: 15976
diff changeset
263
11009
399469e5eb5b Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents: 10992
diff changeset
264 if (! NILP (current_kboard->defining_kbd_macro))
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 error ("Can't execute anonymous macro while defining one");
11009
399469e5eb5b Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents: 10992
diff changeset
266 else if (NILP (current_kboard->Vlast_kbd_macro))
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 error ("No kbd macro has been defined");
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 else
46887
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
269 Fexecute_kbd_macro (current_kboard->Vlast_kbd_macro, prefix, loopfunc);
16562
4999fc12564e (Fcall_last_kbd_macro): Set this_command from last_command
Richard M. Stallman <rms@gnu.org>
parents: 15976
diff changeset
270
4999fc12564e (Fcall_last_kbd_macro): Set this_command from last_command
Richard M. Stallman <rms@gnu.org>
parents: 15976
diff changeset
271 /* command_loop_1 sets this to nil before it returns;
4999fc12564e (Fcall_last_kbd_macro): Set this_command from last_command
Richard M. Stallman <rms@gnu.org>
parents: 15976
diff changeset
272 get back the last command within the macro
4999fc12564e (Fcall_last_kbd_macro): Set this_command from last_command
Richard M. Stallman <rms@gnu.org>
parents: 15976
diff changeset
273 so that it can be last, again, after we return. */
22968
edcf24874ef5 (Fcall_last_kbd_macro): this_command renamed to Vthis_command.
Richard M. Stallman <rms@gnu.org>
parents: 22915
diff changeset
274 Vthis_command = current_kboard->Vlast_command;
16562
4999fc12564e (Fcall_last_kbd_macro): Set this_command from last_command
Richard M. Stallman <rms@gnu.org>
parents: 15976
diff changeset
275
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 return Qnil;
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 }
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 /* Restore Vexecuting_macro and executing_macro_index - called when
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 the unwind-protect in Fexecute_kbd_macro gets invoked. */
15968
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
281
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 static Lisp_Object
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 pop_kbd_macro (info)
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 Lisp_Object info;
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 {
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 Lisp_Object tem;
24530
14cc75ebfd7b (Fexecute_kbd_macro): Save real_this_command.
Karl Heuer <kwzh@gnu.org>
parents: 24482
diff changeset
287 Vexecuting_macro = XCAR (info);
14cc75ebfd7b (Fexecute_kbd_macro): Save real_this_command.
Karl Heuer <kwzh@gnu.org>
parents: 24482
diff changeset
288 tem = XCDR (info);
14cc75ebfd7b (Fexecute_kbd_macro): Save real_this_command.
Karl Heuer <kwzh@gnu.org>
parents: 24482
diff changeset
289 executing_macro_index = XINT (XCAR (tem));
14cc75ebfd7b (Fexecute_kbd_macro): Save real_this_command.
Karl Heuer <kwzh@gnu.org>
parents: 24482
diff changeset
290 real_this_command = XCDR (tem);
35119
97a19f647a12 (Qkbd_macro_termination_hook): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 34361
diff changeset
291 Frun_hooks (1, &Qkbd_macro_termination_hook);
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 return Qnil;
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 }
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294
46887
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
295 DEFUN ("execute-kbd-macro", Fexecute_kbd_macro, Sexecute_kbd_macro, 1, 3, 0,
41940
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
296 doc: /* Execute MACRO as string of editor command characters.
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
297 If MACRO is a symbol, its function definition is used.
46887
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
298 COUNT is a repeat count, or nil for once, or 0 for infinite loop.
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
299
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
300 Optional third arg LOOPFUNC may be a function that is called prior to
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
301 each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */)
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
302 (macro, count, loopfunc)
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
303 Lisp_Object macro, count, loopfunc;
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 {
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 Lisp_Object final;
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 Lisp_Object tem;
46295
b77ef572e1c9 Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents: 41940
diff changeset
307 int pdlcount = SPECPDL_INDEX ();
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 int repeat = 1;
46887
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
309 struct gcpro gcpro1, gcpro2;
15968
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
310 int success_count = 0;
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311
24482
9b722e922325 (Fexecute_kbd_macro): Initialize executing_macro_iterations at beginning.
Karl Heuer <kwzh@gnu.org>
parents: 23434
diff changeset
312 executing_macro_iterations = 0;
9b722e922325 (Fexecute_kbd_macro): Initialize executing_macro_iterations at beginning.
Karl Heuer <kwzh@gnu.org>
parents: 23434
diff changeset
313
14100
0950fefc4bd1 (Fexecute_kbd_macro): Reindent properly.
Erik Naggum <erik@naggum.no>
parents: 14094
diff changeset
314 if (!NILP (count))
0950fefc4bd1 (Fexecute_kbd_macro): Reindent properly.
Erik Naggum <erik@naggum.no>
parents: 14094
diff changeset
315 {
0950fefc4bd1 (Fexecute_kbd_macro): Reindent properly.
Erik Naggum <erik@naggum.no>
parents: 14094
diff changeset
316 count = Fprefix_numeric_value (count);
0950fefc4bd1 (Fexecute_kbd_macro): Reindent properly.
Erik Naggum <erik@naggum.no>
parents: 14094
diff changeset
317 repeat = XINT (count);
0950fefc4bd1 (Fexecute_kbd_macro): Reindent properly.
Erik Naggum <erik@naggum.no>
parents: 14094
diff changeset
318 }
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319
647
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
320 final = indirect_function (macro);
9122
9ba3f17d6631 (Fexecute_kbd_macro): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 4696
diff changeset
321 if (!STRINGP (final) && !VECTORP (final))
22915
ef9dd93e3077 (Fexecute_kbd_macro): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents: 20299
diff changeset
322 error ("Keyboard macros must be strings or vectors");
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323
24530
14cc75ebfd7b (Fexecute_kbd_macro): Save real_this_command.
Karl Heuer <kwzh@gnu.org>
parents: 24482
diff changeset
324 tem = Fcons (Vexecuting_macro,
14cc75ebfd7b (Fexecute_kbd_macro): Save real_this_command.
Karl Heuer <kwzh@gnu.org>
parents: 24482
diff changeset
325 Fcons (make_number (executing_macro_index),
14cc75ebfd7b (Fexecute_kbd_macro): Save real_this_command.
Karl Heuer <kwzh@gnu.org>
parents: 24482
diff changeset
326 real_this_command));
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 record_unwind_protect (pop_kbd_macro, tem);
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328
46887
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
329 GCPRO2 (final, loopfunc);
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 do
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 {
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 Vexecuting_macro = final;
15968
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
333 executing_macro = final;
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 executing_macro_index = 0;
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335
12119
d7b51659a56d (Fexecute_kbd_macro): Vprefix_arg is now part of kboard.
Karl Heuer <kwzh@gnu.org>
parents: 11341
diff changeset
336 current_kboard->Vprefix_arg = Qnil;
46887
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
337
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
338 if (!NILP (loopfunc))
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
339 {
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
340 Lisp_Object cont;
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
341 cont = call0 (loopfunc);
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
342 if (NILP (cont))
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
343 break;
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
344 }
d9b11a5b4ebf (Fstart_kbd_macro): Added NO-EXEC argument to inhibit
Kim F. Storm <storm@cua.dk>
parents: 46295
diff changeset
345
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 command_loop_1 ();
1682
af0995b9b142 * macros.c (Fend_kbd_macro): Don't use XFASTINT to check if arg is
Jim Blandy <jimb@redhat.com>
parents: 647
diff changeset
347
15968
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
348 executing_macro_iterations = ++success_count;
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
349
1682
af0995b9b142 * macros.c (Fend_kbd_macro): Don't use XFASTINT to check if arg is
Jim Blandy <jimb@redhat.com>
parents: 647
diff changeset
350 QUIT;
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 }
9122
9ba3f17d6631 (Fexecute_kbd_macro): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 4696
diff changeset
352 while (--repeat
9ba3f17d6631 (Fexecute_kbd_macro): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 4696
diff changeset
353 && (STRINGP (Vexecuting_macro) || VECTORP (Vexecuting_macro)));
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354
15968
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
355 executing_macro = Qnil;
231e14e38946 (executing_macro_iterations, executing_macro): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 15223
diff changeset
356
23434
1dd05eb0443d (Fexecute_kbd_macro): Set real_this_command.
Richard M. Stallman <rms@gnu.org>
parents: 22968
diff changeset
357 real_this_command = Vexecuting_macro;
1dd05eb0443d (Fexecute_kbd_macro): Set real_this_command.
Richard M. Stallman <rms@gnu.org>
parents: 22968
diff changeset
358
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 UNGCPRO;
14094
e5e4fe8e968f (Fexecute_kbd_macro): Local var `pdlcount' renamed from
Karl Heuer <kwzh@gnu.org>
parents: 14081
diff changeset
360 return unbind_to (pdlcount, Qnil);
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 }
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362
20299
608c1a9aefc8 (store_kbd_macro_char): Define as returning nothing.
Andreas Schwab <schwab@suse.de>
parents: 16562
diff changeset
363 void
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 init_macros ()
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 {
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 Vexecuting_macro = Qnil;
15976
e6d654e1fa2a (init_macros): Initialize executing_macro, too.
Erik Naggum <erik@naggum.no>
parents: 15968
diff changeset
367 executing_macro = Qnil;
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 }
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369
20299
608c1a9aefc8 (store_kbd_macro_char): Define as returning nothing.
Andreas Schwab <schwab@suse.de>
parents: 16562
diff changeset
370 void
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 syms_of_macros ()
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 {
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 Qexecute_kbd_macro = intern ("execute-kbd-macro");
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 staticpro (&Qexecute_kbd_macro);
35119
97a19f647a12 (Qkbd_macro_termination_hook): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 34361
diff changeset
375 Qkbd_macro_termination_hook = intern ("kbd-macro-termination-hook");
97a19f647a12 (Qkbd_macro_termination_hook): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 34361
diff changeset
376 staticpro (&Qkbd_macro_termination_hook);
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 defsubr (&Sstart_kbd_macro);
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 defsubr (&Send_kbd_macro);
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 defsubr (&Scall_last_kbd_macro);
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 defsubr (&Sexecute_kbd_macro);
12845
9ee2045cda62 (Fcancel_kbd_macro_events): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12119
diff changeset
382 defsubr (&Scancel_kbd_macro_events);
13773
7d50ac085b12 (Fstore_kbd_macro_event): New function.
Karl Heuer <kwzh@gnu.org>
parents: 12845
diff changeset
383 defsubr (&Sstore_kbd_macro_event);
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384
11009
399469e5eb5b Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents: 10992
diff changeset
385 DEFVAR_KBOARD ("defining-kbd-macro", defining_kbd_macro,
41940
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
386 doc: /* Non-nil while a keyboard macro is being defined. Don't set this! */);
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 DEFVAR_LISP ("executing-macro", &Vexecuting_macro,
41940
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
389 doc: /* Currently executing keyboard macro (string or vector); nil if none executing. */);
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390
47307
06c376f5df86 (executing_macro_index): Change type to EMACS_INT.
Kim F. Storm <storm@cua.dk>
parents: 46887
diff changeset
391 DEFVAR_INT ("executing-macro-index", &executing_macro_index,
06c376f5df86 (executing_macro_index): Change type to EMACS_INT.
Kim F. Storm <storm@cua.dk>
parents: 46887
diff changeset
392 doc: /* Index in currently executing keyboard macro; undefined if none executing. */);
06c376f5df86 (executing_macro_index): Change type to EMACS_INT.
Kim F. Storm <storm@cua.dk>
parents: 46887
diff changeset
393
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 DEFVAR_LISP_NOPRO ("executing-kbd-macro", &Vexecuting_macro,
41940
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
395 doc: /* Currently executing keyboard macro (string or vector); nil if none executing. */);
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396
11009
399469e5eb5b Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents: 10992
diff changeset
397 DEFVAR_KBOARD ("last-kbd-macro", Vlast_kbd_macro,
41940
63819c5d6049 Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
398 doc: /* Last kbd macro defined, as a string or vector; nil if none defined. */);
246
81e375c3eb58 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 }