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

PDF viewer on mac #1

Open
joonhap opened this issue Jun 29, 2023 · 3 comments
Open

PDF viewer on mac #1

joonhap opened this issue Jun 29, 2023 · 3 comments

Comments

@joonhap
Copy link

joonhap commented Jun 29, 2023

Hello! Thank you for developing this package. I have downloaded it and it works very nicely!

I just want to suggest one small feature-- on Mac (i.e., system-type darwin), the command open runs the system's default application, so it runs the default PDF viewer for .pdf files. I tested this by adding to rnw2pdf.el, defvar rnw2pdf-viewer the line ((eq system-type 'darwin) "open")) and things seem to work nicely. Perhaps this could help other Mac users. Thanks for your consideration!

@AntonioFasano
Copy link
Owner

Thank you for your suggestions. I don't have a macOS system, therefore I was unable to add platform specific code. Now, your approach is similar to what I use for Linux systems, where the user is supposed to figure out how to solve their problems. For macOS, I think it would be better to have a get-the-job-done approach, and give also one (or more) default app, like I do for Windows. Let me explain better.

If the default macOS viewer does not support SyncTeX, when you run the build a second time, nothing is updated, and you think the package is broken. Even worse, some viewers block the file when open, so that the old PDF cannot be rewritten with a fresh one from rnw2pdf, unless you close the viewer.

Now for the solution.
I am told Skim is a popular free viewer which supports SyncTeX. If you have or can install it,
you could then execute in Emacs:

(executable-find "/path/to/Skim")

Where /path/to/Skim could be something like /Applications/Skim.app/Contents/MacOS/Skim, but may be that Skim only works.
If the Skim executable is found, the function above returns its full path (otherwise one gets nil)

If Skim is found, then

(defvar rnw2pdf-viewer (executable-find "/path/to/Skim"))

sets it as the rnw2pdf viewer.

Of course, you can do this test with any other popular macOS viewer. If your tests are successfu, l would be happy to update the package.

@joonhap
Copy link
Author

joonhap commented Aug 18, 2023

Thanks for your reply. I have been using Skim for the same reason you mentioned (i.e., refreshing when updated).
I have tested (executable-find "/Applications/Skim.app/Contents/MacOS/Skim") and it works, but it reopens a new window each time the document is compiled. Just using "Skim" instead of "/path/to/Skim" didn't work at all for me.
Using "open" while the default pdf viewer is set to Skim worked well, and the compiled pdf was refreshed without opening a new window. The downside of this approach is that the user has to have "Skim" set as the default app for pdf.

@AntonioFasano
Copy link
Owner

It seems that you can open a PDF with Skim, even if it is not the default viewer, with open -a Skim.app file.pdf. Other sources say open -a Skim file.pdf, I have no way to test.
Kindly set the viewer variable with:

(setq rnw2pdf-viewer "open -a Skim.app")

That is supposed to open the PDF in the way you like. If rnw2pdfdoes not start Skim, try to evaluate again the line above, removing .app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants