Very Secure

Abstract-Sexpr Tool

One process that I want to automate is the process of grabbing an sexpr and turning it into a function. Here is what I do currently manually.

1. I decide that I want to take a block of code inside of a function, and abstract it into a separate function with one or more of the variables inside the sexpr turning into parameters of the new function.

2. I delete the sexpr in emacs (with ctrl-k) and then yank it outside of the original function (ctrl-y).

3. I give the function a name and define it by wrapping the extracted sexpr with

(defun my-new-func-name (param1) (..old sexpr..))

4. I replace the sexpr in the original function with a function call to my-new-func-name with the parameter passed in.

I will try to write this in emacs-lisp and post the code later. I would like to be able to possibly put the cursor on the variable that i want to become a parameter and then have the ability to keep pressing a button going further and further up the sexpr tree until i've reached the root node that i want to be the form that is put into the new function. Ideally with the parens highlighting each time i go up the tree.

One Response to “Abstract-Sexpr Tool”

  1. [...] This is a solution to my previous post [...]

Leave a Reply