A compendium of awesomeness

posted on August 05, 2007

Miro rocks. Due to it's awesomeness I've been catching up on all those Google Tech Talks I haven't found the time to stare at in a Web browser. And it gives me a reason to stop cursing how wmii/stable1 considers "fullscreen" for "chumps" — miro in "fullscreen" mode fits quite nicely in one corner of my laptop display.

Among the Google Tech Talks, the one on 7 Habits For Effective Text Editing 2.0 included a mention of a vim command which (in Emacs-speak) starts an incremental search on the token at point. I rather liked that, which yields:

;; I-search with initial contents
(defvar isearch-initial-string nil)

(defun isearch-set-initial-string ()
  (remove-hook 'isearch-mode-hook 'isearch-set-initial-string)
  (setq isearch-string isearch-initial-string)
  (isearch-search-and-update))

(defun isearch-forward-at-point (&optional regexp-p no-recursive-edit)
  "Interactive search forward for the symbol at point."
  (interactive "P\np")
  (if regexp-p (isearch-forward regexp-p no-recursive-edit)
    (let* ((end (progn (skip-syntax-forward "w_") (point)))
           (begin (progn (skip-syntax-backward "w_") (point))))
      (if (eq begin end)
          (isearch-forward regexp-p no-recursive-edit)
        (setq isearch-initial-string (buffer-substring begin end))
        (add-hook 'isearch-mode-hook 'isearch-set-initial-string)
        (isearch-forward regexp-p no-recursive-edit)))))

But then the real awesomeness I can't believe I've only just recently discovered — what language do you think this is?:

cdef extern from "awesomelib.h":
    cdef int completely_awesome_function(char *nice)

cdef class CoolThing:
    cdef int totally
    def __init__(self, nice):
        self.totally = completely_awesome_function(nice)

Python? Not quite. C? Closer, in a sense. It's Pyrex, a Python-like language which encapsulates (but distinguishes) both Python and C constructs, then compiles to C code which uses the Python/C API to provide a Python module. Pyrex does the standard simple type conversions SWIG or a given <Foo>Inline will handle, but also allows the easy creation of extension types (Python objects with C data members) and by-god-simple Python callback routines passed to C callback APIs.

This might just be the straw which pushes me back into the squeezy embrace of Python as my LoC.

1 Debian's wmii/testing is 3.5, which breaks my ruby-wmii setup.

Commentary most sage

Thanks for that emacs function; it's useful.

Any suggestions for an appropriate keybinding?

I'm experimenting with just putting it on C-s. A normal isearch then becomes C-s C-h. If I decide that isn't working out, I'll probably turn C-s into a prefix and make a normal isearch C-s C-s and the token-at-point isearch C-s C-n.

Because you aren't using Emacs properly if you aren't completely unable to use the default bindings without retraining, or something. :-)