gauteh / vim-evince-synctex

Forward and backward search (synctex) between gvim and Evince
8 stars 14 forks source link

Correctly quote files with spaces and always find bash #1

Closed FrnchFrgg closed 6 years ago

FrnchFrgg commented 6 years ago

This pull request fixes the Tex_ViewLatex() function. Search from evince to GVim works, \ls doesn't yet but I have to find out why (probably a problem of paths in the synctex file because of some missing readlink -f somewhere to ensure the path is always the same: beware that full paths are stored in the synctex file, at least on my system)

gauteh commented 6 years ago

Thanks, this looks good to me. I usually use tee or just redirect the command output to some log file using > 2>&1 when trying to figure out why a command doesn't work. Using "" as you just did doesn't work?

FrnchFrgg commented 6 years ago

I tried to debug it a bit, then bit the bullet and wrote https://gitlab.com/frnchfrgg-latex/evince-synctex Pure Python in Vimscript, ≤50 LOC, bi-dir works. What motivated me to rewrite it is that AFAICT your solution cannot handle several TeX files open at the same time (you check for an existing "evince_backward_search" process). Maybe I misread.

gauteh commented 6 years ago

FrnchFrgg writes on mai 8, 2018 21:58:

I tried to debug it a bit, then bit the bullet and wrote https://gitlab.com/frnchfrgg-latex/evince-synctex Pure Python in Vimscript, ≤50 LOC, bi-dir works. What motivated me to rewrite it is that AFAICT your solution cannot handle several TeX files open at the same time (you check for an existing "evince_backward_search" process). Maybe I misread.

Nice, that looks like a cleaner solution. What I put up was based on various previous work - and probably two different versions of the same program.. Is your plugin ready and working?

gauteh commented 6 years ago

FrnchFrgg writes on mai 8, 2018 21:58:

I tried to debug it a bit, then bit the bullet and wrote https://gitlab.com/frnchfrgg-latex/evince-synctex Pure Python in Vimscript, ≤50 LOC, bi-dir works. What motivated me to rewrite it is that AFAICT your solution cannot handle several TeX files open at the same time (you check for an existing "evince_backward_search" process). Maybe I misread.

It can actually, though it is not pretty; it also filters on the vim servername. So you can have several TeX files, but in different GVIM instances - not very intuitive.

FrnchFrgg commented 6 years ago

Yes, my plugin works. I chose to only listen to sync requests sent by Evince for the current window (of each Vim instance), but changing that to loop over the windows is easy to do. I don't see the point (if you are not displaying it, why changing ?) A possibility would be to actually switch to the buffer containing the file, if opened (so that if you have a master file and files for each section it jumps towards it). Actually it is sensible to do that, but the semantics would have to be gotten right (I hate LatexSuite when it jumps to a sty file because of some compilation error).

gauteh commented 6 years ago

Nice, will try out - I swapped to https://github.com/lervag/vimtex - seems to work better with multi-file projects. I would prefer not to auto-jump between files, so that multi-file projects behave the same way as long single-file projects. If auto-jumping, why not auto-jump in a large single-file projects. Seems easy enough for the user to set up a timer or something that makes the PDF follow the cursor if that is desired.

FrnchFrgg commented 6 years ago

I was thinking about the reverse: if you CTRL-click on the PDF, what should happen ? Only jump to the correct place in the corresponding source file, if currently displayed ? Jump in the background, so that the position is where you clicked when you manually switch to the window? Or show/focus that file in addition to setting the cursor position ? I think I would never open the file if not already opened, because I don't want Evince to mess with my windows, but if I have several TeX files open in a single vim instance, perhaps I'd like the plugin to switch to the given TeX file...

gauteh commented 6 years ago

FrnchFrgg writes on mai 8, 2018 23:57:

I was thinking about the reverse: if you CTRL-click on the PDF, what should happen ? Only jump to the correct place in the corresponding source file, if currently displayed ? Jump in the background, so that the position is where you clicked when you manually switch to the window? Or show/focus that file in addition to setting the cursor position ? I think I would never open the file if not already opened, because I don't want Evince to mess with my windows, but if I have several TeX files open in a single vim instance, perhaps I'd like the plugin to switch to the given TeX file...

Oh right, of course.

Some file of a multi-file project must already be open, and the PDF has been opened in evince from that. Otherwise evince would not know which VIM server to address.

I think it is most logical to always open/swap to/show the buffer and seek to line in the same window that the previous files are already open. Ctrl+Click doesn't happen by accident, and I always want to get to the document position in VIM even though it might open things in a different order/window/tab than what I would have done manually. I understand different priorities, but for me this puts the writing in focus - and if I see something in a document that I need to tweak I don't want to have to do anything else than Ctrl+Click so I don't forget what I was supposed to do in the first place. Perhaps this behavior is something that should be configurable.

I don't remember what LatexSuite can do, but vimtex has some built in support for forward/backward search. This might be integrated more directly with that. I could take a look at that once things stabilize if you don't want to do it yourself.

FrnchFrgg commented 6 years ago

I updated https://gitlab.com/frnchfrgg-latex/evince-synctex so that it switches by default to the buffer responsible for the PDF content CTRL-clicked on before moving the cursor, by splitting the window (or not depending on switchbuf). It can be customized by setting g:EvinceSync_showbuf. Tell me if that suits you. If you have ideas about integration with vimtex (essentially to get the correct PDF filename for forward sync), I accept merge requests.