Thursday, March 18, 2010

(define (more-ergonomics)

'(I got something new.

Pretty good as far as keyboard trays go, but I still find myself wanting one of those squishy wrist-rest pads. The default wrist bit on this tray isn't terribly uncomfortable, but it doesn't quite compress right. And for all the awesome work PFU did on this little beast in terms of key placement/spacing/spring system, they didn't put any effort at all into making the wrist comfortable. That's the one thing I miss from my old behemoth (which is now comfortably at the office). I still prefer the HHL2 for speed; the keys are actually spaced close enough together (and consistently sized enough) that I get a fairly significant boost just from using it (on average 5 wpm).

It's a +5 Keyboard of Speed. Together with my +1 Trackball of Accuracy and +2 Monitors of Insight, as well as the Hard Drive of Premonition, my home machine is now significantly better, in all ways, than my work setup.

Ahem.

There's this little slide-out sub-tray for the mouse, but since I have a tiny keyboard and a trackball, both of my peripherals fit comfortably on one half of the main area. I could use it for drinks I guess.

The only complaint I have is that Fellowes are fucking liars. In fact, anyone that tells you their keyboard tray has "easy installation" is a fucking liar, and you can tell them I said so. It was a pain in the ass. Granted, in this case it was worth it for the extra space and long-term comfort I got out of it, but there was significant short-term discomfort.))

(define (office-follow-up)

'(Almost done configuring my dev environment for work. It's been bearable for a few days actually, so I've managed to get some work done at least, but there's still kinks here and there. The current plan is to get everything I need together in one place (and for the record, it's about twice as much as the documentation would have me believe I need), then create a bootable flash-drive with a dev-environment shell script to take care of everything other than the OS installation. I should be able to announce a dev-environment-on-a-stick (with your choice of editor) next week.))

(define (update-emacs)

'(I'm still updating my .emacs and associated files. The other day, I finally got off my ass and installed nXhtml mode. Which I'm not using right now, incidentally, I prefer the vanilla html-mode for my everyday editing, but nXhtml provides a lot of much-needed functionality for editing PHP, JSP and mixed HTML/JS/CSS files (I try to minimize that last group, but you still run across them sometimes).

I'm also adding little convenience functions. Things like git-svn-fetch and git-svn-commit which let me seamlessley interoperate with my office-mates without giving me the giant headaches associated with Subversion use. I'm sure it's very nice for people that are used to CVS and VSS, but I grew up with GIT and Mercurial. If you think I'll go back to centralized source control without a fight, you've got another thing coming.

Other new stuff includes in no particular order ant-build-project, restart-tomcat, stop-tomcat, and deploy-static. That last one is actually a copy of a couple ant tasks we have, which essentially just copy a whole bunch of css, js, jpg and jsp static files from our local repo to our local tomcat deployment. The thing is, the build file copies in the naive sense, whereas my emacs function uses rsync, and is therefore about ten billion times faster.

Most of that last set wouldn't have been possible without a little help from StackOveflow. I guess no-one's really thought about it, so Emacs doesn't have a built-in sudo-shell-command. Meaning I had to write my own (which is still better than waiting for the maintainer of my IDE to patch their oversight). Here's what I came up with after consulting the overflow boards:

(defun sudo-shell-command (command)
  (shell-command (concat "echo " (read-passwd "Password: ") " | sudo -S " command)))

(defun chain-sudo-shell-command (command-list)
  (let ((prefix (concat "echo " (read-passwd "Password: ") " | sudo -S ")))
    (mapcar (lambda (a-command)
              (shell-command (concat prefix a-command)))
            command-list)))

I use the first one if I can because the second one is more dependant on side-effects, and it only shows the output from the last command it recieved (so if I misspelled something in command 3 of 6 that I pass to it, I'll never know until it screws up something I'd much rather not get screwed up).)))

Tuesday, March 9, 2010

(define (work) (

So lately, I've been thinking about my work setup for hacking, and it occurs that the environment is in need of an overhaul. I've been using Windows and Eclipse, for god's sake. That's not even really excuseable. I mean yeah, I can hide behind the fact that my business card says "Graphic Designer" and take the perspective that it's the responsibility of our lone network admin to figure shit out for me, but that seems less satisfactory than doing something about it. It's not really percieved as a big deal; the rest of the team uses windows too (and our resident x-programmer is at once a Windows and Java fanatic), so there's bound to be little help and perhaps a little resistance. Here are the big reasons I'm thinking about switching now:

  1. We're planning to upgrade OSes soon anyway; it'll probably end up being to Windows 7, but I think I can at least change a couple of minds in IT given that our production servers are in fact running on Linux anyway.
  2. Between Windows, the anti-virus software, outlook and some other utilities, my boot time is in the area of 4 minutes. That doesn't sound too bad, except that my home workstation (which is ostensibly just for fun) boots in under 20 seconds. Also, because it's windows ...
  3. ... I have to reboot it at least once a day or it starts getting sluggish to the point of unuseability. Just. Perfect.
  4. I get the feeling that our admin could fix this had he taken levels in programmer, but Linux is much more easily scriptable. Specifically, the setup process is scriptable. Because of the apt-get facility (and our particular mix of technologies), it's perfectly possible for me to write a shell-script to set up a Linux dev machine from scratch. It's basically the standard LAMP stack plus Tomcat and Java 6. Eclipse and Subversion might take a bit of configuring, but since I use GIT (which can seamlessly interoperate thanks to git-svn) and Emacs, my install is essentially apt-get emacs23 git-core git-svn. Hell, I've even got lines in there to do a full checkout of the trunk and latest branch once git is installed.
  1. The current "solution" is a base image (Windows with an unconfigured outlook, and printer drivers) which the dev then has to spend about a day (two or three the first time) prepping to get up and running. This leaves something to be desired. ))

(define (ping-emacs) (

What, you thought I only got one per post?

I haven't been doing any hardcore elisp hacking for the last few days, but I still make it a habit to eliminate inefficiencies. I ended up removing uniquify from my .emacs. It wasn't getting used (and I noticed a little note it came with to the effect that it has some slight conflicts with iswitchb mode, which I do make extensive use of). I also ripped out the option in smart-tab that has it use hippie-expand. It was much too overzealous in various places.

On the additions side, blog-mode now auto-closes tags when I type the ">" character (which is a behaviour I'm thinking about just hooking into HTML mode), and I set the otherwise undefined C-' to comment-or-uncomment-region. This is another one of those times where it would have served me quite well to read up on stuff as a first reflex. I ended up reading about comment-region and uncomment-region, then spending 20 minutes or so hacking together a woefully inadequate way of getting one key-press to toggle commented state for a given region, then I stumbled across comment-or-uncomment-region on an unrelated trip through apropos.

Bottom line is, I don't think I'll ever be done opimizing, but I'm ok with that. This is an advantage of Emacs which I'm happy to have.

A little while ago, while I was still using Gedit for my typing needs, I decided that I really wanted non-broken frames ("winows" in Emacs parlance) in my editor, and I spent a good two or three hours searching around for an addon to it that would do what I wanted. It's been a while so the situation might have changed, but as I recall, there was one add-on that added a single, secondary frame that basically got treated as a second instance of Gedit (except it didn't auto-save, or ask you to save any changes when you quit the main Gedit window), and a second add-on that did precisely what I wanted but wouldn't be available for another year and a half. This illustrates the common state of editors: they're great if you ignore their limitations or resign yourself to living with them.

Emacs is different; because hacking on it is central to the idea, there's very rarely a feature you could imagine that you can't also implement yourself with a few hours of typing. Even better than that, small changes are trivial to add. That tag-closing function I whipped up that auto-fires on my typing">"? That took about 40 seconds to add. And no, it's not done yet, I'll probably change its binding or behavior, but the fact that I can is awesome.

It feels very gratifying that the cycle of

  • Think up new feature
  • Code it
  • Test it
  • Use it

could be so fast.))

(define (addendum)

'(I decided to change up the interaction on that auto tag-close function to fire when I type "</" rather than ">" (which is to say, when I type "/", Emacs checks if the previous char is "<", and fires the tag-close event if it is, otherwise it just inserts "/" as usual).

Closing tags on ">" with a save-excursion is what Eclipse does as I recall, so I sort of assumed it would be the correct behavior. It turns out that if I have any say in the matter, it's vastly preferable to have my editor close that tag when I'm already half-way into it. I may change it back again later, depending on what I notice during actual use, but this way seems to grant me more control so far.))

Friday, March 5, 2010

(define (quick-thoughts)

I've added uniquify and smart-tab.el to my .emacs (and bound the second to tab, obviously). It feels very close to cheating in some way. Verbose variable names are suddenly that much less taxing on the fingers, and indentation/minibuffer use is unhindered. This may be the single most productive Emacs mod I've used so far, and the damn thing is two functions long. It's ridiculous. There have also been mods to my git-addendum file. The latest is

;;Addendum to the built-in GIT library for Emacs
(defun git-init (directory)
  "Initializes the given directory as a GIT repo, then runs git-status on it"
  (interactive "DSelect directory: ")
  (let ((default-directory directory))
    (git-run-command-buffer "*git-init*" "init"))
  (git-status directory))

;;added (define-key map "\C-p" 'git-pull) to git-status-mode-map in git.el
(defun git-pull (remote-dir)
  "Pulls from a directory. Typical input is 'user@remote-machine:directory master'"
  (interactive 
   (list (completing-read "Select git repo: " 
                          (if (boundp 'git-pull-completion)
                              git-pull-completion
                              '("")))))
  (unless git-status (error "Not in git-status buffer"))
  (git-run-command-buffer "*git-pull*" "pull" remote-dir)
  (customize-save-variable 'git-pull-completion
                           (if (boundp 'git-pull-completion)
                               (add-to-list 'git-pull-completion remote-dir)
                               (list remote-dir)))
  (git-refresh-files))

(provide 'git-addendum)

with many thanks to Junio Hamano, David K├ągedal and Alexandre Julliard of the git.el maintenance team (whose time I won't impose further upon).

It's slowly beginning to dawn on me that Emacs is not an editor. Not in the classic sense, leastwise, which is why Bill Clementson's assessment rings true.

Emacs is a language for succinctly expressing editors.

That seems to be a theme with anything Lisp, and it's a powerful idea in its simplicity. This is the way John managed to break so much new ground. He didn't walk around using editors, or bothering with low level ideas; when he found a problem, his reaction was to define a notation in which expressing its solution was simple. There's a lot I could learn from that approach. )

Wednesday, March 3, 2010

(define (peripherals)

I got something yesterday

[1]

It's awesome. Not only is it about 1/3 the size of my current Microsoft-made behemoth, but it types better too. As in the key action is much smoother, and hitting the spacebar takes exactly as much effort as hitting a regular key (my HP mini managed this too, but the space on that MS ergonomic board is noticeably harder to press down than any of the others).

Now that I've had a chance to compare these two IRL, I have to say that the Apple mini-keyboards are really no substitute. They have the standard apple spring system, which isn't terrible, but it's nowhere near as good. That's a clear win for the Happy Hacking Lite 2.

The layout choices are really personal preference. The ESC key on HH is where ` is on the Mac, the area around the \ is a little shuffled so that Delete ends up directly above return (which doesn't usually bother me since I've been trying to prefer backward-word-kill to backspace), and the Alt and Cmd keys switched places. That last one is a problem, but they give you a switch at the back of the keyboard to reverse their positions back to keyboard standard. I just used it and am thinking no more about it. The other active switch on my little keyboard is the one that makes the Delete key act as backspace. (Even though I use backward-word-kill, it's still more common to backspace than to delete).

I am keeping the mac keyboard for the Mac though; the OS X version of HH2 has an elephant-style return key which I dislike, so I'm not about to shell out another $100 bucks for one (I may eventually burn $300 or so to get my hands on a Happy Hacking 2 Pro, but not any time soon).

A second peripheral I tried out it the Bamboo Touch (not the Pen and Touch, which is actually a separate product).

That one sucks balls. It's basically a trackpad that lets you use two fingers. I don't know about you, but when I'm using a computer that has a trackpad, the first thing I do is plug in a mouse or trackball. The reason I bought the thing is that I thought it acted like a tablet, except without a pen. And no, it's really not the same thing. The difference is that you never have to lift your pen from the tablet to recenter it, the way you used to with old mice.

If you tap the lower left area of a tablet, your cursor automagically appears on the lower left of your screen. Likewise, if you tap the top right corner of your tablet, the cursor teleports to the top right corner of your screen. If you use your finger to tap on your Bamboo Touch ... your cursor stays where it is and invokes the click event. In other words, in order to get the cursor from the top right corner of the screen to the lower left, you start with your finger at the top right, drag it towards the lower left until you inevitably run out of room, then raise your finger, put it back at the top right and repeat this process 'till you get where you're going. On a large screen, you might have to do this 4 to 5 times. Teleporting is really the only reason I use tablets instead of mice; once you get used to the behaviour, it saves you seconds per mouse trip.

This is not a customization accident, or mistake. This is the intended behaviour, and that link will take you to a page where a Wacom rep is trying to happily explain how easy it is to get your pen to behave in "mouse mode". In other words, the only thing you can do is disable the behaviour you'd like.

Until they resolve this, I'm sticking with my tablet and trackball, thank you.


Footnotes

1 - [back] - I closed my old account in a vain attempt to associate it with this gmail account. It was an unboxing of a Happy Hacking 2 Lite keyboard