Vinod Kurup

Hospitalist/programmer in search of the meaning of life

Peanut Allergy, a Personal Clinical Review

A Vignette

A 22-month-old previously healthy girl was brought to the emergency room in respiratory distress. She had been well until the day of presentation. Shortly after disembarking from an airline flight, she developed cough with one episode of emesis. En route to the emergency room, her breathing became labored and she developed hives. She was diagnosed as having an allergic reaction and treated aggressively with IV methylprednisolone, IV diphenhydramine, inhaled albuterol, and oxygen. Mechanical ventilation was not required and her symptoms improved rapidly. She was monitored in the emergency room for an extended period and discharged in stable condition with a prescription for diphenhydramine and methylprednisolone solutions. No specific allergen was identified. She was seen by a pediatric allergist where she was found to have a 6 mm response to peanut on skin prick testing, and a peanut-specific IgE level of 52 kU/L. She was diagnosed as having severe peanut allergy and avoidance was strongly recommended.

Discussion

Peanut allergy affects between 0.4 and 2.0% of children. Prevalence has been increasing in recent years, but the reason for this increase is not well understood. If reactions are identified immediately, treatment is usually effective. Despite this, about 200 people die each year from peanut reactions. Biphasic reactions, in which the initial reaction subsides, but then recurs within a few hours, are common. The second portion of a biphasic reaction is often less treatable. Because of this risk, patients should be monitored for at least 4 hours after a reaction. Patients who successfully treat their own reactions with subcutaneous epinephrine should still seek medical attention, again to monitor for biphasic reactions.

The gold standard for diagnosis is a double blind placebo controlled food challenge (DBPCFC), but this is rarely done. A diagnosis can usually be reliably made with clinical history, skin prick testing and a peanut-specific IgE blood test (psIgE). A skin prick test involves pricking the skin with a needle that is exposed to peanut extract and measuring the allergic rash that develops. The psIgE blood test measures the amount of antibody against peanut proteins. The higher it is, the more allergic the patient is. A positive skin test or psIgE is not sufficient for the diagnosis. Some type of reaction to peanuts is required (either spontaneous, or via monitored food challenge).

Peanut allergy was previously felt to be permanent, but recent evidence documents that 20% of children outgrow their allergy. More than 60% of patients with an psIgE level of less than 5 passed a food challenge. IgE levels correlate inversely with likelihood of resolution, but this correlation is by no means perfect. Some patients with undetectable psIgE levels will fail a challenge, while some patients with very high psIgE levels will pass. One expert recommends waiting until the age of 4 to consider a challenge, and to use a cutoff psIgE level of less than 5 kU/L in most patients. Recurrence of peanut allergy after resolution is rare, but is associated with the lack of regular peanut intake after resolution of the allergy.

Controversy exists regarding risk factors for developing peanut allergy. The AAP initially recommended that peanut not be introduced early in a child’s life, but rescinded that advice given the lack of evidence behind it. This leaves a void for parents as there is no recommendation to withold or introduce peanuts to toddlers. It is also not clear if maternal peanut intake during pregnancy or breast feeding increases the risk of developing peanut allergy in children. Studies have been conflicting, so more definitive studies are underway. No evidence-based advice can be given one way or the other to pregnant or breastfeeding women, but at the minimum, there is no good evidence to support avoiding peanuts.

The mainstay of treatment is education. Parents should be taught not only how to identify peanuts in foods, but to identify situations which are high-risk for exposure to peanuts. Avoidance of buffets, ice-cream parlors, and bakeries is recommended because the risk of cross-contamination in those setting is high. Religious reading of food labels is important. Patients who are allergic to peanuts are often also allergic to tree nuts, despite the dissimilarity in those food types. Highly refined peanut oil is usually NOT a risk, but cold-pressed peanut oil is not safe.

Most importantly, an epi-pen should be carried at all times and extra doses should be left at daycare facilities and schools. All caregivers should be comfortable giving an epi-pen injection and this should be provided at the first sign of a systemic allergic reaction. Waiting to give diphenhydramine or other therapies a “chance to work” can be dangerous. Follow a Food Allergy Action Plan Over 80% of people who died from allergic reactions were not given appropriate instructions on how to prevent future reactions. Most mortality occurs because of late treatment. If you take one thing away from this long post, keep an epi-pen handy and use it liberally.

Trials are underway investigating various oral-based immunotherapies, but none are strongly recommended at this point. Injection immunotherapy has not been found to be useful.

Personal Comment

So, the 22 month old above is Anika and she gave us the scare of our life a couple years ago. The scary part now is that we never saw her actually eat a peanut, so we’re especially vigilant now. Fortunately, Anika seems to understand the importance of avoiding peanuts. When she was diagnosed, I did some research but never documented my notes. She recently had another allergist appointment, so I reviewed those notes and any new data. I figured I should write up my notes so I wouldn’t have to review this again from scratch every year. I didn’t intend it to come out so ‘medical-speaky’, but there it is. Anika and Kavi are sitting next to me as I write this and they want to give some information to you, too.

Kavi says:

“Always ask at the restaurant if things have peanuts and make foods at home that do not have peanuts. Always check if there are peanuts in every food you eat.”

Anika says:

“We might have to go to the doctor if we eat peanuts. If I eat peanuts by accident, my teacher will give me a Happy-Pen (epi-pen).”

References

  1. Sampson HA. Peanut Allergy. N Engl J Med, 2002;346;1294-8. http://www.nejm.org/doi/full/10.1056/NEJMcp012667
  2. Fleischer DM, et. al. The natural progression of peanut allergy: Resolution and the possibility of recurrence. J Allergy Clin Immunol, 2003;112;183-9. http://www.jacionline.org/article/S0091-6749(03)01251-X/abstract
  3. O’B Hourihane J. Peanut Allergy. Pediatr Clin N Am, 2011;58;445-57. http://www.pediatric.theclinics.com/article/S0031-3955(11)00006-X/abstract
  4. Rinaldi M, et. al. Peanut allergy diagnoses among children residing in Olmstead County, Minnesota. J Allergy Clin Immunol, 2012:130:945-50.
  5. Burks AW. Early peanut consumption: postpone or promote? J Allergy Clin Immunol. 2009:123:417-423. http://www.jacionline.org/article/S0091-6749(08)02436-6/fulltext

RSS URL:

Here’s a medline feed URL that I monitor which should show new studies or reviews related to this topic.

Priorities and GTD

Pre-GTD task management systems recommended that you assign a priority to each task. When looking at a list of tasks, you then choose the ones with the highest priority. David Allen (author of GTD) includes ‘priority’ as one of the things that you should consider when you are deciding what to do, but only after you have considered context, time available, and energy available. Which makes sense. As Merlin Mann says, it doesn’t matter if mowing your lawn is your highest priority when you’re sitting in an airplane. Only if you’re in the right context with the right amount of time and the right amount of energy, should you consider which of the remaining available tasks is highest priority.

The risk, though, is that there are so many little ‘easy’ tasks that I could do instead of important, ‘hard’ tasks. I’m also really good at convincing myself that I don’t have the energy available to do harder tasks when I really should. So when I get back into GTD, I process all the things hiding in the back of my brain which leads to the creation of lots of simple tasks. Google this, buy that, throw away the other thing. But the two things that I really want to be doing more are writing and programming. Both of those take blocks of uninterrupted time and effort, so I end up subconsciously shying away from them. I actually feel better about it, too, because now I have all these other tasks that I can do instead. So, I feel productive, even when ignoring the more important things that I should be doing. I’m moving more efficiently, but in the wrong direction.

I’ve avoided that a little bit this time by doing a little bit of prioritization each night before I go to bed. I look through my todo list and pick about 3-5 things that I want to get done the next day. I tag those with the ‘today’ tag and then the next morning I look at that list and start working on those things before doing anything else. I’ve heard this trick from a lot of people before, so I don’t remember who I heard it from first.

So far it’s been effective for me. The problem always starts again though when I go back on service, because then I can only really focus on one thing and that is getting my work done at the hospital. We’ll see if I can somehow figure out a way to get at least one non-work thing done on each of those days.

GTD Again?

Thanks to Merlin Mann’s recent series of podcasts on GTD, I’m getting back on the GTD wagon (for about the 100th time). I read Getting Things Done in 2002 and have been trying to implement it ever since. I’ve had periods where I followed it religiously for a month at a time, but it’s never completely stuck. From what I hear, this is normal and I accept it now. This won’t be the last time that I restart GTD. Even when I’m not actively using GTD, I think in GTD terms, thinking about next actions and projects and ruthlessly placing projects on the backburner. I just have trouble sticking with the entire GTD workflow, especially the ubiquitous capture (I trust my brain too much) and the weekly reviews (they just seem too painful). I’ve used every online and offline tool in the book, too. Despite not doing so great with GTD, I’d say my life is an overwhelming success.

So why try again? Each time I have gotten back on the bandwagon, I’ve had a surge in productivity. I wrote more. I made some clear decisions on issues that I had been procrastinating on. I wouldn’t be surprised if each of my major life improvements over the past 10 years was associated with a time where I got back on the GTD wagon. I can’t prove that, because I don’t keep enough details, but I always feel better and think clearer when I’m on GTD.

But, I’ve failed so many times… what kind of hubris makes me think I’ll get it this time? “Fall down seven times, get up eight.” Parenthood has taught this to me. Of course we don’t expect our kids to learn each skill the first time they try. We expect that walking and reading and writing and bike-riding will take time, multiple efforts, and multiple failures. But eventually they will get it. Yet, with each failure, kids get upset (to varying degrees). The answer at that point is not to tell them to give up. Yet, that’s what I do to myself. So, I’m going to treat myself like a kid and let myself fail, understanding that each failure will get me closer to that one time where I will succeed.

Writing Paralysis

I think twitter and facebook stunt my writing. The more that I read tweets, the more self-conscious I get when I write. Not that my writing is all that original, but I still feel that it is something that comes from me. I worry so much about presenting ideas of others as my own without even remembering that I had seen the ideas before. In the old days, the things that I read were long form. Books, articles, maybe blog posts. They each left an impression on me, maybe good, maybe bad, but I had a sense where they were coming from. When I wrote I could reliably say where the inspiration for my idea had come from. Now with twitter, I see all these ideas and thoughts, some of which are interesting, but few of which leave a lasting impression on me. So now I have this fear that the things that I am considering my own ideas are actually the ideas of others, improperly attributed. Of course, that’s silly. No idea is original, but it’s just serious enough to stifle my writing. Because, as a writer, I am the scaredy-cat of all scaredy-cats and any criticism of my writing bites deep to the heart. I also know that this is something that I just need to get over. You cannot express ideas without inviting criticism. I also don’t just want to let criticism fall off me. I want to learn from critics. But saying all that doesn’t necessarily make it any easier. Even writing this post, I feel like a fraud. I’ve said that I’m a writer a couple times up there, but what evidence do I have to support that claim? Most of my blog posts are so simple or technical or repetitive. Nothing that would strike me as an ‘original idea’. This whole post makes it seem like I am more important or better than I really am.

What is my point with all this? I want to be able to write. I know that there are people out there who could benefit from things in my brain (maybe not a lot). I know that there are people out there who can help me (in ways that I can’t even expect). So, I want to write and I want it to be freely flowing and I don’t want to force myself to feel that what I am writing is useful or authoritative or perfect. I apologize to you, Vinod, my biggest critic. I know that you are cringing inside because you’re thinking that anyone who reads this will think that you are so full of yourself for even considering yourself a writer. But, this is my first step in letting my guard down to get this blog flowing. Because I do believe that writing is healthy and will make me a better person.

In addition to committing to blogging more frequently, I’m also going to try a twitter hiatus for a week and see what happens.

Steal My Web App Idea

Now that we have 3 kids, I’m always internally comparing one to the other. Sure that’s not healthy and will probably breed resentment in them during their teenage years, but what’s a bad parent to do?

I need an app that takes 2 kids’ birthdays and then shows me what day it was when the older kid was the age that the younger kid is now. Wow, that’s a confusing sentence. In simpler terms, if I have a 3-year-old and a 1-year-old, then the app would show me the day that the 3-year-old was 1.

Then, I want the app to take that date and go through all of my personal files (photos, notes, twitter stream, facebook stream, etc.) and show me what was happening in our life around that day.

In short, it would show a snapshot of what our life was like when the older kid was the age that the younger kid is now. I’d call it WhenIWasYourAge or something catchy like that.

Seems simple enough to build, but I don’t see myself getting to it anytime soon. Smart people say to set your ideas free and if they love you they’ll come back. (Wait, I think I’m mixing metaphors here).

How to Change the Rear Tire on a 12 Inch Bicycle

I’m not the handiest guy in the world, so I’m pretty proud that I was able to fix a flat tire on Kavi’s 12” bicycle.

DISCLAIMER: I have almost no idea what I’m doing. Follow my instructions at your peril.

I’ve fixed flats before, but it’s been a long time. Fixing it on such a tiny bike was a lot harder than I thought. The manual makes it seem so simple. “Remove the wheel, take the tube out, patch the tube and then replace the tube and tire.” Right… I got stuck at step 1. Removing the wheel isn’t straightforward. Most of the videos available online focus on adult-sized bikes which have quick-release tires. You pull a release lever back and then pull the tire off. Kids bikes have bolts instead of quick-release levers. You have to loosen the bolts, but you don’t have to take the bolts completely off. You also have to take off the plastic chain guard that prevents kids from rubbing their legs against the chain. Finally, there’s this little metal piece that attaches the wheel to the frame. I think it’s there for the pedal-brake to work. In any case, you have to take that off. Once the wheel is loosened, you have to unhook the wheel from the chain. This is also easier in big bikes which have multiple gears, making it possible to place the chain in a position to easily get it off the wheel. In a kid’s bike, it’s harder. Once I loosened the bolts on both sides of the wheel, I pushed the wheel a little forward, which loosened the chain and made it easy to release from the chain.

The next difficulty was getting the tube out of the tire. All the videos make this seem so easy. Place a tire lever in the tire to pull it over the rim. Put another tire lever in and slide it around the rim to get the rest of the tire out. Kavi’s tires are so tight that this was impossible. I could get the first tire lever in, but when I put the second tire lever in, it was completely immovable. There was no way that I was going to be able to slide it anywhere. I finally found a website where they recommended using a third tire lever. Put the first two in a few inches apart. Then put the third one in another inch away from the second one. Finally remove the middle one and move it an inch past the third one. In this way, I was able to get the tire off eventually.

I then got the tube out and found the leak. I placed a patch on it, but when I reinflated the tire, the leaking air just pushed it’s way through the patch. I tried roughing up the area with the roughing tool, but that didn’t help. Finally, I resorted to the layman’s favorite tool: duct tape. I placed the patch, then wrapped it with duct tape. It’s held together for a few months now.

Hopefully Kavi will graduate to the next size bike before my handiwork breaks down. On another note, Kavi was easily able to pick up the basics of riding a bike by following the REI guide. I took off the training wheels and the pedals, which allowed him to get the feeling of balancing the bike without having to keep his feet on the pedals. Once he got that part, it was relatively easy for him to balance with the pedals on. He also proved to be a much tougher kid than I was. Everytime he fell, he got right back on.

NSBrief Gets the Best Guests

I’m not an OS X programmer, but I’ve really enjoyed 2 recent episodes of the NSBrief podcast. First was Mark Dalrymple’s interview. Here was my 140 character description:

Today, I listened to Mark Aufflick’s interview where he talks eloquently about starting your own business. I love the perspective he had on his first business and how shutting it down gave him the necessary (though painful) experience to make his current business work. He also talked about the importance of computing history especially given the availability of interesting subjects. He ended with great advice on the importance of professionalism. Paraphrased: “Make sure your team is the most professional side of any relationship.”

I know Mark and Mark from the OpenACS glory days and it’s great to hear how well they’re doing. Computing history was a prominent part of both talks. I think this is important. Old ideas are always new again. Some of the ideas that these pioneers had were only limited by the horsepower we had to work with at the time. Now thanks to Moore’s law, those limitations are gone, so we should re-investigate those ideas. Or maybe we’re all just getting old and like to talk about the good-old-days. :-) It’s nice to see that they both mentioned the OpenACS period of their programming lives as important. It certainly was for me. It was also great to hear Mark Aufflick’s voice for the first time, even though I feel like he’s been a friend for many years.

Emacs for Python Programming

(Note: See the bottom of this post for updates)

I was honored to to give my “Emacs for Python Programming” talk at the inaugural PyCarolinas conference. The conference was a huge success in every way, thanks to the efforts of Calvin Spealman, et. al. I promised that I would post my Emacs setup, so here it is.

Step 0: Prerequisites

This may work with other setups, but here’s what I tested:

Step 1: Clear out any previous customization

As evidenced by the numerous blog posts documenting how to set this up, it’s not straightforward. I recommend starting from scratch to make sure everything is set up properly. Once you have it working, then you can customize it. Make sure to start these commands in your home directory.

1
2
vinod:~$ mkdir old-emacs
vinod:~$ mv .emacs .emacs.d old-emacs/

Step 2: Set up initial Emacs configuration

Create an empty .emacs.d directory and a subdirectory named with your username. My username is vinod, so we’ll create a directory structure called .emacs.d/vinod/. The emacs-starter-kit tells emacs to automatically load any elisp files from that special directory, so you’ll always have a place to drop custom elisp files.

1
vinod:~$ mkdir -p ~/.emacs.d/$USER

Create a file named .emacs.d/init.el with the following contents:

my-init.ellink
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
(require 'package)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(package-initialize)

(when (not package-archive-contents)
  (package-refresh-contents))

(defvar my-packages '(starter-kit
                      starter-kit-bindings
                      starter-kit-js
                      autopair
                      yasnippet
                      auto-complete
                      fuzzy)
  "A list of packages to ensure are installed at launch.")

(dolist (p my-packages)
  (when (not (package-installed-p p))
    (package-install p)))

;; autopair and yas in all modes
(autopair-global-mode)
(yas-global-mode 1)

;; autocomplete
(require 'auto-complete-config)
(setq ac-dictionary-files (list (concat user-emacs-directory ".dict")))
(ac-config-default)
;; hack to fix ac-sources after pycomplete.el breaks it
(add-hook 'python-mode-hook
          '(lambda ()
             (setq ac-sources '(ac-source-pycomplete
                                ac-source-abbrev
                                ac-source-dictionary
                                ac-source-words-in-same-mode-buffers))))

;; Set up python-mode
(setq py-install-directory (concat esk-user-dir "/python-mode.el-6.0.12/"))
(add-to-list 'load-path py-install-directory)
;; this will show method signatures while typing
(setq py-set-complete-keymap-p t)
(require 'python-mode)
;; activate the virtualenv where Pymacs is located
(virtualenv-workon "default/")

(defun load-pycomplete ()
  "Load and initialize pycomplete."
  (interactive)
  (let* ((pyshell (py-choose-shell))
         (path (getenv "PYTHONPATH")))
    (setenv "PYTHONPATH" (concat
                          (expand-file-name py-install-directory) "completion"
                          (if path (concat path-separator path))))
    (if (py-install-directory-check)
        (progn
          (setenv "PYMACS_PYTHON" (if (string-match "IP" pyshell)
                                      "python"
                                    pyshell))
          (autoload 'pymacs-apply "pymacs")
          (autoload 'pymacs-call "pymacs")
          (autoload 'pymacs-eval "pymacs")
          (autoload 'pymacs-exec "pymacs")
          (autoload 'pymacs-load "pymacs")
          (load (concat py-install-directory "completion/pycomplete.el") nil t)
          (add-hook 'python-mode-hook 'py-complete-initialize))
      (error "`py-install-directory' not set, see INSTALL"))))
(eval-after-load 'pymacs '(load-pycomplete))

;; pyflakes flymake integration
;; http://stackoverflow.com/a/1257306/347942
(when (load "flymake" t)
  (defun flymake-pyflakes-init ()
    (let* ((temp-file (flymake-init-create-temp-buffer-copy
                       'flymake-create-temp-inplace))
           (local-file (file-relative-name
                        temp-file
                        (file-name-directory buffer-file-name))))
      (list "pycheckers" (list local-file))))
  (add-to-list 'flymake-allowed-file-name-masks
               '("\\.py\\'" flymake-pyflakes-init)))
(add-hook 'python-mode-hook 'flymake-mode)

;; menu bar is useful when getting started
(menu-bar-mode)
(setq-default default-tab-width 4)

Step 3: Create a python virtualenv

We’ll keep all the python-side customization in a virtualenv named default. It’s important that the name you choose is the same as the name in the (virtualenv-workon) command in line 45 of Step 2.

1
vinod:~$ mkvirtualenv -p python2 default

After it does its thing, your shell prompt should change, indicating that your new virtualenv is activated

1
(default)vinod:~$

Step 4: Install Pymacs

Pymacs is a really cool piece of software that sets up a 2 way communication between Emacs and Python, allowing you to control Emacs with python commands rather than elisp commands. It requires a python piece (Pymacs.py) and an Emacs piece (pymacs.el). Unfortunately, they’re not installable via pip or package.el, but installation is easy enough.

1
2
3
4
5
6
7
8
9
10
11
12
13
(default)vinod:~$ mkdir src
(default)vinod:~/src$ cd src
(default)vinod:~/src$ git clone git://github.com/pinard/Pymacs.git
(default)vinod:~/src$ cd Pymacs

# check to make sure tests pass
(default)vinod:~/src/Pymacs$ make check

# install it (Be sure you're inside your virtualenv!)
(default)vinod:~/src/Pymacs$ make install

# install the emacs extension
(default)vinod:~/src/Pymacs$ cp pymacs.el ~/.emacs.d/$USER/

Step 5: Install other python packages

These helper packages are easier to install:

1
(default)vinod:~$ pip install pyflakes pep8

The pyflakes and pep8 packages check your code as you type using Emacs’ flymake mode. Now, deactivate your virtualenv.

1
2
(default)vinod:~$ deactivate
vinod:~$

Step 6: Install pycheckers

Flymake is the part of Emacs that checks your code for errors on the fly. It calls a shell script called pycheckers, so you need to have a script by that name in your shell’s PATH. Here’s mine (~/bin/pycheckers):

pycheckers.shlink
1
2
3
4
5
#!/bin/bash

pyflakes "$1"
pep8 --repeat "$1"
true

Step 7: Install python-mode.el

As I mentioned in my talk, there are multiple Python modes available, but I recommend using the one named python-mode.el, which is developed at http://launchpad.net/python-mode. It does periodically get uploaded to Marmalade, but the auto-completion using pycomplete doesn’t work well on the version that is there now (6.0.10), so I recommend that you manually download and install the latest stable version (6.0.12). I’ll update this post once a stable working version gets uploaded to Marmalade or Melpa.

1
2
vinod:~$ cd ~/.emacs.d/$USER
vinod:~/.emacs.d/vinod$ curl -L https://launchpad.net/python-mode/trunk/6.0.12/+download/python-mode.el-6.0.12.tar.gz | tar xz

Step 8: Test it all out

Launch emacs and open a python file named test.py. Type the following:

import os
os.path.jo

Wait at this point. You should see auto-completion of os.path.join followed shortly by a yellow popup showing documentation of that method. Hitting return should accept the completion. Then type ( and you should see the method signature in the minibuffer.

Move the cursor over any letter in join. Hit ‘F1’. A window should popup with the docstring for os.path.join. Hit ‘F2’. A new window should be opened with the code for os.path.join. Hit ‘F3’. You’ll be prompted to enter the name of any python command, and Emacs will show you the docstring.

Type the string ‘blah’ and hit return. The string should be highlighted in pink and if you mouseover it, the minibuffer will say undefined name 'blah'. That’s flymake working for you.

Hit C-c C-c and the buffer should be sent to a Python interpreter and you’ll be dropped in the REPL after the code has been loaded. Any errors in the code will be reported.

If all of this works, then CONGRATULATIONS!!! If not, let me know and I’ll see if I can help debug.

Step 9: Customize

All of this is customizable in hundreds of ways. Try M-x customize-group RET python-mode RET to see how.

Step 10: How to create a new python project

Whenever you want to create a new Python project, you have do the following:

Create a new virtualenv

1
vinod:~$ mkvirtualenv newproject

Install pymacs into that virtualenv

1
2
(newproject)vinod:~$ cd ~/src/Pymacs
(newproject)vinod:~/src/Pymacs$ make install

Install the other pip modules

1
(newproject)vinod:~/src/Pymacs$ pip install pyflakes pep8

Switch to that virtualenv in emacs

M-x virtualenv-workon RET newproject/ RET

Issues

Changing virtualenvs doesn’t restart Pymacs

For the most part, this won’t affect much, but if you move from a Python2 project to a Python3 project, you may have problems. The workaround is to call M-x pymacs-terminate-services, then M-x virtualenv-workon to change your virtualenv, and then finally M-x load-pycomplete to restart pymacs and pycomplete.

Latest stable version of python-mode.el isn’t on Melpa

I’d much prefer to just load python-mode using the built-in Emacs package manager.

Pymacs installation is harder than it needs to be

I wish Pymacs could be installed by a 2 step process

  1. pip install Pymacs
  2. M-x package-install RET pymacs RET

Which pycheckers to use?

My script uses pep8 and pyflakes. There are a lot of other options out there and I do not know which is best. See this post for more details.

Not using ropemacs any more

In my talk, I used ropemacs. In this setup, I have decided against it. I was mostly using it for code-completion and documentation lookup, but I like pycomplete.el better for those purposes. It’s included in python-mode and it shows method signatures as you type. Ropemacs does have other features such as project management (easily jumping to files in the same project), and refactoring (changing variable names throughout project). I haven’t used those, so I decided not to install ropemacs.

Project management not included

I haven’t yet decided which package to use for this. I’ll probably try projectile, but there are many other options, some lightweight (ropemacs, eproject, pony-mode) and some heavyweight (ecb, CEDET).

References

I gleaned knowledge from all of the following, in no particular order.

Updates

2012-10-27

Thanks to @danpoirier and @gregnewman for testing. I initially recommended using the master branch of python-mode.el, but now I recommend using the latest stable release (as of now) which is version 6.0.12 to avoid problems loading Pymacs. There’s a bug on 6.0.12 with virtualenv-workon that requires you to put a trailing slash after the name of your virtualenv, so I’ve updated the init.el file above to account for those changes.

Emacs Autocomplete Stumbles on Yasnippet

Autocomplete Mode is an Emacs mode that tries to guess what word you’re typing and provide auto-completion. Recently, it started failing in simple scenarios.

It can use various ‘sources’ to try to figure out what you’re about to type. The simplest source is ac-source-dictionary which is a simple list of words. If you start typing any of those words, it will try to autocomplete them for you. Normally, you’d put those words in a file, with each word on a separate line, but for testing purposes, you can also add them manually using an elisp function. Here’s the test that failed for me:

(add-to-list 'ac-user-dictionary "foobar@example.com")

That adds the email address to the dictionary. Then, typing ‘foo’ in any buffer, should offer to autocomplete the entire email address. Unfortunately, it wasn’t working.

To debug, I typed ‘foo’ and then did M-x auto-complete, which forces auto-complete to look for a completion. This resulted in an error in the Minibuffer:

ac-yasnippet-candidates: Symbol's function definition is void: yas/current-snippet-table

This led me to check which ‘sources’ autocomplete was trying to use: C-h v ac-sources

(ac-source-features ac-source-functions ac-source-yasnippet
 ac-source-variables ac-source-symbols ac-source-abbrev
 ac-source-dictionary ac-source-words-in-same-mode-buffers)

So, autocomplete is looking through each one of those sources, trying to find possible words I might be typing. The third one is called ac-source-yasnippet, which seems to be where my error is coming from.

So, I looked into the yasnippet source code and found that, indeed, there was no function named yas/current-snippet-table. That function has been renamed to yas--get-snippets-table in version 0.8.0, but autocomplete is still relying on the old function name. (RANT: Don’t rename functions that others might be using without providing some kind of alias, at least temporarily) I looked at the code for autosnippet on github and noted that the latest version has been fixed to use the new code, but it hasn’t yet been released on MELPA. Until it is, the quick solution is to remove ac-source-yasnippet from ac-sources.

(delq 'ac-source-yasnippet ac-sources)

Then typing ‘foo’ autocompletes to ‘foobar@example.com’.

It seems that autocomplete should be more forgiving of errors in any specific ‘source’, passing it up to use other sources. Alternatively, it should fail loudly when there’s an error, so that I can know to fix or remove the offending ‘source’.

I’ve Gone to the Dark Side

I was a huge Apple fan growing up and IBM was Apple’s enemy. Buying an IBM computer would have been unthinkable.

Well, the unthinkable has happened. Of course IBM doesn’t make laptops anymore, but their computers live on under the Lenovo name. I am the proud owner of a new Lenovo Thinkpad T420S. I love this computer. It’s an ugly black boxy thing, but it’s light (4 lbs), quiet and speedy. And the keyboard is just pure awesome. That’s the main reason that I bought the T420S as opposed to the current T430 line. The new line has the chicklet keyboard that is being used on all laptops these days. The T420 is the last one with the old-fashioned clicky keyboard, which I love.

I also feel very lucky to get the deal that I got. I bought it from Lenovo’s Outlet store, which had about thirty T420s’s in stock when I was shopping. This one was about half the price of the others, by my estimation. It’s so underpriced that I’m wondering if I’m missing an obvious flaw, but I don’t see it. (Please let me know if you do!)

Here’s a comparison between the specs of my computer compared to one that was available at the Outlet store on October 4th, 2012:

  Mine Other one
Part Number 417153U 4170CTO
Processor Core i5-2540 Core i5-2540
OS Windows 7 Pro Windows 7 Home
Graphics Intel HD3000 Intel HD3000
Memory 4 GB 8 GB
Display 14” 1600x900 HD+ 14” 1600x900 HD+
HD 128GB SSD 128GB SSD
Optical DVD recordable DVD recordable
Battery 6-cell 6-cell
Network Intel Centrino Advanced Not specified
Bluetooth V3.0 Not specified
Fingerprint reader No No
Price $ 663.72 $ 1,355.39

The RAM is better on the other model, but Windows 7 Professional is an upgrade on my model. I don’t really understand why mine was so cheap, but I’m pretty happy about it!

I added another 4G of RAM, moved Windows to a VirtualBox image and installed Arch Linux with Xmonad. It takes about 10 seconds to get from the BIOS screen to a working computer. I’ll post some info on my setup in a future post.