Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (40 sloc) 1.34 KB
;; Functions to help Emacs Lisp refactoring
(defun insert-new-function-definition (function-name body)
"Add a new function in the buffer, given a name and a body"
(progn (newline)
(set-mark (point))
(insert "(defun ")
(insert function-name)
(insert " ()")
(insert body)
(insert ")")
(indent-region (mark) (point))))))
(defun get-region ()
"Captures and delete the region between mark and point"
(filter-buffer-substring (mark) (point) 1))
(defun current-line-empty-p ()
(looking-at "[[:space:]]*$")))
(defun move-to-empty-point ()
"Move point to the first point outside of a form, before the
current point"
(while (not (current-line-empty-p))
(defun create-new-function (function-name)
"Creates a new function definition, given a selection. Removes
the selection and replaces it with a call to the newly created function"
(interactive "sFunction name: ")
(let ((code (get-region)))
(insert-new-function-definition function-name code)))
(insert "(" function-name " )"))))
(provide 'larsen-refactoring)