[Top][All Lists]

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

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

From: Jan Djärv
Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r100117: Run kill-emacs when exiting for display closed or SIGTERM/HUP.
Date: Wed, 05 May 2010 09:21:44 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20100423 Thunderbird/3.0.4

2010-05-04 20:50, Stefan Monnier skrev:

I still don't understand what was that feature you're talking about.
The way I see it, it was more like some accidental behavior which
happened to be convenient.  I'd like to use this "breakage" as an
opportunity to replace those lucky accidents by sound behavior.

To get Emacs to automatically read my desktop:
% cd to/dir/of/interest
% emacs &

To get session management to automatically read my desktop, --chdir emulates that usage.

Maybe people just start Emacs at $HOME and load desktop interactivly, I don't know.

Doesn't matter as long as the end result is the one we want.
Usually I'd expect $HOME to be a good choice.
And how will Emacs avoid to load my desktop file there if I didn't use
it previously?

That argues for a change in desktop.el to make it behave better with
session management.

Yes it does.

It may be to you, but it is not to me.  I open files all the time from
*scratch* just because the default directory there is right.  It is a bug
for Emacs not to restore this after a session restart.

Can you describe your use-case more precisely?

Some directory trees I work with are very deep, 7 to 8 layers of subdirectories are not uncommon. But they are part of the same project. I save the desktop at the top of that tree, because I do a svn up there before I start Emacs. When I am at the deepest part of the tree and want to open a file that is in another directory, I have to either

  C-x C-f <delete file name to the top> <move down in tree to file>


  C-x b *s<TAB><RET> C-x C-f <move down in tree to file>

I find the latter to be much faster.

BTW, why use --chdir rather than save the default-directories in the
session file if you think that it should work even without desktop.el?

I doesn't work with desktop. desktop adds itself to after-init-hook, and that is run before session restore. So desktop will load my desktop in $HOME before default-directories are restored.

I'd like desktop.el to be more modular so we could save desktop
automatically in the session specific restore data file.  I tried
once, but it was so hard coded to use just one file, so I gave up.

Ah, now you're starting to talk.  Can you give some details of what you
tried and where the "hardcoding" was showing its ugly head?

desktop-save can't save to an arbitrary buffer. When desktop isn't used and Emacs is to be killed by the session manager, it would be good to save the desktop in the session-specific file. But desktop-read can't read just part of a file, so restore may become an issue. Ideally we would just load the session specific file on restart, but desktop has some cleanups it does in desktop-read after load.

You never know if desktop-save is going to ask questions or not (well, except duplicating the logic behind ask-if-new and so on). This makes it unsuitable for use when the session manager says "save state". Note that in those cases, we may not be stopped at all, and user interaction should not take place. And there is the possibility that the desktop file is locked, so it will ask a question anyway.

If I start emacs in /some/dir without a desktop file and have desktop-mode
enabled, there will be no desktop saved when I log out.
When the session manager then restarts Emacs in $HOME it will read my
desktop file in $HOME.  That is a bug also.

OK, let's try and fix it right, then.

My first attemt was to let desktop save its state if desktop is enabled, otherwise save it in the session specific file. But I now think that we must save in the session specific files always, due to the locking and stuff in desktop. Desktop may also choose to save in its file, so we save desktop in two places (just one if desktop-save-mode isn't enabled).

On restore, you should somehow tell desktop not to load its file, because if it does, it might be the wrong thing to do. We wan't to restore to the state we had when stopped, and we don't know what has happend to that desktop file while we weren't running (some other Emacs may have modified it). But now session restore kicks in after desktop has already read its file. After we have restored from the session file, we must then tell desktop that it is now okay to save to its file again.

If desktop-save-mode isn't on, this becomes easier.

        Jan D.

reply via email to

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