aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2008-10-27 07:02:30 +0000
committerDan Nicolaescu2008-10-27 07:02:30 +0000
commit4ff029f613a6f9a4bd54bf3b3e7763c25a510045 (patch)
tree5cfd4a8426c9fed83af07e022aa3d148332b00eb
parentb918aa6b5d512ffbdca994d0e60dfabc43fed6c3 (diff)
downloademacs-4ff029f613a6f9a4bd54bf3b3e7763c25a510045.tar.gz
emacs-4ff029f613a6f9a4bd54bf3b3e7763c25a510045.zip
* emacs.c (daemon_name): New variable.
(main): Deal with --daemon=SERVER_NAME. (Fdaemonp): Return a name if one was passed to --daemon. * startup.el (server-name): Pacify byte compiler. (command-line): If --daemon=SERVER_NAME was used, set server-name before calling server-start. * cmdargs.texi (Initial Options): Document -daemon=SERVER_NAME.
-rw-r--r--doc/emacs/ChangeLog4
-rw-r--r--doc/emacs/cmdargs.texi4
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/startup.el10
-rw-r--r--src/ChangeLog6
-rw-r--r--src/emacs.c19
6 files changed, 43 insertions, 6 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog
index 7f1cf1b78e0..fbbe7ec0ed3 100644
--- a/doc/emacs/ChangeLog
+++ b/doc/emacs/ChangeLog
@@ -1,3 +1,7 @@
12008-10-27 Dan Nicolaescu <dann@ics.uci.edu>
2
3 * cmdargs.texi (Initial Options): Document -daemon=SERVER_NAME.
4
12008-10-23 Chong Yidong <cyd@stupidchicken.com> 52008-10-23 Chong Yidong <cyd@stupidchicken.com>
2 6
3 * custom.texi (Function Keys): Note that modified keypad keys are not 7 * custom.texi (Function Keys): Note that modified keypad keys are not
diff --git a/doc/emacs/cmdargs.texi b/doc/emacs/cmdargs.texi
index 94e69bcdfe8..6be6a983461 100644
--- a/doc/emacs/cmdargs.texi
+++ b/doc/emacs/cmdargs.texi
@@ -286,6 +286,10 @@ terminal), do not open any frames and start the server. Clients can
286connect and create graphical or terminal frames using 286connect and create graphical or terminal frames using
287@code{emacsclient}. 287@code{emacsclient}.
288 288
289@item -daemon=@var{SERVER-NAME}
290Start emacs in background as a daemon, and start the server with the
291name set to @var{SERVER-NAME}.
292
289@item --no-splash 293@item --no-splash
290@opindex --no-splash 294@opindex --no-splash
291@vindex inhibit-startup-screen 295@vindex inhibit-startup-screen
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9175fe33918..0efd40b7fad 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12008-10-27 Dan Nicolaescu <dann@ics.uci.edu>
2
3 * startup.el (server-name): Pacify byte compiler.
4 (command-line): If --daemon=SERVER_NAME was used, set server-name
5 before calling server-start.
6
12008-10-26 Romain Francoise <romain@orebokech.com> 72008-10-26 Romain Francoise <romain@orebokech.com>
2 8
3 * startup.el (command-line): Call daemon-initialized after 9 * startup.el (command-line): Call daemon-initialized after
diff --git a/lisp/startup.el b/lisp/startup.el
index 7b7fbb2fd68..2d7995a1c0b 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -693,6 +693,8 @@ opening the first frame (e.g. open a connection to an X server).")
693(declare-function tool-bar-mode "tool-bar" (&optional arg)) 693(declare-function tool-bar-mode "tool-bar" (&optional arg))
694(declare-function tool-bar-setup "tool-bar") 694(declare-function tool-bar-setup "tool-bar")
695 695
696(defvar server-name)
697
696(defun command-line () 698(defun command-line ()
697 (setq before-init-time (current-time) 699 (setq before-init-time (current-time)
698 after-init-time nil 700 after-init-time nil
@@ -1212,9 +1214,11 @@ the `--debug-init' option to view a complete error backtrace."
1212 ;; This is done after loading the user's init file and after 1214 ;; This is done after loading the user's init file and after
1213 ;; processing all command line arguments to allow e.g. `server-name' 1215 ;; processing all command line arguments to allow e.g. `server-name'
1214 ;; to be changed before the server starts. 1216 ;; to be changed before the server starts.
1215 (when (daemonp) 1217 (let ((dn (daemonp)))
1216 (server-start) 1218 (when dn
1217 (daemon-initialized)) 1219 (when (stringp dn) (setq server-name dn))
1220 (server-start)
1221 (daemon-initialized)))
1218 1222
1219 ;; Run emacs-session-restore (session management) if started by 1223 ;; Run emacs-session-restore (session management) if started by
1220 ;; the session manager and we have a session manager connection. 1224 ;; the session manager and we have a session manager connection.
diff --git a/src/ChangeLog b/src/ChangeLog
index 4de35db502f..6379e86b9e6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12008-10-27 Dan Nicolaescu <dann@ics.uci.edu>
2
3 * emacs.c (daemon_name): New variable.
4 (main): Deal with --daemon=SERVER_NAME.
5 (Fdaemonp): Return a name if one was passed to --daemon.
6
12008-10-26 Romain Francoise <romain@orebokech.com> 72008-10-26 Romain Francoise <romain@orebokech.com>
2 8
3 * emacs.c (daemon_pipe): New variable. 9 * emacs.c (daemon_pipe): New variable.
diff --git a/src/emacs.c b/src/emacs.c
index bcc7fb05792..6f54291a514 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -237,6 +237,8 @@ int noninteractive1;
237 237
238/* Nonzero means Emacs was started as a daemon. */ 238/* Nonzero means Emacs was started as a daemon. */
239int is_daemon = 0; 239int is_daemon = 0;
240/* Name for the server started by the daemon.*/
241static char *daemon_name;
240 242
241/* Pipe used to send exit notification to the daemon parent at 243/* Pipe used to send exit notification to the daemon parent at
242 startup. */ 244 startup. */
@@ -796,6 +798,7 @@ main (int argc, char **argv)
796#endif 798#endif
797 int no_loadup = 0; 799 int no_loadup = 0;
798 char *junk = 0; 800 char *junk = 0;
801 char *dname_arg = 0;
799 802
800#if GC_MARK_STACK 803#if GC_MARK_STACK
801 extern Lisp_Object *stack_base; 804 extern Lisp_Object *stack_base;
@@ -1074,7 +1077,8 @@ main (int argc, char **argv)
1074 exit (0); 1077 exit (0);
1075 } 1078 }
1076 1079
1077 if (argmatch (argv, argc, "-daemon", "--daemon", 5, NULL, &skip_args)) 1080 if (argmatch (argv, argc, "-daemon", "--daemon", 5, NULL, &skip_args)
1081 || argmatch (argv, argc, "-daemon", "--daemon", 5, &dname_arg, &skip_args))
1078 { 1082 {
1079#ifndef DOS_NT 1083#ifndef DOS_NT
1080 pid_t f; 1084 pid_t f;
@@ -1123,6 +1127,8 @@ main (int argc, char **argv)
1123 exit (1); 1127 exit (1);
1124 } 1128 }
1125 1129
1130 if (dname_arg)
1131 daemon_name = xstrdup (dname_arg);
1126 /* Close unused reading end of the pipe. */ 1132 /* Close unused reading end of the pipe. */
1127 close (daemon_pipe[0]); 1133 close (daemon_pipe[0]);
1128 is_daemon = 1; 1134 is_daemon = 1;
@@ -2419,10 +2425,17 @@ decode_env_path (evarname, defalt)
2419} 2425}
2420 2426
2421DEFUN ("daemonp", Fdaemonp, Sdaemonp, 0, 0, 0, 2427DEFUN ("daemonp", Fdaemonp, Sdaemonp, 0, 0, 0,
2422 doc: /* Return t if the current emacs process is a daemon. */) 2428 doc: /* Return non-nil if the current emacs process is a daemon.
2429If the daemon was given a name argument, return that name. */)
2423 () 2430 ()
2424{ 2431{
2425 return is_daemon ? Qt : Qnil; 2432 if (is_daemon)
2433 if (daemon_name)
2434 return build_string (daemon_name);
2435 else
2436 return Qt;
2437 else
2438 return Qnil;
2426} 2439}
2427 2440
2428DEFUN ("daemon-initialized", Fdaemon_initialized, Sdaemon_initialized, 0, 0, 0, 2441DEFUN ("daemon-initialized", Fdaemon_initialized, Sdaemon_initialized, 0, 0, 0,