Note that there are some explanatory texts on larger screens.

plurals
  1. PORefactoring in Emacs
    primarykey
    data
    text
    <p>I am working on splitting code into smaller files and refactoring it a bit. Consider the following code below as the section I want to extract:</p> <pre><code>(require 'package) (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/") t) (package-initialize) (when (not package-archive-contents) (package-refresh-contents)) (defvar my-packages '(org magit) "A list of packages to ensure are installed at launch.") (dolist (p my-packages) (when (not (package-installed-p p)) (package-install p))) </code></pre> <ul> <li>I want to take the section above and replace it with something like <code>(require `file-name)</code></li> <li>Then take the text replaced and place that in a new file in the current directory named <code>file-name.el</code></li> <li>And then add a line to the top of the file <code>(provides `file-name)</code></li> </ul> <p>It would be great if I could hit a keychord and then type a name and have this happen. If there is an easy way to do this then I would love to hear possible solutions.</p> <p><strong>Edit:</strong> I'm starting a bounty because I think this applies to more types of code than Lisp and I would like to have something a little more general that I can expand upon. </p> <p>I have considered yasnippet but I don't think it's powerful enough to perform the task at hand. Basically the ideal workflow would be marking the lines to be extracted, replacing that with an appropriate require or include directive and sending the text off to it's own file. Ideally one command and something that is aware of the type of file being edited or at least the major mode so the behavior can be customized, again yasnippet is good at performing different tasks when editing in different major modes however I would have no idea how to make that work or evaluate the possibility of making it work.</p> <p>Let me know if you need any more information.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload