I have a GUI emacs running as the major working area,

When I reading articles from web, need to open a emacs as a tool to keep note;

Web on the left and new emacs on the right,

Usually, get the prompts

Please answer y or n.  Warning: desktop file appears to be in use by PID 17861.                                               
Using it may cause conflicts.  Use it anyway? (y or n)   

I assure the conflicts are the buffer.

Should I ignore it to continue or actions could be taken to tackle the prompt?

  • 2
    Are you using desktop-save-mode? – user12563 Jan 15 '19 at 6:54
  • Two questions: 1) What happens if you answer n to the prompt? 2) Would opening a new frame instead with key chords C-x 5 2 help? BTW the C in C-x is Cntrl key so C-x means press Control and x keys and same time. – Melioratus Jan 15 '19 at 14:58

You can't usefully have two simultaneous Emacs session that use the same file to store the session state. Each time a session saves its state, it would overwrite the other session's state.

Many people run a single Emacs session. To open a file in the existing Emacs session, use emacsclient (see also the Emacs wiki). Emacsclient has several options to control its behavior, including whether to open a new window (-c) or run inside the current terminal (-t) or let you switch to the existing window (default). Emacsclient can start Emacs if needed (emacsclien --alternate-editor=).

I normally start Emacs when I log in, and I use Desktop to save my session. In order to be able to occasionally run a separate instance of Emacs, I arrange to only use Desktop if Emacs is invoked in a special way, and I invoke Emacs in this special way in my operating system's session startup. Specifically, I run this when I log in:

EMACS_SESSION_DIR=~/.emacs.d/session emacs --daemon

This runs emacs --daemon (so it doesn't open any Emacs window) and loads my normal session which is stored in the directory ~/.emacs.d/session. Here's the code from my Emacs init file to only use Desktop if EMACS_SESSION_DIR is set.

(let ((env (getenv "EMACS_SESSION_DIR")))
  (unless (or (null env) (equal env ""))
    (setq desktop-dirname (expand-file-name env)
          desktop-path (list desktop-dirname))))

;; `desktop' will look for `desktop-basefilename' in the current directory,
;; then in the home directory. But I don't ordinarily want that.
(defadvice desktop-read
  (around dont-search-state-file-in-current-directory activate)
  "Don't let Desktop look for the state file in the current directory."
  (let ((default-directory desktop-dirname))

;; Enable desktop if a session directory has been defined.
(setq desktop-enable (and desktop-dirname t))

(Some of this code was writen a long time ago and may no longer be necessary in modern Emacs versions.)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.