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
1answer
151 views

Custom search function for dictionary lookup

I have a plain text dictionary in which each headword is matched by ^# \(† \)?headword, How can I make a custom search function that relieves me of typing the whole regex every time I want to look ...
0
votes
1answer
54 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
1answer
9 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.
3
votes
2answers
233 views

Cua-mode and keyboard macros

I have just started using emacs, so I decided to use cua-mode. I got this weird problem when I'm using macros and copy/cut (C-c/ C-x). let's assume this simple macro for example: <F3> C-S-right ...
0
votes
0answers
19 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
1answer
173 views

What is the difference between `C-i` and `<C-i>`?

I've just set (define-key input-decode-map "\C-i" [\C-i]) (define-key input-decode-map "\C-m" [\C-m]) (define-key input-decode-map "\C-[" [\C-\[]) in my config, but I noticed that C-i is now ...
3
votes
1answer
163 views

Process unread-command-events and redisplay

(defun pretend (keys) (dolist (e (reverse (listify-key-sequence (kbd keys)))) (push e unread-command-events) ;; (mystery-function) (redisplay t) (sleep-for 0.1))) (pretend "M-x my-...
1
vote
0answers
16 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 ...
0
votes
2answers
255 views

org-sparse-tree on multiple keywords

I currently have a keyboard shortcut bound to C-c t that shows me all of the NEXTACTION items I have, no matter what headline level they're at. It works by using a kbd macro wherein I just typed C-c / ...
0
votes
1answer
151 views

How to insert/dump all keyboard macros at once?

Is there a way to show all keyboard macros (similar to insert-kbd-macro) without having to first name each macro? Using macros with evil-mode in case this makes a difference.
3
votes
2answers
197 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 ...
0
votes
0answers
10 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....
3
votes
0answers
48 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 ...
0
votes
1answer
25 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 ...
1
vote
0answers
71 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 ...
0
votes
0answers
15 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
3answers
60 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? ...
10
votes
4answers
595 views

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 ...
4
votes
4answers
291 views

Write `var0, var1, var2, …, var10` in a buffer

Most of the times there is no need to write manually many variables with the same name and a different index, like var0, var1, var2, var3, ..., var9 because one can use arrays, vectors or whatever ...
0
votes
1answer
87 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 ...
1
vote
0answers
34 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 ...
0
votes
0answers
125 views

Record a keyboard macro in Evil Mode to a register with another keyboard macro inside it

In vim, one can type qw to start recording a macro to register w, then record the macro, then finish recording to w by pressing q again. It is then possible to record another macro by typing qe, ...
2
votes
1answer
74 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, ...
0
votes
1answer
70 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
1answer
66 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
1answer
77 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 --- ...
1
vote
0answers
42 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). ...
0
votes
1answer
27 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 ...
8
votes
4answers
1k views

How can I run a keyboard macro in selected buffers from Ibuffer or selected files from dired?

If I have to do some variable name refactoring, I use ag and multiple-cursors. But when I have to do some code block removal/addition/moving, I use keyboard macros. But I need to switch to each ...
0
votes
1answer
31 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 ...
1
vote
0answers
53 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 ...
4
votes
1answer
114 views

Binding a key sequence to a key sequence instead of a command

In my .emacs, I tried to use (global-set-key (kbd "M-r") (kbd "C-x r j") so I can use M-r to jump to a register. However, doing this and using the command gives After 0 kbd macro iterations: Args ...
4
votes
2answers
375 views

Inserting the plus minus unicode symbol ± as a keyboard macro

I insert the plus minus symbol ± frequently enough that I want to bind it to a key. From emacs -Q, I've tried this: (global-set-key (kbd "C-c m") "±") However, when I enter C-c m, the minibuffer ...
0
votes
1answer
49 views

What is wrong with this keyboard macro ?

I would like to accomplish following Set mark Advance to end of sentence Copy selection -> macro start here Open journal using ^c c Paste copied item Save using C-x C-s Exit using C-c C-c ...
0
votes
2answers
258 views

How to deal with particular key-binding conflict (F3 key on Mac)

I would like to make a very basic macro on my Mac, to have a command that writes a list of slashes in the current file : //////////////////// The "Basic emacs macros" section of the manual says : ‘&...
3
votes
3answers
159 views

Keyboard macros or command for quick refiling using dired or similar

I scan all the mail (not email, but good ol' mail) I receive and have these saved as PDF files into a directory, which we think of as an inbox. I would like to find a workflow to quickly refile these ...
0
votes
1answer
148 views

Hydra that executes interactive search

What I want is an easy-to-use hydra for macro execution. Typically I execute a keyboard macro a few times (e), and then might want to repeat infinitely until the end of a buffer (u). Sometimes I ...
0
votes
1answer
61 views

Keyboard macro get data from one buffer and put to another buffer

I use keyboard macros in one buffer like this: 'C-x (’ or <f3>– start defining a keyboard macro `C-x )’ or <f4>– stop defining the keyboard macro Nice. It's work fine. But I use macro in ...
1
vote
1answer
45 views

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 ...
1
vote
2answers
76 views

Writing a small elisp function

Could someone here write a small Elisp function for me? What I would like Emacs to do is the following: I have a region like this: [0.04579] [0.06569] [0.09507] [0.12696] [0.27929] [0....
5
votes
2answers
1k views

Incrementing characters in Emacs, next to numbers?

You can place a pointer on a number, like 1, and increment it to 2. There are many alternatives on this. See also the Emacs Wiki: https://www.emacswiki.org/emacs/IncrementNumber 7 alternatives to ...
0
votes
1answer
41 views

Wrap one line of text into a multiple line block

I have a very long line of text (8000 characters). I would like to format this nicely so it splits across multiple lines in a block. Where the line breaks occurs does not matter for this purpose. ...
1
vote
1answer
123 views

Weird behavior when inserting parentheses in keyboard macro

In my init file, I have these bindings: (global-set-key (kbd "C-x S-SPC") (kbd ")")) (global-set-key (kbd "S-SPC") (kbd "(")) Now, starting with empty buffer, if I define this keyboard macro: S-SPC ...
1
vote
1answer
123 views

How can I stop keyboard-quit from ending macro definition?

When I am defining keyboard macro with kmacro-start-macro and I press C-g (for example to deactivate mark or I press it accidentally), macro definition is aborted and I have to start over. Is there ...
3
votes
3answers
713 views

Evil mode: How to run evil-indent on the text I've just pasted

When I copy line three below in evil-mode function foo() { } var bar; #copy and paste it at line two, I get function foo() { var bar; #paste } instead of the correctly indented function foo() { ...
2
votes
1answer
148 views

Repeat actions in slow motion, for presentation purposes

I would like to repeat actions (preferably as a keyboard macro, but I am open to other solutions), in some kind of automated, "slow motion". By "slow motion", I mean at a speed that is close to human ...
10
votes
2answers
436 views

What might be unused keys on Emacs that generally can be used to bind keyboard macros?

I read that the usual way to bind key to keyboard macros are C-x C-k 0 to 9 and A to Z. So for example, after we define a keyboard macro, we can type C-x C-k b and Emacs will ask for a key to bind. ...
0
votes
1answer
151 views

Get Org Link Description From Table Column of Links

I have an org table and I want to take an existing column of org links of the form: [[http://blah.com/blah/blah/foo][foo]] And create an adjacent column containing only the description - i.e. foo. ...
0
votes
1answer
115 views

Run keyboard macro after open file?

Is it possible to run a keyboard macro in Emacs right after opening a file? For example, when I open a text file I want to get information in buffer Hello world.
0
votes
2answers
98 views

Unable to supply macro name to edit-kbd-macro when M-x is bound to smex

When I M-x edit-kbd-macro, it prompts saying: Keyboard macro to edit (C-x e, M-x, C-h l, or keys): Here, I would hit M-x. It will then allow me to enter the name of the macro. I have several named ...