expand-file-name doesn't expand files under my magic prefix

2017-03-20 23:40:09

I've been implementing a magic file handler that accesses files remotely if they start with a particular prefix--say, /:foo:/--using the documentation as a guide.

When it came to implementing expand-file-name, I figured I could just fall through to the default implementation, since my magic prefix looks like a file on the local filesystem. It's one that doesn't exist, but then (expand-file-name "file" "/does/not/exist/") returns "/does/not/exist/file", so I thought I'd be OK. However, (expand-file-name "file" "/:foo:/") just returns "foo".

I assumed this was simply due to me incorretly implementing some other file operation, but when I log every operation passed to my handler, I don't see that expand-file-name invokes any other file operation.

So...why is expand-file-name behaving like this?

Edited to add:

After restarting Emacs, expand-file-name is now working as I expected it to. I'll close this question if the issue doesn't recur.