Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 246460 - app-emacs/emacs-daemon should allow for setting up a proper environment
Summary: app-emacs/emacs-daemon should allow for setting up a proper environment
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Emacs project
Keywords: InVCS
Depends on:
Reported: 2008-11-12 07:57 UTC by Tassilo Horn
Modified: 2008-12-05 16:32 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Tassilo Horn 2008-11-12 07:57:14 UTC
That's the short email communication I had with Ulrich Müller (ulm):

>> 1. I'd like to have control over the environment the emacs process is
>>    started in.  It would be very nice if in conf.d/emacs I could add
>>    something like
>>              EMACS_ENV_FILE="${HOME}/.profile"
>>    which would be sourced before starting emacs.
> Do you have any suggestion how this should be implemented? We cannot
> source a file owned by the user while we are being root, because that
> would be a security issue. At the moment only an intermediate shell
> between start-stop-daemon and Emacs comes to my mind, but that doesn't
> look like te most elegant solution ...

Currently I see 2 possibilities:

1. start-stop-daemon supports an "-e, --env VAR=VALUE" option.  So I
guess one could add a variable to the conf.d/emacs file which lists
var-value pairs.  Or maybe a conf.d/emacs.user would be better.  But I
guess that's not a too good solution, because then users would have to
duplicate their envvar settings.  I have them all in ~/.profile and
wouldn't like to add the same with other syntax to another config file.

2. Implement a source function in elisp which parses an EMACS_ENV_FILE
set in conf.d/emacs and uses the builtin `setenv' function.  I guess
that shouldn't be too hard to do.

That function could be added as site-lisp file, I think.

If no-one comes up with a better solution, I'd volunteer to give 2 a

Reproducible: Always
Comment 1 Tassilo Horn 2008-11-13 08:07:22 UTC
It seems that point 2 doesn't work.  I tried expanding my PATH using

  M-x setenv RET PATH RET $PATH:/home/horn/bin RET

and M-x getenv shows that the value is just like I wanted, but when I hit RET on a link which should launch "conkeror" which is located in that directory, it won't be found.

  apply: Searching for program: no such file or directory, conkeror
Comment 2 Ulrich Müller gentoo-dev 2008-11-13 12:05:00 UTC
How about the following:

We add a variable EMACS_LAUNCHER (any better suggestion for the name?) in conf.d/emacs, with an empty default value. The init script's start function would then call "start-stop-daemon --exec ${EMACS_LAUNCHER:-${EMACS}}". This should allow for maximum flexibility.

As added bonus we could install a default start-emacs-daemon script (probably this should then go into /usr/libexec/) with the following contents:

   #!/bin/bash -l
   exec "${EMACS}" "$@"

(In reply to comment #0)
> Or maybe a conf.d/emacs.user would be better.

This is called "multiplexing" and already working. I'll add a respective comment to conf.d/emacs.
Comment 3 Tassilo Horn 2008-11-13 13:30:01 UTC
The EMACS_LAUNCHER option sounds just perfect!
Comment 4 Ulrich Müller gentoo-dev 2008-11-13 16:21:31 UTC
2008-11-13  Ulrich Mueller  <>

	* emacs.rc (start): Allow for a wrapper script specified by
	variable EMACS_START. Thanks to Tassilo Horn, bug 246460.
	* emacs.conf (EMACS_START): Document as a variable.
	* New file.
	* Makefile (DISTFILES): Add

	* emacs.conf: Add a comment about multiplexed configuration files.
Comment 5 Tassilo Horn 2008-11-13 16:44:06 UTC
Using emacs-daemon-9999 the is not installed.
Comment 6 Ulrich Müller gentoo-dev 2008-11-13 16:48:49 UTC
It should, see:
Did you re-sync the overlay?
Comment 7 Tassilo Horn 2008-11-13 19:24:24 UTC
Ups, you're right.  I forgot that.

Now it works just beautiful.  Thanks a lot!
Comment 8 Ulrich Müller gentoo-dev 2008-11-15 13:25:50 UTC
Fixed in emacs-daemon-0.6. Thank you for the suggestion.
Comment 9 Ulrich Müller gentoo-dev 2008-12-05 16:32:14 UTC
Just for info: The wrapper script is now called by default. I've also added a start timeout, in order to avoid a hanging runscript (which is quite nasty at boot time).

It might be worthwhile to test this again, emacs-daemon-9999, in Emacs overlay.