all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Nix <nix@esperi.org.uk>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] A myriad of interrelated daemon-mode startup bugs
Date: Tue, 13 Nov 2012 13:34:52 -0500	[thread overview]
Message-ID: <jwvsj8dz83j.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87haotpg6g.fsf@spindle.srvr.nix> (nix@esperi.org.uk's message of "Tue, 13 Nov 2012 17:26:47 +0000")

> [Stefan Cc:ed because part of this is fixing lexical-binding fallout,
>  and as a way of saying thank you for fixing a bug of mine: here's a
>  fix for a bug of yours! :) ]

Actually, it's got nothing to do with lexical-binding, but is due to
a bug of mine in gv-define-simpler-setter which was fixed yesterday.

> --- lisp/desktop.el.orig	2012-11-13 16:36:38.833375966 +0000
> +++ lisp/desktop.el	2012-11-13 16:38:18.634889091 +0000
> @@ -627,6 +627,7 @@
>                     (and
>                      (or (memq desktop-save '(ask ask-if-new))
>                          (and exists (eq desktop-save 'ask-if-exists)))
> +                    (and (not noninteractive))
>                      (y-or-n-p "Save desktop? ")))))

No need for `and' here, but otherwise, that looks OK.  Tho maybe a better
fix is to make it so y-or-n-p just returns nil when there's no live
terminal.

> -      (cl-letf (((default-file-modes) ?\700)) (make-directory dir t))
> +      (make-directory dir t ?\700)

The cl-letf ends up doing the exact same thing, via dynamic scoping
(note how it's not a simple `let' and it doesn't bind a variable but
a "place").
I'm not completely opposed to adding a "modes" argument to
make-directory, but I'm not sure it's worth the trouble.

> -      (server-start)
> +      (condition-case err
> +	  (server-start)
> +	(error (message (error-message-string err))))
>        (if server-process
>  	  (daemon-initialized)
>  	(if (stringp dn)

I'm not sure I understand enough of what could/should happen.  E.g. how
does the above compare to using:

    (unwind-protect
        (server-start)
      (if server-process
          (daemon-initialized)
        (if (stringp dn)
        ...

> +	;; We must pretend to be noninteractive at this point to tell
> +	;; kill-emacs-hook functions that read input if interactive
> +	;; not to do so, since reads from stdin are shared with the
> +	;; parent.
> +	(let ((noninteractive t))
> +	    (kill-emacs 1)))))

Actually, `noninteractive' can sometimes interact with the user via
stdin/stdout.

> -	/* End of file in -batch run causes exit here.  */
> -	if (noninteractive)
> +	/* End of file in -batch run or before the daemon is
> +	   initialized causes exit here.  */
> +	if ((noninteractive) ||
> +	    (IS_DAEMON && !daemon_initialized))
>  	  Fkill_emacs (Qt);

How 'bout having a Lisp-exported variable that controls whether to call
kill-emacs here?  Then server.el could set this var (after successfully
starting the daemon) to prevent exit.

Also, maybe the right way to solve this is to think harder about what
noninteractive means and how to split it into several variables.
E.g. one meaning is "no input events", another is "I/O is via
stdin/stdout", and another we need is "there's no I/O available right
now".


        Stefan



  reply	other threads:[~2012-11-13 18:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-13 17:26 [PATCH] A myriad of interrelated daemon-mode startup bugs Nix
2012-11-13 18:34 ` Stefan Monnier [this message]
2012-11-13 18:41   ` Nix
2012-11-13 19:41     ` Stefan Monnier
2012-12-11 16:50       ` Nix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvsj8dz83j.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=nix@esperi.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.