this

(setq org-link-abbrev-alist
'(("foo" . "file:/path/to/%s.txt")))

allow me to do this

[[foo:file to open]]

but it creates a file with spaces in the name.  so I'd like to replace "%s" with "%(myfun)".

with your example, how can I get "foo bar  loo" from

[[foo:foo bar  loo]]

see what I mean?