Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
21 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 ...
3
votes
3answers
61 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 ...
1
vote
1answer
27 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
55 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....
0
votes
1answer
33 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. ...
0
votes
1answer
32 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 ...
0
votes
0answers
23 views

How to enclose each integer of an array of integers with quotes?

Say I have a line of code like this: int[] array = {1, 2, 3, 4, 5}; Now I want to change it to this: String[] array = {"1", "2", "3", "4", "5"}; So instead of enclosing each number with quotes ...
0
votes
1answer
36 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
1answer
68 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
1answer
77 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.
0
votes
1answer
71 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
63 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.
3
votes
0answers
23 views

Keyboard macro with occur

In a keyboard macro, there is an occur command. While recording the macro, I switched to the occur window, did some editing, closed occur buffer reverted back to original buffer to continue editing. ...
6
votes
1answer
83 views

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 ...
0
votes
2answers
52 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 ...
2
votes
1answer
44 views

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 ...
0
votes
0answers
19 views

Recording a keyboard macro with actual character strings

I could not better word the question. So, I have finalized a few M-x commands I want to execute on a buffer. I have also tried and tested a few regexps using C-M-% for search and replace. Now, I ...
3
votes
1answer
101 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-...
5
votes
2answers
188 views

Keybinding for buffer word count

The following in my .emacs file does not produced the desired result of showing me the word count for the current buffer (it "does nothing"): (global-set-key (kbd "<f9>") (kbd "C-u M-=")) Is ...
0
votes
0answers
18 views

Having emacsclient send lisp recorded as part of macros?

I'm using a script that uses emacsclient to send Emacs editing commands to execute. I pass Emacs Lisp directly to emacsclient -e to have Emacs run. However, if I try to record a keyboard macro, and ...
0
votes
0answers
17 views

Is there any way to reliably tell when a keyboard macro definition fails than `defining-keyboard-macro`?

I coded up a function designed to manage my keyboard macros with one hotkey; it takes a numeric prefix argument and defines a macro if the argument is non-nil. It stops defining the macro and saves it ...
0
votes
1answer
26 views

Search with locale on Microsoft Windows

I'm using Emacs on MS Windows and suddenly I noticed that when I press C-s (incremental search) the prompt shows I-search [NL]: which I presume is my locale. I still can search incrementally but I can'...
1
vote
1answer
83 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 ...
2
votes
0answers
40 views

Replace formula by computed value

I'd like to select a simple formula like 17+5 and replace that by the computed result, 22 in this case. And I need this to work during keyboard macro execution, to quickly process large portions of my ...
2
votes
1answer
56 views

Inhibit redraw during keyboard macros?

In the good old days, repeated emacs keyboard macros ran without repainting the display until the end. Over the years this changed, and now it appears that the display is redrawn 100% of the time -- ...
1
vote
2answers
56 views

Removing preceding text from each line of a text [duplicate]

I am new to Emacs. I am reading a book on Python. The book has many code examples. What I would like to do is to convert this: 61. def getRandomWord(wordList): 62. # This function returns a ...
3
votes
3answers
266 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() { ...
3
votes
1answer
82 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 ...
1
vote
1answer
96 views

How to use double keyboard macro, or keyboard macro of keyboard macro?

First of all, I made a new keyboard macro called 'mac'. [F3] abcd [F4] M-x name-last-kbd-macro mac Then, I can get 'abcd' by typing [F4] or M-x mac. I tried to get 'abcd' five times. So I ...
1
vote
2answers
87 views

How to simplify macro declaration?

Using kmacro-exec-ring-item, is it possible to wrap this in an elisp macro or function so its much less verbose? In this example the only unique part is ds( and the function name. (fset 'delete-...
0
votes
2answers
163 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
109 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 ...
7
votes
2answers
176 views

Key bound to string does not handle some chars in string correctly

(I ask this question after reading this one.) The form (global-set-key (kbd "M-e") "e") is, as far as I can tell, equivalent to (global-set-key (kbd "M-e") (lambda () (interactive) (insert "e"))) ...
0
votes
2answers
304 views

Setting key problem: save and close just like vim

I'm trying to use global-set-key to bind commands ":x" as save and close, just like the way vim do. Right now I'm doing: (global-set-key (kbd "S-; x") (lambda() (kbd "C-x C-s") (kill-emacs))) But ...
0
votes
1answer
594 views

How to change keyboard shortcuts for copy, cut and paste and set keyboard shortcut for debugger (GDB)?

I would like to set the following keyboard shortcuts: Copy (selected text): C-c Cut (selected text): C-x Paste from clipboard: C-v Debugger (GDB): M-g Now I realize that to do this I merely need the ...
1
vote
0answers
75 views

key-chord not working with kmacro

When trying to define a macro in emacs and trying to expand key-chord in process its not working - its simply inputs letters instead. I saw explanation of this in key-chord.el but is there any ...
0
votes
2answers
922 views

Configuring multiple key bindings

I would like to bind M-S-up to C-u 7 S-up to move a timestamp a week forward (and down for back). A modification of this answer resulted in a "Symbol is void" error in Emacs. I tried modifying the ...
1
vote
3answers
412 views

How to delete all instances of a character in a bunch of files?

I was given a directory of files in which I was asked to make some systematic changes. Because it was a one-off task, and because there were only a few hundred files I thought I'd use an Emacs ...
1
vote
1answer
129 views

Transform selected text like a Python macro

I've only just started with Emacs (about 6 weeks now) so I'm not really familiar with its coding language. I was wondering if it was possible to write, for Emacs, the equivalent of a Python macro I ...
4
votes
2answers
436 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 ...
9
votes
2answers
256 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. ...
3
votes
2answers
308 views

Org-mode: any keyboard shortcut for Latex code?

On p.33 of the Org-guide Carsten Dominek writes you can use #+LATEX: and #+BEGIN_LATEX ... #+END_LATEX construct to add verbatim LATEX code Is there a keyboard combination or default snippet that ...
0
votes
1answer
36 views

Repeat typed characters before a space

Using Emacs with Evil Mode, I wonder if there's a way to quickly re-enter all the characters that were typed before a whitespace character is entered. Example: you type \hat{\beta}_{OLS,j} and then ...
0
votes
2answers
27 views

How to run a macro in a buffer that would take an argument?

If I want, for example, add all numbers in a line with a keyboard macro, how can I do it? It would add: 1 1 34 53 into: 89. Or, given a word: asdf transform it into fdsa I know how to define the ...
1
vote
0answers
107 views

Evil mode - help with custom prefix key

I had a custom key that I used extensively in Emacs for custom editing actions: C-z. I decided to use evil mode (I came from vim originally so nothing too new) but I don't know how to rebind evil's C-...
2
votes
0answers
31 views

Can the kmacro internal format contain literal commands?

I'm trying to modify key-chord.el so that you can have key-combination specific timeouts and I noticed that key-chord uses heuristics to decide when two keys pressed sequentially in a kmacro are ...
3
votes
1answer
122 views

How can I enter some text in a keyboard macro that uses helm mode?

I want a keyboard macro that does something like this: Call org-refile Insert two characters(In this case '') So whenever I invoke the keyboard macro, it lets me enter some other text, but ...
6
votes
1answer
137 views

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? ...
8
votes
2answers
199 views

Translating strings to keypresses

Given a string in elisp, I'd like to simulate emacs receiving whatever keypresses are necessary to re-create that string. So given the string "Hello" emacs would act exactly the same as if I had ...
4
votes
1answer
232 views

Execute keyboard macro in the current buffer

I need to be able to parse a string like the following: M-: (forward-word 4) RET and execute it from elisp. For that purpose I'm trying to use execute-kbd-macro and edmacro-parse-keys but I'm a ...