EmacsCustomizations

From Eigenpedia

Jump to: navigation, search

Contents

Intro

If you use Emacs for development of Eigenbase projects, be sure to add our elisp customizations to your .emacs startup script. Customization scripts are checked into Perforce under open/util/elisp. There's a standard one named eigenbaseCode.el, and another one named jvs_emacs.el which adds some optional customizations used by JVS.


And here's what xkcd has to say on this contentious subject:

real_programmers.png

Setup

Before loading the scripts, you need to set variable eigenbase-elisp-dir to their location in your Perforce sandbox. Here's an example of loading the standard script; place these two lines in your own .emacs file:

(set-variable 'eigenbase-elisp-dir "~/open/util/elisp")
(load-file (concat eigenbase-elisp-dir "/eigenbaseCode.el")

Standard

Here's what you get when you load eigenbaseCode.el:

  • Automatic code formatting for Java, JavaCC, XML, and C++ files to match Eigenbase conventions. (To get the correct XML mode, be sure to install the psgml package.)
  • Automatic insertion of the correct file header and legal boilerplate in new Java and C++ files.
  • Automatic execution of the correct command when you run M-x compile. For C++ buffers, this will run make; for Java buffers, this will run ant -find build.xml -emacs, which uses the closest buildfile it can find up the tree. Afterwards, you can use C-x ` to step through any errors.
  • Perforce integration

JVS

Here's what you get in addition if you load my jvs_emacs.el instead (a lot of these are thanks to Julian Hyde)

  • Compilation buffer tailing. When you run a compile (customized to C-x C-e), the compilation buffer will track the tail of the output rather than remaining stuck on the head, so you can see what it's doing.
  • M-x make-buffer-file-writeable: runs chmod +w on the current buffer's file and updates the buffer read/write state. Very handy, but if you actually want to check out a file from Perforce, be sure to use p4-edit instead.
  • M-x buffer-search, buffer-query-replace: search or search/replace across all loaded buffers.
  • Diff-based test output management. In dired mode, visit a directory containing .log files resulting from failure of diff-based tests. To view a diff, move the cursor to a .log file and press the underscore key; ediff will be run to compare the .log file with the corresponding .ref file (in the ediff minibuffer, hit n to move to the next diff section, p for the previous, q to quit, ? for help). Back in dired, if you want to update the .ref file to match the .log file, hit the equals key. This will check out the .ref file and copy the .log file contents on top of it (but it won't submit the change).
  • Tags management for projects in standard locations. For example, M-x farrago-tags will load tags table ~/open/farrago/TAGS. This happens automatically if you run Emacs from the corresponding location and the TAGS file exists there. For Java projects, run ant etags to create the TAGS file. For C++ projects, run make tags.
  • Frame placement. In your .emacs file, setq local-frame-alist to the geometry you want before loading jvs_emacs.el, and it will do the rest. For example, (setq local-frame-alist '((width . 81) (height . 71) (top . 10) (left . 645)))
  • Miscellaneous behaviors such as key bindings (e.g. M-g for goto-line), buffer-bubbling, hungry mode and auto-newlines.
  • Settings for various non-Eigenbase projects in which I am involved.
  • WARNING: backup files are disabled; I hate the clutter. And all searches are case-sensitive.
  • Time, line number, and column in status bar.
  • All syntax colorization is disabled. I'm a very black-and-white person, and I hope to be taken out and shot before I ever need syntax colorization to help me parse code. If you want to use jvs_emacs.el but with colorization enabled, you can add these lines to your .emacs after the line where it loads jvs_emacs.el:
(setq hilit-auto-highlight t)
(setq-default hilit-auto-rehighlight t)
(global-font-lock-mode 1)
Personal tools