Hi all,
I wrote a patch allowing to store mc configuration to /etc/mc. It's
tested within Fedora for a few months with no complaints. I moved these
configuration files from /usr/share/mc to /etc/mc:
extfs/extfs.ini
extfs/sfs.ini
syntax/Syntax
cedit.menu
edit.indent.rc
edit.spell.rc
mc.charsets
mc.ext
mc.lib
mc.menu
and let the rest in the /usr/share/mc location since they are not config
files. The patch changes the default way how mc looks for config files
in the way that it first searches /etc/mc and if not found, the fallback
is to search /usr/share/mc. So it is fully consistent with the former mc
behavior.
Cheers,
Jindrich
--
Jindrich Novy [EMAIL PROTECTED]
--- mc-4.6.1a/src/charsets.c.etcmc 2005-05-27 05:35:15.0 +0200
+++ mc-4.6.1a/src/charsets.c 2006-02-24 15:17:05.0 +0100
@@ -45,12 +45,17 @@ load_codepages_list (void)
char *fname;
char buf[256];
extern char *mc_home;
+extern char *mc_home_alt;
extern int display_codepage;
char *default_codepage = NULL;
fname = concat_dir_and_file (mc_home, CHARSETS_INDEX);
if (!(f = fopen (fname, r))) {
- fprintf (stderr, _(Warning: file %s not found\n), fname);
+g_free (fname);
+fname = concat_dir_and_file (mc_home_alt, CHARSETS_INDEX);
+if (!(f = fopen (fname, r))) {
+ fprintf (stderr, _(Warning: file %s not found\n), fname);
+}
g_free (fname);
return -1;
}
--- mc-4.6.1a/src/main.h.etcmc 2006-02-24 15:17:05.0 +0100
+++ mc-4.6.1a/src/main.h 2006-02-24 15:17:05.0 +0100
@@ -112,7 +112,7 @@ void print_vfs_message(const char *msg,
extern const char *prompt;
extern const char *edit_one_file;
-extern char *mc_home;
+extern char *mc_home, *mc_home_alt;
char *get_mc_lib_dir (void);
int maybe_cd (int move_up_dir);
--- mc-4.6.1a/src/ext.c.etcmc 2005-07-31 22:29:35.0 +0200
+++ mc-4.6.1a/src/ext.c 2006-02-24 15:17:05.0 +0100
@@ -444,6 +444,10 @@ regex_command (const char *filename, con
g_free (extension_file);
check_stock_mc_ext:
extension_file = concat_dir_and_file (mc_home, MC_LIB_EXT);
+ if (!exist_file (extension_file)) {
+ g_free (extension_file);
+ extension_file = concat_dir_and_file (mc_home_alt, MC_LIB_EXT);
+ }
mc_user_ext = 0;
}
data = load_file (extension_file);
--- mc-4.6.1a/src/setup.c.etcmc 2006-01-29 21:26:05.0 +0100
+++ mc-4.6.1a/src/setup.c 2006-02-24 15:17:05.0 +0100
@@ -481,8 +481,15 @@ setup_init (void)
if (exist_file (inifile)){
g_free (profile);
profile = inifile;
- } else
+ } else {
g_free (inifile);
+ inifile = concat_dir_and_file (mc_home_alt, mc.ini);
+ if (exist_file (inifile)) {
+ g_free (profile);
+ profile = inifile;
+ } else
+ g_free (inifile);
+ }
}
profile_name = profile;
@@ -501,6 +508,11 @@ load_setup (void)
/* mc.lib is common for all users, but has priority lower than
~/.mc/ini. FIXME: it's only used for keys and treestore now */
global_profile_name = concat_dir_and_file (mc_home, mc.lib);
+
+if (!exist_file(global_profile_name)) {
+ g_free (global_profile_name);
+ global_profile_name = concat_dir_and_file (mc_home_alt, mc.lib);
+}
/* Load integer boolean options */
for (i = 0; int_options[i].opt_name; i++)
--- mc-4.6.1a/src/Makefile.am.etcmc 2006-02-04 12:13:30.0 +0100
+++ mc-4.6.1a/src/Makefile.am 2006-02-24 15:17:05.0 +0100
@@ -8,9 +8,11 @@ bin_PROGRAMS = mc mcmfmt
if CONS_SAVER
pkglibexec_PROGRAMS = cons.saver
AM_CPPFLAGS = -DDATADIR=\$(pkgdatadir)/\ -DLOCALEDIR=\$(localedir)\ \
- -DSAVERDIR=\$(pkglibexecdir)\
+ -DSAVERDIR=\$(pkglibexecdir)\ \
+ -DSYSCONFDIR=\$(sysconfdir)/@PACKAGE@/\
else
-AM_CPPFLAGS = -DDATADIR=\$(pkgdatadir)/\ -DLOCALEDIR=\$(localedir)\
+AM_CPPFLAGS = -DDATADIR=\$(pkgdatadir)/\ -DLOCALEDIR=\$(localedir)\ \
+ -DSYSCONFDIR=\$(sysconfdir)/@PACKAGE@/\
endif
noinst_PROGRAMS = man2hlp
--- mc-4.6.1a/src/util.c.etcmc 2006-02-24 15:17:05.0 +0100
+++ mc-4.6.1a/src/util.c 2006-02-24 15:17:05.0 +0100
@@ -40,7 +40,7 @@
#include tty.h
#include global.h
#include profile.h
-#include main.h /* mc_home */
+#include main.h /* mc_home, mc_home_alt */
#include cmd.h /* guess_message_value */
#include mountlist.h
#include win.h /* xterm_flag */
@@ -950,16 +950,25 @@ load_mc_home_file (const char *filename,
if (!data) {
g_free (hintfile);
- /* Fall back to the two-letter language code */
- if (lang[0] lang[1])
- lang[2] = 0;
+ g_free (hintfile_base);
+
+ hintfile_base = concat_dir_and_file (mc_home_alt, filename);
+
hintfile = g_strconcat (hintfile_base, ., lang, (char *) NULL);
data = load_file (hintfile);
-
+
if (!data) {
- g_free (hintfile);
- hintfile = hintfile_base;
- data = load_file (hintfile_base);
+ /* Fall back to the two-letter language code */
+ if (lang[0] lang[1])
+ lang[2] = 0;
+ hintfile =