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.

Filter by
Sorted by
Tagged with
0 votes
2 answers
29 views

How to insert kbd macros in Yas-snippets?

I'm trying to learn how to: Define a kbd-macro, (here I'm using kbd-macros, because I'm bad at elisp currently). Letting that to be executed when yas-snippet to expand. (here I'm struggling with) My ...
  • 347
1 vote
1 answer
30 views

How to remove the whitespace on the beginning of every expression on this Clojure code snippet?

I have the following Clojure code snippet: { :id "SchK-Cash-contributions-(60%)" :description "Schedule K - Cash contributions (60%)" :line "L12a" :ultratax-...
0 votes
1 answer
45 views

How to replay combination of sequence of commands and key stroke?

I want to record sequence of command and key stroke. for example. open =~/.doom.d/config.org= search buffer with ~+default/search-buffer~ type in =with-eval-after-load 'org= in this case, If I can ...
2 votes
1 answer
27 views

Documenting keyboard macros Can I have a doc string for fset the same way as defun

I often create and save elaborate keyboard macros that I wish to use later, and hope to be prompted for the proper context to use them. I note that if I manually write a function to use as a command ...
1 vote
0 answers
19 views

Repeate keyboard macro (e) doesn't work when I ace-jump-window/aw-flip-window to another frame

If I use ace-jump-window's aw-flip-window functionality in the middle of defining a macro (i.e. switch to the last window - I want which windows I jump between to be dynamic, not fixed to the current ...
1 vote
1 answer
67 views

Elisp function to transform word at point

How to write an elisp function that transforms the word at point? Specifically, in the C++ code I am refactoring I have to replace tons of raw pointers into smart pointers. Say, for class Foo, I would ...
  • 145
0 votes
3 answers
70 views

How do I convert a `matrix` in one form to a `matrix` in another form (like `bmatrix` environment)

I'm attempting to take faster linear algebra notes within org-mode. The latex of a matrix is complex to write, so I'm trying to develop a shorthand expansion. My current workflow is to highlight a ...
1 vote
4 answers
73 views

how to define keyboard macro from text

I am using shell inside Emacs. Often I need to execute a series of shell commands around ~40 chars, as of now I copy all the commands together and paste it from documentation. Is there any way to ...
  • 11
1 vote
1 answer
22 views

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-...
  • 157
2 votes
2 answers
126 views

Emacs 28: How to use `RET` without exiting a recursive edit within a keyboard macro?

Now that I switched to using GNU Emacs 28.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95)) of 2022-05-11 I can no longer end my use of my keyboard macro that ...
1 vote
1 answer
60 views

How to write a Lisp representation of a keyboard macro and bind it to a command name?

I'm using spacemacs with vim-bindings, but I only mention it so you don't scratch your head too long at the keystrokes of the macro. A regular emacs solution will work just the same. I've read through ...
0 votes
0 answers
18 views

How to control behavior of command storage for macro repeat?

There are some actions which I would like to repeat however repeating the action doesn't work as I would like it to. Take dabbrev, if I repeat a dabbrev completion, the result may be different based ...
  • 7,969
2 votes
1 answer
19 views

shortcut to select data to the last row

I'm new to Emacs. First of all sorry if my English is weird because it is not my first language. I don't know much about the terminologies used in Emacs. Currently, I'm just using Emacs for data ...
2 votes
0 answers
49 views

How to edit keyboard macro saved in file?

Here is my custom keyboard macro: (fset 'gen-numbers (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (...
  • 3,738
3 votes
2 answers
35 views

count-matches' result in kill-ring?

I'm trying to create a keyboard macro to generate a report which displays the number of times a certain string occurs. I have two buffers, with all the strings to look for(on a separate line) the ...
  • 301
1 vote
1 answer
49 views

How to automate the test step in "debugging by bisection"?

Sometimes I run into a problem with Emacs that goes away if invoke Emacs with the --no-init-flag. In other word, I can deduce that the problem in question is caused by code somewhere in my .emacs file....
  • 3,095
0 votes
0 answers
42 views

Make undo during I-search revert last call to ding

Entering a failing search string during I-search triggers a call to ding(). If this happens during a macro recording that ding when the macro is being played will abort the macro which in turns ...
  • 467
2 votes
0 answers
26 views

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 ...
  • 7,969
1 vote
1 answer
57 views

How to tell, with Elisp, whether a command is running as part of a keyboard macro?

In some situations a command will use timers or hooks in a way that doesn't work when repeating as a keyboard macro. How can I detect if a function is running as part of a keyboard macro that is being ...
  • 7,969
0 votes
1 answer
72 views

Do something for all regular expression matches

I have a named-and-saved keyboard macro that I want to apply to all regular expression matches. How to do that? (Related: I found this stackoverflow post: Running a macro till the end of text file in ...
1 vote
1 answer
51 views

how to end macro expansion in *scratch* buffer and return to writable buffer

In scratch buffer, Emacs can expand macros(C-c e; macrostep-expand). But once I expanded the macro, it seems to become a read-only buffer. I don't know how to end macro expansion and return to ...
  • 11
0 votes
1 answer
142 views

`C-c C-c` compilation stopped working in SLIME but works if manually typed, how to fix it?

I am new to Emacs and Slime. I have been using both of them daily for the last 10 days. And it is amazing! I am impressed. Today, I decided to install and try the package Paredit. Not sure if this is ...
0 votes
0 answers
119 views

Kill buffers - how to make *scratch* and *Messages* last

Any setting I can use to get back the old behavior where killing a buffer I get to the next buffer for the files I have given on the command line? I have been using Emacs like this for years Open ...
  • 11
0 votes
1 answer
84 views

Change vertical characters to horizontal

I have the following data and want to change from Code 1 to Code 2. Is there any useful method to do that? Code 1 11130101 11130102 11130201 Code 2 11130101, 11130102, 11130201
  • 101
3 votes
1 answer
46 views

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-...
  • 288
1 vote
1 answer
47 views

How to duplicate text but increment a numeric part of a name?

Say that I have rect1 one and I'll multiply it 3 times by yanking. let rect1 = Rectangle { width: 10, height: 40, } let rect1 = Rectangle { width: 10, height: 40, } ...
0 votes
1 answer
120 views

Execute function by using evil-set-register

I use evil and I want to execute a function by using Emacs macro system. Let's say I have the following macro. (evil-set-register ?f [?i ?f ?o ?o ?b ?a ?r escape]) I can run the macro by using @f. ...
0 votes
0 answers
77 views

How to run a keyboard macro (saved in my init.el) automatically when Emacs starts up?

I have saved a keyboard macro in my init.el file as follows (fset 'remember-notes-my-macro (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-...
  • 135
1 vote
1 answer
27 views

How to reference the contents of a variable in a keyboard macro definition?

I have a macro called f5, which I globally bind the keyboard key <f5> to: (fset 'f5 [?i ?\[ ?* ?* ?P ?1 ? ?\] escape ?h ?a]) (global-set-key (kbd "<f5>") 'f5) So when I ...
0 votes
1 answer
185 views

How to overwrite by pasting a string without selecting a region?

I can't figure out how to paste a string, for example 145 characters long, into a text line in a way, that the next 145 characters after the string are overwritten by this string or simply erased. An ...
0 votes
1 answer
15 views

Get keyboard macro mapping

What functionality is available in emacs to get information about a keyboard macro? Even something as simple as printing out what the macro evaluates.
1 vote
0 answers
115 views

How do I disable Swiper while defining a keyboard macro?

I don't like the swiper behavior when interactively defining a macro, it is slow and seems to cause other problems. How can I revert bound keys to isearch-forward and isearch-backward when defining ...
1 vote
0 answers
69 views

keyboard macro with input-method inserts characters twice

When I define keyboard macro with some input method enabled (lets say, english-dvorak), self-insert commands are repeated twice. For example, if I define macro like this: F3insert chars asdfF4 and ...
  • 249
3 votes
2 answers
541 views

How do I get an initial M-x argument?

I use an asterisk in my function names, so that to execute one of my own functions, I would begin by typing M-x *. Now I would like to save myself a keystroke and achieve the same by M-X. How do I ...
  • 3,094
0 votes
0 answers
16 views

How to execute a keyboard macro until termination inside another one, without stopping the recording?

I have a buffer with the following content and I need to delete the duplicate lines. 57,04/15/2020 03:02PM,'Weight'='2.478 lb','tare'='0.918 lb' 57,04/15/2020 03:02PM,'Weight'='2.478 lb','tare'='0....
  • 219
3 votes
1 answer
252 views

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 ...
  • 31
0 votes
1 answer
35 views

Customizing f6-key for fast "M-x imenu" + "Pr" + Enter

I wish to customize my f6key so it corresponds to a fast way of doing M-x imenu, then Pr RET. I've added the following to my ~/.emacs: (global-set-key [f6] 'imenu) Then I've tried to add different ...
2 votes
1 answer
257 views

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 ...
1 vote
0 answers
57 views

isearch in kmacro-step-edit-macro

I'm trying to edit a keyboard macro using kmacro-step-edit-macro. The macro starts by isearching for a word. C-s ;; isearch-forward binary_function ;; self-insert-command * 15 RET ...
1 vote
3 answers
235 views

How to create loops for inserting text?

Imagine I want to create a list with 10 items, i. e. 1. 2. 3. ... 10. In Vim I can use the command :for i in range(1,10) | put =i.'. ' | endfor for this. How can I do the same thing in Emacs? ...
1 vote
0 answers
63 views

Simple regexp inside emacs keyboard macro

Newbie question: I'm trying to record a keyboard macro with a simple regexp inside (search-backward-regexp ^[0-9]). This works well when recording the macro, but as soon as I try to execute it, the ...
  • 11
3 votes
1 answer
207 views

alphabetic keyboard macro "counter"?

I very much {like, use} the kmacro-*-counter family of commands. However I sometimes find myself needing to generate alphabetic sequences (e.g., A, B, C, ...) instead of integer sequences (e.g., 1, 2, ...
  • 592
0 votes
1 answer
241 views

keyboard macro for opening a file

How can I create a keyboard macro where a file myfile is opened by executing M-x openmyfile. The main part should look like (fset 'openmyfile [?\C-x ?\C-f <dir of myfile> return]) but I don'...
3 votes
1 answer
128 views

Octal character representation in keyboard macros

I generated a macro as a help for generating indices for words I have marked before. Now this macro looks as follows (fset 'index "\367\\index{\C-y") What does \367stand for and where can I look ...
0 votes
1 answer
240 views

How can I apply a keyboard macro to every line that starts with rectangle mark region

Lets suppose I would like to edit my text and to add comments to the column in the text. This is my text: something-text1 foobar1 something-text1 something-text2 foobar2 something-text2 --- ...
  • 308
2 votes
0 answers
119 views

execute-kbd-macro apparently not working according to its doc?

The doc of execute-kbd-macro says: (execute-kbd-macro MACRO &optional COUNT LOOPFUNC) ... If MACRO is a symbol, its function definition is used. I tried M-: (execute-kbd-macro 'ignore). ...
  • 31.7k
0 votes
1 answer
47 views

Creating a macro to change dictionary and run ispell

I would like to create a simple key binding (e.g. C-c s e) to spell check the (mu4e) email message I am composing using English (and use other bindings for other languages). I thought I'd simply ...
0 votes
1 answer
55 views

macro execution with i-search fails under Linux and succeeds under windows?

Imagine you've got file with FirstName|LastName| like this : John|toto| Hanz|titi| and want to put the first names at the end of the lines (just an stupid exemple). You may use Macro Recordind for ...
  • 111
2 votes
0 answers
100 views

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 ...
  • 3,738
0 votes
1 answer
180 views

how to generate dynamic json data with emacs (macros)?

I was in a meeting yesterday where I was presenting a program that referenced a certain json file with data like this: [ { id: 1, text: '...', ... }, { id: 2, text: '...', ... } ] In ...
  • 143