Posted by Doug
Mon, 21 Jan 2008 13:49:00 GMT
Friday was my last day at the company that won’t let me blog about them. I am very excited to be 100% independent freelancing! This has been a goal of mine for many years and it’s finally come true.
This morning Mark Windholtz is coming over to pair with me on a contract we share. It’s his good for not making me commute on my first day of independence. I’m looking forward to working with him and several other independent developers.
Hopefully now that I’m not under corporate thumbs I’ll be able to blog more about the types of problems I’m seeing and methods for overcoming. I’ve specifically been asked to write an article on my experiences working remotely on a Scrum project.
In addition to writing more, I’m also hoping to be able to contribute back to the open source community. It’s tricky when your family depends on your billable hours to also give your work away. However, I think it’s good balance to work on things my clients require as well as things I’m interested in. At first, this is likely to be helping Phil Hagelberg shape up Emacs for ruby development.
So, there you go. I’m going to be working with some good guys; doing more writing; and working on more open source. Wish me luck!
Tags consulting, emacs, family, Rails, Ruby | 4 comments
Posted by Doug
Thu, 08 Nov 2007 02:58:00 GMT
OK, last emacs tip for a while. It’s ironic, but the last two years I’ve written some cool elisp while at RubyConf. I typically run emacs full screen and split buffers both vertically and horizontally to arrange bits of code. It’s not uncommon for me to end up with three, four, five or even six visible windows in emacs. The problem though is navigating between them.
The out-of-the-box solution is to use other-window (bound to C-x o) and just cycle through them. If you’re fancy you can give a prefix argument to other-window and go backwards. This window cycling is tedious to me though and I’d like something faster. Particularly when I’m mostly bouncing back and forth between two windows.
To solve this problem I wrote jump-to-buffer. Of course, right now I’m really enamored with the fuzzy matching in ido-completing-read. That’s what allows you to type non-sequential characters to match the buffer name. It’s very similar to TextMate’s pattern matching. So, jump-to-buffer uses ido-completing-read. The buffers it gives you as options for completion are only the buffers in visible windows. It also sorts those buffers in the order of the buffer-list; which is in the order of most recently accessed.
To make this work, I’ve written two helper functions: rotate-list, and sort-by-other-list. Without further ado:
(defun dka-sort-by-other-list (to-sort-list other-list)
(let* ((index 0)
(other-alist (mapcar (lambda (buffer)
(setq index (+ index 1))
(cons buffer index))
other-list))
(swartz (mapcar (lambda (item)
(cons (cdr (assoc item other-alist)) item))
to-sort-list))
(sorted-list (sort swartz (lambda (a b) (< (car a) (car b))))))
(mapcar 'cdr sorted-list)))
(defun rotate-list (list count)
"Rotate the LIST by COUNT elements"
(cond
((= count 0) list)
((not list) list)
(t
(rotate-list (nconc (cdr list) (list (car list)) '()) (1- count)))))
(defun dka-jump-to-window ()
"Interactively jump to another visible window based on it's `buffer-name' using `ido-completing-read'"
(interactive)
(let* ((visible-buffers (mapcar '(lambda (window) (window-buffer window)) (window-list)))
(sorted-visible-buffers (dka-sort-by-other-list visible-buffers (buffer-list)))
(rotated-buffer-list (rotate-list sorted-visible-buffers 1))
(visible-buffer-names (mapcar (lambda (buffer) (buffer-name buffer)) rotated-buffer-list))
(buffer-name (ido-completing-read "Enter buffer to jump to: "
visible-buffer-names
nil t))
(window-of-buffer
(delq nil
(mapcar '(lambda (window)
(if (equal buffer-name (buffer-name (window-buffer window)))
window nil)) (window-list)))))
(select-window (car window-of-buffer)))
)
I’m definitely interested in feedback on this code. The dka-sort-list-by-other-list method was particularly tricky for me to write. I think it’s both right and fast. I haven’t dove into elunit yet to know for sure if it’s right.
Posted in Emacs, Programming | Tags elisp, elunit, emacs, schwartz, sorting, transform | no comments
Posted by Doug
Thu, 08 Nov 2007 02:09:00 GMT
While I’m sharing emacs hacks, I finally got around to researching this and/or figuring it out. I almost always run emacs inside the terminal in a “no window” mode. It’s pretty natural for me to use M-w to copy something from emacs and then try to Cmd-V it in another Terminal window or likewise Cmd-C something in Terminal and then try paste it into emacs with C-y. Until now, I haven’t known how to share the clipboard with emacs.
(defun copy-from-osx ()
(shell-command-to-string "pbpaste"))
(defun paste-to-osx (text &optional push)
(let ((process-connection-type nil))
(let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
(process-send-string proc text)
(process-send-eof proc))))
(setq interprogram-cut-function 'paste-to-osx)
(setq interprogram-paste-function 'copy-from-osx)
This takes advantage of the pbcopy and pbpaste command line programs to access the clipboard and offers them up as elisp method for emacs’ interprogram-*-functions. Easy, peasy, pumkin weasy.
I need to give some props to Mark Aufflick for his post on Automatic Copy from X11 App to Mac OS Clipboard. My paste-to-osx is pretty much a straight rip from him.
Posted in Emacs, Mac OS X | Tags clipboard, emacs, mac, pbcopy, pbpaste | no comments