All Projects → Silex → Elmacro

Silex / Elmacro

Package to display keyboard macros or latest interactive commands as emacs lisp.

Programming Languages

macro
33 projects

Labels

Projects that are alternatives of or similar to Elmacro

Emacs Doom Themes
A megapack of themes for GNU Emacs.
Stars: ✭ 1,706 (+1253.97%)
Mutual labels:  emacs
Cheatsheet
Pretty cheat sheets, or ``reference cards'', obtainable from Org files.
Stars: ✭ 116 (-7.94%)
Mutual labels:  emacs
Novels.org
Novels.org - Your Novels in Plain Text (Emacs . org-mode)
Stars: ✭ 120 (-4.76%)
Mutual labels:  emacs
Burly.el
Save and restore frames and windows with their buffers in Emacs
Stars: ✭ 109 (-13.49%)
Mutual labels:  emacs
Pocket Reader.el
Emacs client for Pocket reading list (getpocket.com)
Stars: ✭ 113 (-10.32%)
Mutual labels:  emacs
1pass
A caching wrapper for the 1Passworld CLI
Stars: ✭ 117 (-7.14%)
Mutual labels:  emacs
Lsp Pyright
lsp-mode ❤️ pyright
Stars: ✭ 111 (-11.9%)
Mutual labels:  emacs
Wgeecn
Writing GNU Emacs Extensions 翻译
Stars: ✭ 124 (-1.59%)
Mutual labels:  emacs
Emacs Mini Frame
Show minibuffer in child frame on read-from-minibuffer
Stars: ✭ 115 (-8.73%)
Mutual labels:  emacs
Walkman
Write HTTP requests in Org mode and replay them at will using cURL
Stars: ✭ 120 (-4.76%)
Mutual labels:  emacs
Dotfiles
If there is a shell, there is a way!
Stars: ✭ 112 (-11.11%)
Mutual labels:  emacs
Emacs Application Framework
A free/libre and open-source extensible framework that revolutionizes the graphical capabilities of Emacs, the key to ultimately Live in Emacs
Stars: ✭ 1,932 (+1433.33%)
Mutual labels:  emacs
Mg
Micro (GNU) Emacs-like text editor ❤️ public-domain
Stars: ✭ 117 (-7.14%)
Mutual labels:  emacs
Marginalia
📜 marginalia.el - Marginalia in the minibuffer
Stars: ✭ 111 (-11.9%)
Mutual labels:  emacs
Emacs Solidity
The official solidity-mode for EMACS
Stars: ✭ 120 (-4.76%)
Mutual labels:  emacs
Magit Delta
Use delta (https://github.com/dandavison/delta) when viewing diffs in Magit
Stars: ✭ 109 (-13.49%)
Mutual labels:  emacs
Doom Emacs
An Emacs framework for the stubborn martian hacker
Stars: ✭ 12,774 (+10038.1%)
Mutual labels:  emacs
Mypy boto3 builder
Type annotations builder for boto3 compatible with VSCode, PyCharm, Emacs, Sublime Text, pyright and mypy.
Stars: ✭ 123 (-2.38%)
Mutual labels:  emacs
Elisp Koans
Emacs Lisp Koans -- learn elisp through test-driven development.
Stars: ✭ 123 (-2.38%)
Mutual labels:  emacs
Emacs Gdb
GDB graphical interface for GNU Emacs
Stars: ✭ 119 (-5.56%)
Mutual labels:  emacs

MELPA MELPA Stable

elmacro

Shows keyboard macros or latest interactive commands as emacs lisp.

Examples

upcase-last-word

Say you have the following text:

violets are blue
roses are red

With the cursor somewhere on the first line. Press the following keys:

F3 C-e M-b M-u C-a C-n F4

Then doing M-x elmacro-show-last-macro upcase-last-word RET produces a buffer with:

(defun upcase-last-word ()
  (interactive)
  (move-end-of-line 1)
  (backward-word 1)
  (upcase-word 1)
  (move-beginning-of-line 1)
  (next-line 1 1))

You can now do M-x eval-buffer followed by M-x upcase-last-word or call it from your emacs lisp code.

Table of Contents

Installation

The recommended way to install elmacro is through MELPA.

Otherwise, simply add elmacro.el to your load-path and then (require 'elmacro).

To enable elmacro, do M-x elmacro-mode or enable it from your config file like this:

(elmacro-mode)

Commands

elmacro-show-last-macro

M-x elmacro-show-last-macro shows your latest macro as emacs lisp.

In order to use this, you must first record a keyboard macro. Then, when you do M-x elmacro-show-last-macro it will ask you for a defun name and show the latest macro as emacs lisp.

elmacro-show-last-commands

M-x elmacro-show-last-commands shows your latest emacs activity as emacs lisp.

This is basically a better version of kmacro-edit-lossage.

The default number of commands shown is modifiable in variable elmacro-show-last-commands-default.

You can also modify this number by using a numeric prefix argument or by using the universal argument, in which case it’ll ask for how many in the minibuffer.

elmacro-clear-command-history

Clears the list of recorded commands.

Customization

elmacro-processors

Default value: (elmacro-processor-filter-unwanted elmacro-processor-prettify-inserts elmacro-processor-concatenate-inserts elmacro-processor-handle-special-objects)

List of processors functions used to improve code listing.

Each function is passed the list of commands meant to be displayed and is expected to return a modified list of commands.

elmacro-show-last-commands-default

Default value: 30

Number of commands shown by default in elmacro-show-last-commands.

elmacro-additional-recorded-functions

Default value: (copy-file copy-directory rename-file delete-file make-directory)

List of non-interactive functions that you also want to be recorded.

For example, dired-copy-file (C key in dired) doesn't reads its arguments as an interactive specification, and thus the file name is never stored.

elmacro-unwanted-commands-regexps

Default value: ("^(ido.*)$" "^(smex)$")

Regexps used to filter unwanted commands.

elmacro-special-objects

Default value:

'(("#<frame [^0]+\\(0x[0-9a-f]+\\)>" ",(elmacro-get-frame \"\\1\")")
  ("#<window \\([0-9]+\\)[^>]+>"     ",(elmacro-get-window \\1)")
  ("#<buffer \\([^>]+\\)>"           ",(get-buffer \"\\1\")"))

List of (regexp replacement) for special objects.

This will be used as arguments for replace-regexp-in-string.

elmacro-debug

Default value: nil

Set to true to turn debugging in buffer * elmacro debug *.

Processors

The way elmacro processes commands can be modified using processors.

A processor is an emacs lisp function that takes a list the commands meant to be displayed and is expected to return a modified list of commands.

For example, a simple processor that filters anything you insert in a buffer:

(defun filter-insert-processor (commands)
  (--remove (eq 'insert (car it)) commands))

elmacro-processor-filter-unwanted

Remove unwanted commands using elmacro-unwanted-commands-regexps.

elmacro-processor-prettify-inserts

Transform all occurences of self-insert-command into insert. This filter should be not be enabled with packages that advice self-insert-command, see the FAQ for more information.

Before:

(setq last-command-event 97)
(self-insert-command 1)
(setq last-command-event 98)
(self-insert-command 1)
(setq last-command-event 99)
(self-insert-command 3)

After:

(insert "a")
(insert "b")
(insert "ccc")

elmacro-processor-concatenate-inserts

Concatenate multiple text insertion together.

Before:

(insert "a")
(insert "b")
(insert "c")

After:

(insert "abc")

elmacro-processor-handle-special-objects

Turn special objects into usable objects using elmacro-special-objects.

FAQ

org-mode, smartparens, etc

Normally elmacro works reasonably well with these, but if you want to ensure the most accurate experience you should disable the elmacro-processor-prettify-inserts processor (see elmacro-processors).

This is necessary because these packages usually advice self-insert-command, and by transforming it into an insert the advice does not run and we miss functionnality.

Mouse events

A nice addition to normal macros is that mouse events (clicks / scroll) are also recorded and elmacro can figure which emacs window / frame was the target.

For example, by default clicking in a window will generate code like:

(mouse-set-point '(mouse-1 (#<window 75 on foo.el> 913 (90 . 286) 185432429 nil 913 (10 . 15) nil (90 . 1) (9 . 19))))

We see that the <#window 75 on foo.el> part is not very useful. Thanks to the processor elmacro-processor-handle-special-objects, the following code is generated instead (elmacro-get-window is a helper that returns the correct emacs window object):

(mouse-set-point `(mouse-1 (,(elmacro-get-window 75) 913 (90 . 286) 185432429 nil 913 (10 . 15) nil (90 . 1) (9 . 19))))

Contributions welcome!

Either as suggestions or as pull requests by opening tickets on the issue tracker.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].