Yup, there is no reason to not use Vim 9 for bundled scripts since we don't
have backwards compatibility to worry about.

Interesting point about using osascript,. I didn't know that. I tested it
and it does seem to block. I do want to avoid having to ask about
permissions just to print a file (since such permissions could be broad and
the user may not want to give it to begin with), and I found that I could
trick it into a weird state. In particular, if the pdf file doesn't exist
for some reason or is corrupted (I just typed "asdf" into a blank file),
you can trick Preview to pop up a dialog box (in the background) saying
that it can't open the file but *not *show the app icon in the Dock,
meaning the user has no way of finding it. The precise steps is a little
convoluted (you need to close Preview first) and to be fair we shouldn't
generate corrupt PDF files, and this actually seems more like a macOS bug
per se, but in this case the blocking behavior can actually become a
liability. I think I will stick with the timer trick for now but good to
know that osascript can block on this for future reference.

On Fri, Jun 30, 2023 at 9:58 AM Lifepillar <[email protected]> wrote:

> On 2023-06-30, Lifepillar <[email protected]> wrote:
> > On 2023-06-30, Yee Cheng Chin <[email protected]> wrote:
> > The fix was in https://github.com/macvim-dev/macvim/pull/1390
>
> To delete the PDF file synchronously after it has been opened in
> Preview, AppleScript can be used:
>
>     system($"osascript -e 'tell app \"Preview\" to open POSIX file
> \"{v:fname_in}.pdf\"'")
>     delete($"{v:fname_in}.pdf")
>
> osascript should return only after the document has been opened. Running
> that will probably ask once for permissions to access files.
>
> Life.
>
> --
> --
> You received this message from the "vim_mac" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups
> "vim_mac" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vim_mac/u7n1ih%2473c%241%40ciao.gmane.io
> .
>

-- 
-- 
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_mac/CAHTeOx_OArPBUZyiyyjXbxwvBrY3ABxebOsaChmogHT4ha0MKA%40mail.gmail.com.

Reply via email to