I connect this simple macro to a keyboard shortcut (CTRL-D) in my case.
I have the Open File window set up to not automatically switch directories when I select new file windows.
When I have a bunch of files open and switch to back and forth from open files but want to switch the Open File window to the directory where the file lives, I run the macro.
#region Imports
#include "slick.sh"
#import "dir.e"
#import "dirlist.e"
#endregion
_command cd_to_file_location() name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)
{
_str directory;
if (_mdi.p_child.p_window_id && _mdi.p_child.p_buf_name != '' && file_exists(_mdi.p_child.p_buf_name) ) {
directory = strip_filename(_mdi.p_child.p_buf_name, 'NE');
_dlSetPath(directory,true);
}
}