Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printing problem with Custom Version 9.0.472 (174) on MacOS Ventura 13.0.1 #1347

Closed
1 of 7 tasks
MichaelHendry opened this issue Nov 28, 2022 · 15 comments · Fixed by #1390
Closed
1 of 7 tasks

Printing problem with Custom Version 9.0.472 (174) on MacOS Ventura 13.0.1 #1347

MichaelHendry opened this issue Nov 28, 2022 · 15 comments · Fixed by #1390

Comments

@MichaelHendry
Copy link

Steps to reproduce

Open a text file in MacVim
Print the file (using command-P or File->Print)

MacVim reports "Print job sent" and opens the Preview App, but the file is not opened in Preview. Clicking on the Preview icon in the Dock brings up an open file window.

Expected behaviour

Up until the most recent Ventura update, the file would be opened in Preview. and could be printed with Command-P.

I suspect this may be the result of a tightening of security features in Mac OS, which may be preventing the creation of an intermediate file, or preventing its being opened by Preview.

Version of Vim and architecture

Version 9.0.472 (174)

Environment

MacOS Ventura 13.0.1 Intel Processor on iMac Retina 5K 27 Inch 2020

How MacVim was installed

MacVim updated via MacVim->Check for updates

Logs and stack traces

No response

Vim configuration where issue is reproducable

No response

Issue has been tested with given configuration

  • by running MacVim.app from GUI macOS interface
  • by running vim/gvim/etc installed by MacVim
  • by running other versions of vim (e.g. /usr/bin/vim)

Issue has been tested with no configuration

  • by running mvim --clean (or gvim, supplied by MacVim distribution)
  • by running vim --clean (in terminal, supplied by MacVim distribution)
  • by running vim --clean (in terminal, other suppliers, e.g. /usr/bin/vim)

Other conditions

  • The both Homebrew packages "vim" and "macvim" are installed
@ychin
Copy link
Member

ychin commented Nov 29, 2022

I can reproduce. Looking into it. Meanwhile you can manually use the :hardcopy Vim command to work around it.

@ychin ychin added this to the Release 175 milestone Nov 29, 2022
@MichaelHendry
Copy link
Author

Thanks, ychin.

I'll stop the (now proved futile) sequence of uninstallation, re-installation, rebooting etc!

I'd tried the :hardcopy command, but got the same result as Cmd-P.

Michael

@ychin
Copy link
Member

ychin commented Nov 30, 2022

For hardcopy you should be able to save it out to a dedicated file (or you can just modify printexpr). Then you can manually open that in Preview.

@MichaelHendry
Copy link
Author

The problem seems to be that Preview no longer opens .ps files - they're ghosted when I try a File-Open in Preview.

I've worked around the problem using the following:

:hardcopy > 0.ps | !ps2pdf 0.ps && open -a preview 0.pdf

0.pdf is then opened in Preview and can be printed in the usual way.

@MichaelHendry
Copy link
Author

PS It turns out that the above only works for vim, run from the command line, and saves 0.ps etc in the current working directory, before opening the .PDF in Preview. I don't know what directory MacVim sends its output to.

@MichaelHendry
Copy link
Author

Preview on Ventura no longer supports .PS files, see:

https://support.apple.com/en-us/HT213250

"...The Preview app included with your Mac supports PostScript (.ps) and Encapsulated PostScript (.eps) files in macOS Monterey or earlier. Starting with macOS Ventura, Preview no longer supports these files. Other apps that can view or convert .ps and .eps files are available from the App Store and elsewhere..."

@ychin
Copy link
Member

ychin commented Dec 1, 2022

Oh crap yeah you are right, now I vaguely remember reading about the drop of PostScript support and was thinking "who still uses PostScript" lol. Famous last words…

I guess we could either bundle ps2pdf or find another alternative. I will need to think about it a little.

@ychin ychin modified the milestones: Release 175, Release 176 Feb 3, 2023
ychin added a commit that referenced this issue Feb 7, 2023
Updated to Vim 9.0.1276

Features
====================

Dictionary lookup
--------------------

You can now use Force Touch or Cmd-Ctrl-D to look up definitions of word
under the cursor (or selected text in visual mode). This will also
preview URLs, and support data types such as phone numbers and
addresses. #1312 #1313

This feature can also be invoked programmatically from VimScript (see
`:h macvim-lookup`). #1315

Tool bar / Touch Bar / menu icons
--------------------

You can now use SF Symbols for Tool bar and Touch Bar icons, including
using different symbol styles such as "palette" or "multicolor". Menu
items can now also use the `icon=` syntax to specify icons as well. See
`:help macvim-toolbar-icon` for details. #1329

The default tool bar also has updated icons to look similar to SF
Symbols used by newer macOS versions. #1214 by @sfsam

Window management actions
--------------------

There are new `macaction`'s for managing the MacVim window. The new
`zoomLeft`/`zoomRight` actions allow you to pin the window to the
left/right of the screen, and there are also new actions for interacting
with Stage Manager (requires macOS 13+). See `:h macvim-actions` for
details. #1330

Pre-release updates / Sparkle 2
--------------------

MacVim now supports pre-release software builds. It's sometimes hard for
us to release frequent updates due to the desire to pick a stable
upstream Vim version, needing to test the release on multiple OS
versions, making sure there aren't half-complete or buggy features, and
other reasons.

This new feature now allows us to push pre-release beta builds out in a
more frequent fashion, which could be useful if there are particular
features or fixes that you would like to try out before the next
official release. Pre-release builds will be released depending on bug
fixes and features instead of a fixed cadence. Do note that these
pre-release builds may not be as well-validated and may have half-baked
features.

If you are using the built-in auto-updater to update MacVim, you can
turn this on by going to Advanced settings pane, and enable "Enable
pre-release software updates".

This feature is only available for macOS 10.13 or above.

The auto-updater has also been updated from Sparkle 1.27.1 to 2.3.0 for
10.13+ builds. Legacy (10.9-10.12) builds are still using Sparkle 1.

See #1332.

New Vim features
--------------------

New `smoothscroll` option allows you to scroll through a long wrapped
line (using Ctrl-E or mouse wheel) without immediately jumping to the
next line. (v9.0.0640)

`splitscroll` option has been renamed `splitkeep`, with more flexibility
than before. (v9.0.0647)

Sound playback on macOS is now supported. You can use `has('sound')` to
check. See `help sound` for details. (v9.0.0694)

Terminals now support `:confirm` for `:q`, etc, which also means
MacVim's Cmd-W will work properly for terminal windows. (v9.0.0710)

Virtual text had numerous bugs fixed.

General
====================

Legacy build for 10.9 - 10.12
--------------------

Per a previous announcement (#1271), the default MacVim binary will now
require macOS 10.13 or above. Users of macOS 10.9 - 10.12 can use a
separate "legacy" build which will still be supported. The legacy binary
will still have the latest versions of Vim and be supported, but may not
have all the latest features (e.g. pre-release builds).

If you are using the auto-updater (Sparkle) to update MacVim, it should
"just work" and find the best version for you. If you are downloading
MacVim from the website, there is also a link to download the legacy
version marked for 10.9+ as well. If you download the normal binary
marked for 10.13+ from the website, it won't work on these older macOS
versions.

See #1331.

Fixes
====================

CoreText Renderer clipping and rendering bugs
--------------------

Unicode characters with multiple composing characters (e.g. "x⃗") will
now render correctly. #1172

Texts (e.g. Tibetan, Zalgo texts) that are taller than the line height
will no longer be clipped inappropriately. You can use a new setting
`MMRendererClipToRow` to re-enable clipping if the tall texts are
distracting. #995 / #1356

Tab crash
--------------------

Fixed a crash when opening new tabs that seems to only occur in macOS 13
Ventura. #1333

Other bugs
--------------------

- Fixed non-native full screen not working well with the notch on newer
  MacBook's when set to not show menu bar. You can also use
  `MMNonNativeFullScreenSafeAreaBehavior` to force MacVim to use the
  notch area as well if you don't mind some content being obscured. Note
  that the previous release also claimed it fixed this, but because the
  binary was built against an old macOS SDK (Big Sur), the fix did not
  work in the binary release. #1261
- Allow "Open untitled window: never" and "After last window closes:
  Quit MacVim" to be set together again. Added safeguards to make sure
  doing so won't immediately close the app. #1338
- Edit.Cut / Copy menu items will now be properly disabled when there
  isn't selected text. #1308
- Fixed potential `:emenu` crash when the menu is associated with an
  action in a non-valid mode. #1305
- Fixed bug where just bringing up the right-click (or the
  MacVim→Services) menu would somehow copy the selected texts to the
  system clipboard. #1300
- Fixed a Japanese input method bug where using left/right arrow to move
  to a different section of the input text would previously result in
  the candidate list not showing up at the correct position. #1312
- Fix non-CoreText renderer not handling text styles like strikethrough
  correctly (note: this renderer has been deprecated for a while and you
  should not use it). #1296
- This release uses an older sh/bash syntax file because the latest one
  in Vim has a bug. #1358

Misc
====================

New settings:

- "No drop shadows" (Appearance). #1301
- "Treat Ctrl-click as right-click" (Input) (#1326). This was previously
  configurable via command-line, but now also possible in the settings
  pane under the new "Input" category.

"About MacVim" now reports the version number in a clearer way with
clearly specified release number vs Vim version.

Known Issues
====================

Printing
--------------------

Printing using File→Print or `:hardcopy` is currently not working under
macOS 13 Ventura due to its removal of PostScript support in the Preview
app. This will be fixed in a later release. See the issue for
workarounds. #1347

Scripting
====================

- Scripting languages versions:
    - Perl is now built against 5.30, up from 5.18.
    - Ruby is now built against 3.2, up from 3.1.

Compatibility
====================

Requires macOS 10.9 or above. (10.9 - 10.12 requires downloading a
separate legacy build)

Script interfaces have compatibility with these versions:

- Lua 5.4
- Perl 5.30
- Python2 2.7
- Python3 3.10
- Ruby 3.2
@ychin
Copy link
Member

ychin commented Mar 15, 2023

Btw, @MichaelHendry , I'm wondering if you have tried the :TOhtml command before and see if that solves your issue? It's another way to tackle the issue but it generates an HTML page that you can then print in a browser. I'm just trying to gather how important it is to fix this issue.

Also, if you want a shorter term fix, I believe you can set printexpr to be system(['lpr'] + (empty(&printdevice)?[]:['-P', &printdevice]) + [v:fname_in]). delete(v:fname_in)+ v:shell_error. Only issue with using lpr is that it directly sends the doc to the printer, without a way to preview it which is kind of sucky.

ychin added a commit to ychin/macvim that referenced this issue Mar 15, 2023
MacVim's :hardcopy implementation just uses Preview to show the
generated PostScript file and lets the user decide what to do with it.
macOS 13 Ventura removed PostScript support from Preview, so we now have
to manually convert it to PDF first using `pstopdf` (which is thankfully
bundled with macOS).

Fix macvim-dev#1347
ychin added a commit to ychin/macvim that referenced this issue Mar 15, 2023
MacVim's :hardcopy implementation just uses Preview to show the
generated PostScript file and lets the user decide what to do with it.
macOS 13 Ventura removed PostScript support from Preview, so we now have
to manually convert it to PDF first using `pstopdf` (which is thankfully
bundled with macOS).

While we are at it, update the script so that we actually delete the
file after sending it to Preview. Previously MacVim never did that and
therefore leaks the file in a temp folder until Vim closes, which isn't
ideal for privacy. Now, just set a 10 sec timer to delete the file
afterwards (we just need some time to allow Preview to open and load the
file, which doesn't take much time. The 10 sec timer is to account for
slow computers).

Fix macvim-dev#1347
ychin added a commit to ychin/macvim that referenced this issue Mar 15, 2023
MacVim's `:hardcopy` implementation just uses Preview to show the
generated PostScript file and lets the user decide what to do with it.
macOS 13 Ventura removed PostScript support from Preview, so we now have
to manually convert it to PDF first using `pstopdf` (which is thankfully
bundled with macOS).

While we are at it, update the script so that we actually delete the
file after sending it to Preview. Previously MacVim never did that and
therefore leaks the file in a temp folder until Vim closes, which isn't
ideal for privacy. Now, just set a 10 sec timer to delete the file
afterwards (we just need some time to allow Preview to open and load the
file, which doesn't take much time. The 10 sec timer is to account for
slow computers).

Fix macvim-dev#1347
ychin added a commit to ychin/macvim that referenced this issue Mar 15, 2023
MacVim's `:hardcopy` implementation just uses Preview to show the
generated PostScript file and lets the user decide what to do with it.
macOS 13 Ventura removed PostScript support from Preview, so we now have
to manually convert it to PDF first using `pstopdf` (which is thankfully
bundled with macOS).

While we are at it, update the script so that we actually delete the
file after sending it to Preview. Previously MacVim never did that and
therefore leaks the file in a temp folder until Vim closes, which isn't
ideal for privacy. Now, just set a 10 sec timer to delete the file after
it's opened (we just need enough time to allow Preview to open and load
the file, which doesn't take much time. The 10 sec timer is to account
for slow computers).

Fix macvim-dev#1347
ychin added a commit to ychin/macvim that referenced this issue Mar 17, 2023
MacVim's `:hardcopy` implementation just uses Preview to show the
generated PostScript file and lets the user decide what to do with it.
macOS 13 Ventura removed PostScript support from Preview, so we now have
to manually convert it to PDF first using `pstopdf` (which is thankfully
bundled with macOS).

While we are at it, update the script so that we actually delete the
file after sending it to Preview. Previously MacVim never did that and
therefore leaks the file in a temp folder until Vim closes, which isn't
ideal for privacy. Now, just set a 10 sec timer to delete the file after
it's opened (we just need enough time to allow Preview to open and load
the file, which doesn't take much time. The 10 sec timer is to account
for slow computers).

Fix macvim-dev#1347
ychin added a commit to ychin/macvim that referenced this issue Mar 18, 2023
MacVim's `:hardcopy` implementation just uses Preview to show the
generated PostScript file and lets the user decide what to do with it.
macOS 13 Ventura removed PostScript support from Preview, so we now have
to manually convert it to PDF first using `pstopdf` (which is thankfully
bundled with macOS).

While we are at it, update the script so that we actually delete the
file after sending it to Preview. Previously MacVim never did that and
therefore leaks the file in a temp folder until Vim closes, which isn't
ideal for privacy. Now, just set a 10 sec timer to delete the file after
it's opened (we just need enough time to allow Preview to open and load
the file, which doesn't take much time. The 10 sec timer is to account
for slow computers).

Fix macvim-dev#1347
ychin added a commit to ychin/macvim that referenced this issue Mar 18, 2023
MacVim's `:hardcopy` implementation just uses Preview to show the
generated PostScript file and lets the user decide what to do with it.
macOS 13 Ventura removed PostScript support from Preview, so we now have
to manually convert it to PDF first using `pstopdf` (which is thankfully
bundled with macOS).

While we are at it, update the script so that we actually delete the
file after sending it to Preview. Previously MacVim never did that and
therefore leaks the file in a temp folder until Vim closes, which isn't
ideal for privacy. Now, just set a 10 sec timer to delete the file after
it's opened (we just need enough time to allow Preview to open and load
the file, which doesn't take much time. The 10 sec timer is to account
for slow computers).

Fix macvim-dev#1347
ychin added a commit to ychin/macvim that referenced this issue Mar 18, 2023
MacVim's `:hardcopy` implementation just uses Preview to show the
generated PostScript file and lets the user decide what to do with it.
macOS 13 Ventura removed PostScript support from Preview, so we now have
to manually convert it to PDF first using `pstopdf` (which is thankfully
bundled with macOS).

While we are at it, update the script so that we actually delete the
file after sending it to Preview. Previously MacVim never did that and
therefore leaks the file in a temp folder until Vim closes, which isn't
ideal for privacy. Now, just set a 10 sec timer to delete the file after
it's opened (we just need enough time to allow Preview to open and load
the file, which doesn't take much time. The 10 sec timer is to account
for slow computers).

Fix macvim-dev#1347
@jubilatious1
Copy link

#1390 (comment)

@jubilatious1
Copy link

hardcopy > 0.ps | !ps2pdf 0.ps && open -a preview 0.pdf

This works in MacOS Ventura 13.3 with MacVim: Vim 9.0.1276 (MacVim r176).

@MichaelHendry

tono pushed a commit to tono/macvim that referenced this issue Apr 8, 2023
MacVim's `:hardcopy` implementation just uses Preview to show the
generated PostScript file and lets the user decide what to do with it.
macOS 13 Ventura removed PostScript support from Preview, so we now have
to manually convert it to PDF first using `pstopdf` (which is thankfully
bundled with macOS).

While we are at it, update the script so that we actually delete the
file after sending it to Preview. Previously MacVim never did that and
therefore leaks the file in a temp folder until Vim closes, which isn't
ideal for privacy. Now, just set a 10 sec timer to delete the file after
it's opened (we just need enough time to allow Preview to open and load
the file, which doesn't take much time. The 10 sec timer is to account
for slow computers).

Fix macvim-dev#1347
@MichaelHendry
Copy link
Author

Now that I've upgraded to Sonoma, I'm having a problem with printing from Adobe Acrobat, which fails to print with the following explanation::

Stopped. Michael Hendry, "Filter" failed. 0 pages, 1 copy

The hardcopy method above works, but I'd prefer not to have to remember these magic spells.

My .gvimrc file now reads as follows:

set tabstop=4
set shiftwidth=4
"se printexpr=system('ps2pdf\ '.v:fname_in.'\ '.v:fname_in.'.pdf\ &&\ open\ '.v:fname_in.'.pdf')\ +\ v:shell_error
se printexpr=system('ps2pdf\ '.v:fname_in.'\ '.v:fname_in.'.pdf\ &&\ open\ -a\ Preview\ '.v:fname_in.'.pdf')\ +\ v:shell_error

Having completed this comment, I realise that the problem probably lies with Acrobat, not MacVim, but it may help another Mac User who has recently upgraded to Sonoma.

which works around the problem by directing the output specifically to Preview instead of the default application for .PDF files.

@ychin
Copy link
Member

ychin commented Nov 2, 2023

Huh, I didn't consider the possibility that someone may have assigned another application to open PDFs by default. Let me play around with Acrobat a little first before I decide how to resolve this. I wonder if the issue is since we delete the PDF after a timeout.

@ychin
Copy link
Member

ychin commented Nov 9, 2023

Actually @MichaelHendry , why do you still have an explicit printexpr set? You know that this was fixed a while ago (r177) in July right? It will automatically use Preview to open it. You should just remove the line that sets printexpr in your vimrc.

@MichaelHendry
Copy link
Author

You're absolutely right - I don't need the printexpr line for MacVim.

I've been grappling with the use of a non-graphical version of vim which is called by "LifeLines" - a curses-based genealogy program which calls an external editor to edit information in its GEDCOM database. I can't use MacVim for this because Mac OS doesn't use the same calling convention for "open file X in application Y".

I can work around this by copying-and-pasting into an opened copy of MacVim.

@ychin
Copy link
Member

ychin commented Dec 8, 2023

Ok, actually… Sonoma broke printing, again, sigh. The fix we did last time used pstopdf which was an Apple bundled tool, but macOS 14 Sonoma has completely removed Postscript support so that tool got nuked as well. Currently investigating options, but maybe I'll just force users to install ps2pdf instead. Printing is a niche enough thing.

ychin added a commit to ychin/macvim that referenced this issue Dec 9, 2023
Fix broken printing in macOS 14. It was broken because the OS stopped
supporting Postscript and removed the `pstopdf` tool. Fix the printexpr
to detect when `pstopdf` doesn't exist and try to use `ps2pdf` instead.
This is a third-party tool and it's not guaranteed to exist. If it
doesn't exist, give an error prompt for the user to suggest installing
Ghostscript first. Settled on this solution as printing is a relatively
niche feature and it's not worth spending too much effort fixing this.

Related:
- macvim-dev#1390 / macvim-dev#1347: macOS 13 Ventura broke printing by removing Preview
  support for PostScript. The fix was to use `pstopdf`, which eventually
  got removed in macOS 14.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants