Re: [Geany-devel] HTML/XML autoindentation - Re: [PATCH] Some editor/snippets/keybindings enhancements
On Wed, 10 Nov 2010 22:44:43 +0300 Eugene Arshinov earshi...@gmail.com wrote: I changed the code slightly to check whether the document uses the HTML/XML lexer rather than those filetypes, and to always read the property. This should allow other filetypes that have XML syntax to work also if the property is set. Agree. Thanks for update and commit. BTW, should we set xml_indent_tags=true for PHP, Docbook filetypes? I think, yes, we should. I attach a patch that have this changes plus some documentation in geany.txt (if you use this patch, please regenerate geany.html yourself as my rst2html causes most of this file to be changed). Thanks, applied. Nick ___ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
Re: [Geany-devel] HTML/XML autoindentation - Re: [PATCH] Some editor/snippets/keybindings enhancements
On Tue, 2 Nov 2010 23:28:43 +0300 Eugene Arshinov earshi...@gmail.com wrote: I think just add a html_tag_autoindentation field to GeanyFiletypePrivate and use that. Okay, the patch is attached. Thanks, applied (with some changes). I named the field 'xml_indent_tags' and the filetype property 'indent_tags'. By default (like all fields in GeanyFiletypePrivate) it is zero, but in global filetypes.{xml,html} I set it to true. I changed the filetype property to xml_indent_tags also, I think it's clearer. I changed the code slightly to check whether the document uses the HTML/XML lexer rather than those filetypes, and to always read the property. This should allow other filetypes that have XML syntax to work also if the property is set. BTW, should we set xml_indent_tags=true for PHP, Docbook filetypes? Nick ___ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
Re: [Geany-devel] HTML/XML autoindentation - Re: [PATCH] Some editor/snippets/keybindings enhancements
On Wed, 10 Nov 2010 17:51:18 +% Nick Treleaven nick.trelea...@btinternet.com wrote: On Tue, 2 Nov 2010 23:28:43 +0300 Eugene Arshinov earshi...@gmail.com wrote: I think just add a html_tag_autoindentation field to GeanyFiletypePrivate and use that. Okay, the patch is attached. Thanks, applied (with some changes). I named the field 'xml_indent_tags' and the filetype property 'indent_tags'. By default (like all fields in GeanyFiletypePrivate) it is zero, but in global filetypes.{xml,html} I set it to true. I changed the filetype property to xml_indent_tags also, I think it's clearer. I changed the code slightly to check whether the document uses the HTML/XML lexer rather than those filetypes, and to always read the property. This should allow other filetypes that have XML syntax to work also if the property is set. Agree. Thanks for update and commit. BTW, should we set xml_indent_tags=true for PHP, Docbook filetypes? I think, yes, we should. I attach a patch that have this changes plus some documentation in geany.txt (if you use this patch, please regenerate geany.html yourself as my rst2html causes most of this file to be changed). Best regards, Eugene.diff --git a/data/filetypes.docbook b/data/filetypes.docbook index 26a7e11..8d16287 100644 --- a/data/filetypes.docbook +++ b/data/filetypes.docbook @@ -61,3 +61,7 @@ comment_use_indent=true # context action command (please see Geany's main documentation for details) context_action_cmd= + +# if this setting is set to true, a new line after a line ending with an +# unclosed tag will be automatically indented +indent_tags=true \ No newline at end of file diff --git a/data/filetypes.html b/data/filetypes.html index e18ce75..f4cd2f6 100644 --- a/data/filetypes.html +++ b/data/filetypes.html @@ -32,7 +32,7 @@ comment_use_indent=true # context action command (please see Geany's main documentation for details) context_action_cmd= -# If this setting is set to true, a new line after a line ending with an +# if this setting is set to true, a new line after a line ending with an # unclosed tag will be automatically indented xml_indent_tags=true diff --git a/data/filetypes.php b/data/filetypes.php index 4d63874..ef80136 100644 --- a/data/filetypes.php +++ b/data/filetypes.php @@ -28,6 +28,10 @@ comment_use_indent=true # context action command (please see Geany's main documentation for details) context_action_cmd= +# if this setting is set to true, a new line after a line ending with an +# unclosed tag will be automatically indented +indent_tags=true + [build_settings] # %f will be replaced by the complete filename # %e will be replaced by the filename without extension diff --git a/data/filetypes.xml b/data/filetypes.xml index e067e3d..62dde6e 100644 --- a/data/filetypes.xml +++ b/data/filetypes.xml @@ -103,6 +103,6 @@ comment_use_indent=true # context action command (please see Geany's main documentation for details) context_action_cmd= -# If this setting is set to true, a new line after a line ending with an +# if this setting is set to true, a new line after a line ending with an # unclosed tag will be automatically indented -xml_indent_tags=true \ No newline at end of file +xml_indent_tags=true diff --git a/doc/geany.txt b/doc/geany.txt index 6896419..8609583 100644 --- a/doc/geany.txt +++ b/doc/geany.txt @@ -3731,6 +3731,12 @@ symbol_list_sort_mode 1 Sort tags by appearance (line number) = = +xml_indent_tags +If this setting is set to true, a new line after a line ending with an +unclosed XML/HTML tag will be automatically indented. This only applies +to filetypes for which HTML or XML lexer is used. Such filetypes have +this setting in their system configuration files. + [build_settings] Section ___ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
Re: [Geany-devel] HTML/XML autoindentation - Re: [PATCH] Some editor/snippets/keybindings enhancements
On Tue, 2 Nov 2010 15:13:12 +% Nick Treleaven nick.trelea...@btinternet.com wrote: On Fri, 29 Oct 2010 21:56:53 +0400 Eugene Arshinov earshi...@gmail.com wrote: I wasn't thinking of brace autoindentation. In that case perhaps it's simpler to add a HTML-specific setting to disable tag autoindentation. It makes sense, but since now I could not find an acceptable way to implement it. I've just discovered that GeanyFiletype's are stored in a pointer array, so instead of ordinary GeanyFiletype for HTML we may add to the array an instance of hypothetical HtmlFiletype { GeanyFiletype parent; gboolean enable_tag_autoindentation } and of course write some code to load enable_tag_autoindentation from filetype config. Is it OK? I think just add a html_tag_autoindentation field to GeanyFiletypePrivate and use that. Okay, the patch is attached. I named the field 'xml_indent_tags' and the filetype property 'indent_tags'. By default (like all fields in GeanyFiletypePrivate) it is zero, but in global filetypes.{xml,html} I set it to true. Best regards, Eugene.diff --git a/data/filetypes.html b/data/filetypes.html index 1e63c0c..9dcf5b2 100644 --- a/data/filetypes.html +++ b/data/filetypes.html @@ -32,6 +32,10 @@ comment_use_indent=true # context action command (please see Geany's main documentation for details) context_action_cmd= +# If this setting is set to true, a new line after a line ending with an +# unclosed tag will be automatically indented +indent_tags=true + [build_settings] # %f will be replaced by the complete filename # %e will be replaced by the filename without extension diff --git a/data/filetypes.xml b/data/filetypes.xml index e71c8fc..17113fe 100644 --- a/data/filetypes.xml +++ b/data/filetypes.xml @@ -103,3 +103,6 @@ comment_use_indent=true # context action command (please see Geany's main documentation for details) context_action_cmd= +# If this setting is set to true, a new line after a line ending with an +# unclosed tag will be automatically indented +indent_tags=true \ No newline at end of file diff --git a/src/editor.c b/src/editor.c index 33483ae..4f12952 100644 --- a/src/editor.c +++ b/src/editor.c @@ -55,6 +55,7 @@ #include document.h #include documentprivate.h #include filetypes.h +#include filetypesprivate.h #include sciwrappers.h #include ui_utils.h #include utils.h @@ -1360,7 +1361,8 @@ static gint get_indent_size_after_line(GeanyEditor *editor, gint line) * should make the XML-related check */ if (additional_indent == 0 !editor_prefs.auto_close_xml_tags (editor-document-file_type-id == GEANY_FILETYPES_HTML || - editor-document-file_type-id == GEANY_FILETYPES_XML)) + editor-document-file_type-id == GEANY_FILETYPES_XML) + filetypes[editor-document-file_type-id]-priv-xml_indent_tags) { size += iprefs-width * get_xml_indent(sci, line); } diff --git a/src/filetypes.c b/src/filetypes.c index e4d2a5b..b205774 100644 --- a/src/filetypes.c +++ b/src/filetypes.c @@ -1110,6 +1110,20 @@ static void load_settings(gint ft_id, GKeyFile *config, GKeyFile *configh) /* read build settings */ build_load_menu(config, GEANY_BCS_FT, (gpointer)ft); build_load_menu(configh, GEANY_BCS_HOME_FT, (gpointer)ft); + + if (ft_id == GEANY_FILETYPES_XML || ft_id == GEANY_FILETYPES_HTML) + { + tmp = g_key_file_get_boolean(configh, settings, indent_tags, error); + if (error) + { + g_error_free(error); + error = NULL; + tmp = g_key_file_get_boolean(config, settings, indent_tags, error); + if (error) g_error_free(error); + else filetypes[ft_id]-priv-xml_indent_tags = tmp; + } + else filetypes[ft_id]-priv-xml_indent_tags = tmp; + } } diff --git a/src/filetypesprivate.h b/src/filetypesprivate.h index 3a36ce9..335b602 100644 --- a/src/filetypesprivate.h +++ b/src/filetypesprivate.h @@ -43,6 +43,8 @@ typedef struct GeanyFiletypePrivate gchar *last_string; /* last one compiled */ gboolean custom; gint symbol_list_sort_mode; + + gboolean xml_indent_tags; /* XML tag autoindentation, for HTML and XML filetypes */ } GeanyFiletypePrivate; ___ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
Re: [Geany-devel] HTML/XML autoindentation - Re: [PATCH] Some editor/snippets/keybindings enhancements
On Thu, 28 Oct 2010 23:27:53 +0400 Eugene Arshinov earshi...@gmail.com wrote: I think we could add a per-filetype indent mode option so it would be easy to disable in case someone wanted to. The user could then set auto-indent to basic for HTML. I assume it's necessary to give users an opportunity to control automatic indentation of tags (HTML) and braces (JS/PHP) independently. I suggest making the new indent_mode option a I wasn't thinking of brace autoindentation. In that case perhaps it's simpler to add a HTML-specific setting to disable tag autoindentation. Nick ___ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
Re: [Geany-devel] HTML/XML autoindentation - Re: [PATCH] Some editor/snippets/keybindings enhancements
On Fri, 29 Oct 2010 15:31:37 +0100% Nick Treleaven nick.trelea...@btinternet.com wrote: On Thu, 28 Oct 2010 23:27:53 +0400 Eugene Arshinov earshi...@gmail.com wrote: I think we could add a per-filetype indent mode option so it would be easy to disable in case someone wanted to. The user could then set auto-indent to basic for HTML. I assume it's necessary to give users an opportunity to control automatic indentation of tags (HTML) and braces (JS/PHP) independently. I suggest making the new indent_mode option a I wasn't thinking of brace autoindentation. In that case perhaps it's simpler to add a HTML-specific setting to disable tag autoindentation. It makes sense, but since now I could not find an acceptable way to implement it. I've just discovered that GeanyFiletype's are stored in a pointer array, so instead of ordinary GeanyFiletype for HTML we may add to the array an instance of hypothetical HtmlFiletype { GeanyFiletype parent; gboolean enable_tag_autoindentation } and of course write some code to load enable_tag_autoindentation from filetype config. Is it OK? Best regards, Eugene. ___ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
Re: [Geany-devel] HTML/XML autoindentation - Re: [PATCH] Some editor/snippets/keybindings enhancements
On Wed, 27 Oct 2010 17:16:59 +0100% Nick Treleaven nick.trelea...@btinternet.com wrote: On Tue, 26 Oct 2010 12:14:25 +0400 Eugene Arshinov earshi...@gmail.com wrote: For the present, I attach an updated patch which doesn't insert indentation after short HTML tags. OK, looks like a good solution. Do I understand correctly that you think we don't need GUI preference? I think we could add a per-filetype indent mode option so it would be easy to disable in case someone wanted to. The user could then set auto-indent to basic for HTML. I assume it's necessary to give users an opportunity to control automatic indentation of tags (HTML) and braces (JS/PHP) independently. I suggest making the new indent_mode option a combination of flags, each of which control what indent feature will be _disabled_. That this, the default for any filetype will be 0 (all features enabled). For filetypes which aren't HTML users will add 1 to disable autoindentation. For HTML they will add 1 to disable JS/PHP autoindentation and 2 to disable tag autoindentation. I inverse the semantics of flags, so that when an indent feature is added it will be turned on by default. Maybe it's better to name this option disable_indent and use strings instead of numbers. For example, disable_indent=braces,tags for HTML would disable autoindentation completely. Any thoughts/suggestions? Best regards, Eugene. ___ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel