Re: auto save panels setup broken

2016-10-08 Thread Yury V. Zaytsev

On Fri, 7 Oct 2016, Mike wrote:



Here's the patch for {setup.[ch], main.c, midnight.c} to fix the 
restoring of the directory contents of the active panel on startup when 
"Auto Save Panel Setup" option is enabled.


Unless it ends up on the Trac it will surely get buried in the mailing 
list archives... just saying.


--
Sincerely yours,
Yury V. Zaytsev
___
mc mailing list
https://mail.gnome.org/mailman/listinfo/mc


Re: auto save panels setup broken

2016-10-07 Thread Mike
Here's the patch for {setup.[ch], main.c, midnight.c} to fix the 
restoring of the directory contents of the active panel on startup when 
"Auto Save Panel Setup" option is enabled.


See attached 1341 byte gzip:

patch01-setup.ch-main.c-midnight.c-auto-save-restore-panel.161007.diff.gz

It works for me. With no command line directories and no auto save 
panels option it still uses current directory for active panel like always.



--
Peace and Cheer


patch01-setup.ch-main.c-midnight.c-auto-save-restore-panel.161007.diff.gz
Description: application/gzip
___
mc mailing list
https://mail.gnome.org/mailman/listinfo/mc


Re: auto save panels setup broken

2016-10-07 Thread Mike
On closer inspection, saving and retrieving this_dir is a simple hack to 
setup.c, setup.h, and main.c. The real issue is what to do at startup.


In midnight.c:create_panels() around line 600, if command line arguments 
run_param0 and run_param1 are both NULL we assume this_panel (active 
panel) is the current directory, and that's the way it works. There is 
no check for auto_save_panels, and if so, restore the active saved 
directory.


This works to fix the issue:

[code]

if (boot_current_is_left)
{
/* left panel is active */
current_index = 0;
other_index = 1;
current_mode = startup_left_mode;
other_mode = startup_right_mode;

if (mc_run_param0 == NULL && mc_run_param1 == NULL)
{
/* no arguments */
if (panels_options.auto_save_setup) { /* check if we should 
restore active panel */

current_dir = saved_this_dir;
} else {
current_dir = NULL; /* assume current dir */
}
other_dir = saved_other_dir;/* from ini */
}
else if (mc_run_param0 != NULL && mc_run_param1 != NULL)
{
/* two arguments */
current_dir = (char *) mc_run_param0;
other_dir = mc_run_param1;
}
else/* mc_run_param0 != NULL && 
mc_run_param1 == NULL */

{
/* one argument */
current_dir = (char *) mc_run_param0;
other_dir = saved_other_dir;/* from ini */
}
}
else
{
/* right panel is active */
current_index = 1;
other_index = 0;
current_mode = startup_right_mode;
other_mode = startup_left_mode;

if (mc_run_param0 == NULL && mc_run_param1 == NULL)
{
/* no arguments */
if (panels_options.auto_save_setup) {
current_dir = saved_this_dir;
} else {
current_dir = NULL; /* assume current dir */
}
other_dir = saved_other_dir;/* from ini */
}
else if (mc_run_param0 != NULL && mc_run_param1 != NULL)
{
/* two arguments */
current_dir = (char *) mc_run_param0;
other_dir = mc_run_param1;
}
else/* mc_run_param0 != NULL && 
mc_run_param1 == NULL */

{
/* one argument */
current_dir = (char *) mc_run_param0;
other_dir = saved_other_dir;/* from ini */
}
}
[/code]

I can put it all together as a patch and post it if you like. Minor 
modifications to 4 files.



On 2016-10-07 07:03, Mike wrote:


Isn't that what F9 -> Options -> panel options -> auto save panels 
setup is for?


I believe OP is correct: mc forgets the active directory if you do 
have "auto save panels setup" selected.


$HOME/.config/mc/panels.ini:

[Dirs]
other_dir=/some/dir/somewhere
current_is_left=false

I think this file should be saved with:

this_dir=/some/dir

?

Whichever panel is active on shutdown, gets set back to $HOME on 
restart. This is not correct.


From a cursory look, it's a simple hack to setup.c. I guess it got 
overlooked because few people use that option.



On 2016-10-07 05:39, chris glur wrote:

  Also it doesn't remember the active panel on last
close was the right panel.

When, as usual, I've got several mc running: they all initially start with
the latest  conditions.

If I rarely, change the format-order of a mc, I don't want that new specail
setting to be remembered and REPLACE my chosen default settings.

You seems to write as if you had onlu one mc running?
___
mc mailing list
https://mail.gnome.org/mailman/listinfo/mc


--
Peace and Cheer


--
Peace and Cheer
___
mc mailing list
https://mail.gnome.org/mailman/listinfo/mc