Friday, 15 May 2009

Package Management in Emacs

Emacs Lisp Package Archive is a add-on manager for Emacs. Hadn't seen it before. It's incredibly simple to install.


(let ((buffer (url-retrieve-synchronously
"http://tromey.com/elpa/package-install.el")))
(save-excursion
(set-buffer buffer)
(goto-char (point-min))
(re-search-forward "^$" nil 'move)
(eval-region (point) (point-max))
(kill-buffer (current-buffer))))


Evaluate this in Emacs (v.22 or greater), default key is Ctrl+J. This'll retrieve the el file and then evaluate it. Restart (or re-evaluate your .emacs) file and then M-x RET package-list will give you a list of available packages. M-x RET package-install RET name of package will download and install the package.

I used this to get the highlight-parentheses package (useful when you program in Lisp!). Other cool add-ons include:

Labels:


Tuesday, 10 February 2009

Emacs Fonts


Came across a Coding Horror article about fonts and programming and that encouraged me to find a sexier font. I settled on Bitstream Vera Sans Mono font.

I found numerous sites giving instructions about installing fonts for Emacs, but none of those seemed to work straight away for me so I thought I'd document the steps I went though to get things going:

  1. sudo apt-get install ttf-bitstream-vera
  2. M-x customize-face (return)
  3. default (return)
  4. Enter bitstream-bistream vera sans mono as the font family
  5. Save all


Then use the excellent color-theme to select some nice colours (Arjen in my case) and Emacs starts to look nice!

Labels:


Sunday, 1 February 2009

Highlighting Code for the Web using Emacs


(defn process-pixel [x y]
((fn [x y xc yc accum]
(let [x1 (+ (- (* x x) (* y y)) xc)
y1 (+ (* 2 x y) yc)
sq (+ (* x1 x1) (* y1 y1))]
(cond

(> accum *max-iteration*) *max-iteration*
(> sq 2.0) accum
:else (recur x1 y1 xc yc (inc accum))))) x y x y 0))



On Ubuntu you can install a bunch of Emacs goodies by installing the emacs-goodies-el package.

Once you've done this, you'll have Htmlize and can just do M-x htmlize-buffer to get an HTML rendition of the current buffer. This uses CSS, so all you really need to do is whack the definitions in your Blogger template and then paste the body of the code in. Obviously you'll need something like Slime or some other Emacs package that does the highlighting.

Labels:


Monday, 19 January 2009

Learning Emacs

Emacs and vi/vim are the two most popular text editors on Unix. I'm currently learning Emacs (yes, learning, there's a bit more to it than Notepad).

The coolest thing I've found so far is Emacs keyboard macros.



You can combine the execution with C-u to repeat the command a given number of times.

Labels:


This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]