Skip to content

netguy204/.emacs.d

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My Personal Emacs Configuration

This is my personal Emacs configuration. This is the second repository I clone -- after my dotfiles -- when settling in on a new computer . I'm using package.el and Emacs 24 themes, so this requires at least Emacs 24.3!

To use it, clone it into your home directory, or at least wherever Emacs thinks your home directory is. Move your existing .emacs file out of the way, since it being there prevents Emacs from using the init.el in this repository. I do still use a .emacs file for system-specific configuration, but I put this at the top,

(load-file "~/.emacs.d/init.el")

If you did everything right Emacs should simply launch with no errors. You will be greeted with a featureless, empty gray box awaiting your instructions.

Features

I try to keep my Emacs configuration tight and tidy. I generally spend somewhere between 30-60 hours a week in front of Emacs, so this configuration has been carefully pieced together and every line is important.

The Little Things

Here's a list of some small features added by init.el or extras.el.

  • M- -- Move the current line up.
  • M- -- Move the current line down.
  • C-x ! -- Insert a UUID.
  • C-x ~ -- Set the current buffer to 80 columns.
  • C-c r -- Insert random number.
  • C-c e -- Eval and replace.
  • M-g -- Go to line.
  • C-x C-k -- Compile.
  • [f1] -- Start a terminal.
  • [f2] -- Revert the buffer, no questions asked.
  • [pause] -- Dedicate the current window to the current buffer.

And some of the more interesting functions/macros, especially if you're an Elisp developer,

  • unfill-paragraph
  • dos2unix and unix2dos
  • expose
  • measure-time
  • compile-bind*

That last one is used to create bindings to run make: C-x c runs make with the compile target and C-x C runs make with the clean target.

Whitespace

There's a customized hook for whitespace-cleanup in before-save-hook. It will remove all trailing whitespace, and, because I'm so picky, also convert all tabs to spaces just before saving a buffer. To disable this on a per-buffer basis -- for example, to precisely edit a sloppily-spaced file -- run toggle-whitespace-cleanup.

See whitespace-cleanup.el for all the details.

Ido

Something experienced Emacs users may notice at first is that I make heavy use of ido-mode. It's turned on with flex matching, I've got smex loaded to complete M-x commands, and I use it for picking Java documentation. It's a wonderful feature and every Emacs user should be using it.

Magit

To interact with Git repositories, I use Magit (pronounced like "magic"). You can run it at any time with C-x g. As the manual points out, Magit is not a complete interface for Git, nor should it be. It covers 95% of my Git use, with the other 5% directly with Git on the command line. Magit is one of the main reasons I use Git.

Web Server

This configuration includes a built-in web server, written by me. You can launch it with httpd-start and stop it with httpd-stop. It will serve files from the directory at httpd-root and log messages in s-expression form to the *httpd* buffer.

Skewer

The most important use of the web server is for skewer-mode. I run its associated userscript in my browser allowing me to, at any time on any page, attach Emacs to a webpage. Once attached to Emacs I can fully interact with the browser's JavaScript runtime through a JavaScript REPL (skewer-repl) and live expression evaluation in JavaScript buffers, very similar to the various lisp interaction modes. It can also do live "evaluation" of CSS (skewer-css-mode) and HTML (skewer-html-mode).

Lisp: Paredit and Parenface

Paredit is a very significant behavioral change for Lisp modes. It enforces parenthesis balance and provides all sorts of shortcuts for manipulating entire s-expressions at once. It may feel annoying at first, but it quickly becomes indispensable. Keep looking at the cheatsheet until you've got the hang of it.

I also have parenface configured, which darkens the parenthesis in Lisp modes. It makes Lisp code all the more pleasing to look at -- reading Lisp is all about indentation, not parenthesis. It won't be enabled in the *scratch* buffer automatically because that buffer gets set up before parenface does.

You may wonder why I don't have Slime here. That's because I let Quicklisp install and manage it for me. Remember my note about using .emacs for system-specific configuration? That's where I put the hook to load Slime.

nrepl.el

I interact with Clojure projects using nrepl.el and nREPL. This can be fired up at any time with nrepl-jack-in. This requires Leiningen, which is very easy to set up.

Java

This was one of the big ones when I used spend a lot of time writing Java, and Emacs was lacking solid Java support. I built up my own extensions to support Java development: ant-project-mode and javadoc-lookup. The full documentation is listed in the ant-project-mode.el header, but here's a quick rundown of my configuration.

First, I use javadoc-lookup for class completion and lookup, which works by examining the file structure of Javadoc documentation. While it comes with the core API Javadoc built-in, to make more effective use of it I need to tell it about what other things I'll want to look up. Its configuration looks like this,

(javadoc-add-artifacts [org.lwjgl.lwjgl lwjgl "2.8.2"]
                       [com.nullprogram native-guide "0.2"]
                       [joda-time joda-time "2.1"])

I can jump to any class's documentation with C-h j. I use Firefox, so this will try to open the documentation in Firefox if possible.

Notice: ant-project-mode is not currently part of this configuration, so the following will not work at the moment.

Next, when in a java-mode buffer, I can add an import to the imports section at any time with C-x I (the ant-project-short-keybindings binding). Like javadoc-lookup, C-h j, Ido will do a completing read asking you which class I'd like to import. It's inserted in the proper position inside the imports section.

When using Ant like I do, there are a number of bindings that trigger specific Ant targets. The three I use most often are,

  • C-x c -- Compile the program.
  • C-x r -- Run the program.
  • C-x t -- Run the unit tests.

The compilation buffer name is derived from the prefix argument. Using prefixes (C-u number), you can run any number of compilation processes at once. I find this especially useful for hot code replacement.

The YASnippets in emacs-java/snippets/ take advantage of my java-mode extensions. My favorite snippet is cls ("class"): start a fresh Java source file inside a package, type cls, and hit tab. It will attempt to guess the package name from your path and fill out the basics with it, allowing you to quickly get on with your business.

Releases

No releases published

Packages

No packages published

Languages

  • Emacs Lisp 100.0%