It’s time for another examination of Emacs LISP and a selection of ways to solve the same problem. In this case it’s the behaviour of the etags-select package. This handy function will present a selection table when it finds multiple definitions of the same tag. This is handy if your global TAGs file contains reference to multiple binaries that might have a common code heritage. It even provides a handy function etags-select-find-tag-at-point which will check point to see if that is a tag. However if point is on a blank line I’d prefer it to just prompt me for a tag name.
(defun my-naive-find-tag ()
"Find at point or fall back"
Unfortunately this fails rather badly. I naively assumed etags-select-find-tag-at-point would return ‘nil on failure. Instead it bombs out with an error because etags-select-find expects a parameter and when find-tag-default fails it errors out.
"Find tag and call etags-select-find-tag-at-point if it will work"
This works by checking find-tag-default will work before calling etags-select-find-tag-at-point. Of course there is some duplication here because find-tag-default will get called again once I know it will work. Dissatisfied I asked the stackoverflow community for suggestions. The first solution is to simply trap the error case.
"Find at point or fall to etags-select-find-tag on error"
(unless (ignore-errors (or (etags-select-find-tag-at-point) 't))
This works by utilising deep lisp black magic to stop the error propagating and returning a ‘nil if it does. The (or (etags-select-find-tag-at-point) ‘t) line is to ensure a successful call returns something so we don’t then fall through. Interestingly the comments around subr.el mentions some of the keywords used may be redefined by common lisp.
"Find tag at point, caching find-tag-default"
(let ((ftd (find-tag-default)))
(flet ((find-tag-default () ftd))
While I expected something like ignore-errors to exist this demonstrates the flexibility of dynamic languages like Emacs Lisp. The key is the use of flet to redefine find-tag-default so when it gets executed again inside etags-select-find-tag-at-point it simply returns the cached value.
So as usual with these posts I try to invite feedback. Which of these forms do you prefer? Would you solve the problem another way? Have you just learnt something new about Emacs Lisp?
I’ve been running Emacs 24 direct from the version control tree (technically a git mirror, bzr still confuses me) for some time now. As many people have mentioned ELPA is one of the big features that helps de-clutter an Emacs users ~/.emacs.d directory. I thought it might be a useful exercise to discuss which packages I’m now loading from ELPA and which I still track directly.
First and formemost is my my dotemacs collection. Weighing in at around 2700 lines of elisp it’s small by some standards. I’ve toyed with moving my config across to things like the Emacs Starter Kit but I’m not sure if it’s worth the transition pain. There is certainly a lot of cruft in my code but there is also quite a lot of muscle memory now invested in it. I have been trying to modularise it a little more but to be honest most of that was driven by a desire to get autoload working nicely which is no longer much of an issue as my session tends to stay up for weeks at an end.
I’ll gloss over edit-server.el surfice it to say I’d hope your not surprised I keep the development version running given it’s for my extension 😉
After that we have Johnathan Rockway’s eproject. I work with lots of code bases during the day and some sort of sensible project type structure is a must. I’ve tried a number of different solutions and this one stuck as it was fairly lightweight and easy for my smaller lisp brain to extend. I’ve even managed to contribute some changes back. As a result I find tracking the bleeding edge of development useful.
The same reason applies to Stephen Bach’s lusty-emacs. While ido-mode and ibuffer work well for speed nothing matches lusty’s lazy file and buffer matching. It can get a little too much once you start dealing with hundreds of buffers at a time (something midnight-mode is trying to keep on top of). It’s still seeing some activitiy on the repository hence the local checkout.
Finally the biggie but generally unused cedet. There has been some work to make it comparitively easy to run out of a src checkout and as long as it’s included early enough it won’t conflict with the built in cedet shipping with Emacs 23+. I still haven’t really made much use of it although I have managed to get a completion out of it when editing some C. It’s basically sitting there until I can commit enough time to figuring out how to use the beast.
Finally a quick review of the ELPA packages that I’ve got loaded. Obviously there is the latest org-mode which I’m spending an increasing amount of time in. I also have my favourite zenburn-theme for easy on the eyes goodness. The popular GIT interaction mode magit also sits there which I use every day. js2-mode and ssh_config_mode completes the list of modules that I actually use.
So what ELPA packages have you discovered and what hidden gems to you track directly in your .emacs.d?
One of the most challenging things about managing small bundles of fun is the fact their neural circuitry is brand new and developing very quickly. A key part of development at this stage is bonding with their parents. The last few weeks have been quite hard when Ursula has spent large chunks of time in my sole presence being very un-happy and wanting Mum (who I’ve been trying to let have some sleep). Understandably at this point she is most familiar with Fliss as well as having a fairly base urge for the milky goodness only she can provide. It hasn’t helped that I’ve been working hard so not always been able to get home in time for the evening bath and bed ritual.
This combined with lack of sleep has seen me reach a fairly low ebb of late. In fact it’s possible I’ve had a glimpse of the lack of emotional state that someone with depression has to deal with on a more regular basis. I was certainly hard pressed to remember the last feeling of emotion I’d had for some time.
It was fortunate then the jubilee weekend celebrations saw us visiting Leominster for M&T’s wedding anniversary. Being able to spend time with both Ursula and so many of my old friends from Manchester was an excellent tonic for my depressed mood. What was even more useful was being able to chat to fellow parents who had already been down this particular road and were more than reassuring. I didn’t realise quite how much I’d been bottling up worries about my parental abilities and it was good talk about it.
Of course now with those worries put aside for now we are tackling the next emotional roller coaster of trying to instill a regular sleep pattern in our dear daughter. Much as it is satisfying to successfully rock a previously fractious baby to sleep it’s not a long term viable solution. Ursula will have to learn to “self-sooth” and get herself to sleep without her parents. The process however is fraught and there is a lot of conflicting theories on the best way to achieve this. Suffice it to say it’s not been overly popular with Ursula herself and the resulting wobbly lipped tantrums have been taking their toll on us. We are trying to maintain perspective and keep our eyes on the long term goals. Wish us luck!
I haven’t really had much time for hacking at home unless programming my daughters wetware counts. However a few enterprising users have been sending me in some pull requests that fix a few minor bugs that slipped through the extensive pre-release testing I did for v1.10 so I thought it was worth pushing out a bug-fix release:
* Fixed some breakage to the “edit focused area” feature
* Fixed broken link to embedded edit-server
* A couple of fixes for Emacs 24 compatibility
* Globalize the minor mode so it persists through major-mode changes
I’ve finally buckled and now have a Windows laptop. It was mainly forced on me by the need to have some sort of access to the intranet during the large number of meetings I’m now involved in at work. I have to say the experience has been enlightening, especially seeing all the hacky stuff that has to be done to get things working under Windows. For example by default I couldn’t connect to any https (SSL) pages. Luckily I can just hand the laptop back to IT to fix it so I don’t have to scratch my head too much.
I’ve had only sporadic luck getting Emacs up and running on it though. Having been running the tip-of-tree release on my Linux workstation so long going back to Emacs 23 has been a bit of a retrograde step. It doesn’t help there are multiple suggestions for installation. I’ve been trying to get EmacsW32 working but I’ve run into problems on start-up. So far I’ve been unable to fix the issue as the paths Emacs references don’t seem to show up in the system file browser. This seems to be the only avenue by which I can fix the permissions it’s complaining about.
Getting my init file onto the system and in the right place has also proved to be more complex than it should have been (there seems to be two “HOME” directories, one under a Roaming title). The Windows shell has finally gained completion but it’s still a shadow of a decent Unix shell. On the positive side I can already run eshell from within Emacs which provides a nice alternative to the command shell. I’ve yet to get tramp working though but I suspect that’s just a case of getting ssh keys sorted out.
If there are better solutions to getting a decent Emacs set-up on Windows I’m all ears.
So what has my blogging frequency been like, well I’m glad you asked:
[archive_chart name=”Posting frequency over the last 12 months” width=”600″ height=”300″ count=”12″]
It seems the trend is pretty clear and it’s not exactly surprising as my hands have been more than full with other concerns. Despite coming to a phase where the odd hour or two in the evenings is possible blogging is still fairly low down the priority list. This parenting lark does seem to occupy a fair amount of time. So far it’s an exercise in trying to balance a number of competing demands. While being responsive to Ursula’s minute by minute desires keeps her generally happy we are beginning to see the benefit of following some sort of routine. It seems the oft repeated parental sayings are founded in a degree of experience 😉
Of course just as we started to establish a successful routine we disrupted it all with a trip up to Manchester. Thanks to some friends parents we were able to set up a base of operations in Bolton. We then proceeded to do the local tour and introduce Ursula to our northern friends. She was very well received on her debut although we suspect the schedule may have taken it’s toll. By Sunday she was starting to get a little fractious so it was good to end up at P&C’s for a very relaxed evening. We took it easy on the journey down on Monday and have been getting back into the swing of the normal routine.
It was really nice to catch up with everyone we saw while we were visiting. Next time we come up North we will probably try a slightly less hectic schedule with hopefully a less frazzled family. Thankfully next week is all based at home which is a much more familiar environment for all of us!
As predicted the blogging has dropped off quite precipitously. I still seem to be functioning on a reduced amount of sleep (although Fliss is taking the brunt of the sleep interruption by far). However the evenings are both shorter and much more structured. Eating is slowly moving from a task best accomplished at speed as we alternate baby holding/entertaining duties with each other to one where Ursula is happy to sit in a bouncer/bumbo and watch us shovel food in our faces. We have started getting into the bathing/sleeping routine which currently puts us all to bed at roughly the same time.
However it’s still very rewarding. I didn’t think I’d get quite so gooey inside when Ursula started smiling at me. Although she’s simulated smiles for a while it’s mostly been a prelude to some sort of gas incident. She is now firmly into social smiling territory and every time she does it it’s like a gift to salve the troubled soul that your at least doing something right. In the time that this post has been brewing (I started it a couple of weeks ago) we have even moved on to giggles and laughs. It’s certainly noticeable from close up how fast they start developing their personalities as they move from needing food/sleep/cleanliness to discovery and play.
We have managed to leave the house for extended periods and spent a lovely weekend in snowy Yorkshire on the annual walking holiday with friends from Fliss’ time at university. It was particularly fun because there was a spike of new parents with their kids (along with a couple of old hands) along with plenty of helpful hands willing to hold babies when parents needed to do something else. I found is particularly helpful chatting to people a few months/years ahead of us in the parenting game and be reassured about what we are doing. My stated parenting style is to exude a air of calm confidence while paddling like mad under the water to figure out what to do next.
Fliss’ mum was very kind to come over and spend the night giving us a chance for a meal at one of our favourite Italian restaurants with just the two of us. It was nice to get a few hours to ourselves to remind us of what life used to be like. However for all the work and disruption that a new family member causes we are happy with our new life and only occasionally think wistfully of our former freedoms. It does also make those periods of freedom when they do happen taste all the sweeter.
In other news I have also been working quite hard at my day job and have recently been promoted to Principle Software Engineer. I’m now responsible for all the software engineers in the company as well as all the software deliver-ables. I’m not quite a drop-in for the old Head of Software as I’m sharing some of the management type responsibilities with the Head of Engineering as I’m quite keen to keep my hand as a developer. 2012 is certainly shaping up to be a busy and rewarding year.
When you do so much of your work in one text editor the efficiency of switching between buffers becomes more important. For a long time I’ve had two bindings “C-x b” and “C-x C-b” which in days of yore I had bound to bs-show and a hacked up list-buffers that opened another window. These are broadly the “quick switch between working buffers” and “show me all the buffers”.
For some time I’ve relegated bs-show to the longer binding and now use Stephen Bach’s excellent Lusty Explorer which works really well when you know the name of the buffer and it’s fairly unique. However when you’ve been going a while it can get un-manageable with a large number of open buffers, especially if you’ve opened second copy of a file from another source tree. This is what I would use the old classic bs-show for.
A few days ago I discovered ibuffer-mode with it’s ibuffer-bs-show buffer navigator. Looking back through the Planet Emacsen history I can see it has been mentioned before and given it’s been in Emacs since version 22 I’m surprised I hadn’t cottoned on to it earlier.
One thing that might have put me off is the initial buffer list can be quite sparse. By default you only see buffers with files associated which misses out IRC, Edit with Emacs and *scratch* buffers. However hit “h” and you’ll see there are a plethora of quick keys for chaning the view. A quick “//” and all filters are removed and you can quickly filter by different criteria. To get the most out of the mode you’ll probably want to set up some custom filters (“/r<completing filter name”>) to make quickly switching to groups of buffers easy. I currently have “work”, “remote”, “irc” and “logs” as filters. You can filter by name as well as major-mode.
ibuffer-mode does have the concept of Filter Groups although I’m not sure what they add on top of having normal filters which as far as I can tell can be arbitrarily complex. It also has some quite handy sorting and selection modes e.g. “sv” – sort by last viewing time. Given the amount of space the wiki devotes to the topic I wish I’d re-examined my buffer switching habits sooner. The change is already paying dividends for my productivity.
Before I go I thought I’d put in a quick mention of Google+. There is growing community of fellow Emacs users starting to post on it. One thing that attracts me to Google+ over Facebook (too data-miney) and Twitter (too short) is the concept of “Circles”. It makes sharing geeky Emacs posts with people that might actually care easy while sparing them the flood of baby pictures I share with friends and family. If you’d like to follow me or my alter-ego please do mention Emacs in your profile or in a message so I can assign you to the correct circles.
What with becoming a parent and getting promoted I suddenly find myself needing to become a lot more organised. Although I’ve been using org-mode for a bit I need to get a lot more organised with it.
Previously I had two sets of org notes. My personal set where sitting on my server which I could access via the terminal. I generally accessed this at home on the odd occasion when I was doing things like the annual round of insurance quote gathering. The second set was a fairly simple time sheet type affair that I was using at work to keep a vague track of where all my time was spent. The big missing part of this is when I’m on the move.
I’ve just recently upgraded my phone to the latest Galaxy Nexus which is a fine Google enabled device. I make no apologies for using Google’s calendering and shared document services. They work very well and importantly allow me to share things with my wife who doesn’t quite share my desire to run everything from a text editor. However for my personal task lists on the move and remembering what’s coming up at work it doesn’t quite cut it. Besides I like org-mode and I’d heard about MobileOrg so I endeavoured to set it up.
MobileOrg has been around some time for the iPhone but the mechanisms it uses for integrating with org-mode are fairly well documented. As a result there is a couple of Android implementations for it. Matthew Jone’s mobileorg-android was the first version I tried.
The original sync method for MobileOrg was to use a service like Dropbox to sync files. Given the history of Dropbox’s security I wasn’t about to move my files into the proprietary cloud. The alternative is to enable WebDAV on my web-server and therefor enable two way communication via HTTP. It was a little concerning to see self-signed SSL wasn’t supported as this does open up a potential attack vector on my machine. I’ve mitigated it a little by using digest authentication instead of basic-auth but I’d still prefer to be conducting these read-write operations over something more secure.
Initial results were a little underwhelming. After some messing around with the format of org-links I eventually got a basic outline summary up. Unfortunately I can’t seem to sync notes created on my phone to the server. This seems to be a Apache problem which I shall have to dig into later.
After perusing the market some more I noticed there is a new project in town. Konstantin’s MobileOrgNG was forked some time ago from Matthew’s code and on installing I found it looked an awful lot better. I’ve still be unable to post any locally added notes (due to previously mentioned Apache config issues). However it’s presentation is a lot slicker and it shows a lot of potential for being a good MobileOrg client.
I’m now stuck with a classic open source fork dilemma. The code bases look to have diverged enough that these two projects are essential going their own way. Looking at the two impact graphs it looks like they diverged around August 2011 and since then MobileOrgNG looks pretty much like a solo effort albeit with an impressive commit rate of new features.
So the questions for my readers. Which code base should I jump on? Has anyone got experience with the two different code bases and the reason they split? Are there any other Android clients for org-mode I should be looking at?
Looking back the last few months I notice every post has been about family and parenthood. Time to redress the balance a little and add some geek friendly contents.
After Christmas I indulged myself with a new phone. When I got the HTC Hero I’d deliberately skipped the first generation of Android phones to give a chance for the hardware to mature. I also made the rash promise it would be my last phone for some time. As it happens I think 2.5 years is a fairly good innings for a piece of technology where the innovation cycle is measured in months. I still have the Hero but now it’s not my main phone I can afford to be a bit more experimental with the software I put on it.
There were a couple of changes to my approach to choosing a new phone this cycle. The first was I brought it outright off-contract. Although I suspect I could get it slightly cheaper overall through a phone contract there are some non-financial downsides to the contract approach. The first is the operator takes the view that the phone belongs to them so they can install (and prevent you removing) what they like. The recent Carrier IQ controversy should certainly act as a salient reminder that the mobile phone companies do not have your interests closest to their hearts. The second is lack of flexibility. Although thanks to Ofcom we have number portability most people are only able to take advantage of it at contract break points. The operators know this and off course do their very best to keep you tied in to their deals. Now I’m off contract I’m currently paying £10/month for unlimited data and all the calls/texts I use. They have to work doubly hard to keep me as a customer as I can jump ship at any point. That flexibility is more than worth the up-front cost of paying for the phone in full.
As far as choice there was only really one in the frame. Much as I like Android and it’s open-source nature it does suffer from a problem due to that openness. Although it’s heartening to see manufacturers are starting to relent and cease the practice of locking boot-loaders to prevent 3rd party firmware there are still problems in their support. They tend to stop updating the firmware shortly after they stop manufacturing the phone. Some manufacturers also have a hard time meeting their GPL obligations which makes open source support for the hardware a lot harder. As a result I decided to wait for the next in the Google Nexus series which ships with the latest release of Android, Ice Cream Sandwich.
Initial impressions of the new phone are good. The phone is a little bigger than the Hero but pretty much 100% screen with more than a few hints of Star Trek data pad ;-). The Super AMOLED display looks very clear and crisp with both photos and video. The phone is very nippy thanks to the accelerated 3D hardware and duel core processor. The camera is certainly an improvement on the Hero and with the LED flash is close to achieving the quality I was used to on my old Sony K750. The A-GPS also acquires location a lot faster than the Hero. In fact a lot of things I thought were app problems have cleared up when presented with faster hardware. All in all I’m very happy with the Galaxy Nexus and think it easily stacks up against any iPhone you might want to compare it with.