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 563986 - wizard generates modeline inconsistent with indentation prefs
wizard generates modeline inconsistent with indentation prefs
Status: RESOLVED FIXED
Product: anjuta
Classification: Applications
Component: plugins: project-wizard
SVN TRUNK
Other All
: Normal minor
: Anjuta 2.32
Assigned To: Sébastien Granjoux
Anjuta maintainers
: 612761 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-12-10 13:51 UTC by Adam Dingle
Modified: 2012-04-22 14:46 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Adam Dingle 2008-12-10 13:51:15 UTC
Please describe the problem:
When the Application Assistant generates a project, it includes the following modeline in C source files:

/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */

This causes the editor to use tabs for indentation with a 4-character indent.  Unfortunately the wizard includes this modeline even if my Anjuta preferences are completely different (e.g. no tabs, 2-character indent).  This is inconvenient and confusing.

We should either make the modeline consistent with current Anjuta preferences, or simply omit the modeline altogether.

Steps to reproduce:
1. 
2. 
3. 


Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Sébastien Granjoux 2008-12-10 20:38:56 UTC
I don't see it as a big problem. The "easy" fix is to remove all modeline from all  templates.

But I would prefer to keep them, so I have to add some new properties in the project wizard to get this tab settings. Not a very difficult task but I prefer to take care of more important bugs. I will try to do it for the next release.

If you want you can write a patch for this. It should work like the project directory, defining a new value in plugins/project-wizard/druid.c:npw_druid_add_default_property. Then update all template having modeline to use these new value. It's possible that you need to add new shell value in editor plugin to export this tab settings.

Comment 2 John 2009-03-25 22:52:03 UTC
I would vote to make modeline take the values previously configured in the editor.
Comment 3 Johannes Schmid 2010-03-13 08:23:35 UTC
*** Bug 612761 has been marked as a duplicate of this bug. ***
Comment 4 Johannes Schmid 2010-03-13 17:05:26 UTC
*** Bug 612761 has been marked as a duplicate of this bug. ***
Comment 5 Johannes Schmid 2010-06-29 08:51:32 UTC
We also should take care that the generated files are indented properly for the modelines set. As this is reported quite often, it is a good candidate for 3.0.
Comment 6 Sébastien Granjoux 2010-06-29 21:09:56 UTC
Do you have a procedure which can be called by the project wizard an indent the whole file according to the modeline ?

Else, I'm afraid it would be difficult to indent the file correctly using autogen macros.
Comment 7 Johannes Schmid 2010-08-03 06:56:22 UTC
Hmm, actually we can only indent files that are open in the editor (and even this would require a new interface but it's trivial).

So, basically two solutions:
* Indent files somehow using our indenting solution, possibly rewriting it to be able to use files directly.

* Use something like [+Indent+] in the wizard files that will add the correct indentation in that place.

The latter is probably kind of easy to do but of course a pain to maintain. I see no other solution here at the moment though.
Comment 8 Sébastien Granjoux 2010-08-03 17:55:55 UTC
(In reply to comment #7)
> So, basically two solutions:
> * Indent files somehow using our indenting solution, possibly rewriting it to
> be able to use files directly.

The wizard is not able to open file in editor to indent them, so I think it needs a new interface allowing to indent files directly. But I'm not sure that reindenting a complete file can be done without any issue.

> * Use something like [+Indent+] in the wizard files that will add the correct
> indentation in that place.

[+Indent+] will be replace by the value of the Indent variable, so we will have to write something like

[+Indent+]if (a)
[+Indent+]{
[+Indent+][+Indent+]a == 0;
[+Indent+]}

it will be quite a pain to use it everywhere. Moreover it cannot handle style differences like open brace on a separate line or not.


> The latter is probably kind of easy to do but of course a pain to maintain. I
> see no other solution here at the moment though.

I think only the first solution is really usable but we need a new interface for this.
Comment 9 Johannes Schmid 2010-10-12 14:32:10 UTC
I though about this a bit. What we might be able to do:

* After finishing the project-wizard opens all the project sources files in the document-manager (not a bad idea in general)

* I calls something like ianjuta_editor_assist_auto_indent() which will automatically indent the file according to it's modeline if there is an appropriate language-support plugin.

Do you think that's doable?
Comment 10 Sébastien Granjoux 2010-10-12 16:55:04 UTC
(In reply to comment #9)
> I though about this a bit. What we might be able to do:
> 
> * After finishing the project-wizard opens all the project sources files in the
> document-manager (not a bad idea in general)
> 
> * I calls something like ianjuta_editor_assist_auto_indent() which will
> automatically indent the file according to it's modeline if there is an
> appropriate language-support plugin.
> 
> Do you think that's doable?

There is a not obvious limitation with the project-wizard. When the project wizard is running, the current project is not the new project as we are just creating it. It means that if the project wizard open a document, it will be in old project so we probably have to close the document else it will be saved in the opened document of the old project.

Moreover, the project wizard open the new project file by running again anjuta with the project file in the command line. It can open additional files by putting them in the command line but as one file is a project file the project wizard itself is deactivate and then (probably) reactivated. It cannot do anything when the new project is loaded. Perhaps we can plan some actions that will be done when a project is loaded but such mechanism doesn't exist at the moment.

It will be easier if the auto indentation is done directly on a file without having to open it in an editor. Or perhaps we can have hidden editors.


Anyway, I don't see any better solution.
Comment 11 Johannes Schmid 2011-01-20 11:23:41 UTC
> Moreover, the project wizard open the new project file by running again anjuta
> with the project file in the command line. It can open additional files by
> putting them in the command line but as one file is a project file the project
> wizard itself is deactivate and then (probably) reactivated. It cannot do
> anything when the new project is loaded. Perhaps we can plan some actions that
> will be done when a project is loaded but such mechanism doesn't exist at the
> moment.

We should encode that information into the project profile xml in some way. The files to open are already encoded in that file when opening a regular anjuta project so we might be able to set an additional xml property like "auto-indent=yes".

This will require to generate an appropriate profile xml-file for each project file of course but I guess that could be automated a lot. And we need to create correct modelines of course, but that's rather simple.
Comment 12 Sébastien Granjoux 2012-04-22 14:46:15 UTC
Using guile, I have been able to indent files using only autogen. You need to use only tabulation to indent your file and there is post processing step where all tabs are replaced by the right indentation.

In fact, the main issue was rather to get the necessary information for the indentation. These informations were spread between the editor and the language support plugin. I have defined some common settings those can be used more easily.

Thanks for your bug report.