help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: after-init-hook not called with emacs -q -l (and desktop is not read


From: hjuvi
Subject: Re: after-init-hook not called with emacs -q -l (and desktop is not read)
Date: Wed, 28 Mar 2012 19:31:14 -0000
User-agent: G2/1.0

Thanks a lot for your answers. It helps me very much.

> That's exactly what I said: you get fooled because after-init-hook is
> run before you add my-popup to it (since it gets run before the -l is
> processed).

You're right. Now I understand what happens.
I should not say "alternative" init files but "extra" init files.
The problem for me is that desktop uses after-init-hook, and thus
cannot be loaded in an "extra" init file.
This is not really a bug for desktop: it is mentionned clearly in
Emacs Lisp manual.

>From 
>http://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Saving-Emacs-Sessions
"Starting Emacs with the ‘--no-init-file’ option also disables desktop
reloading, since it bypasses the init file, where desktop-save-mode is
usually turned on."

My problem is "usually" :)


> Doesn't matter: don't describe how you think Emacs should be changed,
> just describe what you'd like to be able to do (e.g. select different
> desktops from some command-line option).

I think I will create a bug later... I will post a link in this
discussion when I do.


> > (setq my-opt command-line-args)
> > I run: emacs --no-desktop &
> > I check the value:
> > my-opt's value is ("emacs")
> I think it's gone because It's already been processed by the time .emacs
> is read.

I get fooled again!...
The problem with (setq my-opt command-line-args) is that it doesn't
copy the list, it's only another reference to the same list.
When I read the value, it's already gone.
The right thing to do is:
(if (member "--no-desktop" command-line-args)
  (setq my-no-desktop-option t)
  (setq my-no-desktop-option nil))
Then my-no-desktop-option is correct.


> But you don't need --no-desktop, IIUC, you just need to use some
> new --select-desktop argument to set the desktop file name.

The decision to read the desktop or not is the responsability of my
package. It cannot be specified by the user.
The only thing I want is: if the user specifies --no-desktop, the
package must not load it, even if it should.

Just to explain a little bit:
My package is an IDE. If a project is defined in the directory from
which you launch emacs, my IDE must load the desktop. Otherwise it
must not.
It worked fine until several people told me that they were using my
package with "emacs -q -l my-package.el", because they want to use
several emacs config, and easily switch to one another.
Then they complained that the desktop was not loaded.
I fixed it with emacs-startup-hook, but now the problem is that I want
"--no-desktop" to be taken into account.

I have defined emacs as the editor for git commit message edition, and
for svn propedit svn:externals.
I have specified "emacs --no-desktop", because if I commit from the
project root directory, I don't want the desktop to be loaded: I just
want to edit the commit message. The same for editing svn:externals.

So I still have to make some tests, but I believe I have the solution
now.
Thank you very much for your help.
I will post the complete solution when it's done.


reply via email to

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