Feeds:
Posts
Comments

Archive for April, 2009

I’ve finally published the next installment of my mini-series on Emacs Comint. I’ve decided to publish it as a Squidoo lens. In it, I demonstrate how to create a slick, emacs-based interface to a stock price publisher. Part 1 in the series can be found here.

The first version extracts the ticker and price and displays them nicely in a seperate buffer. The later version highlights the updated line by flashing a magenta background for half a second after any update.

The lens covers the following emacs features: comint, process filters, overlays and timers. Let me know any comments or suggestions you have either here or on the lens itself. Please visit my emacs comint lens.

Read Full Post »

IBuffer

One reason, why I blog about emacs is that I’m often learning new things from people who leave a comment on my blog. My latest cool toy, thanks to a mention from foo is ibuffer. I had heard of it already (and had a vague idea of what it does), but had not investigated it any depth.

So, what does ibuffer do and why is it cool? It is a powerful substitute for list-buffers which by default is bound to C-x C-b. You can get started by typing M-x ibuffer <RETURN> h (for help).

The main features provided are:

  • sorting (with a s prefix)
  • filtering (with a / prefix)
  • marking (with * or % prefixes) and
  • processing (which covers a multitude of sins)

I like to sort the buffers lexicographically before I begin with s a. If it turns out I always do this, I’ll customize ibuffer-default-sorting-mode.

I’ve come up with a few simple recipes so far:

  • * s (mark star buffers) D (delete all marked buffers)
  • * r k (remove read-only buffers from ibuffer)
  • % n (mark buffers by regex) U (regex replace)

One thing that ibuffer doesn’t have is a function that compares two marked buffers. However, its easy enough to add one.

(defun ibuffer-ediff-marked-buffers ()
  (interactive)
  (let* ((marked-buffers (ibuffer-get-marked-buffers))
         (len (length marked-buffers)))
    (unless (= 2 len)
      (error (format "%s buffer%s been marked (needs to be 2)"
                     len (if (= len 1) " has" "s have"))))
    (ediff-buffers (car marked-buffers) (cadr marked-buffers))))

(define-key ibuffer-mode-map "e" 'ibuffer-ediff-marked-buffers)

We might as well replace the default binding for C-x C-b.

(global-set-key (kbd "C-x C-b") 'ibuffer)

Read Full Post »

« Newer Posts

Follow

Get every new post delivered to your Inbox.