jaliste / gedit-synctex-plugin

The gedit-synctex-plugin now lives in the gedit-plugin repository in gnome git (branch gnome-2-32)
6 stars 1 forks source link

Synching from \include’d subfile doesn’t work #2

Closed towolf closed 14 years ago

towolf commented 14 years ago

Complex documents often use a main file that is compiled and subfiles are included with \input or \include that only contain chapters. The purpose often is to make is possible to comment out chapters to make compilation faster.

Without a way to track the main file synching from a subfile doesn’t work.

Not sure what the best way to implement this is. It should be simple.

Perhaps a menu item »☑ SyncTex main file« is appropriate under »Tools«. Dunno.

towolf commented 14 years ago

XML got lost, sorry. Should’ve wrappen it in a pre

jaliste commented 14 years ago

Yeah... there is basic support for backward search with several files, but you need to open the main file. However, forwardsearch is broken for include files. I will try to add support in case the main file is open, but I do want to keep the plugin simple, so not sure I want to add a main file selection. What could work, and I am open to implement is to add a modeline with the main_file, like adding the line %main:main.tex to the first line of a chapter file.

jaliste commented 14 years ago

Tobias, the plugin now lives on gedit-plugins repository of gnome server. So you can file bugs you find in Gnome Bugzilla.

jaliste commented 14 years ago

So I corrected the backward search and implemented the Forward search using a modeline. That is, you need to add the comment % modeline: mainfile.tex to one of the first three lines of the included files so Forward search can work with them. Otherwise, it will be disabled.

towolf commented 14 years ago

Where did you commit that code? In gedit-plugins gnome_2_32 branch on git.gnome.org?

Also is this the intended modeline? Would that be correct?

% modeline: ../Thesis.tex

towolf commented 14 years ago

Perhaps this should be used in GediLatexPlugin too in place of the XML stub.

What about loading both plugins at the same time? Right now Ctrl-Click fires sync in both.

jaliste commented 14 years ago

Tobias, the modeline you describe is correct. I released gedit-plugins 2.31.5 from the gnome_2_32 branch, which contains the fixes I mentioned. All the development of the plugin is moved to gnome servers, so I will delete this repo soon.

I will try to fix issues with gedit-latex plugin later. I still have not decided if make the plugins to cooperate or to implement synctex directly into the gedit-plugin. :)

towolf commented 14 years ago

I think you should change the modeline to something more semantically approriate.

What is included at the top of the file is a modeline, but this particular modeline should have a specifier that mentions what it is for, like key-value pair. I already have other modelines in my files. For example:

% rubber: module xelatex
% vi:set fo=tcroq ft=tex fenc=latin1:

perhaps mainfile: or synctex_mainfile: would be better.

towolf commented 14 years ago

Oh, just read the commit. That was just a typo on your part earlier. It’s alright then.

towolf commented 14 years ago

Ok, more comments regarding modeline.

  1. Putting a relative path like in my question doesn’t work if the current working dir of Gedit is somewhere else. Only absolute paths work for me.
  2. It is common to allow to put modeline also at the end of the file. Even Gedit’s native modeline plugin for Emacs and Vim modelines allows this:
    /\* Parse vi(m) modelines.
    - Vi(m) modelines looks like this:
    -   - first form:   [text]{white}{vi:|vim:|ex:}[white]{options}
    -   - second form:  [text]{white}{vi:|vim:|ex:}[white]se[t] {options}:[text]
    - They can happen on the three first or last lines.
     */
     

Would this patch be ok?:

From: Tobias Wolf 
Date: Fri, 13 Aug 2010 23:52:00 +0200
Subject: [PATCH] Modelines can be placed at the end of the file

---
 plugins/synctex/synctex/synctex.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/plugins/synctex/synctex/synctex.py b/plugins/synctex/synctex/synctex.py
index 08690cf..ced11c3 100644
--- a/plugins/synctex/synctex/synctex.py
+++ b/plugins/synctex/synctex/synctex.py
@@ -101,7 +101,8 @@ class SynctexViewHelper:

     def get_output_file(self):
         file_output = None
-        for i in range(min(3,self._doc.get_line_count())):
+        line_count = self._doc.get_line_count()
+        for i in set(range(min(3,line_count)) + range(line_count)[-3:]):
             start = self._doc.get_iter_at_line(i)
             end = start.copy()
             end.forward_to_line_end()
-- 
1.7.1

towolf commented 14 years ago

Another issue with relative paths

  1. I open Gedit
    • I load Chapters/Methods.tex
    • I ForwarSearch to Evince
    • I BackwarSearch from Evince
    • the plugin tries to load Chapters/Chapters/Methods.tex

The subfile is included with this command in the main file \include{Chapters/Methods}

jaliste commented 14 years ago

The previous issues are fixed by the following patch. http://pastebin.com/yezDApat the latest issue I have not tested it yet.

jaliste commented 14 years ago

The latest issue is corrected by doing the following change to line 172.

Could you test that with the two patches you get the expected behavior? Thanks for testing!

towolf commented 14 years ago

The relative paths work now. Thanks.

But now there is something very odd afoot. I managed to stall gedit at 100% CPU while using BackwardSearches.

Screenshot: http://imgur.com/65c27.png

I have no clue what this is caused by.

jaliste commented 14 years ago

Tobias, I think this is because the plugin search for existing instance only in one window. I am using a dict per window to track the open files, I guess I need to move the dict to the plugin instance. Thanks for testing

jaliste commented 14 years ago

Tobias, I think I fixed all remaining issues (Hopefully), I just released gedit-plugins 2.31.6 with all the fixes. Let me know if you can still reproduce your last issue in this version.

towolf commented 14 years ago

Thanks Jose, it works very nicely now. Make sure you put this prominently in the Gnome 2.32 ReleaseNotes. It’s a mighty fine example of desktop integration in Gnome.

On the topic of integration, the question is whether it should be integrated into the GeditLatexPlugin. I would say no. There will be users who want the one but not the other. Having it separate is a good approach, there just needs to be a minimum of integration, e.g., to enable the »-syntex=1« in the compiler.

I like the GLP overall, it saves time, but I see some issues:

jaliste commented 14 years ago

well, you should raise all these points in bugs in sf for glp. ;) I think I will integrate like this: I will add a preference in the GLP so it knows that you prefer to use external previewer. Then if external previewer is selected, it does not do anything on ctrl click. Thus, you can have both plugins installed and synctex will just work

towolf commented 14 years ago

And when you click a heading in the outline in the sidebar. It keeps popping up ಠ_ಠ