All Projects → AdamNiederer → Metamorph

AdamNiederer / Metamorph

Licence: gpl-3.0
Transform your code in turing-complete ways

Programming Languages

metaprogramming
66 projects

Labels

Projects that are alternatives of or similar to Metamorph

Acejump
🅰️ single character search, select, and jump
Stars: ✭ 786 (+8633.33%)
Mutual labels:  emacs
Char Menu
Create your own menu for fast insertion of arbitrary symbols
Stars: ✭ 19 (+111.11%)
Mutual labels:  emacs
Assess
Test support functions for Emacs
Stars: ✭ 26 (+188.89%)
Mutual labels:  emacs
Dap Mode
Emacs ❤️ Debug Adapter Protocol
Stars: ✭ 809 (+8888.89%)
Mutual labels:  emacs
Chronometer
A Chronometer for GNU Emacs
Stars: ✭ 6 (-33.33%)
Mutual labels:  emacs
Emacs Slack
slack client for emacs
Stars: ✭ 928 (+10211.11%)
Mutual labels:  emacs
Sly
Sylvester the Cat's Common Lisp IDE
Stars: ✭ 766 (+8411.11%)
Mutual labels:  emacs
Emacs Datetime
Stars: ✭ 8 (-11.11%)
Mutual labels:  emacs
Yasnippet Snippets
a collection of yasnippet snippets for many languages
Stars: ✭ 831 (+9133.33%)
Mutual labels:  emacs
Danneskjold Theme
Beautiful high-contrast emacs theme
Stars: ✭ 26 (+188.89%)
Mutual labels:  emacs
Smart Mode Line
A powerful and beautiful mode-line for Emacs.
Stars: ✭ 809 (+8888.89%)
Mutual labels:  emacs
Org Super Agenda
Supercharge your Org daily/weekly agenda by grouping items
Stars: ✭ 829 (+9111.11%)
Mutual labels:  emacs
Org Treescope.el
Provides a time and priority based sparse tree interaction mode
Stars: ✭ 25 (+177.78%)
Mutual labels:  emacs
Clojure Mode
Emacs support for the Clojure(Script) programming language
Stars: ✭ 795 (+8733.33%)
Mutual labels:  emacs
Perfect Margin
[emacs] auto center emacs windows, work with minimap and/or linum-mode
Stars: ✭ 26 (+188.89%)
Mutual labels:  emacs
Awesome Emacs
A community driven list of useful Emacs packages, libraries and others.
Stars: ✭ 6,732 (+74700%)
Mutual labels:  emacs
Emacs Anywhere
Configurable automation + hooks called with application information
Stars: ✭ 917 (+10088.89%)
Mutual labels:  emacs
.emacs.d
bdd's Emacs configuration, split from bdd/.dotfiles/emacs directory.
Stars: ✭ 8 (-11.11%)
Mutual labels:  emacs
Kaleidoscope.el
Control Kaleidoscope-powered devices from the comfort of your Emacs.
Stars: ✭ 8 (-11.11%)
Mutual labels:  emacs
Emacs Libvterm
Emacs libvterm integration
Stars: ✭ 929 (+10222.22%)
Mutual labels:  emacs
  • metamorph Higher-order buffer transformations for Emacs.

** Usage Say you're writing some lovely code for your new libc implementation:

#+BEGIN_SRC c void free(void* ptr) { void* prev_freelist_ptr = (void*)(size_t**)(ptr - 24); void next_freelist_ptr = (void*)*(size_t**)(ptr - 16); size_t this_size = (size_t)(ptr - 8);

// Set prev->next to this->next and next->prev to this->prev
*(size_t*)(prev_freelist_ptr - 24) = next_freelist_ptr;
*(size_t*)(next_freelist_ptr - 16) = prev_freelist_ptr;

} #+END_SRC

But all of a sudden, you want to add a new feature, and change the pointer offsets above:

#+BEGIN_SRC c void free(void* ptr) { void* prev_freelist_ptr = (void*)(size_t**)(ptr - 32); void next_freelist_ptr = (void*)*(size_t**)(ptr - 24); size_t this_size = (size_t)(ptr - 16); size_t magic_number = (size_t)(ptr - 8);

  // Check for freelist corruption
  assert(magic_number == 0xdeadbeefcafefade);

  // Set prev->next to this->next and next->prev to this->prev
  *(size_t*)(prev_freelist_ptr - 32) = next_freelist_ptr;
  *(size_t*)(next_freelist_ptr - 24) = prev_freelist_ptr;
}

#+END_SRC

You could use replace-string three times for each number literal in your code Or, you could use (metamorph-map-region "[0-9]+" "(- %! 8)").

Metamorph provides a powerful way to transform your buffer contents - perform base conversions, increment numbers, transform every nth match, and more. Use any Emacs Lisp function to transform your data - the sky is the limit.

Metamorph's principal function, metamorph-map-region will prompt you for a regular expression, and a lisp expression. It will then replace everything matching the regular expression in your region with the result of the lisp expression. You can use the following variables in the lisp expression:

  • % is the raw matched string without any additional processing

  • %! is the value of the string as a lisp expression

  • %0 is an index which starts at zero, and increments for each match ** Security Metamorph reads all strings matching the regular expression, and will gladly evaluate them as Lisp code if %! is included in the transformation expression. Because of the security implications of such behavior, an alternative function, metamorph-map-region-safe, does not read or evaluate any buffer contents without explicit user direction, and is therefore safe to use on untrusted buffers. metamorph-map-region-safe provides the following arguments:

  • % is the raw matched string without any additional processing

  • %i is the matched string's value as an integer

  • %0 is an index which starts at zero, and increments for each match

Calling (read %) in your transformation expression will nullify the safeguards in metamorph-map-region-safe and carries the same security implications as metamorph-map-region.

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].