I’ve become very conservative about using all the little OS X add-ons and tweaks and enhancements. But this note, for geeks only, is here to plug uControl and offer some related hints from Emacs-land.

uControl has always been a great idea; unfortunately, large parts of it didn’t use to work, but now they do. For me, it does two valuable things: first, turns the function keys from volume and brightness controls back into function keys—you can still get the volume and brightness controls with the little fn key. Second, it gives you a scrollbar effect on the trackpad.

Why, you ask, would anyone want direct access to the function keys? Because, if you’re an Emacs user, you can migrate the things you do all the time there and make a lot of common operations single-keystroke. For the Emacs geeks in the crowd, here’s an excerpt from my .emacs; most of the functions are built-in and I’ve also provided source for the (trivial) ones that aren’t:

(global-set-key [f1] 'other-window)
(global-set-key [f2] 'delete-other-windows)
(global-set-key [f3] 'delete-window)
(global-set-key [f4] 'split-window)
(global-set-key [f5] 'scroll-other-window)
(global-set-key [f6] 'downcase-word)
(global-set-key [f7] 'capitalize-word)
(global-set-key [f8] 'upcase-word)
(global-set-key [f9] 'kill-word)
(global-set-key [f10] 'compile)
(global-set-key [f11] 'copy-region-as-kill)
(global-set-key [f12] 'kill-whole-line)
(global-set-key [home] 'beginning-of-line)
(global-set-key [end] 'end-of-line)
(global-set-key [(control ?])] 'flip-window)
(global-set-key [(control backspace)] 'backward-kill-word)

(define-key ctl-x-map "l" 'buffer-stats)  ;;; like ^G in vi
(define-key esc-map "z" 'advertised-undo) ;;; this is Mac OS X

Try out that F1/F2/F3/F4 stuff for a while, it’s catching.

Here‘s kill-whole-line, something I do all the time that requires three keystrokes with default Emacs key setups:

;; kill-whole-line
;;
(defun kill-whole-line (line-count)
  "Kill the whole line that dot is in.
   With an argument n, kill current line and the next n-1 lines."
  (interactive "p")
  (beginning-of-line 1)
  (if (not line-count)
      (setq line-count 1))
  (kill-line line-count))

Here’s flip-window, I don’t know how anyone gets by without it.

;; flip to the list-visited buffer
(defun flip-window () "Flip this window" (interactive)
  (switch-to-buffer (other-buffer)))

Finally, here’s buffer-stats, which the 0.0003% of the population who switch between Vi and Emacs will appreciate:

;; equivalent of c-G in emacs
(defun buffer-stats () 
  "vi-style lines/chars"
  (interactive)
  (let ((chars (buffer-size)))
    (if (= chars 0)
        (message "%s: 0 lines, 0 characters" (buffer-name))
      (message "%s: %d lines, %d characters" 
               (buffer-file-name)
               (count-lines 1 chars) 
               chars))))

author · Dad · software · colophon · rights
picture of the day
December 30, 2003
· Technology (85 fragments)
· · Emacs (7 more)
· · Mac OS X (118 more)

By .

The opinions expressed here
are my own, and no other party
necessarily agrees with them.

A full disclosure of my
professional interests is
on the author page.