Rainer M Krug <r.m.krug@gmail.com> wrote:Here's a caution: when desktop.el is loaded, it adds to after-init-hook a
> I created the attached init.el file. In my setup, ~/.emacs.d/org-mode
> is a symbolic link. If I set it to org-7.7, everything works as
> expected desktop is loaded and saved without question), but when
> linking it to the git version, the desktop is loaded, but when closing
> it giveas me the above mentioned question:
>
> "Current desktop was not loaded from a file. Overwrite this desktop file?"
>
> As I said, the desktop *is* loaded.
>
> Hope you can reproduce it with this setup,
>
function that reads the desktop file. However, after-init-hook gets called
"at the end of initialization": if you try to reproduce using something like
emacs -q -l init.el
it's not going to work - after-init-hook gets runs "between the -q and -l"
so to speak, whereas desktop.el does not get loaded until init.el is loaded:
that initializes the hook too late to do any good.
Probably the best way to do it is to create a dummy user "foo", copy init.el
to /home/foo/.emacs and then invoke emacs as
emacs -u foo
Using this method, I cannot reproduce the problem with or without org in
the init file: here's the one that I used which also sets a couple of
desktop hooks that make some noise which is recorded in the *Messages*
buffer - that helps to verify that things work according to
expectations:
--8<---------------cut here---------------start------------->8---
;;; -*- mode: emacs-lisp -*-
(setq debug-on-error t)
(require 'desktop)
(desktop-save-mode 1)
(add-to-list 'desktop-after-read-hook (function (lambda () (message "got a desktop file"))))
(add-to-list 'desktop-no-desktop-file-hook (function (lambda () (message "no desktop file read"))))
;;; I tried with and without the following five lines
;;; I also tried with them placed *before* the desktop stuff
(add-to-list 'load-path (expand-file-name "~nick/src/emacs/org/org-mode/lisp"))
(add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))
(require 'org-install)
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
--8<---------------cut here---------------end--------------->8---
Nick