Mapping file paths for pdbtrack

I saw python-mode 6.0.8 was release two weeks ago, and that reminded me to look and see if my change was included. Turns out it was included in 6.0.6, released in April:

– files inside a virtual machine made visible for pdbtrack

That’s my contribution.

python-mode provides support for developing with Python in Emacs. One of its most powerful (and often unknown) features is pdbtrack. pdbtrack recognizes when you’re interacting with a Python Debugger (PDB) session within Emacs, and opens the relevant files for you as you step through the program. When you’re digging into something very deep (lots of calls on the stack) or very broad (using lots of supporting libraries), this is invaluable for providing perspective on “where” your program is.

At work we develop using a Vagrant-managed virtual machine. The source checkout is stored “locally” and exported to the virtual machine using NFS. That’s great for development — edit locally, run from within the virtual machine — but broke pdbtrack. When Python reported it was at a certain line of a certain file, it was referring to a file inside the virtual machine. When pdbtrack tried to find that path, it didn’t exist because Emacs was running outside the virtual machine. When I want to use pdbtrack I’m usually pretty confused and in need of perspective, so it’s a pretty important tool for me. So I decided to fix this.

Starting with python-mode 6.0.6, you can customize the py-pdbtrack-filename-mapping variable. This is an alist which maps paths the Python interpreter sees to paths Emacs can see. If pdbtrack can’t find the buffer to open directly, it checks this mapping to see if the file exists in a different location. For example, my configuration has the following customization:

'(py-pdbtrack-filename-mapping (quote
   (("/home/vagrant/eventbritecore/" . "/Volumes/eb_home/work/eventbritecore/"))
 ))

Using Vagrant means we are able to develop on a configuration far closer to production than we would [easily] be able to otherwise. And starting with python-mode 6.0.6, I don’t have to give up pdbtrack to do that.

date:2012-06-07 07:04:03
wordpress_id:2130
layout:post
slug:mapping-file-paths-for-pdbtrack
comments:
category:tools
tags:emacs, pdbtrack, python-mode

Managing my Emacs packages with el-get

Update (20 April 2011): I’ve now tried this on my old MacBook running OS X 10.5. The bootstrap script initially threw an error, which I tracked down to an outdated version of git. Once I upgraded git and installed bzr (used by the python-mode recipe), I started Emacs and was rewarded with a fully functioning installation, complete with the extensions I want.

I’m on vacation for two weeks between jobs, so of course this means it’s time to sharpen the tools (because writing programs to help you write programs is almost always more fun than actually writing programs). I’ve been an Emacs user for many years, and of course I’ve customized my installation with additional modes and extensions. Previously I would check out code that I needed into a vendor directory, and then load it manually in init.el. And this worked fine, but that doesn’t mean I [STRIKEOUT:can’t] won’t spend a chunk of my day making it better.

A friend mentioned el-get to me, and I decided to give it a try. I like the combination of recipes for installing common things, and the fact that your list of packages is very explicit in init.el (so if I need to dig into one of them, I know exactly where to begin). Additionally, since I’ll have a new computer issued for the new job, I also wanted to get things into shape so that I could easily replicate my preferred editing environment. I wound up creating a small bootstrap file to help things along, getelget.el.

getelget.el checks to see if el-get has been previously bootstrapped, and if not, performs the lazy installation procedure. After it makes sure el-get is available, it loads and executes el-get. So if you need to get a new machine up and going with Emacs and any extensions, you can drop in your init.el and getelget.el, and Emacs will take care of the rest.

To use getelget, define your el-get-sources like you normally would in init.el:

(setq el-get-sources
       '(el-get
          python-mode
         ;; etc...
       )  )

Then load getelget (the following assumes you have getelget.el in your user emacs directory along with init.el):

;; getelget -- bootstrap el-get if necessary and load the specified packages
(load-file
   (concat (file-name-as-directory user-emacs-directory) "getelget.el"))

getelget will handle bootstrapping, loading, and executing el-get.

getelget is pretty trivial; you can download it here, and I’ve waived any rights I may hold on the code using the CC0 Public Domain Dedication.

date:2011-04-19 22:17:05
wordpress_id:1944
layout:post
slug:managing-my-emacs-packages-with-el-get
comments:
category:development, tools
tags:el-get, emacs

Remembering with org-mode and Ubiquity

Yesterday evening I published my second set of Ubiquity commands which provide a Ubiquity interface between Firefox and Emacs — specifically org-mode — using org-protocol. Ubiquity is an experimental extension from Mozilla Labs that lets you interact with the browser by giving it short, plain text commands. For example, “share” to post a bookmark to Delicious, or “map” to open a map of the selected address.

Org-Mode is an Emacs mode that can be used to keep track of notes, agendas and task lists. I use it to maintain my task list for various projects and take notes when I’m in a meeting. I really like that while it’s an outline editor at heart, it lets me write lots of text and go back later and figure out what’s actually actionable, as opposed to maintaining separate notes and task lists. org-protocol is included in recent releases and lets you launch an instance of emacsclient with some additional information (i.e., the URL and title of a web page, etc) and take some action on it. One of the built in “protocols” is sending that information to remember mode, which org-mode augments.

The main command is simply remember. Invoking it will send the current URL and document title to org-mode’s Remember buffer. You can optionally type a note or select text in the page to be captured along with the link.

Once you’re in the buffer you can make any changes needed and then simply C-c C-c to save the note, or C-1 C-c C-c to interactively file the note someplace else. I’m using this command to quickly store links with some notes to project files. I hope this will be particularly useful when I run across something for a project I’m not actually able to spend time on at the moment.

Note that before using the commands you need to configure Firefox to understand org-protocol:// links, and need to configure a remember template. The template I use looks like:

(?w "* %?\n\n  Source: %u, %c\n\n  %i" nil "Notes")

This store the information in the Notes section of my org-default-notes-file and positions the cursor ready to type a heading.

To install, visit the command page and click “Subscribe”in the upper right hand corner when prompted (this assumes you have Ubiquity already installed). You can find the Javascript source on gitorious; I’ll be adding my RDFa commands to that repository as well.

date:2009-10-07 12:52:04
wordpress_id:1186
layout:post
slug:remembering-with-org-mode-and-ubiquity
comments:
category:development, geek
tags:emacs, firefox, mozilla, orgmode, ubiquity