Category Archives: Emacs

Turning off Auctex fontification so that columns can align

I love Emacs. I use it for everything, and particularly love it for doing tables in LaTeX because I can easily align everything so that it looks sensible, and rectangle mode makes it easy to move columns around if desired.

That being said, Auctex defaults do some fontification to math-mode super- and subscripts, which cause the horizontal alignments of characters to be off (essentially it is no longer a fixed-width font). To turn this off, do:

M-x customize-variable font-latex-fontify-script

Beauty!

Finding system files with Spotlight on OSX

By default spotlight won’t search through system files (e.g. anything that lives in ~/Library/), which gave me a bit of a headache today when I was looking for where I had put an emacs mode file that I was initializing in my Preferences.el in Aquamacs.

The trick is to enable “System files” in the “Kind” menu in the Finder spotlight. To do this add a search rule, click on the “Kind” menu, choose “Other” and select “System files” in the list. Wham!

From lifehacker.

Using Rmarkdown with knitr to compose WordPress posts

What I’d like to be able to do is use knitr on an R markdown (i.e. .Rmd) document so include text, code, code output, and images to make a nice looking WordPress post that I can compose and edit locally. And advantage to this is that I can use whatever editor I want for doing the composing (like Aquamacs), and that everything is contained in a single source document.

Workflow

I think the flow will be something like:

  1. Create the post in an .Rmd file locally in emacs.

  2. Use knitr with my local version of R to process the Rmd into either a proper md (Markdown) or an HTML that I can just upload (NOTE: the HTML option doesn’t really seem to work … will maybe need to look into this some more).

  3. Upload (or copy/paste) the md or HTML source into WordPress. The big question is what will happen with generated images, etc. With Markdown, I think the images are created in a directory that is dynamically linked to, but for the HTML there is maybe some way that images are embedded (it appears the embedding isn’t compatible with copying and pasting the HTML source produced by knitr — I guess the images will have to be uploaded manually).

Some code

Here is an example:

x <- seq(1, 1000)
y <- rnorm(length(x))
plot(x, y)

plot of chunk unnamed-chunk-1

Post script

Copying and pasting the .md source produced by knitr works pretty well, though the image links will be broken. To fix this, each image produced by knitr needs to be added to the media library, and then inserted into the post to get the proper path. E.g. for the test figure above, the path is https://codedocean.files.wordpress.com/2014/01/unnamed-chunk-1.png. The linking to the image can still be done in a “markdown” way by using something like:

![plot of chunk unnamed-chunk-1](https://codedocean.files.wordpress.com/2014/01/unnamed-chunk-1.png)

Enabling MELPA package archive for Aquamacs

Thanks to my buddy Ken, I’ve been geeking out on lots of new Emacs/computer tools that could either drastically increase my productivity, or drastically decrease it through incessant messing around. I recently updated to the latest version of Aquamacs, which since it is built on Emacs v24 now contains the handy package management features.

By default it seems that Aquamacs uses the ELPA archive, which is pretty limited in terms of the number of packages. To use the MELPA archive instead (which seems to be the largest and most popular one right now), add this to ~/Library/Preferences/Aquamacs/Preferences.el

;; Melpa
(require 'package)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)

And Voila!