Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit 2df6771

Browse files
committed
Merge branch '4413_user_syntax'
* 4413_user_syntax: Ticket #4413: mcedit: syntax definitions in user location don't work.
2 parents f98cda9 + 3f882f5 commit 2df6771

File tree

6 files changed

+18
-21
lines changed

6 files changed

+18
-21
lines changed

doc/man/mcedit.1.in

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,12 @@ where equal is symbol "=" goes to next function in navigation list
237237
supports syntax highlighting. This means that keywords and contexts
238238
(like C comments, string constants, etc) are highlighted in different
239239
colors. The following section explains the format of the file
240-
.BR ~/.config/mc/mcedit/Syntax .
240+
.BR ~/.local/share/mc/syntax/Syntax .
241241
If this file is missing, system\-wide
242242
.B %pkgdatadir%/syntax/Syntax
243243
is used.
244244
The file
245-
.B ~/.config/mc/mcedit/Syntax
245+
.B ~/.local/share/mc/syntax/Syntax
246246
is rescanned on opening of every new editor file. The file contains
247247
rules for highlighting, each of which is given on a separate line, and
248248
define which keywords will be highlighted with what color.
@@ -631,7 +631,9 @@ affect all users, whether they have ~/.config/mc/ini or not.
631631
.I %pkgdatadir%/syntax/*
632632
.IP
633633
The default system\-wide syntax files for mcedit, used only if
634-
the corresponding user's own ~/.local/share/mc/mcedit/ file is missing.
634+
the corresponding user's own file in
635+
.B ~/.local/share/mc/syntax/
636+
is missing.
635637
.PP
636638
.I ~/.config/mc/ini
637639
.IP

lib/fileloc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@
7272

7373
/* file names */
7474
#define EDIT_HOME_MACRO_FILE EDIT_HOME_DIR PATH_SEP_STR "macros.d" PATH_SEP_STR "macro"
75-
#define EDIT_HOME_SYNTAX_FILE EDIT_HOME_DIR PATH_SEP_STR "Syntax"
7675
#define EDIT_HOME_CLIP_FILE EDIT_HOME_DIR PATH_SEP_STR "mcedit.clip"
7776
#define EDIT_HOME_BLOCK_FILE EDIT_HOME_DIR PATH_SEP_STR "mcedit.block"
7877
#define EDIT_HOME_TEMP_FILE EDIT_HOME_DIR PATH_SEP_STR "mcedit.temp"
78+
#define EDIT_SYNTAX_DIR "syntax"
79+
#define EDIT_SYNTAX_FILE EDIT_SYNTAX_DIR PATH_SEP_STR "Syntax"
7980

8081
#define EDIT_GLOBAL_MENU "mcedit.menu"
8182
#define EDIT_LOCAL_MENU ".cedit.menu"

lib/mcconfig/paths.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ static const struct
6464
{ &mc_config_str, MC_HOTLIST_FILE },
6565
{ &mc_config_str, GLOBAL_KEYMAP_FILE },
6666
{ &mc_config_str, MC_USERMENU_FILE },
67-
{ &mc_config_str, EDIT_HOME_SYNTAX_FILE },
6867
{ &mc_config_str, EDIT_HOME_MENU },
6968
{ &mc_config_str, MC_PANELS_FILE },
7069

@@ -82,6 +81,7 @@ static const struct
8281
{ &mc_data_str, MC_EXTFS_DIR },
8382
{ &mc_data_str, MC_HISTORY_FILE },
8483
{ &mc_data_str, MC_FILEPOS_FILE },
84+
{ &mc_data_str, EDIT_SYNTAX_FILE },
8585
{ &mc_data_str, EDIT_HOME_CLIP_FILE },
8686
{ &mc_data_str, MC_MACRO_FILE },
8787

src/editor/editcmd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,19 +1128,19 @@ edit_load_syntax_file (WDialog * h)
11281128
_("&User"), _("&System wide"));
11291129

11301130
extdir_vpath =
1131-
vfs_path_build_filename (mc_global.sysconfig_dir, "syntax", "Syntax", (char *) NULL);
1131+
vfs_path_build_filename (mc_global.sysconfig_dir, EDIT_SYNTAX_FILE, (char *) NULL);
11321132
if (!exist_file (vfs_path_get_last_path_str (extdir_vpath)))
11331133
{
11341134
vfs_path_free (extdir_vpath, TRUE);
11351135
extdir_vpath =
1136-
vfs_path_build_filename (mc_global.share_data_dir, "syntax", "Syntax", (char *) NULL);
1136+
vfs_path_build_filename (mc_global.share_data_dir, EDIT_SYNTAX_FILE, (char *) NULL);
11371137
}
11381138

11391139
if (dir == 0)
11401140
{
11411141
vfs_path_t *user_syntax_file_vpath;
11421142

1143-
user_syntax_file_vpath = mc_config_get_full_vpath (EDIT_HOME_SYNTAX_FILE);
1143+
user_syntax_file_vpath = mc_config_get_full_vpath (EDIT_SYNTAX_FILE);
11441144
check_for_default (extdir_vpath, user_syntax_file_vpath);
11451145
ret = edit_load_file_from_filename (h, user_syntax_file_vpath, 0);
11461146
vfs_path_free (user_syntax_file_vpath, TRUE);

src/editor/syntax.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
#include "lib/global.h"
5858
#include "lib/search.h" /* search engine */
5959
#include "lib/skin.h"
60-
#include "lib/fileloc.h" /* EDIT_HOME_DIR, EDIT_HOME_SYNTAX_FILE */
60+
#include "lib/fileloc.h" /* EDIT_SYNTAX_DIR, EDIT_SYNTAX_FILE */
6161
#include "lib/strutil.h" /* utf string functions */
6262
#include "lib/util.h"
6363
#include "lib/widget.h" /* Listbox, message() */
@@ -887,20 +887,14 @@ open_include_file (const char *filename)
887887

888888
g_free (error_file_name);
889889
error_file_name =
890-
g_build_filename (mc_config_get_data_path (), EDIT_HOME_DIR, filename, (char *) NULL);
891-
f = fopen (error_file_name, "r");
892-
if (f != NULL)
893-
return f;
894-
895-
g_free (error_file_name);
896-
error_file_name = g_build_filename (mc_global.sysconfig_dir, "syntax", filename, (char *) NULL);
890+
g_build_filename (mc_config_get_data_path (), EDIT_SYNTAX_DIR, filename, (char *) NULL);
897891
f = fopen (error_file_name, "r");
898892
if (f != NULL)
899893
return f;
900894

901895
g_free (error_file_name);
902896
error_file_name =
903-
g_build_filename (mc_global.share_data_dir, "syntax", filename, (char *) NULL);
897+
g_build_filename (mc_global.share_data_dir, EDIT_SYNTAX_DIR, filename, (char *) NULL);
904898

905899
return fopen (error_file_name, "r");
906900
}
@@ -1270,7 +1264,7 @@ edit_read_syntax_file (WEdit * edit, GPtrArray * pnames, const char *syntax_file
12701264
f = fopen (syntax_file, "r");
12711265
if (f == NULL)
12721266
{
1273-
lib_file = g_build_filename (mc_global.share_data_dir, "syntax", "Syntax", (char *) NULL);
1267+
lib_file = g_build_filename (mc_global.share_data_dir, EDIT_SYNTAX_FILE, (char *) NULL);
12741268
f = fopen (lib_file, "r");
12751269
g_free (lib_file);
12761270
if (f == NULL)
@@ -1521,7 +1515,7 @@ edit_load_syntax (WEdit * edit, GPtrArray * pnames, const char *type)
15211515
if (edit != NULL && edit->filename_vpath == NULL)
15221516
return;
15231517

1524-
f = mc_config_get_full_path (EDIT_HOME_SYNTAX_FILE);
1518+
f = mc_config_get_full_path (EDIT_SYNTAX_FILE);
15251519
if (edit != NULL)
15261520
r = edit_read_syntax_file (edit, pnames, f, vfs_path_as_str (edit->filename_vpath),
15271521
get_first_editor_line (edit),

tests/lib/mcconfig/user_configs_path.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ static const struct test_user_config_paths_ds
9797
MC_USERMENU_FILE
9898
},
9999
{ /* 5. */
100-
CONF_MAIN,
101-
EDIT_HOME_SYNTAX_FILE
100+
CONF_DATA,
101+
EDIT_SYNTAX_FILE
102102
},
103103
{ /* 6. */
104104
CONF_MAIN,

0 commit comments

Comments
 (0)