Programmable completion for two arguments in bash

Hi there!

I have this script which handles bookmarks. Bookmarks are basically a string that point to a certain path, e.g., project -> ~/code/projects/project .

Currently I have working completion for the bookmarks:

~ $ m p<Tab>
~ $ m project

What I want to implement now is the cd command's behavior for the second argument.

~ $ m project c<Tab>
~ $ m project config/en<Tab>
~ $ m project config/environments

That is, I can complete directories, and directories only, as if I was currently in ~/code/projects/project .

The source can be found on GitHub as KevinSjoberg/m. (I'm not allowed to post links yet).

Any input is welcome!