Interesting. I actually solved the problem myself, or seem to have via a macro, but I wonder why mine is so different from his. For those who are interested, the code follows here:
#include "slick.sh"
// The following macro changes the current working directory to where the current
// buffer's file resides.
_command void cdbuffer() name_info(','VSARG2_READ_ONLY)
{
_str newdir=strip_filename(p_buf_name, 'N');
cd(newdir);
message("Changed directory: " :+ newdir);
}