dicy icon indicating copy to clipboard operation
dicy copied to clipboard

Continous build with temporary output

Open leezu opened this issue 6 years ago • 3 comments

Is there a way to reproduce the following .latexmkrc?

$preview_prefix="__preview__";
$preview_file = "$preview_prefix%R__.pdf";
$sync_file = "$preview_prefix%R__.synctex.gz";

$pdflatex="lualatex -synctex=1 %O %S; cp %R.pdf $preview_file; cp %R.synctex.gz $sync_file";
$pdf_previewer = "start okular %O $preview_file > /dev/null 2>&1";% 

With that .latexmkrc running latexmk -pvc -pdf main.tex will cause continous rebuilds that are copied to $preview_file whenever the build process finishes (preventing glitches in the pdf viewer when reading an unfinished pdf / waiting for the build to finish).

A simple hack with dicy would be: while inotifywait -e close_write main.tex; do dicy build main.tex -o tmp; mv tmp/*pdf . ; done, but I believe latexmk does not only watch for changes in the main.tex file but in all dependent files, meaning that this hack is not completely equivalent.

Thanks for your efforts developing dicy! It looks like a great tool and I would like to use it due to the easy integration with pythontex etc..

leezu avatar Jan 12 '18 04:01 leezu

Thank you for the enhancement request!

DiCy is not currently capable of doing this yet. It seems to me you are talking about two separate issues:

  1. Continuous building in response to changes in source files.
  2. Opening generated targets with DiCy.

The continuous build feature won't really be possible until I rework the way that DiCy detects file changes. I am planning on looking into this when I start working on optimization.

Opening the generated targets from within DiCy certainly is possible, but I am curious how you are intending on using that feature. Right now this feature is usually implemented in the specific editor integration. For example, in Atom one can use atom-latex. Are you expecting DiCy to respond to changes the files as you edit them in an editor? If so what editor do you currently use?

yitzchak avatar Jan 12 '18 12:01 yitzchak

Thanks for your prompt reply!

Indeed this issue can be split up in two separate features. Regarding your second point instead I mean that DiCy should not overwrite the target file with a unfinished version: I am using emacs to edit my latex files and use the Okular PDF viewer for viewing, which automatically refreshes the output if the PDF file gets changed (but will display a blank screen as long as the updated file is not a valid PDF file).

Above workaround runs DiCy whenever the input file gets written to disk, writes the output file to a temporary directory and copies the output file only after the compilation process finished.

leezu avatar Jan 13 '18 08:01 leezu

In reference to the temporary output issue, I think you may be able to accomplish roughly the same result by using the outputDirectory and the copyTargetsToRoot options together. For instance, using TeX magic comments

%!TeX outputDirectory = output
%!TeX copyTargetsToRoot = yes
\documentclass{article}

If you use this arrangement for all of your documents then you could place the following in $HOME/.dicy.yaml

outputDirectory: output
copyTargetsToRoot: true

yitzchak avatar Jan 13 '18 13:01 yitzchak