Questions tagged [keyboard-macros]

A "keyboard macro" is a command defined by an Emacs user which represents a sequence of keys. Calling a keyboard macro is equivalent to typing that key sequence.

119 questions
10
votes
4 answers

How to resume an INCOMPLETE keyboard macro recording?

Classic use-case: You start recording a macro: C-x ( You do some stuff, let's say hello. You run a command that throws an error, let's say C-g (e.g. you mistakenly run C-s and you have to cancel that with C-g, now your work is lost). Now your…
8
votes
2 answers

Sleep in an kbd macro

I was completing the python koans in emacs, and I was using a kdb macro to test my changes in a shell buffer and jump back into the python code. I wanted to take the line number of the next error from the shell buffer so that I could leap to it…
Matthew Piziak
  • 6,038
  • 3
  • 31
  • 79
6
votes
1 answer

Editing a stored keyboard macro and storing the edited version

In my ~/.emacs, there are several keyboard macros stored. They appear as (fset 'dhteu-macro-name ... entries. BTW, dhteu is just a random alphabet combination prefixed to avoid collision with any existing commands. I can C-x C-k e M-x supply a macro…
deshmukh
  • 1,912
  • 14
  • 31
6
votes
1 answer

Function to count how many times a keyboard macro is invoked?

I am quite bad at counting and remember how many times I have invoked a special command, so I wonder is there any way to count and show in the minibuffer how many time a keyboard macro was invoked? Say that I want to use the macro to navigate the…
JKRT
  • 201
  • 2
  • 4
5
votes
1 answer

Define a keyboard macro to indefinitely execute another keyboard macro and then do something else

I've defined one keyboard macro, bound to keystroke 1, say, and I want to define a second keyboard macro that executes the first one indefinitely and then returns to the beginning of the buffer. I assume that the first one always terminates if…
4
votes
1 answer

Visualise keyboard macros (converting them to human readable key names)

I often find useful/nifty kmacros on the web, like (kmacro-exec-ring-item (quote ([return 3 16 14 5 return 21 3 46 return 24 98 return] 0 "%d")) arg). Being a curious guy I am, I usually want to know how they do what they do. Given the (kbd)…
GergelyPolonkai
  • 758
  • 6
  • 12
4
votes
1 answer

Keyboard macro repeats indefinitely

I'm reading GNU Emacs Manual to learn how to use Emacs in its full power. I now I'm trying to make use of keyboard macros. It's fairly easy, but I cannot understand why the first defined macro repeats infinitely, while all subsequent macros are…
Mark Karpov
  • 4,943
  • 1
  • 26
  • 54
3
votes
1 answer

How to stop execution of keyboard macro?

I mistakenly ran a keyboard macro with an Infinite Argument, which made the macro execute endlessly. Take the following example, which just inserts the character a: C-x ( a C-x ) If I then run: C-u 0 C-x e in the *scratch* buffer, the newly…
Keta
  • 33
  • 3
3
votes
1 answer

How to write documentation for saved keyboard macros?

I have recently defined a keyboard macro using C-x ( and C-x). I then gave the keyboard macro a name using M-x name-last-kbd-macro RET defined-kbd-macro. And saved it to a file using M-x insert-kbd-macro. When I used C-h f RET defined-kbd-macro,…
Tian
  • 288
  • 1
  • 8
3
votes
1 answer

Emacs keyboard macros ? all over

I have used keyboard macros for a long time, but moved between companies, systems, and various machines over my career. I used to be able to record macros and insert-kbd-macro into my .emacs file and they look readable and concise: (fset…
kmcaron
  • 31
  • 1
2
votes
0 answers

Is it possible to control how a command is recorded as a keyboard macro?

Some actions don't work well when repeated in a keyboard macro. For example, dabbrev-expand may give a different expansion based on the surrounding context. I would like to repeat the action as if I had typed in the text that was expanded, or at…
ideasman42
  • 8,786
  • 1
  • 32
  • 114
2
votes
1 answer

Associate (and save) macro with current file (+/- evil spacemacs)

After edit : I am using evil-mode. I often record macros very specific to the file I am editing with qq or qw. Is there a way to autosave those macros and the key associated to them when saving the file ? In order to make those macros working when…
pietrodito
  • 187
  • 7
2
votes
0 answers

After 0 kbd macro iterations: read-kbd-macro: Variable binding depth exceeds max-specpdl-size

Here my kbd macros in mycustom.el (fset 'keep-tv-channels-names (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([134217848 107 101 return 69 88 84 73 78 70 return 134217848 81 85 69 82 return 46 42 44…
a_subscriber
  • 4,062
  • 1
  • 18
  • 56
2
votes
1 answer

Keyboard macro produces a series of numbers

I did some editing. Then went to C-x C-k l edited the stuff to suit my needs. Saved it with C-c C-c. Gave it a name with C-x C-k b. Finally, went to ~/.emacs and did M-x insert-kbd-macro To my surprise, it produced few words and a long series of…
deshmukh
  • 1,912
  • 14
  • 31
1
vote
1 answer

Simple keyboard macro to jump to \begin{document} regardless of current location in file

If you are in the preamble of a TeX document you can do C-s \begin{document} or C-r \begin{document} if you are in the body of the document. It would useful to have a simple, all-purpose macro (say, M-D) that would accomplish this no matter where…
sgmoye
  • 179
  • 1
  • 8
1
2