-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 =pod A long time ago, before I knew elisp, someone told me to never use C. I've ignored their "advice" and have written this: lang:Common Lisp (require 'cl) (defun get-iterator-over-words-in (buffer) (lexical-let ((buf buffer)(pos 1)) (lambda () (save-excursion (let ((cur (current-buffer)) result) (switch-to-buffer buf) (goto-char pos) (forward-word) (let ((pt (point))) (if (not (eq pos pt)) (progn (setq result (buffer-substring-no-properties pos pt)) (setq pos pt)))) (switch-to-buffer cur) result))))) This function returns a function that gets the next word in C. The cool part here is that thanks to C, the C closes over C and C. You can try this out by creating a buffer called "test buffer" and typing something like "This is text." in there. Then run: (setq next-word (get-iterator-over-words-in (get-buffer "test buffer"))) to get yourself the iterator. Then you can extract one word at a time by calling C<(funcall next-word)>. The first time you call C, you get C<"This">. Next time, you get C<" is">. Then, C<" text.">. Finally, you get C forever. As I said before, I'm really glad I finally learned elisp. Even without C and C, it's pretty enjoyable. Wanting an emacs feature and being able to write it in an hour brings me as much joy as writing something in Perl. With this discovery, programming in elisp is even more fun -- I can interactively edit text with closures! Elisp is now my second-favorite programming language :) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFHYRrO2rw+dVvzZm0RAmHJAJ9i6lLOP6myqGhyHLPg6fmQGLKyhQCggfah QwKXVjOXle3t0dOulj4ZpNo= =+W2K -----END PGP SIGNATURE-----