Merge branch '4413_user_syntax'

* 4413_user_syntax:
  Ticket #4413: mcedit: syntax definitions in user location don't work.
This commit is contained in:
Andrew Borodin 2022-12-18 14:20:58 +03:00
commit 2df6771645
6 changed files with 18 additions and 21 deletions

View File

@ -237,12 +237,12 @@ where equal is symbol "=" goes to next function in navigation list
supports syntax highlighting. This means that keywords and contexts
(like C comments, string constants, etc) are highlighted in different
colors. The following section explains the format of the file
.BR ~/.config/mc/mcedit/Syntax .
.BR ~/.local/share/mc/syntax/Syntax .
If this file is missing, system\-wide
.B %pkgdatadir%/syntax/Syntax
is used.
The file
.B ~/.config/mc/mcedit/Syntax
.B ~/.local/share/mc/syntax/Syntax
is rescanned on opening of every new editor file. The file contains
rules for highlighting, each of which is given on a separate line, and
define which keywords will be highlighted with what color.
@ -631,7 +631,9 @@ affect all users, whether they have ~/.config/mc/ini or not.
.I %pkgdatadir%/syntax/*
.IP
The default system\-wide syntax files for mcedit, used only if
the corresponding user's own ~/.local/share/mc/mcedit/ file is missing.
the corresponding user's own file in
.B ~/.local/share/mc/syntax/
is missing.
.PP
.I ~/.config/mc/ini
.IP

View File

@ -72,10 +72,11 @@
/* file names */
#define EDIT_HOME_MACRO_FILE EDIT_HOME_DIR PATH_SEP_STR "macros.d" PATH_SEP_STR "macro"
#define EDIT_HOME_SYNTAX_FILE EDIT_HOME_DIR PATH_SEP_STR "Syntax"
#define EDIT_HOME_CLIP_FILE EDIT_HOME_DIR PATH_SEP_STR "mcedit.clip"
#define EDIT_HOME_BLOCK_FILE EDIT_HOME_DIR PATH_SEP_STR "mcedit.block"
#define EDIT_HOME_TEMP_FILE EDIT_HOME_DIR PATH_SEP_STR "mcedit.temp"
#define EDIT_SYNTAX_DIR "syntax"
#define EDIT_SYNTAX_FILE EDIT_SYNTAX_DIR PATH_SEP_STR "Syntax"
#define EDIT_GLOBAL_MENU "mcedit.menu"
#define EDIT_LOCAL_MENU ".cedit.menu"

View File

@ -64,7 +64,6 @@ static const struct
{ &mc_config_str, MC_HOTLIST_FILE },
{ &mc_config_str, GLOBAL_KEYMAP_FILE },
{ &mc_config_str, MC_USERMENU_FILE },
{ &mc_config_str, EDIT_HOME_SYNTAX_FILE },
{ &mc_config_str, EDIT_HOME_MENU },
{ &mc_config_str, MC_PANELS_FILE },
@ -82,6 +81,7 @@ static const struct
{ &mc_data_str, MC_EXTFS_DIR },
{ &mc_data_str, MC_HISTORY_FILE },
{ &mc_data_str, MC_FILEPOS_FILE },
{ &mc_data_str, EDIT_SYNTAX_FILE },
{ &mc_data_str, EDIT_HOME_CLIP_FILE },
{ &mc_data_str, MC_MACRO_FILE },

View File

@ -1128,19 +1128,19 @@ edit_load_syntax_file (WDialog * h)
_("&User"), _("&System wide"));
extdir_vpath =
vfs_path_build_filename (mc_global.sysconfig_dir, "syntax", "Syntax", (char *) NULL);
vfs_path_build_filename (mc_global.sysconfig_dir, EDIT_SYNTAX_FILE, (char *) NULL);
if (!exist_file (vfs_path_get_last_path_str (extdir_vpath)))
{
vfs_path_free (extdir_vpath, TRUE);
extdir_vpath =
vfs_path_build_filename (mc_global.share_data_dir, "syntax", "Syntax", (char *) NULL);
vfs_path_build_filename (mc_global.share_data_dir, EDIT_SYNTAX_FILE, (char *) NULL);
}
if (dir == 0)
{
vfs_path_t *user_syntax_file_vpath;
user_syntax_file_vpath = mc_config_get_full_vpath (EDIT_HOME_SYNTAX_FILE);
user_syntax_file_vpath = mc_config_get_full_vpath (EDIT_SYNTAX_FILE);
check_for_default (extdir_vpath, user_syntax_file_vpath);
ret = edit_load_file_from_filename (h, user_syntax_file_vpath, 0);
vfs_path_free (user_syntax_file_vpath, TRUE);

View File

@ -57,7 +57,7 @@
#include "lib/global.h"
#include "lib/search.h" /* search engine */
#include "lib/skin.h"
#include "lib/fileloc.h" /* EDIT_HOME_DIR, EDIT_HOME_SYNTAX_FILE */
#include "lib/fileloc.h" /* EDIT_SYNTAX_DIR, EDIT_SYNTAX_FILE */
#include "lib/strutil.h" /* utf string functions */
#include "lib/util.h"
#include "lib/widget.h" /* Listbox, message() */
@ -887,20 +887,14 @@ open_include_file (const char *filename)
g_free (error_file_name);
error_file_name =
g_build_filename (mc_config_get_data_path (), EDIT_HOME_DIR, filename, (char *) NULL);
f = fopen (error_file_name, "r");
if (f != NULL)
return f;
g_free (error_file_name);
error_file_name = g_build_filename (mc_global.sysconfig_dir, "syntax", filename, (char *) NULL);
g_build_filename (mc_config_get_data_path (), EDIT_SYNTAX_DIR, filename, (char *) NULL);
f = fopen (error_file_name, "r");
if (f != NULL)
return f;
g_free (error_file_name);
error_file_name =
g_build_filename (mc_global.share_data_dir, "syntax", filename, (char *) NULL);
g_build_filename (mc_global.share_data_dir, EDIT_SYNTAX_DIR, filename, (char *) NULL);
return fopen (error_file_name, "r");
}
@ -1270,7 +1264,7 @@ edit_read_syntax_file (WEdit * edit, GPtrArray * pnames, const char *syntax_file
f = fopen (syntax_file, "r");
if (f == NULL)
{
lib_file = g_build_filename (mc_global.share_data_dir, "syntax", "Syntax", (char *) NULL);
lib_file = g_build_filename (mc_global.share_data_dir, EDIT_SYNTAX_FILE, (char *) NULL);
f = fopen (lib_file, "r");
g_free (lib_file);
if (f == NULL)
@ -1521,7 +1515,7 @@ edit_load_syntax (WEdit * edit, GPtrArray * pnames, const char *type)
if (edit != NULL && edit->filename_vpath == NULL)
return;
f = mc_config_get_full_path (EDIT_HOME_SYNTAX_FILE);
f = mc_config_get_full_path (EDIT_SYNTAX_FILE);
if (edit != NULL)
r = edit_read_syntax_file (edit, pnames, f, vfs_path_as_str (edit->filename_vpath),
get_first_editor_line (edit),

View File

@ -97,8 +97,8 @@ static const struct test_user_config_paths_ds
MC_USERMENU_FILE
},
{ /* 5. */
CONF_MAIN,
EDIT_HOME_SYNTAX_FILE
CONF_DATA,
EDIT_SYNTAX_FILE
},
{ /* 6. */
CONF_MAIN,