When using a mapping or abbreviation the context of where it was defined
is not used. That is why you need to use <SID> for a script-local
function. This is different from user commands, where the context is
used.
Your "old way" example most likely works because "misc#" finds the
misc.vim script file in an autoload directory. The "import" line
doesn't matter (I haven't tried this though).
When using "misc.Eatchar()" it cannot find "misc" in the current
context. The script context where the abbreviation was defined is not
used.
I can't think of a good way to make this work. Being able to access
"misc", which is script-local in one specific script, from any other
context, means script-local isn't really "local" any more.
The best I can think of is to add a script-local function and use that:
vim9script
import autoload 'misc.vim'
def Eatchar(arg: string): string
return misc.Eatchar(arg)
enddef
iab <buffer> p! println!()<left><c-r>=<SID>Eatchar('\s')<cr>
Disclaimer: I haven't tried this.
--
MAN: Fetchez la vache!
GUARD: Quoi?
MAN: Fetchez la vache!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///