emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r100117: Run kill-emacs when exiting


From: Jan D.
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r100117: Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Date: Sun, 02 May 2010 20:44:04 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100117
committer: Jan D. <address@hidden>
branch nick: trunk
timestamp: Sun 2010-05-02 20:44:04 +0200
message:
  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.
modified:
  doc/emacs/ChangeLog
  doc/emacs/cmdargs.texi
  src/ChangeLog
  src/emacs.c
  src/xsmfns.c
  src/xterm.c
=== modified file 'doc/emacs/ChangeLog'
--- a/doc/emacs/ChangeLog       2010-04-21 16:25:15 +0000
+++ b/doc/emacs/ChangeLog       2010-05-02 18:44:04 +0000
@@ -1,3 +1,7 @@
+2010-05-02  Jan Djärv  <address@hidden>
+
+       * cmdargs.texi (Initial Options): Mention --chdir.
+
 2010-04-21  Jan Djärv  <address@hidden>
 
        * frames.texi (Tool Bars): Add tool-bar-style.

=== modified file 'doc/emacs/cmdargs.texi'
--- a/doc/emacs/cmdargs.texi    2010-03-20 17:24:06 +0000
+++ b/doc/emacs/cmdargs.texi    2010-05-02 18:44:04 +0000
@@ -193,6 +193,15 @@
 other files for them.
 
 @table @samp
address@hidden -chdir @var{directory}
address@hidden -chdir
address@hidden address@hidden
address@hidden --chdir
address@hidden change Emacs directory
+Change to @var{directory} before doing anything else.  This is mainly used
+by session management in X so that Emacs starts in the same directory as it
+stopped.  This makes desktop saving and restoring easier.
+
 @item -t @var{device}
 @opindex -t
 @itemx address@hidden

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2010-05-01 21:38:59 +0000
+++ b/src/ChangeLog     2010-05-02 18:44:04 +0000
@@ -1,3 +1,18 @@
+2010-05-02  Jan Djärv  <address@hidden>
+
+       * 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).
+
 2010-05-01  Dan Nicolaescu  <address@hidden>
 
        Remove LD_SWITCH_MACHINE.

=== modified file 'src/emacs.c'
--- a/src/emacs.c       2010-04-02 03:10:33 +0000
+++ b/src/emacs.c       2010-05-02 18:44:04 +0000
@@ -268,6 +268,7 @@
 Initialization options:\n\
 \n\
 --batch                     do not do interactive display; implies -q\n\
+--chdir DIR                 change to directory DIR\n\
 --daemon                    start a server in the background\n\
 --debug-init                enable Emacs Lisp debugger for init file\n\
 --display, -d DISPLAY       use X server DISPLAY\n\
@@ -385,6 +386,9 @@
     {
       fatal_error_in_progress = 1;
 
+      if (sig == SIGTERM || sig == SIGHUP)
+        Fkill_emacs (make_number (sig));
+
       shut_down_emacs (sig, 0, Qnil);
     }
 
@@ -765,6 +769,7 @@
 #ifdef NS_IMPL_COCOA
   char dname_arg2[80];
 #endif
+  char *ch_to_dir;
 
 #if GC_MARK_STACK
   extern Lisp_Object *stack_base;
@@ -832,6 +837,14 @@
          exit (0);
        }
     }
+  if (argmatch (argv, argc, "-chdir", "--chdir", 2, &ch_to_dir, &skip_args))
+      if (chdir (ch_to_dir) == -1)
+        {
+          fprintf (stderr, "%s: Can't chdir to %s: %s\n",
+                   argv[0], ch_to_dir, strerror (errno));
+          exit (1);
+        }
+
 
 #ifdef HAVE_PERSONALITY_LINUX32
   if (!initialized
@@ -1802,6 +1815,7 @@
 const struct standard_args standard_args[] =
 {
   { "-version", "--version", 150, 0 },
+  { "-chdir", "--chdir", 130, 1 },
   { "-t", "--terminal", 120, 1 },
   { "-nw", "--no-window-system", 110, 0 },
   { "-nw", "--no-windows", 110, 0 },

=== modified file 'src/xsmfns.c'
--- a/src/xsmfns.c      2010-02-10 09:29:28 +0000
+++ b/src/xsmfns.c      2010-05-02 18:44:04 +0000
@@ -90,6 +90,10 @@
 
 #define NOSPLASH_OPT "--no-splash"
 
+/* The option to make Emacs start in the given directory.  */
+
+#define CHDIR_OPT "--chdir="
+
 static void
 ice_connection_closed ()
 {
@@ -206,7 +210,7 @@
   int props_idx = 0;
 
   char *cwd = NULL;
-  char *smid_opt;
+  char *smid_opt, *chdir_opt = NULL;
 
   /* How to start a new instance of Emacs.  */
   props[props_idx] = &prop_ptr[props_idx];
@@ -228,11 +232,12 @@
   props[props_idx]->vals[0].value = SDATA (Vinvocation_name);
   ++props_idx;
 
-  /* How to restart Emacs (i.e.: /path/to/emacs --smid=xxxx --no-splash).  */
+  /* How to restart Emacs.  */
   props[props_idx] = &prop_ptr[props_idx];
   props[props_idx]->name = SmRestartCommand;
   props[props_idx]->type = SmLISTofARRAY8;
-  props[props_idx]->num_vals = 3; /* /path/to/emacs, --smid=xxx --no-splash  */
+  /* /path/to/emacs, --smid=xxx --no-splash --chdir=dir */
+  props[props_idx]->num_vals = 4;
   props[props_idx]->vals = &values[val_idx];
   props[props_idx]->vals[0].length = strlen (emacs_program);
   props[props_idx]->vals[0].value = emacs_program;
@@ -246,7 +251,19 @@
 
   props[props_idx]->vals[2].length = strlen (NOSPLASH_OPT);
   props[props_idx]->vals[2].value = NOSPLASH_OPT;
-  val_idx += 3;
+
+  cwd = get_current_dir_name ();
+  if (cwd) 
+    {
+      chdir_opt = xmalloc (strlen (CHDIR_OPT) + strlen (client_id) + 1);
+      strcpy (chdir_opt, CHDIR_OPT);
+      strcat (chdir_opt, cwd);
+
+      props[props_idx]->vals[3].length = strlen (chdir_opt);
+      props[props_idx]->vals[3].value = chdir_opt;
+    }
+
+  val_idx += cwd ? 4 : 3;
   ++props_idx;
 
   /* User id.  */
@@ -259,7 +276,6 @@
   props[props_idx]->vals[0].value = SDATA (Vuser_login_name);
   ++props_idx;
 
-  cwd = get_current_dir_name ();
 
   if (cwd)
     {
@@ -277,6 +293,7 @@
   SmcSetProperties (smcConn, props_idx, props);
 
   xfree (smid_opt);
+  xfree (chdir_opt);
 
   free (cwd);
 

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2010-04-20 18:52:07 +0000
+++ b/src/xterm.c       2010-05-02 18:44:04 +0000
@@ -7936,8 +7936,8 @@
       if (terminal_list->next_terminal == NULL)
         {
           fprintf (stderr, "%s\n", error_msg);
-          shut_down_emacs (0, 0, Qnil);
-          exit (70);
+          Fkill_emacs (make_number (70));
+          /* NOTREACHED */
         }
       xg_display_close (dpyinfo->display);
 #endif
@@ -7963,8 +7963,8 @@
   if (terminal_list == 0)
     {
       fprintf (stderr, "%s\n", error_msg);
-      shut_down_emacs (0, 0, Qnil);
-      exit (70);
+      Fkill_emacs (make_number (70));
+      /* NOTREACHED */
     }
 
   /* Ordinary stack unwind doesn't deal with these.  */


reply via email to

[Prev in Thread] Current Thread [Next in Thread]