After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 748069 - Completion: labels in \ref commands
Completion: labels in \ref commands
Status: RESOLVED OBSOLETE
Product: gnome-latex
Classification: Other
Component: general
unspecified
Other Linux
: Normal enhancement
: unspecified
Assigned To: LaTeXila maintainer(s)
LaTeXila maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2015-04-17 16:43 UTC by Maximilien Richer
Modified: 2018-02-23 16:24 UTC
See Also:
GNOME target: ---
GNOME version: 3.15/3.16


Attachments
git patch (69.80 KB, patch)
2015-04-17 16:43 UTC, Maximilien Richer
needs-work Details | Review

Description Maximilien Richer 2015-04-17 16:43:58 UTC
Created attachment 301864 [details] [review]
git patch

This is an proof of concept for the dynamic completion of the \ref command using labels, for technical review only.

FEATURES
- Parse documents at load and at save, looking for labels.
- When a document is opened, look for other documents inside the same folder, open them in background and parse them.
- When editing a file, the completion provider use only labels parsed from files from the same directory.

KNOW BUG
- When writing after a \ref, the completion provider keep a message saying he can not provide completion  

IMPROVEMENTS
- Don't only parse the same folder in background, but the entire file tree
Comment 1 Sébastien Wilmet 2015-04-19 14:36:34 UTC
Please follow the code conventions from the start, instead of writing a commit at the end that fixes the code. Also, all the conventions are not followed, from a quick glance at the patches.

Conditions are written like this:

if (blah)
{
}
else
{
}

Comments are written like this (note the spaces):

// foo
/* bar */

Not: //blah

Please avoid trailing spaces (at the end of a line). Also, one blank line is enough to separate sections, no need to have several contiguous blank lines.
Comment 2 Sébastien Wilmet 2015-04-19 15:12:28 UTC
The feature should be implemented in several (small) steps. Here is a rough plan:

1. Support the completion of placeholders, with a hard-coded list of labels to complete labels.

2. Have a list of labels for an opened .tex file. The structure in the side panel already has the needed information, but there is a problem: the structure must be updated manually by the user with the refresh button, so the list of labels may be outdated. So it's needed to write a class that extracts labels, and that listen to the insert-text and delete-range GtkTextBuffer signals to keep the list updated. So each Document object would contain a DocumentLabels object. Ideally the structure in the side panel should be automatically updated, and would contain the AST, but it's more difficult. Extracting just labels is easier.

The code for extracting labels should be in common between the structure and DocumentLabels. This needs several commits to do that incrementally.

3. From the completion provider, retrieve the DocumentLabels.

4. Refactor the code related to projects. I think a Project class would be better.

5. In the Project class, be able to retrieve the list of opened files belonging to the project.

6. From the completion provider, retrieve the current project, and from that retrieve the complete list of labels belonging to the project (but only for files already opened in latexila).

7. In the Project class, scan other files to retrieve the labels of .tex files that are not opened in latexila. This probably needs some refactoring commits to accommodate that.

Maybe after doing the first steps you'll see that the next steps are not the best ideas.
Comment 3 Sébastien Wilmet 2015-04-19 15:33:07 UTC
For DocumentLabels, this should be done similarly to:
https://git.gnome.org/browse/gtksourceview/tree/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c

With a GtkTextRegion (private utility class in GtkSourceView).

Maybe it's a bit too difficult. Taking the labels from the structure is much simpler.
Comment 4 Adam Hirst 2017-05-25 10:09:58 UTC
This would be an incredibly useful feature, especially for large documents with not only a large number of sections and figures, but also equations (in some cases, with labels for each line thereof). I'm afraid I can't offer my own assistance for development (predictably enough due to paper and thesis writing), but I most certainly hope that this feature come back into consideration at some point.
Comment 5 Sébastien Wilmet 2018-02-18 11:59:48 UTC
There was a beginning of a solution in bug #722858.
Comment 6 GNOME Infrastructure Team 2018-02-23 16:24:09 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnome-latex/issues/31.