1

I am trying to use desktop functionality (http://www.emacswiki.org/emacs/DeskTop) in emacs. I added following code to my .emacs:

(require 'desktop)
(setq desktop-save t)
(setq desktop-load-locked-desktop t)
(setq *desktop-dir* (list (expand-file-name "~/.emacs.d/desktop")))
(setq desktop-base-file-name ".emacs.desktop")
(setq desktop-path *desktop-dir*)
(setq desktop-dir *desktop-dir*)
(desktop-save-mode 1)
(desktop-read)

If I use emacs like a standalone application, calling like "$emacs -nw", everything is fine, but when I try to use the same config with emacsclient, emacs just hangs on server starting. Commenting out two last lines make emacs server start as expected.

See part of official Gentoo script from /etc/init.d to start emacs daemon.

: ${EMACS:=/usr/bin/emacs}
: ${EMACS_OPTS:=--daemon}
: ${EMACS_SHELL=/bin/bash}
: ${EMACS_START:=/usr/libexec/emacs/emacs-wrapper.sh}
: ${EMACS_TIMEOUT:=30}
: ${EMACS_SHUTDOWN_TIMEOUT:=10}
USER=${SVCNAME#*.}
PIDFILE_DIR=/var/run/emacs/${USER}
PIDFILE=${PIDFILE_DIR}/emacs.pid
...
local home
checkconfig || return 1

eval home="~${USER}"

SHELL=${EMACS_SHELL:-$(awk -F: "\$1 == \"${USER}\" { print \$7 }" \
    /etc/passwd)}
export SHELL EMACS EMACS_TIMEOUT

ebegin "Starting Emacs daemon for user ${USER}"
if [ -z "${RC_SVCNAME}" ]; then
    # baselayout-1
    start-stop-daemon --start \
        --user "${USER}" --exec "${EMACS}" --pidfile "${PIDFILE}" \
        --chuid "${USER}" --chdir "${home}" --env HOME="${home}" \
        --startas "${EMACS_START}" -- ${EMACS_OPTS}
else
    # OpenRC
    start-stop-daemon --start \
        --user "${USER}" --pidfile "${PIDFILE}" --chdir "${home}" \
        --exec "${EMACS_START}" -- ${EMACS_OPTS}
fi
eend $?

Is possible to debug emacsclient problems somehow? Maybe someone could give a hint?

P.S. I am on Gentoo Linux, emacs-vcs-23.2.9999 package, terminal only.

MageSlayer
  • 421
  • 4
  • 12
  • I'm confused. Is your emacsclient actually executing your .emacs? – Noufal Ibrahim Sep 18 '10 at 09:34
  • 1
    You say Emacs hangs: what happens if you try to create a frame? Is it `(desktop-save-mode)` or `(desktop-read)` that hangs? How exactly are you starting Emacs: `emacsclient -a emacs` or something else? First get things working without the `/etc/init.d` script. – Gilles 'SO- stop being evil' Sep 18 '10 at 13:07
  • 2
    Also, I don't know if it's related to your problem, but on Emacs 23.1, I see a variable `desktop-dirname` but no `desktop-dir`. – Gilles 'SO- stop being evil' Sep 18 '10 at 13:08
  • 1
    From the description I'm not sure this will help at all, but you might try adding `--debug-init` to your start options (both for starting in daemon mode, and otherwise), and see if it tells you anything new. – phils Sep 18 '10 at 13:20
  • Maybe you should add the `gentoo` tag to this question. – Jérôme Radix Sep 18 '10 at 20:43
  • Emacs is loaded as server as hangs when last two lines present, so no, emacsclient does not load my .emacs I cannot connect to emacs server using emacsclient, so I cannot debug anything. But as I've said, the problem is not present when starting not as a daemon. I think I need something like logging to a file to see what is happening. I added gentoo tag – MageSlayer Sep 19 '10 at 17:40
  • Does the issue occur if you use `emacs --daemon` rather than the gentoo script? Or if you start non-daemon emacs and use `M-x server-start`? – phils Sep 21 '10 at 02:01

0 Answers0