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

Resolves #29 #31

Closed
wants to merge 1 commit into from
Closed

Resolves #29 #31

wants to merge 1 commit into from

Conversation

vqv
Copy link

@vqv vqv commented Mar 28, 2018

This resolves #29 in a minimally intrusive way. Rather than trying to change the output filename using the -jobname argument to the latex engine, this PR modifies the file renaming logic and exit hook.

  1. An existing PDF file will be renamed temporarily.
  2. Upon successful compilation, the new PDF will be copied on top of the existing PDF (with the temporary name) and removed.
  3. The PDF (existing or new) is renamed back.

These steps help external viewers detect changes to the PDF, because they will (hopefully) see that the PDF has been overwritten rather than just moved away.

…cessful compilation, rather than moved away permanently.

Signed-off-by: Vince Vu <vqv@me.com>
Copy link
Member

@yihui yihui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see how this PR could fix the problem. My only concern is that file.copy() may be a little less efficient. Essentially, you changed file.remove(filep2) to these three steps: file.copy(filep, filep2, overwrite = TRUE); file.remove(filep); file.rename(filep2, filep).

There is a chance that I can completely get rid of the whole hack here (which existed only because of an edge case). Let me think more about it. Thanks!

@vqv
Copy link
Author

vqv commented Mar 28, 2018

Yes, this is a hack. The external PDF viewers that I've used on macOS (Preview, PDF Expert, and Skim) all hold on and follow a file pointer through renaming. A different approach is to build in a temporary directory and then copy on success. This also saves the trouble of deciding which files to clean up if there already existing temporary files.

I keep things in Dropbox, so I prefer to run the LaTeX compilation in a temporary folder that's not watched by Dropbox to avoid unnecessary syncing, but that can't be controlled with latexmk_emu().

@yihui yihui closed this in dc83674 Mar 28, 2018
@yihui
Copy link
Member

yihui commented Mar 28, 2018

I just removed my original hack. Please test the development version via

devtools::install_github('yihui/tinytex')

Thanks a lot!

@vqv
Copy link
Author

vqv commented Mar 28, 2018

That seems to fix it. Thanks! Now I've added a different feature request in #32 :-)

This pull request was closed.
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

Successfully merging this pull request may close these issues.

Copy (and overwrite) on successful compilation, instead of renaming existing file
2 participants