Fix startup working dir bug on NeXTSTEP

* src/emacs.c (main) [NS_IMPL_COCOA]: Update emacs_wd
after a NS GUI chdirs successfully (Bug#42836).
This commit is contained in:
Paul Eggert 2020-08-13 12:48:57 -07:00
parent 69568674b3
commit 16f4f26632

View file

@ -1638,23 +1638,27 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
{
#ifdef NS_IMPL_COCOA
/* Started from GUI? */
/* FIXME: Do the right thing if get_homedir returns "", or if
chdir fails. */
if (! inhibit_window_system && ! isatty (STDIN_FILENO) && ! ch_to_dir)
chdir (get_homedir ());
bool go_home = (!ch_to_dir && !inhibit_window_system
&& !isatty (STDIN_FILENO));
if (skip_args < argc)
{
if (!strncmp (argv[skip_args], "-psn", 4))
{
skip_args += 1;
if (! ch_to_dir) chdir (get_homedir ());
go_home |= !ch_to_dir;
}
else if (skip_args+1 < argc && !strncmp (argv[skip_args+1], "-psn", 4))
{
skip_args += 2;
if (! ch_to_dir) chdir (get_homedir ());
go_home |= !ch_to_dir;
}
}
if (go_home)
{
char const *home = get_homedir ();
if (*home && chdir (home) == 0)
emacs_wd = emacs_get_current_dir_name ();
}
#endif /* COCOA */
}
#endif /* HAVE_NS */