[OS X Emacs] Warning: Desktop file appears to be in use by PID ...

Hofert Jan Marius marius.hofert at math.ethz.ch
Mon Sep 19 04:07:34 EDT 2011

On 2011-09-19, at 24:59 , Jack Repenning wrote:

> On Sep 18, 2011, at 4:54 AM, Hofert Jan Marius wrote:
>> I have exactly the problem mentioned here [leftover desktop-save lock files]
>> Any ideas? 
> You're reported a symptom, but given no details of your use or debugging. That makes it hard to comment concisely.

Dear Jack,

thank you very much for helping. 

> Do you in fact want to use "desktop save" mode at all?

a definite yes. I recently read about it and it saves me a lot of time to get back to several open files I worked on the last time Aquamacs was open. I read about it here: http://www.gnu.org/s/libtool/manual/emacs/Saving-Emacs-Sessions.html

I therefore put the following line in Preferences.el:
(desktop-save-mode 1)

I just check Options -> Customize Aquamacs -> Specific Group -> desktop -> Desktop Save Mode; It is a "Toggle" and it says "on (non-nil) [probably due to the (desktop-save-mode 1) in Preferences.el.

I also checked Options -> Customize Aquamacs -> Specific Group -> desktop -> Desktop Save and it says "Ask if desktop file is new, else do save". I have these options to choose from:

   A desktop is killed when the user changes desktop or quits Emacs.
   Possible values are:
      t             -- always save.
      ask           -- always ask.
      ask-if-new    -- ask if no desktop file exists, otherwise just save.
      ask-if-exists -- ask if desktop file exists, otherwise don't save.
      if-exists     -- save if desktop file exists, otherwise don't save.
      nil           -- never save.
   The desktop is never saved when `desktop-save-mode' is nil.
   The variables `desktop-dirname' and `desktop-base-file-name'
   determine where the desktop is saved.

shall I set the "Value Menu" to "Always save" here?

> This mode (which is the thing that uses that file) arranges that Emacs will start up displaying the same files it was displaying when last it was shut down. If that's not actually interesting to you, then you can turn if off by setting desktop-save to nil (say, in "Options: Customize Emacs: Specific Group: desktop").
> If you want desktop-save mode, then you need to debug its configuration. The mode includes some code to clean up this lock file; clearly, this code either is failing, or isn't even running. The best way to do that is to step through desktop.el, confirming all its expectations to see which is not satisfied:
> 1. "When the desktop module is loaded, the function `desktop-kill' is added to the `kill-emacs-hoook'." So is desktop-kill in kill-emacs-hook? Go to the *scratch* buffer, check in the mode line to be sure it's in Lisp Interaction mode (if not, do M-x lisp-interaction), type "kill-emacs-hook" and press ^J. You should get a list of possibly several function names; desktop-kill should be among them. If it is not, look in your Preferences.el file to see if you're monkeying with kill-emacs-hook (and unknowingly removing desktop-kill).

thanks for the detailed explanantion, I did this:

M-x lisp-interaction
I then saw the list you described and it contained desktop-kill:
(reftex-kill-emacs-hook server-force-stop desktop-kill savehist-autosave smart-fp--save-frame-positions-to-file save-place-kill-emacs-hook recentf-save-list)

> 2. Looking at the defun of desktop-kill, I see a chance or two for it to ask a question, and certain possible answers (or aborting Emacs while it's waiting for an answer) could defeat the unlocking. Do you get questions while shutting down?

sometimes I get "Save desktop?" but I don't know when exactly (have to check that)

> Do you shut down by some means that might interfere with this question-and-answer dialog?

Rarely. I'm a total beginner (using Aquamacs for about 1 1/2 weeks now). I remember I used "force quit" at some point, but not anymore. I typically just hit "Apple key + Q" which when all buffers are saved [otherwise they will be saved first] just quits Aquamacs without any further questions. Then opening again opens all the previously used buffers, sometimes giving this weird PID warning [again, I should check more carefully when it happens exactly]. 

> If you have some need to shut down without answering questions, then set desktop-save to t rather than 'ask or several other possibilities (again, the Customize menu is probably the easiest path).

okay, I will do that. 

> Also, be sure that desktop-dirname and desktop-base-file-name are set sensibly.

the entry "Desktop Base File Name" says ".emacs.desktop". I couldn't find an entry for desktop-dirname. I tried to search for it via "C-h a", but there were no matches. How can I display that?

I also just saw this: http://www.emacswiki.org/emacs/DeskTop
There is a section called "Auto-Saving the Desktop". Is this a good defun to use? 



> -==-
> Jack Repenning
> Technologist
> CollabNet Cloud Services
> CollabNet, Inc.
> 8000 Marina Boulevard, Suite 600
> Brisbane, California 94005
> office: +1 650.228.2562
> twitter: http://twitter.com/jrep
> _____________________________________________________________
> MacOSX-Emacs mailing list
> MacOSX-Emacs at email.esm.psu.edu
> http://email.esm.psu.edu/mailman/listinfo/macosx-emacs
> List Archives: http://dir.gmane.org/gmane.emacs.macintosh.osx

ETH Zurich
Dr. Marius Hofert
RiskLab, Department of Mathematics
HG E 65.2
Rämistrasse 101
8092 Zurich

Phone +41 44 632 2423
marius.hofert at math.ethz.ch

More information about the MacOSX-Emacs mailing list