Loading syntax rules on demand

Pavel Roskin proski at gnu.org
Tue Jul 17 21:56:45 UTC 2001


Hello!

I've noticed that if the syntax rules are missing (say, you copied the mc
binary only) MC (and GMC) shows a warning even when the syntax
highlighting is disabled.  Loading unused data is not good.

I'm applying a patch that disables loading syntax rules if syntax
highlighting is off.  Also the wedit declaration has been moved to the
right place (edit.h) because it's now needed not only in editmenu.c.

-- 
Regards,
Pavel Roskin

------------------------------------------------------
--- ChangeLog
+++ ChangeLog
@@ -1 +1,10 @@
+2001-07-17  Pavel Roskin  <proski at gnu.org>
+
+	* edit.h [MIDNIGHT]: Declare wedit.
+	* editmenu.c: Remove wedit declaration.
+	* editoptions.c (edit_options_dialog): Load syntax rules if user
+	turned syntax highlighting on.
+	* syntax.c (edit_load_syntax): Don't load rules if syntax
+	highlighting is disabled.
+
 2001-07-13  Pavel Roskin  <proski at gnu.org>
--- edit.h
+++ edit.h
@@ -742,6 +742,7 @@
    or EDIT_KEY_EMULATION_EMACS
  */
 extern int edit_key_emulation;
+extern WEdit *wedit;
 #endif	/* ! MIDNIGHT */

 extern int option_word_wrap_line_length;
--- editmenu.c
+++ editmenu.c
@@ -37,7 +37,6 @@
 #include "../src/mad.h"

 extern int edit_key_emulation;
-extern WEdit *wedit;
 extern WButtonBar *edit_bar;
 extern Dlg_head *edit_dlg;
 extern WMenu *edit_menubar;
--- editoptions.c
+++ editoptions.c
@@ -160,6 +160,8 @@ void edit_options_dialog (void)
 	Quick_options.widgets = quick_widgets;

 	if (quick_dialog (&Quick_options) != B_CANCEL) {
+	    int old_syntax_hl = option_syntax_highlighting;
+
 	    if (p) {
 		option_word_wrap_line_length = atoi (p);
 		free (p);
@@ -193,6 +195,10 @@ void edit_options_dialog (void)
 	    }

 	    edit_key_emulation = *quick_widgets[13 + OA].result;
+
+	    /* Load syntax rules if user turned syntax highlighting on */
+	    if (option_syntax_highlighting && !old_syntax_hl)
+		edit_load_syntax (wedit, 0, 0);

 	    return;
 	} else {
--- syntax.c
+++ syntax.c
@@ -1513,6 +1513,9 @@ void edit_load_syntax (WEdit * edit, cha

     edit_free_syntax_rules (edit);

+    if (!option_syntax_highlighting)
+	return;
+
     if (edit) {
 	if (!edit->filename)
 	    return;
------------------------------------------------------






More information about the mc-devel mailing list