diff options
| author | Jan Djärv | 2010-05-02 20:44:04 +0200 |
|---|---|---|
| committer | Jan Djärv | 2010-05-02 20:44:04 +0200 |
| commit | f63d0028c0cb44c5bf4ca7f36b66ab19595f6ecc (patch) | |
| tree | a72ebe53b4ac0a453ee7b37a37f61cfdcc264cc8 /src | |
| parent | 8f92b8ad07a0af0d0fe7784feaa56cf1ff5b16f9 (diff) | |
| download | emacs-f63d0028c0cb44c5bf4ca7f36b66ab19595f6ecc.tar.gz emacs-f63d0028c0cb44c5bf4ca7f36b66ab19595f6ecc.zip | |
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
* xsmfns.c (CHDIR_OPT): New define.
(smc_save_yourself_CB): Add CHDIR_OPT to options to use when
restarting emacs.
* xterm.c (x_connection_closed): Call Fkill_emacs instead of
shut_down_emacs.
* emacs.c (USAGE1): Mention --chdir.
(main): Handle --chdir.
(standard_args): Add --chdir.
(fatal_error_signal): Call Fkill_emacs for SIGTERM and SIGHUP (Bug
#5552).
* cmdargs.texi (Initial Options): Mention --chdir.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 15 | ||||
| -rw-r--r-- | src/emacs.c | 14 | ||||
| -rw-r--r-- | src/xsmfns.c | 27 | ||||
| -rw-r--r-- | src/xterm.c | 8 |
4 files changed, 55 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 4d3c6dca4e1..2e0a77ce187 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2010-05-02 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * xsmfns.c (CHDIR_OPT): New define. | ||
| 4 | (smc_save_yourself_CB): Add CHDIR_OPT to options to use when | ||
| 5 | restarting emacs. | ||
| 6 | |||
| 7 | * xterm.c (x_connection_closed): Call Fkill_emacs instead of | ||
| 8 | shut_down_emacs. | ||
| 9 | |||
| 10 | * emacs.c (USAGE1): Mention --chdir. | ||
| 11 | (main): Handle --chdir. | ||
| 12 | (standard_args): Add --chdir. | ||
| 13 | (fatal_error_signal): Call Fkill_emacs for SIGTERM and SIGHUP (Bug | ||
| 14 | #5552). | ||
| 15 | |||
| 1 | 2010-05-01 Dan Nicolaescu <dann@ics.uci.edu> | 16 | 2010-05-01 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 17 | ||
| 3 | Remove LD_SWITCH_MACHINE. | 18 | Remove LD_SWITCH_MACHINE. |
diff --git a/src/emacs.c b/src/emacs.c index 400a6b0e594..d40ff3662f0 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -268,6 +268,7 @@ read the main documentation for these command-line arguments.\n\ | |||
| 268 | Initialization options:\n\ | 268 | Initialization options:\n\ |
| 269 | \n\ | 269 | \n\ |
| 270 | --batch do not do interactive display; implies -q\n\ | 270 | --batch do not do interactive display; implies -q\n\ |
| 271 | --chdir DIR change to directory DIR\n\ | ||
| 271 | --daemon start a server in the background\n\ | 272 | --daemon start a server in the background\n\ |
| 272 | --debug-init enable Emacs Lisp debugger for init file\n\ | 273 | --debug-init enable Emacs Lisp debugger for init file\n\ |
| 273 | --display, -d DISPLAY use X server DISPLAY\n\ | 274 | --display, -d DISPLAY use X server DISPLAY\n\ |
| @@ -385,6 +386,9 @@ fatal_error_signal (sig) | |||
| 385 | { | 386 | { |
| 386 | fatal_error_in_progress = 1; | 387 | fatal_error_in_progress = 1; |
| 387 | 388 | ||
| 389 | if (sig == SIGTERM || sig == SIGHUP) | ||
| 390 | Fkill_emacs (make_number (sig)); | ||
| 391 | |||
| 388 | shut_down_emacs (sig, 0, Qnil); | 392 | shut_down_emacs (sig, 0, Qnil); |
| 389 | } | 393 | } |
| 390 | 394 | ||
| @@ -765,6 +769,7 @@ main (int argc, char **argv) | |||
| 765 | #ifdef NS_IMPL_COCOA | 769 | #ifdef NS_IMPL_COCOA |
| 766 | char dname_arg2[80]; | 770 | char dname_arg2[80]; |
| 767 | #endif | 771 | #endif |
| 772 | char *ch_to_dir; | ||
| 768 | 773 | ||
| 769 | #if GC_MARK_STACK | 774 | #if GC_MARK_STACK |
| 770 | extern Lisp_Object *stack_base; | 775 | extern Lisp_Object *stack_base; |
| @@ -832,6 +837,14 @@ main (int argc, char **argv) | |||
| 832 | exit (0); | 837 | exit (0); |
| 833 | } | 838 | } |
| 834 | } | 839 | } |
| 840 | if (argmatch (argv, argc, "-chdir", "--chdir", 2, &ch_to_dir, &skip_args)) | ||
| 841 | if (chdir (ch_to_dir) == -1) | ||
| 842 | { | ||
| 843 | fprintf (stderr, "%s: Can't chdir to %s: %s\n", | ||
| 844 | argv[0], ch_to_dir, strerror (errno)); | ||
| 845 | exit (1); | ||
| 846 | } | ||
| 847 | |||
| 835 | 848 | ||
| 836 | #ifdef HAVE_PERSONALITY_LINUX32 | 849 | #ifdef HAVE_PERSONALITY_LINUX32 |
| 837 | if (!initialized | 850 | if (!initialized |
| @@ -1802,6 +1815,7 @@ struct standard_args | |||
| 1802 | const struct standard_args standard_args[] = | 1815 | const struct standard_args standard_args[] = |
| 1803 | { | 1816 | { |
| 1804 | { "-version", "--version", 150, 0 }, | 1817 | { "-version", "--version", 150, 0 }, |
| 1818 | { "-chdir", "--chdir", 130, 1 }, | ||
| 1805 | { "-t", "--terminal", 120, 1 }, | 1819 | { "-t", "--terminal", 120, 1 }, |
| 1806 | { "-nw", "--no-window-system", 110, 0 }, | 1820 | { "-nw", "--no-window-system", 110, 0 }, |
| 1807 | { "-nw", "--no-windows", 110, 0 }, | 1821 | { "-nw", "--no-windows", 110, 0 }, |
diff --git a/src/xsmfns.c b/src/xsmfns.c index ec5ca3b1a9f..48fd1b7e76d 100644 --- a/src/xsmfns.c +++ b/src/xsmfns.c | |||
| @@ -90,6 +90,10 @@ Lisp_Object Vx_session_previous_id; | |||
| 90 | 90 | ||
| 91 | #define NOSPLASH_OPT "--no-splash" | 91 | #define NOSPLASH_OPT "--no-splash" |
| 92 | 92 | ||
| 93 | /* The option to make Emacs start in the given directory. */ | ||
| 94 | |||
| 95 | #define CHDIR_OPT "--chdir=" | ||
| 96 | |||
| 93 | static void | 97 | static void |
| 94 | ice_connection_closed () | 98 | ice_connection_closed () |
| 95 | { | 99 | { |
| @@ -206,7 +210,7 @@ smc_save_yourself_CB (smcConn, | |||
| 206 | int props_idx = 0; | 210 | int props_idx = 0; |
| 207 | 211 | ||
| 208 | char *cwd = NULL; | 212 | char *cwd = NULL; |
| 209 | char *smid_opt; | 213 | char *smid_opt, *chdir_opt = NULL; |
| 210 | 214 | ||
| 211 | /* How to start a new instance of Emacs. */ | 215 | /* How to start a new instance of Emacs. */ |
| 212 | props[props_idx] = &prop_ptr[props_idx]; | 216 | props[props_idx] = &prop_ptr[props_idx]; |
| @@ -228,11 +232,12 @@ smc_save_yourself_CB (smcConn, | |||
| 228 | props[props_idx]->vals[0].value = SDATA (Vinvocation_name); | 232 | props[props_idx]->vals[0].value = SDATA (Vinvocation_name); |
| 229 | ++props_idx; | 233 | ++props_idx; |
| 230 | 234 | ||
| 231 | /* How to restart Emacs (i.e.: /path/to/emacs --smid=xxxx --no-splash). */ | 235 | /* How to restart Emacs. */ |
| 232 | props[props_idx] = &prop_ptr[props_idx]; | 236 | props[props_idx] = &prop_ptr[props_idx]; |
| 233 | props[props_idx]->name = SmRestartCommand; | 237 | props[props_idx]->name = SmRestartCommand; |
| 234 | props[props_idx]->type = SmLISTofARRAY8; | 238 | props[props_idx]->type = SmLISTofARRAY8; |
| 235 | props[props_idx]->num_vals = 3; /* /path/to/emacs, --smid=xxx --no-splash */ | 239 | /* /path/to/emacs, --smid=xxx --no-splash --chdir=dir */ |
| 240 | props[props_idx]->num_vals = 4; | ||
| 236 | props[props_idx]->vals = &values[val_idx]; | 241 | props[props_idx]->vals = &values[val_idx]; |
| 237 | props[props_idx]->vals[0].length = strlen (emacs_program); | 242 | props[props_idx]->vals[0].length = strlen (emacs_program); |
| 238 | props[props_idx]->vals[0].value = emacs_program; | 243 | props[props_idx]->vals[0].value = emacs_program; |
| @@ -246,7 +251,19 @@ smc_save_yourself_CB (smcConn, | |||
| 246 | 251 | ||
| 247 | props[props_idx]->vals[2].length = strlen (NOSPLASH_OPT); | 252 | props[props_idx]->vals[2].length = strlen (NOSPLASH_OPT); |
| 248 | props[props_idx]->vals[2].value = NOSPLASH_OPT; | 253 | props[props_idx]->vals[2].value = NOSPLASH_OPT; |
| 249 | val_idx += 3; | 254 | |
| 255 | cwd = get_current_dir_name (); | ||
| 256 | if (cwd) | ||
| 257 | { | ||
| 258 | chdir_opt = xmalloc (strlen (CHDIR_OPT) + strlen (client_id) + 1); | ||
| 259 | strcpy (chdir_opt, CHDIR_OPT); | ||
| 260 | strcat (chdir_opt, cwd); | ||
| 261 | |||
| 262 | props[props_idx]->vals[3].length = strlen (chdir_opt); | ||
| 263 | props[props_idx]->vals[3].value = chdir_opt; | ||
| 264 | } | ||
| 265 | |||
| 266 | val_idx += cwd ? 4 : 3; | ||
| 250 | ++props_idx; | 267 | ++props_idx; |
| 251 | 268 | ||
| 252 | /* User id. */ | 269 | /* User id. */ |
| @@ -259,7 +276,6 @@ smc_save_yourself_CB (smcConn, | |||
| 259 | props[props_idx]->vals[0].value = SDATA (Vuser_login_name); | 276 | props[props_idx]->vals[0].value = SDATA (Vuser_login_name); |
| 260 | ++props_idx; | 277 | ++props_idx; |
| 261 | 278 | ||
| 262 | cwd = get_current_dir_name (); | ||
| 263 | 279 | ||
| 264 | if (cwd) | 280 | if (cwd) |
| 265 | { | 281 | { |
| @@ -277,6 +293,7 @@ smc_save_yourself_CB (smcConn, | |||
| 277 | SmcSetProperties (smcConn, props_idx, props); | 293 | SmcSetProperties (smcConn, props_idx, props); |
| 278 | 294 | ||
| 279 | xfree (smid_opt); | 295 | xfree (smid_opt); |
| 296 | xfree (chdir_opt); | ||
| 280 | 297 | ||
| 281 | free (cwd); | 298 | free (cwd); |
| 282 | 299 | ||
diff --git a/src/xterm.c b/src/xterm.c index 4f191922561..ec550100cea 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -7936,8 +7936,8 @@ x_connection_closed (dpy, error_message) | |||
| 7936 | if (terminal_list->next_terminal == NULL) | 7936 | if (terminal_list->next_terminal == NULL) |
| 7937 | { | 7937 | { |
| 7938 | fprintf (stderr, "%s\n", error_msg); | 7938 | fprintf (stderr, "%s\n", error_msg); |
| 7939 | shut_down_emacs (0, 0, Qnil); | 7939 | Fkill_emacs (make_number (70)); |
| 7940 | exit (70); | 7940 | /* NOTREACHED */ |
| 7941 | } | 7941 | } |
| 7942 | xg_display_close (dpyinfo->display); | 7942 | xg_display_close (dpyinfo->display); |
| 7943 | #endif | 7943 | #endif |
| @@ -7963,8 +7963,8 @@ x_connection_closed (dpy, error_message) | |||
| 7963 | if (terminal_list == 0) | 7963 | if (terminal_list == 0) |
| 7964 | { | 7964 | { |
| 7965 | fprintf (stderr, "%s\n", error_msg); | 7965 | fprintf (stderr, "%s\n", error_msg); |
| 7966 | shut_down_emacs (0, 0, Qnil); | 7966 | Fkill_emacs (make_number (70)); |
| 7967 | exit (70); | 7967 | /* NOTREACHED */ |
| 7968 | } | 7968 | } |
| 7969 | 7969 | ||
| 7970 | /* Ordinary stack unwind doesn't deal with these. */ | 7970 | /* Ordinary stack unwind doesn't deal with these. */ |