--- git/mc.org/src/main.c	2009-07-19 11:25:40.000000000 +0200
+++ git/mc/src/main.c	2009-08-16 17:20:03.000000000 +0200
@@ -654,7 +654,9 @@
 int
 do_cd (const char *new_dir, enum cd_enum exact)
 {
-    return (do_panel_cd (current_panel, new_dir, exact));
+    int r = do_panel_cd (current_panel, new_dir, exact);
+    sync_other_panel_relative(current_panel);
+    return r;
 }
 
 void
--- git/mc.org/src/panel.h	2009-05-10 17:39:09.000000000 +0200
+++ git/mc/src/panel.h	2009-07-19 11:34:03.000000000 +0200
@@ -57,6 +57,7 @@
     int      exec_first;	/* Show executable top in list? */
     int      split;		/* Split panel to allow two columns */
     int      is_panelized;	/* Flag: special filelisting, can't reload */
+    int      is_locked; 	/* toggle if other dir should sync */
     int      frame_size;	/* half or full frame */
     sortfn   *sort_type;	/* Sort type */
     char     *filter;		/* File name filter */
@@ -120,5 +121,6 @@
 void directory_history_next (WPanel *panel);
 void directory_history_prev (WPanel *panel);
 void directory_history_list (WPanel *panel);
+void sync_other_panel_relative(WPanel *panel);
 
 #endif
--- git/mc.org/src/screen.c	2009-05-10 17:39:09.000000000 +0200
+++ git/mc/src/screen.c	2009-08-16 17:21:21.000000000 +0200
@@ -826,6 +826,11 @@
     addstr (">");
     widget_move (&panel->widget, 0, panel->widget.cols - 3);
     addstr ("v");
+    if (panel->is_locked){
+      widget_move (&panel->widget, 0, panel->widget.cols - 4);
+      addstr ("L");
+    }
+    
 
     if (!show_mini_info) {
 	if (panel->marked == 0) {
@@ -1129,6 +1134,7 @@
     panel->searching = 0;
     panel->dirs_marked = 0;
     panel->is_panelized = 0;
+    panel->is_locked = 0;
     panel->format = 0;
     panel->status_format = 0;
     panel->format_modified = 1;
@@ -2151,6 +2157,65 @@
     return 1;
 }
 
+void
+sync_other_panel_relative(WPanel *panel)
+{
+    if(!panel->is_locked) return;
+
+    char *cwd = current_panel->cwd;
+    char *owd = other_panel->cwd;
+    char *rwd = NULL;
+    char *csel_entry = NULL,*osel_entry = NULL;
+    char *cending = NULL, *oending = NULL;
+    char *opath = NULL, *cpath = NULL;
+    int direction = 0;
+    int autounlock = 1; // read from config?
+    struct stat buf;
+    csel_entry = strrchr(cwd, PATH_SEP);
+    osel_entry = strrchr(owd, PATH_SEP);
+    cending = concat_dir_and_file (osel_entry, csel_entry + 1);
+    oending = concat_dir_and_file (csel_entry, osel_entry + 1);
+    cpath   = concat_dir_and_file (owd, csel_entry + 1);
+    opath   = concat_dir_and_file (cwd, osel_entry + 1);
+
+    if(strcmp(cwd+strlen(cwd)-strlen(cending), cending)==0)
+      direction=1;
+    if(strcmp(owd+strlen(owd)-strlen(oending), oending)==0)
+      direction=-1;
+
+    free(cending);
+    free(oending);
+
+    if(!direction && mc_stat(cpath, &buf)!=-1 && S_ISDIR(buf.st_mode) )
+      direction=1;
+
+    if(!direction && mc_stat(opath, &buf)!=-1 && S_ISDIR(buf.st_mode) )
+      direction=-1;
+
+    free(cpath);
+    free(opath);
+
+    if(direction <0)
+      rwd = concat_dir_and_file (owd, "..");
+    else
+      rwd = concat_dir_and_file (owd, csel_entry+1); //no double slash
+
+    if(autounlock && strcmp(cwd,rwd)==0){
+      free(rwd);
+      panel->is_locked = 0;
+      return;
+    }
+
+    change_panel ();
+    do_cd (rwd, cd_exact);
+    try_to_select (current_panel, selection (panel)->fname);
+    change_panel ();
+
+    free(rwd);
+
+
+}
+
 static int
 do_enter (WPanel *panel)
 {
@@ -2264,6 +2329,7 @@
 static void cmd_select(WPanel *wp) { (void) wp;select_cmd(); }
 static void cmd_unselect(WPanel *wp) { (void) wp;unselect_cmd(); }
 static void cmd_reverse_selection(WPanel *wp) { (void) wp;reverse_selection_cmd(); }
+static void toggle_panel_locked(WPanel *wp) { (void) wp;wp->is_locked = !wp->is_locked; other_panel->is_locked=0; /*if(wp->is_locked) sync_other_panel(wp);*/}
 
 static const panel_key_map panel_keymap [] = {
     { KEY_DOWN,   move_down },
@@ -2303,6 +2369,7 @@
     { ALT('i'),   sync_other_panel },
     { ALT('l'),   chdir_to_readlink },
     { ALT('H'),   directory_history_list },
+    { ALT('L'),   toggle_panel_locked },
     { KEY_F(13),  cmd_view_simple },
     { KEY_F(14),  cmd_edit_new },
     { KEY_F(15),  cmd_copy_local },
